akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#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) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
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);

    int N; cin >> N;
    int T=N;
    int f=0;
    while(N!=0){
        f+=N%10;
        N/=10;
    }
    if(T%f==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
//#define MOD 1000000007
#define MOD 998244353
#define INF LLONG_MAX/2
#define int long long

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,sum=0,k;
    cin>>n;
    vector<int> v(n);
    REP(i,0,n){
        cin>>v[i];
        sum+=v[i];
    }
    k=RUP(sum,2);
    int ans=1;
    REP(i,0,n) ans= (ans*3)%MOD;
    
    int h=91000,w=310;
    vector< vector<int> > dp1(h,vector<int>(w,0)),dp2(h,vector<int>(w,0));
    dp1[0][0]=1;
    REP(i,0,h){
        REP(j,0,n){
            if(dp1[i][j]!=0){
                dp1[i+v[j]][j+1] = (dp1[i+v[j]][j+1]+dp1[i][j])%MOD;
                dp1[i][j+1] = (dp1[i][j+1]+(2*dp1[i][j])%MOD)%MOD;
            }
        }
    }
    REP(i,k,h){
        ans = (ans-(3*dp1[i][n])%MOD)%MOD;
        if(ans<0) ans+=MOD;
    }
    if(sum%2!=0){cout<<ans<<ENT;return 0;}
    
    dp2[0][0]=1;
    REP(i,0,h){
        REP(j,0,n){
            if(dp2[i][j]!=0){
                dp2[i+v[j]][j+1] = (dp2[i+v[j]][j+1]+dp2[i][j])%MOD;
                dp2[i][j+1] = (dp2[i][j+1]+dp2[i][j])%MOD;
            }
        }
    }
    ans = (ans+(3*dp2[sum/2][n])%MOD)%MOD;
    cout<<ans<<ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 448128
#include<iostream>

using namespace std;

int main(){

    int a[32];

    a[0] = 1;
    a[1] = 1;
    a[2] = 1;
    a[3]=  2;
    a[4]= 1;
    a[5] = 2; 
    a[6]=1;a[7]= 5; a[8]= 2;a[9]= 2;a[10]= 1; a[11]=5;a[12]= 1;a[13]= 2;a[14]= 1;a[15]= 14;a[16]= 1;a[17]= 5;a[18]= 1;a[19]= 5;a[20]= 2;a[21]= 2;a[22]= 1;a[23]= 15;a[24]= 2;a[25]= 2;a[26]= 5;a[27]= 4; a[28]=1;a[29]= 4;a[30]= 1;a[31]= 51; 

    int k;
    cin >> k;

    cout << a[k-1] <<endl;


}

Measured memory_bytes: 256
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    n, q = intin()
    s = input()
    lrlist = intinl(q)

    prev = None
    pos_i_list = []
    for i, c in enumerate(s):
        if prev == 'A' and c == 'C':
            pos_i_list.append(i)
        prev = c

    for l, r in lrlist:
        start = binl(pos_i_list, l)
        end = binl(pos_i_list, r)
        print(end - start)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19444
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  string S; cin >> S;
  int N = S.length();

  string S1 = S.substr(0, (N - 1) / 2);
  string S2 = S.substr((N + 3) / 2 - 1);

  string R(S); reverse(R.begin(), R.end());
  string R1(S1); reverse(R1.begin(), R1.end());
  string R2(S2); reverse(R2.begin(), R2.end());

  if (S == R && S1 == R1 && S2 == R2) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
/*
AtCoder Beginner Contest 177- D - Friends
https://atcoder.jp/contests/abc177/tasks/abc177_d
*/

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

class dsu {
private:
    vector<ll> d, sz;
public:
    dsu(ll n) {
        d=vector<ll>(n);
        sz=vector<ll>(n, 1);
        REP(i,n) d[i]=i;
    }

    ll p(ll a) {
        if (d[a]==a) return a;
        else return d[a]=p(d[a]);
    }

    ll get_sz(ll a) {
        return sz[p(a)];
    }

    void unite(ll a, ll b) {
        ll pa=p(a);
        ll pb=p(b);
        if (pa==pb) return;
        else {
            sz[pb]+=sz[pa];
            sz[pa]=0;
            d[pa]=pb;
            return;
        }
        return;
    }
};

void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif
//
//    int tc; cin >> tc;
//    TC(tc) solve();
	ll n, m, a, b;
	cin >> n >> m;
	dsu d=dsu(n);
    REP(i,m){
    	cin >> a >> b;
    	--a,--b;
		d.unite(a,b);
	}
	int ans=-INT_MAX;
	REP(i,n) MAX(ans,(int)d.get_sz(i));
	OUT(ans);
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    int now = 1, ans = 0;
    for(int a : A){
        if(a == now){
            now++;
        }else{
            ans++;
        }
    }
    if(now == 1) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
_ = gets.to_i
a = gets.split.map(&:to_i)
num_negative = a.count{_1<0}
if num_negative.even?
  puts a.map{|i| i<0 ? -i : i}.sum
else
  a = a.map{|i| i<0 ? -i : i}
  puts a.sum - a.min*2
end

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

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

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int N,Q;
  cin >> N >> Q;
  
  str S;
  VI s2(N+1,0);
cin >> S;
  
  REP(i,N){
   s2[i+1] =s2[i] + (S.substr(i,2)=="AC"?1:0);  
  }

  REP(i,Q){
    int l,r;
    cin >> l >> r;
    cout << (s2[r-1]-s2[l-1]) << endl;
  }
  return 0;
}


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

