akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=509;
	int mod;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	struct Limit{
		int l,r,val,id;explicit Limit(){}
		Limit(int _l,int _r,int _val,int _id):l(_l),r(_r),val(_val),id(_id){}
		inline bool operator <(const Limit &A)const{
			if(A.val!=val) return val<A.val;
			return r<A.r;
		}
	}d[N];
	int n,f[2][N][N];
	int main(){
		n=read<int>(),mod=read<int>();
		for(int i=0;i<2*n;i++){
			if(i<=n) d[i].l=ceil(sqrt(n*n-i*i));
			else d[i].l=0;
			d[i].r=min(2*n-1,(int)sqrt(4*n*n-i*i));
			if(i<n) d[i].val=d[i].l-1;
			else d[i].val=d[i].r;
			d[i].id=i;
		}
		sort(d,d+2*n);

		int cur=0;
		for(int k=0;k<=n;k++) f[cur][k][0]=1;
		for(int i=1,t=0;i<=2*n;i++){
			int pre=cur;cur^=1;
			for(int k=0;k<=n;k++)
				for(int j=k;j>=0;j--){
					if(d[i-1].id>=n) f[cur][k][j]=1LL*f[pre][k][j]*(d[i-1].r+1-(t+j))%mod;
					else{
						f[cur][k][j]=1LL*f[pre][k][j]*(d[i-1].r+1-(2*n-d[i-1].id-1+k-j))%mod;
						if(j) f[cur][k][j]=(1LL*f[pre][k][j-1]*(d[i-1].l-(t+j-1))+f[cur][k][j])%mod;
					}
				}
			if(!d[i-1].l) t++;
		}
		int ans=0;
		for(int k=0;k<=n;k++)
			if(k&1) ans=sub(ans,f[cur][k][k]);
			else ans=add(ans,f[cur][k][k]);
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 5756
fun main(args: Array<String>) {
    val nm = readLine()!!.split(" ").map { it.toInt() }
    val n = nm[0]
    val m = nm[1]

    if (n >= m) {
        println(0)
        return
    }

    val x = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val l = mutableListOf<Int>()

    for (i in 1..(x.size - 1)) {
        l.add(x[i] - x[i - 1])
    }

    val tmp = l.sorted().reversed().subList(0, n - 1).sum()
    val range = x[x.size - 1] - x[0]
    println(range - tmp)
}


Measured memory_bytes: 55568
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<numeric>
#include<iomanip>
#include<climits>

using namespace std;
using ll = long long;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    vector<int> input = {a, b, c, d, e};
    vector<int> permu(5);
    iota(permu.begin(), permu.end(), 0);
    int minTime = INT_MAX;
    do {
        int time = 0;
        for (auto& index : permu) {
            if (time%10 != 0)
                time = (time/10 + 1) * 10;
            time += input[index];
        }
        minTime = min(minTime, time);
    } while (next_permutation(permu.begin(), permu.end()));
    cout << minTime << endl;
}


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

bool solve(int n) {
  for (int x=1; x<=9; ++x) {
    if (n%x) continue;
    int y = n / x;
    if (1<=y && y<=9) return true;
  }
  
  return false;
}

