akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=300010,M=1000010,P=1e9+7;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const double eps=1e-9,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(1ll*a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n,m;
int l[N],r[N];
int c[N];

#ifdef FILE
const int READ_SIZE=1<<20;
char buf[READ_SIZE],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,READ_SIZE,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),m=read();
	for(int i=1;i<=n;i++)
	{
		int L=read()-1,R=read();
		for(int l=1,r=0;l<=L;l=r+1)
		{
			r=min(L/(L/l),R/(R/l));
			if(L/l<R/l) c[l]++,c[r+1]--;
		}
		c[L+1]++,c[R+1]--;
	}
	for(int i=1;i<=m;i++) c[i]+=c[i-1];
	for(int i=1;i<=m;i++) printf("%d\n",c[i]);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n; cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<2*n<<endl;
}

Measured memory_bytes: 256
// Problem : C - /\/\/\/
// Contest : AtCoder - AtCoder Beginner Contest 111
// URL : https://atcoder.jp/contests/abc111/tasks/arc103_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
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;
 
#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,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#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()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	unordered_map<int,int,custom_hash> m0,m1;
	vpi v0,v1;
	F0R(x,N)
	{
		int nb;
		cin>>nb;
		if(x%2==0)
			m0[nb]++;
		else
			m1[nb]++;
	}
	// int a0=-1,a1=-1;
	for(auto i:m0)
	{
		v0.pb({i.s,i.f});
	}
	for(auto i:m1)
	{
		v1.pb({i.s,i.f});
	}
	sort(v0.rbegin(),v0.rend());
	sort(v1.rbegin(),v1.rend());
	if(v0[0].s!=v1[0].s)
	{
		cout<<N/2-v0[0].f+N/2-v1[0].f<<nl;
	}
	else if(sz(v0)==1 && sz(v1)==1)
	{
		cout<<N/2<<nl;
		// return 0;
	}
	else if(sz(v0)==1)
	{
		cout<<N/2-v1[1].f<<nl;
		// return 0;
	}
	else if(sz(v1)==1)
	{
		cout<<N/2-v0[1].f<<nl;
		// return 0;
	}
	else
	{
		int ans=min(N/2-v0[0].f+N/2-v1[1].f,N/2-v0[1].f+N/2-v1[0].f);
		cout<<ans<<nl;
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8452
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll f(ll x){
    ll ret = 0;
    while(x){
        ret++;
        x /= 10;
    }
    return ret;
}

int main(){

    ll N;
    cin >> N;
    ll ans = N;
    for(ll i = 1; i * i <= N; i++){
        if(N % i)continue;
        ll a = i;
        ll b = N / i;
        ans = min(ans, max(f(a), f(b)));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N, NN;

  std::cin >> N;

  NN = N;

  for (long long i = 0, l = 26; ; i ++) {
    if (N <= l) {
      std::string s;

      N --;

      for (int j = 0; j <= i; j ++, N /= 26)
        s.push_back(N % 26 + 'a');

      std::reverse(ALL(s));

      std::cout << s << std::endl;

      break;
    }
    else {
      N -= l;
      l *= 26;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3652
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void main() {
    auto a = reads();
    if (a[0] + a[1] == 15)
        writeln("+");
    else if (a[0] * a[1] == 15)
        writeln("*");
    else
        writeln("x");
}


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

int main(){
    string S;
    cin >> S;
    string a[4];

    for(int i = 0; i < 4; i++){
        a[i] = S.substr(i,1);
    }

    int cou = 0;

    for(int i = 1; i < 4; i++){
        if(a[0] == a[i]){
            cou++;
        }
    }

    int ans = 0;
    for(int i = 2; i < 4; i++){
        if(a[1] == a[i]){
            ans++;
        }
    }

    int k = 0;
    if(a[2] == a[3]){
        k++;
    }

    if((cou == 1 && ans == 1) || (cou == 1 && k == 1) || (ans ==1 && k == 1) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

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

	while(true){
	    H = in.nextInt();
	    W = in.nextInt();
	    if(H==0 && W==0)break;
	     
	    for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
		    if(i==0 ||i==H-1)System.out.print("#");
		    else {
			if(j==0 || j==W-1)System.out.print("#");
			else System.out.print(".");
		    }
		}
		System.out.println(); 
	    }
	    System.out.println();  
	}
    }
}
	   



Measured memory_bytes: 34560
package main

import (
	. "fmt"
)

// func init() { Println("----------------------------------------") }

func main() {
    var n, m int
    var cnt map[string]int = make(map[string]int)

    Scanf("%d", &n)
    for i := 0; i < n; i++ {
        var tmp string
        Scanf("%s", &tmp)

        if _, ok := cnt[tmp]; ok {
            cnt[tmp]++
        } else {
            cnt[tmp] = 1
        }
    }

    Scanf("%d", &m)
    for i := 0; i < m; i++ {
        var tmp string
        Scanf("%s", &tmp)

        if _, ok := cnt[tmp]; ok {
            cnt[tmp]--
        } else {
            cnt[tmp] = -1
        }
    }

    max := 0
    for _, v := range cnt {
        if v > max {
            max = v
        }
    }
    Println(max)
}


Measured memory_bytes: 512
import math
import itertools

def main():
    N = int(input())
    towns = []
    for _ in range(N):
        x, y = map(int, input().split())
        towns.append([x, y])

    ans = 0
    for order in itertools.permutations(list(range(N)), N):
        d = 0
        for i in range(N-1):
            s, e = order[i], order[i+1]
            d += math.sqrt((towns[s][0] - towns[e][0]) ** 2 + (towns[s][1] - towns[e][1]) ** 2)
        ans += d / math.factorial(N)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74408
z[75][75];s,d,t,a,*p,j;main(i){for(;scanf("%d%d",&s,&d)*d++;printf("%d\n",s)){for(memset(z,t=9,2e4);s--;)for(j=i=d;--i;a&&*p>a?*p=a:0,*z[t]>*p?t=i:0)scanf("%d",&a),p=z[i];for(;--j;)for(s=j;--s;a?z[s][j]=z[j][s]=a:0)scanf("%d",&a);for(s=i=0;d+~i++;t=a)for(s+=*z[t],*z[t]=0,a=j=d;--j;*p&&*z[a]>*p?a=j:0)p=z[j],*p=fmin(*p,p[t]);}}

Measured memory_bytes: 0
if __name__ == '__main__':
    S = list(input())
    ans = 0
    for state in range(1 << (len(S)-1)):
        ans += eval(S[0] + ''.join(('+' if (state >> i & 1) else '')+x for i, x in enumerate(S[1:])))
        # print(str(state))
        # print(S[0] + ''.join(('+' if (state >> i & 1) else '')+x for i, x in enumerate(S[1:])))
        # print("------------------")
    print(ans)

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

int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
    int dp[n+1];
    dp[2]=abs(arr[1]-arr[0]);
    dp[3]=min(dp[2]+abs(arr[2]-arr[1]),abs(arr[2]-arr[0]));
    for(int i=4;i<=n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
	}
  cout<<dp[n];
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 1010101;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[8] = { 1,-1,0,0,1,1,-1,-1 };
ll dy[8] = { 0,0,1,-1,1,-1,1,-1 };
ll dp[2010][2010];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	string s;
	cin >> s;
	ll n = s.length();
	if (s[n - 1] == 's')s += "es";
	else s += "s";
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSubarraySum solver = new CSubarraySum();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSubarraySum {
        private static final int MAX = 1_000_000_000;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int s = in.nextInt();
            int bad = s == MAX ? s - 1 : s + 1;

            int[] answer = new int[n];
            for (int i = 0; i < n; i++) {
                answer[i] = i < k ? s : bad;
            }

            out.println(Util.join(answer));
        }

    }

    static class Util {
        public static String join(int... i) {
            StringBuilder sb = new StringBuilder();
            for (int o : i) {
                sb.append(o);
                sb.append(" ");
            }
            if (sb.length() > 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
            return sb.toString();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32276
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int N;
	vector<pii> dat;
	
	cin >> N;
	REP(i, N) {
		int A, B;
		scanf("%d %d", &A, &B);
		dat.push_back(pii(B, A));
	}
	sort(ALL(dat));
	
	bool ok = true;
	int cur = 0;
	REP(i, N) {
		cur += dat[i].se;
		if (cur > dat[i].fi) ok = false;
	}
	
	puts(ok ? "Yes" : "No");
	
	return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

set<string>st;
int N;
void dfs(int idx,char c,vector<int>dat){
	dat[idx] = c - 'a';
	for (int i = idx + 1; i < N; i++) {
		if (dat[i] == -1)dfs(i,c,dat);
	}
	int ok = 1;
	for (int i = 0; i < N; i++) {
		if (dat[i] == -1) { dfs(i, c + 1, dat); ok = 0; break; }
	}
	if (ok) {
		string S;
		for (int i = 0; i < N; i++)S.pb(dat[i]+'a');
		st.insert(S);
	}
}

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

	cin >> N;
	vector<int>dat(N, -1);
	dfs(0,'a',dat);
	fore(x, st)puts(x);

	return 0;
}


Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

bool compare(pair<int, int> a, pair<int, int> b)
{
  return a.second < b.second;
}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> cnt;
  cnt.resize(N);
  for (int i = 0; i < M; ++i)
  {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ++cnt[a], ++cnt[b];
  }
  for (int i = 0; i < N; ++i)
  {
    if (cnt[i] % 2 == 1)
    {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e18;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    ll r,g,b;
    cin >> r >> g >> b;
    if((r*100 + g*10 + b) % 4 == 0){
        puts("YES");
    }else{
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,k;
  cin>>n>>k;
  vector<ll> p(n);
  rep(i,n)cin>>p[i];
  vector<ll> acc(n+1);
  rep(i,n) {
    acc[i+1]=acc[i]+p[i];
  }
  ll mx=0;
  rep(i,n) {
    if(i+k-1>=n) {
      break;
    }
    mx=max(mx,acc[i+k]-acc[i]);
  }
  cout << 1.0*(mx+k)/2 << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
ll x;
ll a[2010][2010];

int main(){

  n = in();
  x = in();
  REP( i , n ){
    a[0][i] = in();
  }
  ll ans = INFLL;
  REP( i , n ){
    ll res = 0;
    REP( j , n ){
      res += a[i][j];
    }
    chmin( ans , res + x * i );
    REP( j , n ){
      a[i+1][j] = min( a[i][j] , a[i][(j+n-1)%n] );
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    string S;cin>>S;
    int ans=S.size(),s=0;
    rep(i,S.size()){
        if(S[i]=='S')s++;
        else{
            if(s){
                s--;
                ans-=2;
            }
        }
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long int
 #define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
int main(){
    ll n,m,g,cnt=1;
    cin>>n>>m;
  	g=__gcd(n,m);
  	  for(ll i=2; i*i<=g; i++){
    if(g%i==0){
      cnt++;
      while(g%i==0) g/=i;
    }
  }
  if(g!=1) cnt++;
  cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, P, a[51], dp[52][2];

ll func(int cur, int st){
	if(cur == N)	return (st == P);
	ll &ret = dp[cur][st];
	if(ret != -1)	return ret;
	ret = func(cur + 1, st);
	ret += func(cur + 1, (st + a[cur]) % 2);
	return ret;
}

int main(){
	memset(dp, -1, sizeof(dp));
	scanf("%lld %lld", &N, &P);
	for(int i = 0; i < N; i++)	scanf("%lld", a + i);
	printf("%lld\n", func(0, 0));
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, k = MI()
    H = LI()

    dp = [INF] * n
    dp[0] = 0
    def f(a, b):
        return abs(a - b)
    for i in range(n):
        for j in range(1, k+1):
            if i + j < n:
                dp[i+j] = min(dp[i+j], dp[i] + f(H[i], H[i+j]))
    print(dp[i])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 55392
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
pii a[100010];
int main()
{
	int i,j,k,n,m;
	ll x,y;
	scanf("%d",&n);
	x=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i].fi,&a[i].se);
		x=max(x,1ll*abs(a[i].se)+abs(a[i].fi));
		if(i>0&&(((1ll*abs(a[i].se)+abs(a[i].fi))&1)!=((1ll*abs(a[i-1].se)+abs(a[i-1].fi))&1)))
		{
			printf("-1");
			return 0;
		}
	}
	for(i=0;i<=40;i++)
	{
		if((1ll<<(i))-1>=x)
		{
			break;
		}
	}
	if(x%2==1)
	{
		printf("%d\n",i);
		m=i;
		for(i=0;i<m;i++)
		{
			printf("%d ",1<<i);
		}
		printf("\n");
		string s;
		for(i=0;i<n;i++)
		{
			j=0;
			s="";
			while(1)
			{
				if(j==m-1)
				{
					if(a[i].fi==0)
					{
						if(a[i].se==1)
						{
							s+='U';
						}
						else
						{
							s+='D';
						}
					}
					else
					{
						if(a[i].fi==1)
						{
							s+='R';
						}
						else
						{
							s+='L';
						}
					}
					break;
				}
				else
				{
					if(abs(a[i].fi)>abs(a[i].se))
					{
						if(a[i].fi>0)
						{
							s+="R";
							a[i].fi-=(1<<(m-j-1));
						}
						else
						{
							s+="L";
							a[i].fi+=(1<<(m-j-1));
						}
					}
					else
					{
						if(a[i].se>0)
						{
							s+="U";
							a[i].se-=(1<<(m-j-1));
						}
						else
						{
							s+="D";
							a[i].se+=(1<<(m-j-1));
						}
					}
				}
				j++;
			}
			reverse(s.begin(),s.end());
			cout<<s;
			printf("\n");
		}
	}
	else
	{
		printf("%d\n",i+1);
		m=i;
		for(i=0;i<m;i++)
		{
			printf("%d ",1<<i);
		}
		printf("1");
		printf("\n");
		string s;
		for(i=0;i<n;i++)
		{
			a[i].fi++;
			j=0;
			s="";
			while(1)
			{
				if(j==m-1)
				{
					if(a[i].fi==0)
					{
						if(a[i].se==1)
						{
							s+='U';
						}
						else
						{
							s+='D';
						}
					}
					else
					{
						if(a[i].fi==1)
						{
							s+='R';
						}
						else
						{
							s+='L';
						}
					}
					break;
				}
				else
				{
					if(abs(a[i].fi)>abs(a[i].se))
					{
						if(a[i].fi>0)
						{
							s+="R";
							a[i].fi-=(1<<(m-j-1));
						}
						else
						{
							s+="L";
							a[i].fi+=(1<<(m-j-1));
						}
					}
					else
					{
						if(a[i].se>0)
						{
							s+="U";
							a[i].se-=(1<<(m-j-1));
						}
						else
						{
							s+="D";
							a[i].se+=(1<<(m-j-1));
						}
					}
				}
				j++;
			}
			reverse(s.begin(),s.end());
			cout<<s<<'L';
			printf("\n");
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const double pi=acos(-1);
double a,b,n,m,x,y,z;
signed main()
{
	cin>>a>>b>>n>>m;
	x=n*30+m/2;
	y=m*6;
	z=min(abs(x-y),abs(360-y+x));
	printf("%.15lf",sqrt(a*a+b*b-2*cos(pi/180*z)*b*a));
    return 0;
}

Measured memory_bytes: 4212
import sys
fin = sys.stdin.readline
from collections import defaultdict

class UnionFind(object):
    def __init__(self, N):
        self.__root = list(range(N))
    

    def root(self, x):
        if self.__root[x] == x:
            return x
        else:
            # root abbreviation
            self.__root[x] = self.root(self.__root[x])
            return self.__root[x]

    
    def same(self, x, y):
        return self.root(x) == self.root(y)


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if (x == y):
            return
        self.__root[x] = y
        return


N, K, L = [int(elem) for elem in fin().split(' ')]
road_list = tuple([tuple([int(elem)-1 for elem in fin().split(' ')]) for _ in range(K)])
train_list = tuple([tuple([int(elem)-1 for elem in fin().split(' ')]) for _ in range(L)])

uf_road = UnionFind(N)
uf_train = UnionFind(N)

for p, q in road_list:
    uf_road.unite(p, q)

for r, s in train_list:
    uf_train.unite(r, s)


key_list = []
count = defaultdict(int)
for i in range(N):
    # logN
    key = (uf_road.root(i), uf_train.root(i))
    key_list.append(key)
    count[key] += 1

assert len(key_list) == N
answer_list = [0] * N
for i, key in enumerate(key_list):
    answer_list[i] = str(count[key])
print(' '.join(answer_list))


Measured memory_bytes: 87176
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>

struct Bit{
    const int n;
    std::vector<int> data;
    Bit(const int n):n(n){ data.assign(n + 1, 0); }
    void add(int idx, int val = 1){
        for(; idx <= n; idx += idx & -idx) data[idx] += val;
    }
    int sum(int idx) const {
        int res = 0;
        for(; idx > 0; idx -= idx & -idx) res += data[idx];
        return res;
    }
};


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int n, q; std::cin >> n >> q;
    std::vector<int> A(n); for(int i = 0; i < n; ++i){ std::cin >> A[i]; --A[i]; }

    Bit BIT(n);
    std::vector<int> lastAppend(n, 0);
    std::vector<int> res(q);

    std::vector<std::array<int, 3>> Query(q);
    for(int i = 0; i < q; ++i){
        int l, r; std::cin >> l >> r;
        Query[i][0] = r;
        Query[i][1] = l;
        Query[i][2] = i;
    }
    std::sort(Query.begin(), Query.end());

    for(int r = 1, idx = 0; r <= n; ++r){
        const int color = A[r - 1];
        if(lastAppend[color] != 0) BIT.add(lastAppend[color], -1);
        lastAppend[color] = r; BIT.add(r, 1);
        while(idx < q and Query[idx][0] == r){
            // [l, r] 1-indexedで
            res[Query[idx][2]] = BIT.sum(r) - BIT.sum(Query[idx][1] - 1);
            ++idx;
        }
    }
    for(int i = 0; i < q; ++i){
        std::cout << res[i] << '\n';
    }



    
    return 0;
}

Measured memory_bytes: 17400
s = str(input())
n = 4
for bit in range(1 << (n-1)):
    f = s[0]
    for i in range(0,(n-1)):
        if bit & (1 << i):
            f += '+-' + s[i+1]
        else:
            f += '+' + s[i+1]
    #print(f)
    ans = sum(map(int,f.split('+')))
    if ans == 7:
        break
print(f.replace('+-','-')+'=7')


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

namespace AtTest.ABC_161
{
    class F
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long sqrt = (long)Sqrt(n);

            var hashSet = new HashSet<long>();
            for(long i = 1; i <= sqrt; i++)
            {
                if ((n-1) % i == 0)
                {
                    hashSet.Add(i);
                    hashSet.Add((n - 1) / i);
                }
            }

            for(long i = 2; i <= sqrt; i++)
            {
                if (n % i == 0)
                {
                    long tmp = n;
                    while (tmp % i == 0)
                    {
                        tmp /= i;
                    }
                    if (tmp % i == 1)
                    {
                        hashSet.Add(i);
                    }

                    if (i % (n / i) == 1)
                    {
                        hashSet.Add(i);
                    }
                }
            }

            WriteLine(hashSet.Count);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

int gcd(int a, int b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl


int32_t main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    int cur = 1;
    int ret = 0;
    
    while(cur < B)
    {
        cur += A;
        ret += 1;
        cur -= 1;
    }
    
    cout << ret << endl;
      
    return 0;
}


Measured memory_bytes: 256
n=int(input())
m=[int(pow(6,i)) for i in range(7)]
m9=[int(pow(9,i)) for i in range(1,6)]
m+=m9
m.sort(reverse=True)
# print(m)
dp=[10**18 for i in range(n+1)]
dp[0]=0
for i in range(1,n+1):
  for j in m:
    if i-j>=0:
      dp[i]=min(dp[i],dp[i-j]+1)
# print(dp)
print(dp[n])

Measured memory_bytes: 3864
import java.io.*;
import java.util.*;

class Main{

	public static void main(String[] args){
		solve();
	}
	
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long count = 0;

		if(k==0){
			count = (long)n*(long)n;
		}
		else{
			for(int i=2;i<=n;i++){
				if(i>k){
					count += (long)Math.max(0, n/i*(i-k));
					count += (long)Math.max(0, (n%i)-k+1);
				}
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 23892
#include<iostream>
#include<cstdio>
#define mod 1000000007
#define ll long long
using namespace std;

ll qpow(ll x,ll t){
	ll ans=1;
	while(t){
		if(t&1)ans=(ans*x)%mod;
		x=(x*x)%mod;
		t>>=1;
	}
	return ans%mod;
}

ll fac[200010],nf[200010],h,w,a,b,ans=0;

ll c(ll x,ll y){
	return (((fac[y]*nf[x])%mod)*nf[y-x])%mod;
}

int main(){
	
	fac[0]=1;
	for(ll i=1;i<=200001;i++)
		fac[i]=(fac[i-1]*i)%mod;
	for(ll i=0;i<=200001;i++)
		nf[i]=qpow(fac[i]%mod,mod-2)%mod;
	
	cin>>h>>w>>a>>b;
	
	for(ll i=h-a,j=b+1;i>=1&&j<=w;i--,j++){
//		cout<<i<<" ! "<<j<<endl;
		ans=(ans+mod+((c(i-1,i+j-2)%mod)*(c(h-i,w+h-j-i)%mod))%mod)%mod;
	}
	
	cout<<ans;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {

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


    int m;
    cin >> m;
    vector<ll> b(m);
    rep(i, m) cin >> b[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    vector<ll> results;
    set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(results, end(results)));

    for(ll i : results) {
        cout << i << endl;
    }

}



Measured memory_bytes: 6580
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main()
{
  int N;
  cin >> N;
  unordered_map<string, ll> mp;
  string s;
  rep(i, N){
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  
  //for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
  //      cout << "key = " << itr->first           // キーを表示
  //                      << ", val = " << itr->second << "\n";    // 値を表示
  //}
  
  ll res = 0;
  
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    ll x = itr->second;
    res += x * (x-1) / 2;
  }
  
  cout << res << endl;

}

Measured memory_bytes: 10660
fn insertionsort(a:&mut [u32], g:usize, cnt:&mut usize){
    for i in g..a.len(){
        let v = a[i];
        let mut j = i;
        while j >= g && a[j-g] > v {
            a[j] = a[j-g];
            *cnt += 1;
            j -= g;
        }
        a[j] = v
    }
}

fn shellsort(a:&mut [u32])->(Vec<usize>,usize){
    let mut cnt = 0;
    let gs = {
        let mut gs = vec![];
        let mut x = 1;
        while x <= a.len(){
            gs.push(x);
            x = x*3 + 1;
        }
        gs.reverse();
        gs
    };
    for g in &gs{
        insertionsort(a,*g as usize, &mut cnt);
    }
    (gs,cnt)
}

fn main() {
    use std::io::{BufRead,BufReader};
    let mut input:Vec<u32> = BufReader::new(std::io::stdin())
        .lines()
        .filter_map(|e|e.ok())
        .skip(1)
        .filter_map(|e|e.parse().ok())
        .collect();
    let mut ans = input.clone();
    let (gs,res) = shellsort(&mut input);
    ans.sort();
    assert_eq!(ans,input);
    println!("{}",gs.len());
    for i in 0..gs.len()-1{
        print!("{} ",gs[i]);
    }
    println!("{}",gs[gs.len()-1]);
    println!("{}",res);
    for a in input{
        println!("{}",a);
    }
}



Measured memory_bytes: 14068
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

string toBinary(long long n)
{
    string s;
    while (n != 0)
    {
        int r = abs(n % 2);
        s += to_string(r);
        n -= r;
        n /= 2;
    }
    reverse(s.begin(), s.end());

    return s;
}

int main()
{
    int D, p[11], c[11];
    long long G;
    cin >> D >> G;
    for (int i = 0; i < D; i++)
    {
        cin >> p[i] >> c[i];
    }

    int p_num_min = 100 * 10;
    for (int i = 0; i < pow(2, D); i++)
    {
        string s = toBinary(i);
        while (s.size() < D)
        {
            s = '0' + s;
        }

        long long score = 0;
        int p_num = 0;
        for (int i = 0; i < s.size(); i++)
        {
            score += ((i + 1) * 100 * p[i] + c[i]) * (s[i] - '0');
            p_num += p[i] * (s[i] - '0');
        }

        // cout << score << ", " << p_num << endl;

        if (score >= G && p_num < p_num_min)
        {
            p_num_min = p_num;
        }
        else if (score < G)
        {
            for (int j = 0; j < D; j++)
            {
                // cout << "---------- j = " << j << " ----------" << endl;
                if (s[j] == '1')
                {
                    continue;
                }
                long long tmp_score = score;
                int tmp_p_num = p_num;
                for (int k = 0; k < p[j]; k++)
                {
                    tmp_score += 100 * (j + 1);
                    tmp_p_num++;
                    // cout << tmp_score << " : " << tmp_p_num << endl;
                    if (tmp_score >= G && tmp_p_num < p_num_min)
                    {
                        p_num_min = tmp_p_num;
                        break;
                    }
                }
            }
        }
    }

    cout << p_num_min << endl;

    return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  int hn[n];rep(i,n) cin>>hn[i];
  int good[n];rep(i,n)good[i]=0;
  int a,b;
  rep(i,m) {
    cin>>a>>b;
    if (hn[a-1] >= hn[b-1]) good[b-1]++;
    if (hn[a-1] <= hn[b-1]) good[a-1]++;
  }
  int cnt=0;
  rep(i,n) if (good[i]==0) cnt++;
  cout<<cnt;
}


Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    map<ll, ll> mp;
    for (ll i = 0; i < n; i++) {
        ll t;
        cin >> t;
        mp[t]++;
    }
    ll ans = 0;
    for (auto i : mp){
        if (i.first > i.second) ans += i.second;
        else
            ans += i.second - i.first;
    }
    cout << ans << endl;
}

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


int main(){

    int N, A[200000];
    cin >> N;
    for( int i = 0; i < N; i++ ) cin >> A[i];


    long ans = 0; 
    int right = 0, sum = 0;
    
    /* しゃくとり法 */
    for( int left = 0; left < N; left++ ){ // 左端を動かす
        /* [left,right)の範囲が条件を満たす間 */
        while( right < N && ( sum^A[right] ) == sum + A[right] ){ 
            sum += A[right];
            right++;
        }
        
        ans += right - left; // その区間に含まれる全てが条件を満たす
        
        if( left == right ) right++; // rightとleftが同じならrightも進める
        else sum -= A[left]; // iを1つ左へ動かすのでその分をbitから引く
    }
    
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1024
def inpl(): return list(map(int, input().split()))
N, K = inpl()
A = inpl()

DP = [0]*(K+1)
for i in range(K, -1, -1):
    if DP[i]%2 == 0:
        for a in A:
            if i - a < 0:
                break
            DP[i-a] = 1
if DP[0]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 40176
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define db double
#define ld long double
#define maxn 110
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}
void dfs(){}
int dp[maxn][maxn];
signed main()
{
   
    int num;
    cin>>num;
    memset(dp,0, sizeof(dp));
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j) {
        for (int i = 1; i <=9 ; ++i) {
            if(num<=dp[j][i]){
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)break;
    }
    l--;
    ans.push(r);
    while(l!=0){
        if(num<=dp[l][r-1]){
            r--;
            ans.push(r);
        }else{
            num-=dp[l][r-1];
            if(num<=dp[l][r]){
                ans.push(r);
            }else{
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty()){
        int now=ans.front();
        cout<<now;
        ans.pop();
    }
    return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5;
const int mod=998244353;
bool check[N];
int prime[N];
int mu[N];
void mo(){
    memset(check,false,sizeof check);
    mu[1]=1;int tot=0;
    for(int i=2;i<N;++i){
        if(!check[i]){
            prime[tot++]=i;
            mu[i]=-1;
        }
        for(int j=0;j<tot;++j){
            if(i*prime[j]>=N) break;
            check[i*prime[j]]=true;
            if(i%prime[j]==0){
                mu[i*prime[j]]==0;
                break;
            }else{
                mu[i*prime[j]]=-mu[i];
            }
        }
    }
}
ll quick_pow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
int a[N];
int pre[N];
ll sol(ll x){
    ll anx=0;
    if(x<1e6){
        if(pre[x]) return pre[x];
    }
    for(int i=x;i<=(1e6);i+=x){
        anx+=1ll*(i/x)*a[i];
        anx%=mod;
    }
    if(x<1e6) return pre[x]=anx*anx%mod;
    return anx*anx%mod;
}
int main(){
    mo();
    ll inv2=quick_pow(2,mod-2);
    int n;scanf("%d",&n);
    int x;
    ll sum=0;
    memset(a,0,sizeof a);
    for(int i=1;i<=n;++i){
        scanf("%d",&x);
        a[x]++;sum+=x;
    }
    int NN=1000000;
    ll anx=0;
    //cout<<"cic\n";
    for(int i=1;i<=NN;++i){
        ll tmp=0;
        for(int j=1;j<=NN/i;++j){
            if(mu[j])
            tmp=tmp+1ll*mu[j]*j*j%mod*sol(1ll*i*j)%mod;
            tmp%=mod;
        }
        anx=anx+1ll*i*tmp%mod;anx%=mod;
    }
    anx=(anx-sum)%mod*inv2%mod;if(anx<0) anx+=mod;
    printf("%lld\n",anx);
}


Measured memory_bytes: 14848
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var c = int.Parse(_[2]);
            var k = int.Parse(Console.ReadLine());

            var maxV = Math.Max(Math.Max(a,b),c);

            var v = maxV;
            for(var i = 0; i < k; i++){
                v *= 2;
            }

            Console.WriteLine(a + b + c - maxV + v);
        }
    }
}


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

vector<vector<int>> adj;
vector<int> vis, dist;

void dfs(int u) {
  vis[u] = true;
  for(int v : adj[u]) {
    if(!vis[v]) dfs(v);
    dist[u] = max(dist[u], dist[v] + 1);
  }
}

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

  int n, m;
  cin >> n >> m;

  adj.resize(n+1);
  vis.resize(n+1);
  dist.resize(n+1);

  int x, y;
  for(int i=0; i<m; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
  }
  
  for(int i=1; i<=n; i++) {
    if(!vis[i]) {
      dfs(i);
    }
  }

  cout << *max_element(dist.begin(), dist.end()) << '\n';
  
  return 0;
}

Measured memory_bytes: 11500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n,cx,cy;cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  vector<long long int> h(n);
  long long int cand;
  long long int pcand;
  int fl=0;
  for(i=0;i<n;i++){cin>>x[i]>>y[i]>>h[i];}
 
  for(cx=0;cx<=100;cx++){
    for(cy=0;cy<=100;cy++){
      fl=0;for(i=n-1;i>-1;i--){if(h[i]){pcand=h[i]+abs(cx-x[i])+abs(cy-y[i]);break;}}
       for(i=0;i<n;i++){
        if(h[i]){
         cand=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
         if(pcand!=cand){fl=1;break;}
        }else{
          if(pcand>abs(x[i]-cx)+abs(y[i]-cy)){fl=1;break;}
        }
      }
      if(fl==0){cout<<cx<<" "<<cy<<" "<<pcand<<endl;cx=101;cy=101;}
    }
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  double s,a;
  int i;
  while(scanf("%lf",&s)!=EOF){
    a=s;
    for(i=2; i<=10; i++){
      if((i%2)==0){
	s=s*2;
	a+=s;}
      else{
	s=s/3;
	a+=s;
      }
    }
    printf("%f\n",a);
    a=0;
  }
    return 0; 
  
}

Measured memory_bytes: 648
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  int x,y;
  cin >> x >> y;
  if(((x+y)%3)!=0){
    cout << "0";
  }
  else{
    int acnt=x-(x+y)/3;
    int bcnt=y-(x+y)/3;
    long long int ans=1;
    long long int l;
    int k=min(acnt,bcnt);
    COMinit();
    ans=COM(acnt+bcnt,k);
    cout << COM(acnt+bcnt,k) <<endl;
  }
}

Measured memory_bytes: 16640
#define pi 3.1415926535
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    float R;
    float L;
    cin >> R;
    L = pi * R * 2;
    cout << L;
    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int a, b;
int main() {
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	
	return 0;
}

Measured memory_bytes: 256