int main() {
  int n, x;
  cin >> n;
  for (int i = n; i > 0; i /= 10) {
    x += i % 10;
  }
  if (n % x == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,c,ans;

main() {
    cin >> a >> b >> c;
    if (a==b && b==c) {if (a%2)ct(0) else ct(-1)return 0;}
    if (a%2 || b%2 || c%2) {ct(0)return 0;}
    while(1) {
        int tmpa=b/2+c/2,tmpb=a/2+c/2,tmpc=a/2+b/2;
        a=tmpa,b=tmpb,c=tmpc,ans++;
        if (a%2 || b%2 || c%2) {ct(ans)return 0;}
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[100001][4];
int a[100001][4];
int main()
{
	int n,i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		for(j=1;j<=3;j++)
			scanf("%d",&a[i][j]);
	for(i=1;i<=n;i++)
		for(j=1;j<=3;j++)
			for(k=1;k<=3;k++)
			{
				if(j!=k)
					f[i][j]=max(f[i][j],f[i-1][k]+a[i][j]);
			}
	printf("%d",max(max(f[n][1],f[n][2]),f[n][3]));
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
vi f(N);
int bp(int pow, int ml){
    int res = 1;
    while(pow){
        if(pow%2)res=(res*ml)%mod;
        ml=(ml*ml)%mod;
        pow/=2;
    }
    res%=mod;
    return res;
}
int A1(int n, int k){
    int res = 1;
    for(int i = n-k+1; i <= n; i++){
        res%=mod;
        res=(res*i)%mod;
    }
    res%=mod;
    return res;
}
int C(int n, int k){
    int res = 1;
    for(int i = 1; i <= k; i++){
        res%=mod;
        res=(res*i)%mod;
    }
    return (A1(n, k)*bp(mod-2, res))%mod;
}
void solve(){
    int n, a, b;
    cin>>n>>a>>b;
    int ans = bp(n, 2);
    ans+=5ll*mod;
    ans--;
    ans-=C(n, a);
    ans-=C(n, b);
    ans%=mod;
    cout<<ans;
}   
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 4640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int H, W, ite, ans=0;
  std::cin >> H >> W;
  std::vector<string> a(H);
  range(i, H) std::cin >> a[i];
  vvi num = vv(H, W, 9999999, int);
  range(i, H){
    ite = -1;
    range(j, W){
      if(a[i][j] == '#') num[i][j] = 0, ite = j;
      else if(ite != -1) num[i][j] = num[i][j-1] + 1;
    }
    for(int j = W-2;j>=0;j--) num[i][j] = min(num[i][j+1]+1, num[i][j]);
  }
  range(j, W){
    for(int i=1;i<H;i++) num[i][j] = min(num[i][j], num[i-1][j]+1);
    for(int i=H-2;i>=0;i--) num[i][j] = min(num[i][j], num[i+1][j]+1);
  }
  range(i, H){
    range(j, W){
      //std::cout << num[i][j] << " ";
      ans=max(ans, num[i][j]);
    }
    //std::cout << '\n';
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6136
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }

int main() {
  int n; cin >> n;
  vector<int> v(n);
  rep(i, n){
    cin >> v[i];
  }

  int ans = 0;
  for(int i = 0; i < n; i+=2) {
    if(v[i] & 1) {
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
#define g(I)(p[x=P[I-1]]-p[P[I]])*1./(h[y=P[I]]-h[x])-h[x]-h[y]
long C,h[2<<17],p[2<<17],a;P[2<<17];s,t,x,y;main(i){for(scanf("%*d%ld%d",&C,h);~scanf("%d",&a);i++){for(h[i]=a;s<t&&g(s+1)>-2*a;s++);for(p[P[++t]=i]=p[P[s]]+(a-=h[P[s]])*a+C;s+1<t&&g(t)>g(t-1);P[--t]=i);}printf("%ld",p[i-1]);}

Measured memory_bytes: 4608
//#define LOCAL_DEBUG

#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

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

int main() {
#ifdef LOCAL_DEBUG
	freopen("input.txt","r", stdin);
#endif

	const ll MOD = 1e9 + 7;
	int count[1001];
	for (int i = 0; i < 1001; i++) count[i] = 0;
	int n; cin >> n;
	for (int i = 2; i <= n; i++) {
		int x = i;
		for (int j = 2; x > 1;) {
			if (x % j == 0) {
				count[j]++;
				x /= j;
			}
			else {
				j++;
			}
		}
	}

	ll ans = 1;
	for (int i = 2; i <= n; i++) {
		ans *= (count[i] + 1);
		ans %= MOD;
	}

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


Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    // 双方向エッジ
    val edges = Array(N) { mutableListOf<Pair<Int, Int>>() }
    
    for (i in 0 until N - 1) {
        val (a, b) = readInputLine().split(" ").map { it.toInt() - 1 }
        edges[a].add(Pair(i, b))
        edges[b].add(Pair(i, a))
    }
    
    var color = 0
    
    for (i in 0 until N) {
        color = Math.max(color, edges[i].size)
    }
    
    println(color)
    
    val nodeColor = IntArray(N)
    val ans = IntArray(N - 1)

    for (i in 0 until N - 1) {
        var nowColor = 1
        for (e in edges[i]) {
            if (ans[e.first] != 0) {
                continue
            }
            if (nowColor == nodeColor[i]) {
                ans[e.first] = nowColor + 1
                nodeColor[e.second] = nowColor + 1
                nowColor += 2
            } else {
                ans[e.first] = nowColor
                nodeColor[e.second] = nowColor
                nowColor++
            }
        }
    }

    for (c in ans) {
        println(c)
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 94508
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;

int a = 0, b = 0, c = 1, x = 0, y = 0, z = 0, maxy = -1, mini = 9999, counter = 0,startp=0,endp=0,checker=0;
std::vector<unsigned long long int> vec{}, vecsec{};
int iremono[101];
std::vector<char>kinds{}, ans{}, kaku{};

bool okada = false,okada2=false;
std::string output, output2, input, one, two;
char cutcount[201];
int kakunou2[50][50] = {};

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> a;
	rep(i, a) {
		cin >> iremono[i];
		counter += iremono[i];
		maxy = std::max(maxy, iremono[i]);
	}
	if (counter - maxy > maxy) {
		cout << "Yes" << endl;	
	}
	else {

		cout << "No" << endl;
	}
}

	
	





Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

ll a[maxn];
ll x,d;
struct P{
  ll l,r;
  P(){}
  P(ll l,ll r):l(l),r(r){}
  bool operator<(const P&a)const {
    return l<a.l;
  }
};

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n>>x>>d;
  if(d==0){
    if(x==0)cout<<1<<endl;
    else cout<<n+1<<endl;
    return 0;
  }
  a[0] = x;
  ll mod = abs(d);
  for(int i=1;i<n;i++)a[i] = a[i-1]+d;
  sort(a,a +n);
  unordered_map<ll,vector<P>> mp;
  mp[0] = {P(0,0)};
  ll ls = 0,rs = 0;
  for(int i=0;i<n;i++){
    ls +=a[i];
    rs +=a[n-i-1];
    if(ls>rs)swap(ls,rs);
    ll tt = (ls%mod+mod)%mod;
    if(mp.find(tt)==mp.end())mp[tt]={};
    mp[tt].push_back(P(ls,rs));
  }
  ll ret = 0;
  for(auto pr:mp){
    auto arr = pr.second;
    sort(arr.begin(),arr.end());
    ll lt = arr[0].l,rt = arr[0].r;
    for(int i=1;i<arr.size();i++){
      if(arr[i].l<=rt)rt=max(rt,arr[i].r);
      else {
        ret+=(rt-lt)/mod+1;
        lt = arr[i].l,rt=arr[i].r;
      }
    }
    ret+=(rt-lt)/mod+1;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 19400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF (1e9)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define print(s) cout<<(s)<<endl
#define all(x) (x).begin(),(x).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(0, A - 2 * B) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;

class UnionFind {
public:

  //親の番号、親だった場合は-(size)
  vector<int> Parent;

  //Parentの値を全て-1にする
  UnionFind(int N){
    Parent = vector<int>(N,-1);
  }
  //Aがどのグループに属しているか
  int root(int A) {
    if ( Parent[A] < 0 ) return A;
    return Parent[A] = root(Parent[A]);
  }

  //自分のいるグループの頂点数
  int size(int A) {
    return -Parent[root(A)];
  }

  //AとBをつなぐ
  bool connect(int A, int B ) {
    A = root(A);
    B = root(B);
    if ( A == B ) return false;

    if ( size(A) < size(B) ) swap(A,B);

    Parent[A] += Parent[B];

    Parent[B] = A;

    return true;
  }

};
  
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(M),B(M);
  for ( int i = 0; i < M; i++ ) {
    cin >> A[i] >> B[i];
    A[i]--,B[i]--;
  }

  vector<ll>ans(M);
  ans[M-1] = (ll)N*(N-1)/2;

  UnionFind Uni(N);

  for ( int i = M-1; i >=1; i-- ) {
    ans[i-1] = ans[i];
    if ( Uni.root(A[i]) != Uni.root(B[i])) {
      ans[i-1] -= (ll)Uni.size(A[i])*Uni.size(B[i]);
      Uni.connect(A[i],B[i]);
    }
  }
  
  for ( int i = 0; i < M; i++ ) {
    cout << ans[i] << endl;
  }  
  return 0;
}


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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()	
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll a, b, c; cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}

Measured memory_bytes: 3600
#include <iostream>


int main()
{
	int r, c, element;
	std::cin >> r >> c;

	int *sums = new int[c]();

	for (int i = 0; i < r; i++) {
		int rowSum = 0;
		for (int j = 0; j < c; j++) {
			std::cin >> element;
			sums[j] += element;
			rowSum += element;
			std::cout << element << " ";
		}
		std::cout << rowSum << "\n";
	}
	int total = 0;
	for (int i = 0; i < c; i++) {
		total += sums[i];
		std::cout << sums[i] << " ";
	}
	std::cout << total << "\n";
	delete[] sums;
    return 0;
}




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

int main() {
    int n;
    string ans = "";
    cin >> n;
    vector<int> num(4);
    rep(i, 4) {
        num.at(3 - i) = n % 10;
        n /= 10;
    }
    rep(i, i < (1 << 3)) {
        int temp = num.at(0);
        rep(j, 3) {
            if(1 & (i >> j)) temp += num.at(j + 1);
            else temp -= num.at(j + 1);
        }
        if(temp == 7) {
            ans += (char)(num.at(0) + '0');
            rep(j, 3) {
                if(1 & (i >> j)) ans += '+';
                else ans += '-';
                ans += (char)(num.at(j + 1) + '0');
            }
            ans += "=7";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import bisect


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, q = list(map(int, input().rstrip('\n').split()))
    s = [int(input().rstrip('\n')) for _ in range(a)]
    t = [int(input().rstrip('\n')) for _ in range(b)]
    x = [int(input().rstrip('\n')) for _ in range(q)]
    for xv in x:
        ps = bisect.bisect_left(s, xv)
        pt = bisect.bisect_left(t, xv)
        sl = []
        if ps == 0:
            sl.append(s[0])
        elif ps == a:
            sl.append(s[-1])
        else:
            sl.append(s[ps-1])
            sl.append(s[ps])
        tl = []
        if pt == 0:
            tl.append(t[0])
        elif pt == b:
            tl.append(t[-1])
        else:
            tl.append(t[pt-1])
            tl.append(t[pt])
        mt = 10 ** 20
        for sv in sl:
            for tv in tl:
                if xv <= sv and xv <= tv:
                    mt = min(mt, abs(max(sv, tv) - xv))
                elif sv <= xv and tv <= xv:
                    mt = min(mt, abs(min(sv, tv) - xv))
                else:
                    mt = min(mt, min(abs(sv - xv), abs(tv - xv)) + abs(tv - sv))
        print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 66780
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int N, M;
vector<double> L, a, b;

inline double SQ(double x) {
  return x*x;
}

double solve(vector<int> &v, const int idx, const double sum, const int cnt) {
  
  if(cnt == M) {
    return sum;
  }
  
  if(idx == N) {
    return 0.;
  }
  
  double ret;
  {
    double add = 0.;
    for(int i=0; i<v.size(); i++) {
      add += SQ(L[idx]-L[v[i]]) + SQ(a[idx]-a[v[i]]) + SQ(b[idx]-b[v[i]]);
    }
    v.push_back(idx);
    ret = solve(v, idx+1, sum+add, cnt+1);
    v.pop_back();
  }
  {
    ret = max(ret, solve(v, idx+1, sum, cnt));
  }
  
  return ret;
}

int main() {
  
  cin >> N >> M;
  L.resize(N);
  a.resize(N);
  b.resize(N);
  
  for(int i=0; i<N; i++) {
    cin >> L[i] >> a[i] >> b[i];
  }
  
  vector<int> v;
  printf("%.7f\n", solve(v, 0, 0., 0));
  
  return 0;
}

Measured memory_bytes: 1260
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "damage", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    bool check = true;
    foreach (e; a)
    {
        if (e % 2)
            continue;
        else if (e % 3 && e % 5)
            check = false;
    }
    if (check)
        writeln("APPROVED");
    else
        writeln("DENIED");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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




int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> cnt(4);
    rep(i,n) {
        string s;
        cin >> s;
        rep(j,s.size()-1){  
            if(s[j]=='A'&&s[j+1]=='B') cnt[0]++;
        }
        if(s[0]=='B'){
            if(s[s.size()-1]=='A') cnt[1]++;
            else cnt[3]++;
        }else if(s[s.size()-1]=='A') cnt[2]++;
    }
    //rep(i,4) cout << cnt[i] << endl;

    if(cnt[1] >= 1){
        cnt[0] += cnt[1]-1;
        cnt[1] = 1;
    }
    
    //if(cnt[2]+cnt[3]>0) cnt[0] += cnt[1]+min(cnt[2],cnt[3]);
    cnt[0] += min(cnt[1],cnt[3]) + min(max(cnt[1],cnt[3]),cnt[2]);
    cout << cnt[0] << endl;

    // rep(i,2)rep(j,10000)rep(k,10000){
    //     int a,b;
    //     a = 0;
    //     if(j+k>0) a = i+min(k,j);
    //     b = min(i,k)+min(max(i,k),j);
    //     if(a != b) cout << i << " "<< j << " "<< k << endl;


    // }
}


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

using namespace std;

void solve() {
  int N, M;
  string S;
  cin >> N >> M >> S;

  vector<int> hist;
  int pos = N;
  while (pos > M) {
    bool a = false;
    for (int i = M; i > 0; i--) {
      if (S[pos-i] == '0') {
        hist.push_back(i);
        a = true;
        pos = pos-i;
        break;
      }
    }

    if (a == false) {
      cout << -1 << endl;
      return;
    }
  }

  hist.push_back(pos);

  reverse(hist.begin(), hist.end());
  for (int x:hist) {
    cout << x << " ";
  }
  cout << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define inp(a) int a; cin>>a;
#define inpa(a,n) vector<int>a(n+2); FOR(i,1,n) cin>>a[i];
#define PI 3.141592653589793238
#define vec(x) vector<x>
#define pii pair<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define FOR(i,j,n) for(int i= j; i<=n; i++)
#define CASE int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define print(x) for(auto c : x) cout << c << " ";
#define dbg(x) cerr << #x << " :: "<< x << endl;
#define dbg2(x,y) cerr << #x << " :: "<<x <<"\t" << #y << " :: "<<y <<endl;
const int INF = 1e9 + 7;
const int maxn = 1e6 + 3;
const int MOD = 1e9 + 7; 
//////////// template ends here //////////////////////////


void solve(){
	inp(n); inp(k);
	inpa(h, n);

	vec(int)dp(n+1, INF);
	dp[1] = 0;

	FOR(i,2,n){
		for(int j = 1; j <= k; j++){
			if(i-j > 0)
				dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
			else
				break;
		}
	}


	cout << dp[n] << endl;


}



int32_t main(){
	#ifndef ONLINE_JUDGE 
		freopen ("input.txt","r",stdin);
		freopen ("output.txt","w",stdout);
	#endif	
	 ios::sync_with_stdio(0); 
	 cin.tie(0); cout.tie(0);
	//CASE{
		solve();
	//}

	cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
}

Measured memory_bytes: 4776
n, k = map(int, input().split())
p = list(map(int, input().split()))

def calc(x):
    return (x + 1) / 2


w = 0

for i in range(k):
    w += calc(p[i])

ans = w
for i in range(k, n):
    w += calc(p[i]) - calc(p[i - k])
    ans = max(ans, w)
print(ans)

Measured memory_bytes: 25060
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(dead_code)]
fn ext_gcd(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (g, x, y) = ext_gcd(b, a % b);
        (g, y, x - (a / b) * y)
    }
}
#[allow(dead_code)]
fn mod_inverse(n: u64, modulo: u64) -> u64 {
    let (_, inv, _) = ext_gcd(n as i64, modulo as i64);
    ((inv + modulo as i64) as u64 % modulo) % modulo
}
#[allow(dead_code)]
fn mod_factor(n: u64, modulo: u64) -> u64 {
    let mut fact = 1;
    for i in 1..=n {
        fact = fact * i % modulo;
    }
    fact
}
#[allow(dead_code)]
fn mod_combination(n: u64, r: u64, modulo: u64) -> u64 {
    if n < r {
        return 0;
    }
    let a1 = mod_factor(n, modulo);
    dbg!(a1);
    let a2 = mod_factor(r, modulo);
    let a3 = mod_factor(n - r, modulo);
    a1 * mod_inverse(a2 * a3 % modulo, modulo) % modulo
}

fn main() {
    input! {
        n: usize,
        c_: [u64; n],
    }
    let mut c = c_.clone();
    c.sort();
    c.reverse();

    let modulo = 1_000_000_007;

    let mut pow4 = vec![1u64; n];
    for i in 1..n {
        pow4[i] = pow4[i - 1] * 4 % modulo;
    }

    let mut dp = vec![0u64; n + 1];
    for i in 0..n {
       dp[i + 1] = 4 * dp[i] % modulo + ((i as u64 + 2) * pow4[i] % modulo) * c[i] % modulo;
       dp[i + 1] %= modulo;
    }
    println!("{}", dp[n]);

    // let mut ret = 0;
    // for i in 0..n {
    //     ret = (ret + c[i] * (i as u64 + 2) % modulo) % modulo;
    // }
    // for _ in 0..n-1 {
    //     ret = ret * 4 % modulo;
    // }
    // println!("{}", ret)
}


Measured memory_bytes: 8144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String[] ab = sc.nextLine().split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		int mennseki = a * b;
		int shuu = 2*a + 2*b;

		System.out.println(mennseki + " " + shuu);
	}

}

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

ans = "APPROVED"
for val in A:
    if val % 2 == 0:
        if (val % 3 == 0) or (val % 5 == 0):
            continue
        else:
            ans = "DENIED"
            break
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#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 pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int x, y;
    cin >> x >> y;
    if (y%2 == 0) {
        int a = 2*x - y/2;
        int b = y/2 - x;
        if (a >= 0 && b >= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }  
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

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

typedef long long ll;
using namespace std;

int main() {
  vector<ll> vec(3);
  cin >> vec[0], cin >> vec[1], cin >> vec[2];
  sort(vec.begin(), vec.end());

  ll A, B, C;
  A = vec[0];
  B = vec[1];
  C = vec[2];

  if (A == B && B == C) {
    cout << 0 << endl;
    return 0;
  }
  if (A == B && B < C) {
    cout << vec[2] - vec[0] << endl;
    return 0;
  }

  // B < Cの場合は処理をスキップ
  ll ans = 0;
  while (B < C) {
    A++;
    B++;
    ans++;
  }

  // ここでB==Cになっているはず
  // abs(A-B)のぶんだけ2を加算する
  ll diff = abs(A - B);
  if (diff % 2 == 0) {
    ans += diff / 2;
  } else {
    ans += (ll)(diff / 2) + 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N+1)
	b := make([]int, N)
	for i := 0; i < N+1; i++ {
		a[i] = getInt()
	}
	for i := 0; i < N; i++ {
		b[i] = getInt()
	}

	ans := 0
	rest := 0
	for i := 0; i < N; i++ {
		if rest != 0 && a[i] > 0 {
			if a[i] >= rest {
				a[i] -= rest
				ans += rest
			} else {
				ans += a[i]
				a[i] = 0
			}
			rest = 0
		}
		if a[i] >= b[i] {
			a[i] -= b[i]
			ans += b[i]
		} else {
			ans += a[i]
			rest += b[i] - a[i]
			a[i] = 0
		}
	}
	ans += min(rest, a[N])
	out(ans)
}


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

int  n, N[20];
bool flag;

void search(int i, int m){
  if(m == 0){
    flag=true;
    return;
  }
  if(i == n) return;
  if(m < 0) return;

  search(i+1, m);
  search(i+1, m-N[i]);
}

int main(void){
  int m, q;
  
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%d", &N[i]);
  scanf("%d", &m);

  for(int i=0; i<m; i++){
    scanf("%d", &q);
    flag=false;
    search(0, q);
    
    if(flag) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



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

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

constexpr int Q_MAX = 1000006;
bool is_prime[Q_MAX];
void init() {
    rep(i, Q_MAX) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep(i, Q_MAX) if (i >= 2) {
        if (is_prime[i]) {
            for (int j = i * 2; j < Q_MAX; j += i) is_prime[j] = false;
        }
    }
}

int n,a[1<<17];
long long dp[1<<17];
long long mod=1e9+7;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	init();
	if(n==1)
	{
		cout<<is_prime[a[0]]<<endl;
		return 0;
	}
	dp[0]=is_prime[a[0]];
	for(int i=0;i<n;i++)
	{
		if(!is_prime[a[i]])continue;
		if(is_prime[a[i+2]]&&a[i+2]>a[i])dp[i+2]=(dp[i+2]+dp[i])%mod;
		if(is_prime[a[i+1]]&&a[i+1]>a[i])dp[i+1]=(dp[i+1]+dp[i])%mod;
	}
	cout<<((dp[n-1]+dp[n-2])%mod)<<endl;
	return 0;
}


Measured memory_bytes: 5248
A, V=map(int,input().split())
B, W=map(int,input().split())
T =int(input())
D = abs(A-B)

if (V-W)*T>=D:
  print("YES")
#elif 10**9-A<=V*T and A<B:
#  print("YES")
#elif abs(-10**9-A)<=V*T and A>B:
#  print("YES")
else:
  print("NO")


Measured memory_bytes: 9172
import queue
N, M = map(int,input().split())
A = list(map(int,input().split()))
B = [0] * M
C = [0] * M
for i in range(M):
  B[i], C[i] = map(int,input().split())

pq = queue.PriorityQueue()
for i in range(N):
  pq.put(A[i])

query = [] 
for i in range(M):
  query.append((C[i],B[i]))

query.sort()
query.reverse()
for i in range(M):
  j = 0
  while j < query[i][1]:
    C = pq.get()
    if(C < query[i][0]):
      pq.put(query[i][0])
    else:
      pq.put(C)
      break
    j = j + 1

  if j < query[i][1]:
    break

ans = 0
while not(pq.empty()):
  ans += pq.get()

print(ans)


Measured memory_bytes: 24232
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var task1 = Convert.ToInt32(input[0]);
        var task2 = Convert.ToInt32(input[1]);
        var task3 = Convert.ToInt32(input[2]);

        var min = Math.Min(task1, task2);
        var max = Math.Max(task1, task2);
        Console.WriteLine(Math.Max(max, task3) - Math.Min(min, task3));
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
int main(void)
{
	int in_second;//??\??????????????????S
	int out_hour, out_minute, out_second;//?????????h:m:s
	
	//??\???
	scanf("%d", &in_second);
	
	//?????????????¨????
	out_second = in_second % 60;
	out_minute = (in_second / 60) % 60;
	out_hour = (in_second / 60) / 60;
	
	//??????
	printf("%d:%d:%d\n", out_hour, out_minute, out_second);
	
	return 0;
}

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

int main() {
  int n, k; cin >> n >> k;
  map<int, int, greater<int>> m;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    m[a]++;
  }

  priority_queue<int, vector<int>, greater<int>> que;
  for (pair<int, int> p : m) que.push(p.second);

  int ans = 0;
  for (int i = 0; i < (int)m.size() - k; i++) {
    ans += que.top(); que.pop();
  }
  cout << ans << endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

struct UnionFind {
    vector<int> par,rank,large;

    void init(int N){
        rank.assign(N,0);
        large.assign(N,1);
        par.resize(N);
        for(int i= 0; i < N; i++){
            par[i]=i;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(rank[rx]<rank[ry]) {
            par[rx]=ry;
            large[ry]+=large[rx];
            large[rx]=0;
        }
        else {
            par[ry]=rx;
            large[rx]+=large[ry];
            large[ry]=0;
            if(rank[rx]==rank[ry])rank[x]++;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return large[root(x)];
    }
};

int main() {
  int N,M;
  cin>>N>>M;
  vector<vector<int>> v(M,vector<int>(3));
  for(int i = 0; i < M ;i++) cin>>v[i][0]>>v[i][1]>>v[i][2];
  UnionFind tree;
  tree.init(N);
  for(int i = 0; i < M; i++){
    tree.unite(v[i][0]-1,v[i][1]-1);
  }
  int ans = 0;
  for(auto x:tree.large){
    if(x!=0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b)
    {
        return b;
    }
    return a; 
}

template<class T>
bool chmin(T &a, const T &b) {
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0; 
}

int main() {
    ll n; cin >> n;
    vector<ll> a(n), s(n+1);
    rep(i, n) {
        cin >> a[i];
        s[i+1] = a[i] + s[i];
        // cout << s[i] << endl;
    }

    if (n == 2)
    {
        cout << abs(a[0] - a[1]) << endl;
        return 0;
    }

    ll min_sum = 10000000000;
    REP(i, 1, n) {
        min_sum = min(abs((s[n]-s[i]) - s[i]), min_sum);
        // cout << min_sum << endl;
    }

    cout << min_sum << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main(void)
{
  int N,A,B;
  int sum=0;
  
  cin>>N>>A>>B;

  for(int i=1;i<=N;i++){
    int tmp=i;
    int tsum=0;
    while(tmp){
      tsum+=tmp%10;
      tmp/=10;
    }
    if(tsum>=A && tsum<=B)
      sum+=i;
  }	

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<set>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
int n,m,i,j,a[100005],l[100005],r[100005],x,y,p[100005];
vector<int> bi[100005],ord;
void dfs(int x,int fa)
{
	p[x]=fa;
	ff(bi[x],it)
	{
		if (*it==fa) continue;
		dfs(*it,x);
		l[x]=max(l[x],l[*it]-1);
		r[x]=min(r[x],r[*it]+1);
	}
	ord.push_back(x);
}
void calc(int x,int fa)
{
	if (!fa) return;
	if (a[x]>-1) return;
//	l[x]=-1<<25;r[x]=1<<25;
	l[x]=max(l[x],a[fa]-1);
	r[x]=min(r[x],a[fa]+1);
	if ((r[x]%2)==(a[fa]%2)) r[x]--;
	a[x]=r[x];
}
int main()
{
	scanf("%d",&n);
	fz1(i,n-1)
	{
		scanf("%d%d",&x,&y);
		bi[x].push_back(y);
		bi[y].push_back(x);
	}
	memset(a,-1,sizeof(a));
	memset(l,-1,sizeof(l));
	memset(r,15,sizeof(r));
	scanf("%d",&m);
	int t;
	while (m--)
	{
		scanf("%d%d",&x,&y);
		t=x;
		a[x]=l[x]=r[x]=y;
	}
	dfs(t,0);
	for (i=n-1;i>-1;i--) calc(ord[i],p[ord[i]]);
	fz1(i,n)
	{
		ff(bi[i],it)
		{
			if (abs(a[i]-a[*it])!=1)
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	fz1(i,n)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 13176
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b;

	cin >> a >> b;
	int check = 0;
	if (a > 0) {
		check = 1;
	} else if (a <= 0 && b >= 0) {
		check = 0;
	} else {
		b = min(b, 0);
		check = (b - a + 1) % 2 == 1 ? -1 : 1;
	}

	vector<string> ret = {"Negative", "Zero", "Positive"};
	cout << ret[check + 1] << endl;
	return 0;
}


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

int main() {
    int n; // size of the array
    long long res = 0;

    cin >> n;
    int monsters[n+1], heros[n], change = 0;

    for(auto &i : monsters)
        cin >> i;
    for(auto &i : heros)
        cin >> i;

    int ptr_monsters = n;
    for(int i = n - 1; i >= 0 && ptr_monsters >= 0; ) {
        ptr_monsters = min(ptr_monsters, i + 1);
        int subsr = min(monsters[ptr_monsters], heros[i]);

        monsters[ptr_monsters] -= subsr;
        heros[i] -= subsr;
        res += subsr;

        if(heros[i] == 0)
            --i;
        else
            --ptr_monsters;
        if(ptr_monsters < i)
            --i;
    }

    cout << res;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int min=0;
    int ans=0;
    for(int i=0;i<n;i++){
        int num;
        cin >> num;
        if(i==0){
        ans++;
        min =num;
        }
        else if(min>=num){
        ans++;
        min =num;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256