int main(){
  int n;
  cin >> n;
  cout << (solve(n) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, k, x, y, ans;
	cin >> n >> k >> x >> y;
	if (n <= k) ans = n * x;
	else ans = x * k + y * (n - k);

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include<stdlib.h>
#include<stdio.h>
#define M 1000000007
int main()
{
    int N,i;
    long long int sum=1;
    while(scanf("%d",&N)!=EOF)
    {
        for(i=1;i<=N;i++)
        {
            sum=((sum%M)*i)%M;
        }
        printf("%lld\n",sum%M);
        sum=1;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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


Measured memory_bytes: 256
//ITP1_6_A

#include <stdio.h>

int main(){

	int n,i;
	scanf("%d",&n);
	
	int x[n];
	
	for(i=0;i<n;i++){
	
		scanf("%d",&x[i]);
	
	}
	
		for(i=n;i>0;i--){
			printf("%d",x[i-1]);
			if(i==1){printf("\n"); break;}
			printf(" ");
		}

	return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		int n;
		cin >> n;
		n%= 10;
		int flag = 0;
		if (n == 0 || n == 1 || n == 6 || n == 8) {
			flag = 1;
		} else if (n == 3) {
			flag = 2;
		}
		string res = "hon";
		if (flag==1) {
			res = "pon";
		} else if (flag == 2) {
			res = "bon";
		}
		put(res);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
  struct Node *parent;
  struct Node *left;
  struct Node *right;
  int key;
} node;
void preOrder(node *);
void inOrder(node *);
void insert(int);
node *root;
int n;
int main() {
  int i, j, key;
  char command[7];

  scanf("%d", &n);
  for (i = 0; i < n; i++) {    
    scanf("%s", command);
    if ('i' == command[0]) {
      scanf("%d", &key);
      insert(key);
    } else {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n"); 
    }
  }
  return 0;
}
void inOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  if (u->left != NULL) inOrder(u->left);
  printf(" %d",u->key);
  if (u->right != NULL) inOrder(u->right);
  return ;
}
void preOrder(node *u) {
  if (u == NULL) {
    return ;
  }
  printf(" %d",u->key);
  if (u->left != NULL) preOrder(u->left);
  if (u->right != NULL) preOrder(u->right);
  return ;
}
void insert(int key) {
  node *y = NULL;
  node *x = root;
  node *z;

  z = (node*) malloc(sizeof(node));
  z->left = NULL;
  z->right = NULL;
  z->key = key;

  while (x != NULL) {
    y = x;
    if (key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
 
  z->parent = y;
  if ( y==NULL ) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
  return ;
}

Measured memory_bytes: 24040
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
int main()
{
	fast;
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
		cout<<"1"<<endl;
	else if(b==0)
		cout<<"2"<<endl;
	else if(c==0)
		cout<<"3"<<endl;
	else if(d==0)
		cout<<"4"<<endl;
	else if(e==0)
		cout<<"5"<<endl;
}






Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;

int fact[N];
int rev[N];

int bin_pow(int a, int b, int mod) {
  if (!b)
    return 1;
  if (b & 1)
    return a * bin_pow(a, b - 1, mod) % mod;
  int t = bin_pow(a, b / 2, mod);
  return t * t % mod;
}

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  fact[0] = 1;
  rev[0] = 1;
  for (int i = 1; i <= 200000; ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
    rev[i] = bin_pow(fact[i], MOD - 2, MOD);
  }
  int ret = 0;
  for (int i = 1; i <= h - a; ++i) {
    int cntt = i - 1;
    int cntt1 = b - 1;
    int x = (fact[cntt + cntt1] * rev[cntt] % MOD * rev[cntt1] % MOD);
    int cnt1 = h - i;
    int cnt2 = max(0ll, w - b - 1);
    ret += x * (fact[cnt1 + cnt2] * rev[cnt1] % MOD * rev[cnt2] % MOD) % MOD;
    ret %= MOD;
  }
  cout << ret;
  return 0;
}


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

long long gcd(long long x,long long y){
    return y == 0 ? x : gcd(y, x % y);
}


int main(void){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long i;
    long long count = 0;
    long long  C_divable_count = 0;
    long long  D_divable_count = 0;
    long long  CD_divable_count = 0;
    
    C_divable_count = B / C - (A - 1) / C;
    D_divable_count = B / D - (A - 1) / D;
    CD_divable_count = B / (C * D / gcd(C, D)) - (A - 1) / (C * D / gcd(C, D));
    count = B - (A - 1) - C_divable_count - D_divable_count + CD_divable_count;
    cout << count << endl;
}
    




Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, x[1001], y, i;
	double p, p1 = 0, p2 = 0, p3 = 0, p4 = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	for(i = 0; i < n; i++){
		scanf("%d", &y);
		p = abs(x[i] - y);
		p1 += p;
		p2 += pow(p, 2);
		p3 += pow(p, 3);
		if(p > p4) p4 = p;
	}
	printf("%f\n", p1);
	printf("%f\n", sqrt(p2));
	printf("%f\n", pow(p3, 1.0/3.0));
	printf("%f\n", p4);
	
	return(0);
}



Measured memory_bytes: 1972
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(a<=5){
        cout << 0 << endl;
    }else if(a<=12){
        cout << b/2 << endl;
    }else{
        cout << b << endl;
    }

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

const int MIRE = 196471;

int main(void) {
    int n;
    cin >> n;
    while (n--) {
        int Y,M,D;
        cin >> Y >> M >> D;
        int day = 0;
        day += ((Y-1)/3)*590 + ((Y-1)%3)*195;
        if (Y%3 == 0) {
            day += 20 * (M-1);
        }
        else {
            for (int i=1; i<M; i++) {
                day += 19 + (i%2);
            }
        }
        day += D;
        cout << MIRE - day << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int A[4];
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int ans = 0;
    rep(i, N){
        cin >> A[i];
        if (i % 2 == 0 && A[i] % 2 == 1)ans++;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3584
n=int(input())
l=list()
for i in range(n):
  li=[int(i) for i in input().split()]
  l.append(li)
dp=[[0,0,0] for i in range(n)]
dp[0][0]=l[0][0]
dp[0][1]=l[0][1]
dp[0][2]=l[0][2]
for i in range(1,n):
  for j in range(3):
    for k in range(3):
        if j!=k:
            dp[i][j]=max(dp[i-1][k]+l[i][j],dp[i][j])
print(max(dp[-1]))


Measured memory_bytes: 44128
#include <iostream>
 #include <vector>
 using namespace std;
 int main(){
 int N;
 cin>>N;
 vector<int> A(N);
 for(int i=0;i<N;i++) cin>>A[i];
 vector<int> rev(N);
 for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
 for(int i=0;i<N;i++) cout<<rev[i]<<endl;
 return 0;
}

Measured memory_bytes: 1536
import sys
X, N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()
  
if X == 100 and N == 100:
  print(-100)
  sys.exit()
  
  
P = list(map(int, input().split()))

lis = []
for i in range (-100,102,1):
    if i not in P:
        lis.append(i)


        
        
        
ans = 10**18
suzi = 0
lis2 = []
for j in lis:
    num = abs(X-j)
    if num < ans:
        ans = num
        suzi = j

print(suzi)

    


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

using namespace std;

int main() {
    int n,tmp;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    for (int i = 0; i < n; i++) {
        tmp = a.at(i);
        b.at(tmp-1) = i+1;
    }

    for (int i = 0; i < n - 1; i++) {
        cout << b.at(i) << " ";
    }
    cout << b.at(n-1) << endl;

    return 0;
}

Measured memory_bytes: 1664
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
ll lcm(ll a,ll b)
{
  return (a*b)/__gcd(a,b);
}
int main()
{
  // int x = -1, y = 10000;
  // double z = 0.2;
  // string s2 = "beginner1010";
  // long long b = 1LL << 60;
    
  // // debug(x, y, z, s, b);
    
  // double aux = 1010.0;
  // string code = "code";
    
  // debug(code + "forces",-aux / 10 * 2.3);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,f = 0;
  cin >> n;
  map<string,int>m;
  for (int i = 0; i < n; ++i)
  {
    string a;
    cin >> a;
    m[a]++;
  }
  for (auto i : m)
  {
    f = max(f,i.ss); 
  }
  for (auto i : m)
  {
    if (f == i.ss)
    {
      cout << i.ff << endl;
    }
  }
  return 0;
}


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

#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 21;
const int M = (1LL<<N);

int a[N][N];
int pw[N+5];
int n;

vector<int> cur(M),nex(M);
vector<int> go[N+1];

int cnt[M];
const int MOD = 1e9 + 7;

void solve()
{
    pw[0] = 1;
    for(int i=1;i<=N;i++) pw[i] = pw[i-1]<<1;
    
    cin >> n;
    f(i,n) f(j,n) cin >> a[i][j];
    
    f(i,n) if(a[0][i] == 1) cur[pw[i]] = 1;
        
    for(int i=1;i<n;i++)
    {    
        for(auto j : go[i-1]) nex[j] = 0;
        
        for(auto j : go[i])
        {
            for(int k=0;k<n;k++)
            {
                if(a[i][k] == 1 && ( (j&pw[k]) == 0))
                    nex[j|pw[k]] = (nex[j|pw[k]] + cur[j])%MOD;
            }
        }
        
        swap(cur,nex);
    }
    
    cout << cur[pw[n]-1]; 
}

signed main()
{
    f(i,M) go[__builtin_popcount(i)].pb(i);
    
    fast;
    solve();
}

Measured memory_bytes: 26560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<cassert>
#include<stack>
#include<fstream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mad(a,b,m) a=(a+b)%m;
#define N 6666
ll n,m;
ll dp[N][2*N];
int main(){
	cin>>n>>m;
	rep(i,N)rep(j,2*N)dp[i][j]=0;
	dp[0][N]=1;
	for(int a=0;a<3*n;a++){
		for(int b=3;b<2*N-3;b++){
			mad(dp[a+3][b],dp[a][b]*(a+2)*(a+1),m);
			mad(dp[a+2][b-1],dp[a][b]*(a+1),m);
			mad(dp[a+1][b+1],dp[a][b],m);
		}
	}
	ll ans=0;
	for(int i=N;i<2*N;i++)mad(ans,dp[3*n][i],m);
	cout<<ans<<endl;
}


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

namespace abc123c
{
    class Program
    {

        static void Main(string[] args)
        {
            long mina = 10000000000000000;
            long N = long.Parse(Console.ReadLine());
            for (int i = 0; i < 5; i++)
            {
                long a = long.Parse(Console.ReadLine());
                mina = Math.Min(mina, a);
            }
            long tim;
            if (N % mina != 0) {
                tim = N / mina + 5;
            }
            else
            {
                tim = N / mina + 4;
            }


            Console.WriteLine(tim);

        }
    }
}


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

using namespace std;

int main(int argc, char *argv[])
{
    const int M = 1e9 + 7;
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    for (int i = 0; i < H; i++) {
        cin >> grid[i];
    }
    vector<vector<int>> dp(H, vector<int>(W));
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i + 1 < H && grid[i + 1][j] == '.') {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= M;
            }
            if (j + 1 < W && grid[i][j + 1] == '.') {
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= M;
            }
        }
    }
    cout << dp[H - 1][W - 1] << endl;
    return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	char a , b ;
	scanf("%c %c",&a , &b );
	if(a=='H' && b=='H')
    {
     printf("H");
    }
    else if(a=='H' && b=='D')
    {
     printf("D");
    }
    else if(a=='D' && b=='H')
    {
     printf("D");
    }
    else if(a=='D' && b=='D')
    {
     printf("H");
    }
}


Measured memory_bytes: 256
max_n500 = int(input())
max_n100 = int(input())
max_n50 = int(input())
target_amount = int(input())

count = 0
for n500 in range(max_n500 + 1):
    amount_500 = n500 * 500
    if amount_500 > target_amount:
        break
    for n100 in range(max_n100 + 1):
        amount_100 = n100 * 100
        amount_500_100 = amount_500 + amount_100
        if amount_500_100 > target_amount:
            break
        for n50 in range(max_n50 + 1):
            amount_50 = n50 * 50
            current_amount = amount_500_100 + amount_50
            if current_amount == target_amount:
                count += 1
print(count)


Measured memory_bytes: 3064
while(n=gets.to_i)>0
a=[b=[x=0,0]]
p=a*n
m=p.map{gets}
n.times{|i|w=0
n.times{|j|h,w=p[j][0]+1,w+1;m[i][j]==?*&&h=w=0
a[j]=[h,s=[h,w,p[j-1][1]+1].min]
x<s&&x=s}
p,a=a,[b]}
p x
end

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

int main(){
    int n;
    cin>>n;
    vector<int>b(n+1,0);
    for(int i =0;i<3;i++){
        int m;
        cin>>m;
        for(int j=0;j<m;j++){
            int a;
            cin>>a;
            b[a] |= 1<<i;
        }
    }
    int ans =0;
    for(int i =1;i<=n;i++){
        if(b[i]==4||b[i]==6 || b[i] ==7){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3092
<?php
list($k) = ints();
if ($k % 2 === 0) exit('-1');
$mod = 7 % $k;
$cnt = 1;
while ($mod > 0) {
    $mod = ($mod * 10 + 7) % $k;
    ++$cnt;
    if ($cnt > 10 ** 6) exit('-1');
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,a1,b1,c1,sum=0;
    cin>>a>>b>>c;
    if(a<b){a1=a;
    a=b;
    b=a1;}
    if(a<c)
    {
        a1=a;
        a=c;
        c=a1;
    }
    if(b<c)
    {
        b1=b;
        b=c;
        c=b1;
    }
    a1=a%2;
    b1=b%2;
    c1=c%2;
    if((a1==0&&b1==0&&c1==0)||(a1==1&&b1==1&&c1==1))
    {
     sum+=(a-b)/2;
     sum+=(a-c)/2;
    }
    else
    {
        if(a1==b1)
        {
            a+=1;
            b+=1;
        }
        else if(a1==c1)
        {
            a+=1;
            c+=1;
        }
        else if(b1==c1)
        {
            b+=1;
            c+=1;
        }
        sum+=(a-b)/2;
        sum+=(a-c)/2;
        sum++;

    }
    cout<<sum<<endl;

}


Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; typedef long double ldouble ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int k;
  string s;
  cin>>k>>s;
  if(k >= s.length()){
    cout<<s<<endl;
  }else{
    cout<<s.substr(0,k)<<"..."<<endl;
  }

}


Measured memory_bytes: 3640
import java.util.*;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int n = sc.nextInt();
    	int max = sc.nextInt();
    	int[] w = new int[n];
    	int[] v = new int[n];
    	for(int i = 0; i < n; i++) {
    		w[i] = sc.nextInt();
    		v[i] = sc.nextInt();
    	}

    	long[] dp = new long[max+1];
    	for(int i = 0; i < n; i++) {
    		for(int j = max; j >= w[i]; j--) {
    			dp[j] = Math.max(dp[j], dp[j-w[i]] + v[i]);
    		}
    		// System.out.println(Arrays.toString(dp));
    	}

    	// System.out.println(n);
    	// System.out.println(Arrays.toString(dp));
    	System.out.println(dp[max]);
    }
}	

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

int main(void) {
  long N, M; cin >> N >> M;
  long l = 1, r = N;

  for (long i = 0; i < M; i++) {
    long L, R; cin >> L >> R;
    if (l < L) l = L;
    if (R < r) r = R;
  }

  if (r < l) cout << 0 << endl;
  else cout << r-l+1 << endl;

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> card(n);
	for(int i=0;i<n;++i) cin >> card[i];
	sort(card.rbegin(),card.rend());
	bool turn=true;
	auto alice=0,bob=0;
	for(auto i:card){
		if(turn){
			alice+=i;
			turn=false;
		}else{
			bob+=i;
			turn=true;
		}
	}
	cout << alice-bob << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] bingo = new int[3][3];
        bingo[0][0] = sc.nextInt();
        bingo[0][1] = sc.nextInt();
        bingo[0][2] = sc.nextInt();
        sc.nextLine();
        bingo[1][0] = sc.nextInt();
        bingo[1][1] = sc.nextInt();
        bingo[1][2] = sc.nextInt();
        sc.nextLine();
        bingo[2][0] = sc.nextInt();
        bingo[2][1] = sc.nextInt();
        bingo[2][2] = sc.nextInt();
        sc.nextLine();
        int n = sc.nextInt();
        sc.nextLine();
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
            if (i != n -1) {
                sc.nextLine();
            }
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (set.contains(bingo[i][j])) {
                    bingo[i][j] = 0;
                }
            }
        }

        boolean isBingo = false;
        for (int i = 0; i < 3; i++) {
            if ((bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0)
                    || (bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0)) {
                isBingo = true;
                break;
            }
        }
        if (!isBingo) {
            if ((bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0)
                    || (bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0)) {
                isBingo = true;
            }
        }

        if (isBingo) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


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

using i64 = int64_t;

int main(){
    i64 n, m;
    cin >> n >> m;
    vector<pair<i64, i64>> v;
    for(int i=0;i<n;++i){
        i64 a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }

    sort(v.begin(), v.end());
    i64 ans = 0, sum = 0;
    for(auto e: v){
        i64 num = min(e.second, m);
        sum += num;
        ans += num * e.first;
        m -= num;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

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

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}


int n;
int a[2][110];
int dp[2][110];

int main(){
  scanf("%d",&n);
  REP(i,2)REP(j,n){
    scanf("%d",&a[i][j]);
    dp[i][j] = 0;
  }
  dp[0][0] = a[0][0];
  FOR(j,1,n){
    dp[0][j] = dp[0][j-1] + a[0][j];
  }
  dp[1][0] = dp[0][0] + a[1][0];
  FOR(j,1,n){
    dp[1][j] = a[1][j] + max(dp[1][j-1],dp[0][j]);
  }
  printf("%d\n",dp[1][n-1]);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
main(){
  int H,W;
  cin>>H>>W;
  vector<vector<int>>xss(H+2,vector<int>(W+2));
  for(int h=1;h<=H;++h){
    for(int w=1;w<=W;++w){
      char c;
      cin>>c;
      xss[h][w]=c;
    }
  }
  bool failed=false;
  for(int h=1;h<=H;++h){
    for(int w=1;w<=W;++w){
      const vector<pair<int,int>>directions={{0,-1},{0,1},{-1,0},{1,0}};
      if(xss[h][w]=='#'){
        bool found=false;
        for(auto d:directions){
          if(xss[h+d.first][w+d.second]=='#')found=true;
        }
        if(!found)failed=true;
      }
    }
  }
  cout<<(!failed?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

int func(int x, int a, int b) { return a * x / b - a * (x / b); }

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

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

    int x = min(n, b - 1);

    cout << func(x, a, b) << endl;
}


Measured memory_bytes: 3612
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: Vec<char> = read::<String>().chars().collect();
    println!(
        "{}",
        if n[0..3].iter().all(|&c| c == n[0]) || n[1..].iter().all(|&c| c == n[1]) {
            "Yes"
        } else {
            "No"
        }
    );
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
ll L[MAX/2+2],R[MAX/2+2];
ll cnt=0,sum=0;
void merge(ll A[],ll n,ll left,ll mid ,ll right){
    ll n1 = mid   - left;
    ll n2 = right - mid;
    REP(i,n1)L[i] = A[left+i];
    REP(i,n2)R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    ll i = 0,j = 0;
    REP2(k,left,right){
        cnt++;
        if(L[i]<=R[j]){
            A[k] = L[i++];
        }else{
            A[k] = R[j++];
            sum+=n1-i;
        }
    }
}
void mergeSort(ll A[],ll n,ll left,ll right){
    if(left+1<right){
        ll mid = (left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int main(){
    ll N,a,b;
    cin >> N;
    ll A[MAX];
    REP(i,N){
        cin >> A[i];
    }
    mergeSort(A,N,0,N);
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 6340
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

char X, Y;

int main()
{
	in >> X >> Y;
	if (X < Y) { out << '<' << std::endl; }
	else if (X == Y) { out << '=' << std::endl; }
	else { out << ">" << std::endl; }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i], a[i]--;

    deque<int> b;
    vector<bool> f(n, false);
    f[0] = true;
    ll pos = 0, cnt = 0;
    while (1) {
        if (cnt == k) {
            cout << pos+1 << endl;
            return 0;
        }
        cnt++;
        b.push_back(pos);
        pos = a[pos];
        if (f[pos]) {
            b.push_back(pos);
            break;
        } else {
            f[pos] = true;
        }
    }
    while (1) {
        if (b.front() != pos) {
            b.pop_front();
        } else {
            break;
        }
    }
    b.pop_back();

    k -= cnt;

    // cout << k << endl;

    k = k%b.size();

    // cout << k << endl;
    // cout << endl;
    // rep(i,b.size()) {
    //     cout << b[i] << endl;
    // }

    // k -= 1;
    // k %= b.size();
    cout << b[k]+1 << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int r;
  cin>>r;
  
  if(r<1200) {
    cout<<"ABC";
  } else if(r<2800) {
    cout<<"ARC";
  } else {
    cout<<"AGC";
  }
  
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
hs = [0]
ans = [0]
ans.extend([1]*n)
hs.extend(list(map(int, input().split())))

for i in range(m):
    a, b = map(int, input().split())
    if hs[a] == hs[b]:
        ans[a] = 0
        ans[b] = 0
    elif hs[a] < hs[b]:
        ans[a] = 0
    else:
        ans[b] = 0

print(sum(ans))


Measured memory_bytes: 20864
import bisect
n, d, a = map(int, input().split())
data = []
for i in range(n):
    data.append(list(map(int, input().split())))
data.sort()
monster_hp = []
monster_x = []
for i in range(n):
    monster_hp.append(data[i][1])
    monster_x.append(data[i][0])
ans = 0
damage_range = [0 for i in range(n+1)]
for i in range(n):
    #step1 i体目のモンスターに入ってるダメージを計算。
    damage_range[i+1] += damage_range[i]
    damage = damage_range[i+1] * a
    if damage < monster_hp[i]:
        #もしこのモンスターが既に致死量でないなら,魔法を打つ必要がある
        min_requaired = (monster_hp[i] - damage + a - 1) // a
        index = bisect.bisect_right(monster_x, monster_x[i] + 2 * d)
        damage_range[i+1] += min_requaired
        if index < n:
            damage_range[min(index+1, n)] -= min_requaired
        ans += min_requaired
print(ans)
    

Measured memory_bytes: 106456
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int n,m;
    cin >> n >> m;
    int a[n][m];
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int flag[m+1] = {};

    int ans = 9999;

    rep(loop,m){
        int count[m+1] = {};
        rep(i,n){
            rep(j,m){
                if(flag[a[i][j]] == 0){
                    count[a[i][j]]++;
                    break;
                }
            }
        }
        int tmp = 0;
        int argi = 0;
        rep(i,m+1){
            if(tmp<count[i]){
                tmp = count[i];
                argi = i;
            }
        }
        ans = min(ans,tmp);
        flag[argi] = 1;
    }

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


Measured memory_bytes: 640
#!/usr/bin/env python
# coding: utf-8

# In[8]:


s = input()
K = int(input())


# In[9]:


mylist = []
length = len(s)
for i in range(length):
    for j in range(i,min(length, i+K)):
        mylist += [s[i:j+1]]
mylist_s = sorted(list(set(mylist)))
print(mylist_s[K-1])


# In[ ]:






Measured memory_bytes: 11276
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

typedef struct{
	int a; //下限
	int b; //上限
	int c; //派手さ
}clothes;

int d, n;
int t[200];
clothes p[200];

long dp[202][201];

long rec(int x, int y){ //x日目,前の日にきてた服y
	if(dp[x][y]>=0) return dp[x][y];
	
	long ret=0;
	if(x==0){
		for(int i=0; i<n; ++i){
			if(p[i].a<=t[x] && t[x]<=p[i].b){
				int tmp=rec(x+1, i);	
				if(ret<tmp) ret=tmp;
			}
		}	
	}
	else if(x==d) return 0;	
	else{
		int mm=0;
		for(int i=0; i<n; ++i){
			if(p[i].a<=t[x] && t[x]<=p[i].b){
				int cc=p[i].c-p[y].c;
				if(cc<0) cc=-cc;
				
				int tmp=rec(x+1, i)+cc;	
				if(mm<tmp) mm=tmp;
			}
		}
		ret+=mm;	
	}
	
	return dp[x][y]=ret;
}

int main(){
	scanf(" %d %d", &d, &n);
	for(int i=0; i<d; ++i) scanf(" %d", &t[i]);
	for(int i=0; i<n; ++i) scanf(" %d %d %d", &p[i].a, &p[i].b, &p[i].c);
	
	memset(dp, -1, sizeof(dp));
	printf("%ld\n", rec(0,0));	
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    string ans;
    while(n>0){
        n--;
        ans+='a'+n%26;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001;

int N;
ll cum[MX], xo[MX], A[MX], ans;

bool bad(int l, int r) {
    return cum[r]-cum[l-1] != (xo[r]^xo[l-1]);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    FOR(i,1,N+1) {
        cin >> A[i];
        cum[i] = cum[i-1] + A[i];
        xo[i] = xo[i-1] ^ A[i];
    }
    int l = 1;
    FOR(r,1,N+1) {
        while (bad(l,r)) l ++;
        ans += r-l+1;
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 4992
#include <stdio.h>

long long int between(long long int a, long long int b, long long int c) {
	long long int lo = a/c, hi = b/c;
	if (a%c != 0) lo++;
	if (lo > hi) return 0;
	return hi-lo + 1;
}

long long int gcd(long long int a, long long int b) {
	while (b) {
		long long int t = b;
		b = a%b;
		a = t;
	}
	return a;
}

long long int lcm(long long int a, long long int b) {
	long long int g = gcd(a, b);
	return a*b / g;
}

int main(void) {
	long long int a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

	long long int cnt = b-a + 1;
	cnt -= between(a, b, c);
	cnt -= between(a, b, d);
	cnt += between(a, b, lcm(c, d));
	printf("%lld\n", cnt);
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (5000)
#define MAX_K (5000)

int N, K;
int A[MAX_N];
bool DP[MAX_K];

void solve() {
  sort(A, A + N);
  ll sum = 0;
  for (int i = 0; i < N; i++) sum += A[i];
  for (int j = 0; j < K; j++) DP[j] = false;
  DP[0] = true;

  int ans = 0;
  for (int i = N - 1; i >= 0; i--) {

    bool no_need = true;
    for (int j = 0; j < K; j++) {
      if (DP[j] && j + sum >= K) {
        no_need = false;
        break;
      }
    }
    if (no_need) ans++;

    for (int j = K - 1; j >= 0; j--) {
      int k = j + A[i];
      if (k < K) DP[k] |= DP[j];
    }
    sum -= A[i];

    debug_printf("sum = %lld, a = %d\n", sum, A[i]);
    for (int j = 0; j < K; j++) debug_printf("%s ", DP[j]? "o": "x");
    debug_printf("\n");
  }
  printf("%d\n", ans);
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);

  solve();

  return 0;
}


Measured memory_bytes: 888
n = int(input())
P = [float(i) for i in input().split()]

DP = [[0] * (n+1) for j in range(n+1)]
DP[0][0] = 1

for i in range(n):
    for j in range(n):
        DP[i+1][j+1] += DP[i][j] * P[i]
        DP[i+1][j] += DP[i][j] * (1 - P[i])

print(sum(DP[n][(n+1)//2:]))

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

const int N = 1 << 20;

int l[N], vals[N], v[N];

int ant, n, m;

int main() {
#ifdef HOME
	freopen("agc17c.in", "r", stdin);
	freopen("agc17c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int x, y, t;

	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		l[i] = i + 1;
	for (int i = 1; i <= n; ++i)
		cin >> vals[i], --l[vals[i]];

	for (int i = 1; i <= n; ++i)
		for (int j = max(1, l[i]); j <= i; ++j)
			++v[j];

	for (int i = 1; i <= n; ++i)
		ant+= int(!v[i]);

	while (m--) {
		cin >> x >> y;
		t = x;
		x = vals[x];
		vals[t] = y;

		if (l[x] > 0) {
			--v[l[x]];
			if (!v[l[x]])
				ant+= 1; }
		++l[x];

		--l[y];
		if (l[y] > 0) {
			++v[l[y]];
			if (v[l[y]] == 1)
				ant-= 1; } 

		cout << ant << '\n'; }

	return 0; }


Measured memory_bytes: 6400
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
x = int(input())

A = [1]
for i in range(x+1):
    for j in range(2,x+1):
        if i**j <= x and i**j not in A:
            A.append(i**j)
        if i**j > x:
            break

print(max(A))

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

int main()
{
	int N, K;
	cin >> N >> K;

	vector<int> D(K);
	for (int i = 0; i < K; i++)
	{
		cin >> D.at(i);
	}

	for (int j = N; j < 100000; j++)
	{
		//桁数
		int digit = log10(j) + 1;
		vector<int>vec(digit);
		int temp = j;
		for (int i = 0; i < digit; i++)
		{
			vec[i] = temp % 10;
			temp = temp - vec[i];
			temp /= 10;
		}

		for (int a = 0; a < digit; a++)
		{
			//ブラックリストに含まれている
			if (std::find(D.begin(), D.end(), vec.at(a)) != D.end())
			{
				vec.at(a) = -1;
				break;
			}
		}
		int counter = 0;
		for (int a = 0; a < digit; a++)
		{
			if (vec.at(a) != -1) counter++;
		}

		if (digit == counter)
		{
			cout << j << endl;
			break;
		}

	}

}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL S(LL n) {
  LL ans = 0;
  while (n > 0) {
    ans += n % 10;
    n /= 10;
  }
  return ans;
}

int main() {
  LL K; cin >> K;
  set<LL> s;

  LL base = 1;
  for (LL i = 0; i < 15; ++i) {
    for (LL j = 1; j < 1000; ++j) {
      s.insert(base * (j + 1LL) - 1LL);
    }
    base *= 10LL;
  }

  vector<LL> v;
  double vmin = DBL_MAX;
  for (auto it = s.rbegin(); it != s.rend(); ++it) {
    LL x = *it;
    double y = (double)x / S(x);
    if (y <= vmin) {
      vmin = y;
      v.push_back((LL)x);
    }
  }

  reverse(v.begin(), v.end());
  for (int i = 0; i < K; ++i) cout << v[i] << endl;
}


Measured memory_bytes: 4200
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 21;
int mat[N][N];
int dp[(1<<N)+10];
  int n;
int full=0;
const int M = 1e9 + 7;
int solve(int msk,int id){
  if(msk==full)return 1;
  int &x = dp[msk];
  if(x!=-1)return x;
  x=0;
  for(int j=0;j<n;j++){
      if(msk&(1<<j))continue;
      if(mat[id][j]==1)x=(x+ solve(msk|(1<<j),id+1))%M;
  }
  return x%M;
}

int32_t main(){
  memset(dp,-1,sizeof(dp));
  fastio; 
  cin>>n;
  full = (1<<n)-1;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>mat[i][j];
    }
  }

  cout << solve(0,0) << endl;
 
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 16768