akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int calc(string s){
    int num=0;
    for(int i=0; i<s.size(); i++){
        if('2' <= s[i] && s[i] <= '9'){
            if(s[i+1] == 'm') num += (s[i] - '0') * 1000;
            if(s[i+1] == 'c') num += (s[i] - '0') * 100;
            if(s[i+1] == 'x') num += (s[i] - '0') * 10;
            if(s[i+1] == 'i') num += (s[i] - '0') * 1;
            i++;
        }
        else{
            if(s[i] == 'm') num += 1000;
            if(s[i] == 'c') num += 100;
            if(s[i] == 'x') num += 10;
            if(s[i] == 'i') num += 1;
        }
    }

    return num;
}

string restoration(int n){
    string ans;
    for(int i=0; i<4; i++){
        int num = n % 10;
        n /= 10;

        if(1 <= num && num <= 9){
            if(i == 0) ans += "i";
            if(i == 1) ans += "x";
            if(i == 2) ans += "c";
            if(i == 3) ans += "m";

            if(2 <= num){
                string t = to_string(num);
                ans += t;
            }
        }
    }

    reverse(ans.begin(), ans.end());

    return ans;
}

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        string a, b; cin>>a>>b;

        int anum = calc(a);
        int bnum = calc(b);

        cout << restoration(anum + bnum) << endl;
    }
}


Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
  string s;
  int ans = 0;
  while(getline(cin, s)) {
    s += "$";
    string num;
    for(int i = 0; i < s.size(); ++i) {
      if(isdigit(s[i])) {
        num += s[i];
      } else if(num.size()) {
        ans += atoi(num.c_str());
        num = "";
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    string s;cin >> s;
    if(count(ALL(s),s[0]) ==  2 && 
        count(ALL(s),s[1]) == 2 && 
        count(ALL(s),s[2]) == 2 &&
        count(ALL(s),s[3]) == 2)
    cout << "Yes";
    else
    cout << "No";
    return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	string s[3];
	REP(i,3) cin >> s[i];
	int idx[3] = {0};
	int curr = 0;

	while(1){
		curr = s[curr][idx[curr]++] - 'a';
		if(idx[curr] >= s[curr].size()){
			cout << char('A' + curr) << endl;
			return 0;
		}
	}


	return 0;

}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	int avg = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		avg += A[i];
		A[i] *= N;
	}
	int mn = 1 << 30, ptr = -1;
	for (int i = 0; i < N; ++i) {
		int c = abs(A[i] - avg);
		if (mn > c) {
			mn = c;
			ptr = i;
		}
	}
	cout << ptr << endl;
	return 0;
}

Measured memory_bytes: 764
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){

	int N,X,cnt=1;

	cin >> N >> X;
	int L[N+1],i,sum=0;

	for(i = 0; i < N; i++){
		cin >> L[i];

		sum = sum + L[i];
		if(sum <= X)
			cnt++;
	}

	cout << cnt << endl;


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=stdIn.nextLine();
		String ans="";
		for(int i=0;i<s.length();i++){
			char tmp=s.charAt(i);
			if('A'<=tmp&&tmp<='Z')
				ans+=(char)(tmp-'A'+'a');
			else if('a'<=tmp&&tmp<='z')
				ans+=(char)(tmp-'a'+'A');
			else
				ans+=tmp;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 31712
#include <stdio.h>

int main() {

    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);

    int arr[k * 2];

    int cnt = 0;
    int maxdata = a + k;

    int counter = (b - a + 1 <= k ? b - a + 1 : k);

    for (int i = 0; i < counter; i++) {
        //printf("%d\n", a + i);
        arr[i] = a + i;
        cnt++;
    }
    //printf("%d %d\n", maxdata, b - k + 1);

    if (maxdata <= b - k + 1) {
        maxdata = b - k + 1;
    }

    for (int j = maxdata; j <= b; j++) {
        if (j >= a) {
            //printf("%d\n", j);
            arr[cnt] = j;
            cnt++;
        }
    }

    for (int k = 0; k < cnt; k++) {
        printf("%d\n", arr[k]);
    }

    return 0;
}


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

int main(void)
{
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int> c(N),d(N);
	int a,b;
	vector<int> tonari[10000];
  for(int i=0;i<N-1;i++){
    cin>>a>>b;
		tonari[a-1].push_back(b-1);
		tonari[b-1].push_back(a-1);
  }
	int total=0;
  for(int i=0;i<N;i++){
    cin>>c[i];
		total+=c[i];
  }
  sort(c.begin(),c.end());
	int M=total-c[N-1];
	queue<int> q;
	d[0]=c[N-1];
	q.push(0);
	int count=1;
	vector<int> flag(N,0);
	flag[0]=1;
	while(!q.empty()){
		int pos=q.front();
		q.pop();
		for(int i=0;i<tonari[pos].size();i++){
			if(flag[tonari[pos][i]]==0){
				flag[tonari[pos][i]]=1;
				d[tonari[pos][i]]=c[N-1-count];
				count++;
				q.push(tonari[pos][i]);
			}
		}
	}
	cout<<M<<endl;
	for(int i=0;i<N-1;i++){
		cout<<d[i]<<" ";
	}
	cout<<d[N-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long q,h,s,d,n,ans,cnt;
int main()
{
    cin>>q>>h>>s>>d>>n;
    cnt=min(q*4,min(h*2,s));
    if(cnt*2<=d)
    cout<<cnt*n<<endl;
    else
    cout<<((n%2)*cnt)+n/2*d<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,m,v,p;cin>>n>>m>>v>>p;
    vector<ll> a(n);
    rep(i,0,n-1){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll ans=0;
    ll line=a[p-1];
    ll S=0;
    ll ii=0;
    rep(i,0,n-1){
        if(a[i]>=line){
            ii=i;
        }else{
            break;
        }
    }
    rep(i,0,n-1){
        if(i<p){
            ans++;
            continue;
        }
        if(i==p){
            S=m-(a[i-1]-a[i]);
        }else{
            S+=m;
            S=S-(a[i-1]-a[i])*(i-p+1);
        }
        //cout<<i<<" "<<S<<endl;
        if(a[i]==line){
            ans++;
            continue;
        }
        if(a[i]+m<line){
            break;
        }
        if(a[i]==a[i-1]){
            ans++;
            continue;
        }
        if(m*v<=(p-1+n-i)*m+S){
            ans++;
            continue;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 1024
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;

const int mod=1000000007;
const int inf=1000000009;

typedef double db;
typedef long long ll;
typedef vector<int> VI;
typedef unsigned int uint;
typedef pair<int,int> pii;

int rd() {
	char c=getchar(); int t=0,f=1;
	while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
	while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
	if (x<0) putchar('-'),wt(-x);
	else { if (x>9) wt(x/10); putchar(x%10+48); }
}

const int N=100015;
int n,x[N],len,fac[N],Ans=1,rest;

int main() {
	n=rd(),fac[0]=1;
	For (i,1,n) x[i]=rd();
	For (i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
	
	len=1,rest=x[1]-1;
	For (i,2,n)
		if (x[i]-x[i-1]==1) {
			if (rest) rest--,len++;
			else Ans=1ll*Ans*(len+1)%mod,x[i]--;
		}
		else rest+=x[i]-x[i-1]-2,len++;
	
	Ans=1ll*Ans*fac[len]%mod;
	printf("%d\n",Ans);
	return 0;
}






Measured memory_bytes: 896
n,A,B,C = map(int, input().split())
l = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(used, a, b, c):
    if used == n: # n本の使い道を決め終わった
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF # -30は、合成してないときでも＋１０してるからそれの調整
    
    ret0 = dfs(used+1, a, b, c) # 竹iをどの材料にもしない場合
    ret1 = dfs(used+1, a + l[used], b, c) + 10 # 竹iをAの材料にする場合
    ret2 = dfs(used+1, a, b + l[used], c) + 10 # 竹iをBの材料にする場合
    ret3 = dfs(used+1, a, b, c + l[used]) + 10 # 竹iをCの材料にする場合
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> hVec(N);
    for(int i = 0; i < N;i++) cin >> hVec.at(i);


    vector<int> dp(N,INT_MAX);
    dp[0] = 0;
    dp[1] = abs(hVec[1] - hVec[0]);
    for(int i= 2; i < N; i++){
        dp[i] = min(dp[i-1] + abs(hVec[i] - hVec[i-1]),dp[i-2] + abs(hVec[i] - hVec[i-2]) );
    }

    cout << dp[N-1];
    
    return 0;

}

Measured memory_bytes: 1024
def main():
  M=10**9+7
  r1,c1,r2,c2=map(int,input().split())
  n=r2+c2+2
  fac=[0]*(n+1)
  fac[0]=1
  for i in range(1,n+1):fac[i]=fac[i-1]*i%M
  pr1=pow(fac[r1],M-2,M)
  pc1=pow(fac[c1],M-2,M)
  pr2=pow(fac[r2+1],M-2,M)
  pc2=pow(fac[c2+1],M-2,M)
  a=fac[r2+c2+2]*pr2*pc2
  a-=fac[r2+c1+1]*pr2*pc1
  a-=fac[r1+c2+1]*pr1*pc2
  a+=fac[r1+c1]*pr1*pc1
  print(a%M)
main()

Measured memory_bytes: 54128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
 
int main(){
  int n;
  cin >> n;
  string ans;
  if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9) {
    ans = "hon";
  }
  else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
    ans = "pon";
  }
  else {
    ans = "bon";
  }
 
  cout << ans << endl;
  return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a >0 && c >0){
    c -= b;
    a -= d;
  }
  if( c > 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
  

Measured memory_bytes: 3544
import Foundation

let (A, B, H, M) = readLine()!
    .split(separator: " ")
    .map { Double($0)! }
    .mapToTuple()
var diff = (H * 30 + M / 2) - (M * 6)

//print(diff)

let x = B - A * cos(diff / 180 * .pi)
let y = A * sin(diff / 180 * .pi)

//print(x, y)

print(sqrt(x*x + y*y))



// MARK: -----------------------------------------------------------------------


func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating get {
            if let note = dictionary[argument] {
                return note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                return result
            }
        }
    }
}


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

int main(){
  string s, t; cin >> s >> t;
  int n = s.size();
  bool ans = true;
  for(int i = 0; i < n; i++){
  	if(s[i]!=t[i]) ans = false;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
struct Seg_max {
	int n;
	VL dat;
	Seg_max(int n_) : n(), dat(n_ * 4, UNDER) {
		int x = 1;
		while (n_ > x) x *= 2;
		n = x;
	}
	void up(int i) {
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	void change(int i, ll x) {
		i += n - 1;
		dat[i] = x;
		up(i);
	}
	void dec(int i) {
		i += n - 1;
		dat[i]--;
		up(i);
	}
	void inc(int i) {
		i += n - 1;
		dat[i]++;
		up(i);
	}
	ll rec(int a, int b, int k, int l, int r) { // a,b=区間,k=現在見ているところ、
		if (r <= a || b <= l) return UNDER;
		else if (a <= l && r <= b) return dat[k];
		else {
			ll vl = rec(a, b, k * 2 + 1, l, (l + r) / 2);
			ll vr = rec(a, b, k * 2 + 2, (l + r) / 2, r);
			return max(vl, vr);
		}
	}
	ll query(int a, int b) { return rec(a, b, 0, 0, n); }
};
int main() {
	int h, w, m;
	cin >> h >> w >> m;
	VV list(h);
	Seg_max seg(w);
	rep(i, w) {
		seg.change(i, 0);
	}
	rep(i, m) {
		int y, x;
		cin >> y >> x;
		y--, x--;
		list[y].push_back(x);
		seg.inc(x);
	}
	int ans = 0;
	rep(i, h) {
		int f = list[i].size();
		rep(j, list[i].size()) {
			seg.dec(list[i][j]);
		}
		f += seg.query(0, w);
		rep(j, list[i].size()) {
			seg.inc(list[i][j]);
		}
		chmax(ans, f);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 29052
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
using ll  = long long;
template <typename T> T In() {
    T t;
    cin >> t;
    return t;
}
template <typename T> vector<vector<T>> Vec2(int i, int j, T ini = 0) {
    vector<vector<T>> vec(i, vector<T>(i, ini));
    return move(vec);
}
template <typename T> vector<vector<vector<T>>> Vec3(int i, int j, int k, T ini = 0) {
    vector<vector<vector<T>>> vec(i, vector<vector<T>>(j, vector<T>(k, ini)));
    return move(vec);
}

int main() { 
    int N = In<int>();
    int prev = In<int>();
    int max = 0;
    int now = 0;
    for(int i = 0; i < N - 1; i++) {
        int h = In<int>();
        if(prev >= h){
            now++;
        }
        else{
            now = 0;
        }
        if(max < now){
            max = now;
        }
        prev = h;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
using namespace std;
int main(){
    int n,e;
    while(cin>>n>>e,n){
        double mn=INF;
        double tmp;
        for(int i=0;i<=n;i++){
            tmp=(n-i)*(n-i)+i*i;
            tmp=sqrt(tmp);
            tmp-=e;
            mn=min(mn,abs(tmp));
        }
        cout<<mn<<endl;
    }
    return 0;
}




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

int main() {
    int K;
    string S;

    cin >> K >> S;

    int L_S = S.length();

    if (L_S <= K){
        cout << S << endl;
    }
    else{
        cout << S.substr(0, K) << "..." << endl;
    }
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int x=0,y=0;
	int t=0;
	string ans="Yes";

	for(int i=0;i<n;i++){
		int T,X,Y;
		cin>>T>>X>>Y;

		if((T-t)-(abs(x-X)+abs(y-Y))<0 || ((T-t)-(abs(x-X)+abs(y-Y)))%2==1){
			ans="No";
			break;
		}

		t=T;
		x=X;
		y=Y;
	}

	cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e9
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  string s;
  cin >> s;
  map<char, int> m;
  rep(i, s.size()) m[s[i]]++;
  if (m.size() == 2) {
    for (auto a : m) {
      if (a.second != 2) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  char crt = s[0];
  int nb = 1,ans = 1,prev = 0;
  for(ll i = 1; i < s.size(); ++i){
    if(s[i] != crt or i-prev >= 2){
      ++ans;
      if(i-prev >= 2) crt = ' ';
      else crt = s[i];
      prev = i;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r,g,b,n,ans=0;
	cin>>r>>g>>b>>n;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(n-(i*r+j*g)>=0&&(n-(i*r+j*g))%b==0)
				ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    AB = [LI() for _ in range(N)]
    
    AB.sort(key=lambda x: x[0] + x[1], reverse=True)

    score_t = 0
    score_a = 0
    for i in range(N):
        a, b = AB[i]
        if i % 2 == 0:
            score_t += a
        else:
            score_a += b

    print(score_t - score_a)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31312
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    map<int,int> mp;
    int a;
    rep(i,n){
        cin>>a;
        mp[a]++;
    }
    int m=mp.size();
    bool ans=false;
    if(mp[0]==n) ans=true;
    else if(m==2&&mp[0]==n/3&&n%3==0) ans=true;
    else if(m==3&&n%3==0){
        bool flag=true;
        ll s=0;
        for(auto p:mp){
            if(p.second&&p.second!=n/3) flag=false;
            s^=p.first;
        }
        if(flag&&s==0) ans=true;
    }
    if(ans) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 7096
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&a[i][j])
		}
	}
	b := make([]int, m)
	for j := 0; j < m; j++ {
		fmt.Scan(&b[j])
	}

	for i := 0; i < n; i++ {
		ans := 0
		for j := 0; j < m; j++ {
			ans += a[i][j] * b[j]
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 1764
def my_round(x, d=0):
    import math
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x)))/p

def resolve():
    import statistics
    n = int(input())
    x = [int(i) for i in input().split()]
    median = my_round(statistics.mean(x))
    res = sum([(i-median)**2 for i in x])
    print(int(res))
    
resolve()

Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

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

int main()
{
	fastio;
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	range(i,0,n)
		cin>>a[i];
	sort(a.begin(),a.end());
	if(a.back()<k)
	{
		cout<<"IMPOSSIBLE\n";
	}
	else
	{
		int hcf=a[0];
		for(int i=0;i<n;i++)
			hcf=gcd(hcf,a[i]);
		//cout<<hcf<<endl;
		cout<<(k%hcf?"IMPOSSIBLE":"POSSIBLE")<<endl;
	}
}


Measured memory_bytes: 3684
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

int main(){
	string S;
	cin >> S;
	if(S[0]==S[1]&&S[2]==S[3]&&S[0]!=S[2]){
		cout << "Yes" << endl;
		return 0;
	}
	if(S[0]==S[2]&&S[1]==S[3]&&S[0]!=S[3]){
		cout << "Yes" << endl;
		return 0;
	}
	if(S[0]==S[3]&&S[2]==S[1]&&S[0]!=S[2]){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONGINF 1000000000000000000
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int allover_cnt = 0;
	int oversea_cnt = 0;
	REP(i, n) {
		if (s[i] == 'a') {
			if (allover_cnt < a + b) {
				cout << "Yes" << endl;
				allover_cnt++;
				goto ok;
			}
		}
		else if (s[i] == 'b') {
			if (allover_cnt < a + b && oversea_cnt < b) {
				cout << "Yes" << endl;
				allover_cnt++;
				oversea_cnt++;
				goto ok;
			}
		}
		cout << "No" << endl;
	ok:;
	}
	return 0;
}

Measured memory_bytes: 896
private fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}
private fun readCharArray(): CharArray {
    return readLine()!!.toCharArray()
}
fun main(args: Array<String>) {
    val first = readIntArray()
    val H = first[0]
    val W = first[1]

    val s: MutableList<CharArray> = mutableListOf()
    for (i in 0 until H) {
        s.add(readCharArray())
    }

    var count = 0
    for(i in 0 until H) {
        for(j in 0 until W) {
            if(s[i][j] == '.') {
                count += 1
            }
        }
    }

    val ans = bfs(s, W, H)

    println(if (ans < 0) "-1" else count - ans -1)

}

private val dx = arrayListOf(1, 0, -1, 0)
private val dy  = arrayListOf(0, 1, 0, -1)
private val INVALID = -1

fun bfs(s: List<CharArray>, W: Int, H: Int): Int {

    val queue: MutableList<Pair<Int, Int>> = mutableListOf()
    queue.add(Pair(0, 0))

    val d: MutableList<MutableList<Int>> = mutableListOf()

    for(i in 0 until H) {
        d.add(mutableListOf())
        for(j in 0 until W) {
            d[i].add(INVALID)
        }
    }
    d[0][0] = 0

    while(!queue.isEmpty()) {
        val p = queue[0]
        queue.removeAt(0)

        if (p.first == H - 1 && p.second == W - 1) {
            break
        }

        for(i in 0 until 4) {
            val ny = p.first + dy[i]
            val nx = p.second + dx[i]

            if (0 <= nx && nx < W &&
                0 <= ny && ny < H &&
                s[ny][nx] != '#' &&
                d[ny][nx] == INVALID
            ) {
                queue.add(Pair(ny, nx))
                d[ny][nx] = d[p.first][p.second] + 1
            }
        }
    }

//    for(i in 0 until H) {
//        println(d[i])
//    }

    return d[H - 1][W - 1]
}


Measured memory_bytes: 37908
#include<stdio.h>
main(){
char W[7][10]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
int M,D=0;
int a,b,c,d,e,f,g=0;
int days=0;
int weeks=0;
while(1){
scanf("%d %d",&M,&D);
if(M==0&&D==0)break;
for(a=1;a<M;a++){
if(a==2){
days=days+29;
}
else if(a==4||a==6){
days=days+30;
}
else if(a==9||a==11){
days=days+30;
}
else{
days=days+31;
}
}
days=days+D;
weeks=days%7;
for(b=0;b<7;b++){
if(weeks==b){
printf("%s\n",W[b]);
}
}
days=0;
weeks=0;
}
return 0;
}

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


void displayVector(vector<string> v)
{
	int n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

int main(){
  int N; cin >> N;
  vector<string> A;
  string tmp;
  REP(i,N){ cin >> tmp; A.push_back(tmp); }
  std::sort(A.begin(), A.end());
  A.erase( unique(A.begin(), A.end()), A.end()  );
  int out = A.size();
  cout << out << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

i32 keta(i64 n) {
  i32 cnt = 0;
  while (n) { n /= 10; cnt++; }
  return cnt;
}

i32 kazu(i64 n, i32 k) {
  while (k) { n /= 10; k--; }
  return n % 10;
}

i32 ketawa(i64 n) {
  i32 sum = 0;
  while (n) { sum += n % 10; n /= 10; }
  return sum;
}

i64 solve(i64 n) {
  f64 mn = 1e18;
  i64 ret = 0;
  for (i32 i = 0; i < keta(n); i++) {
    i32 j = kazu(n, i);
    i64 p = pow(10, i);
    for (i32 k = 0; k <= 9 - j; k++) {
      f64 x = (f64) n / ketawa(n);
      if (mn > x) {
        mn = x; ret = n;
      }
      if (k < 9 - j) n += p;
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 k;
  cin >> k;
  i64 n = 1;
  rep(_, k) {
    i64 ans = solve(n);
    cout << ans << endl;
    n = ans + 1;
  }
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {

 int W ,H ,x ,y ,r;    

scanf("%d %d %d %d %d" ,&W ,&H ,&x ,&y ,&r);    

if((0<=(x-r) && (x+r)<=W && 0<=(y-r) && (y+r)<=H)){      

printf("Yes\n");     

}    

else{      

printf("No\n");     

}    

return 0;

}
 

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		// 素数を全列挙
		boolean[] isPrime = new boolean[55556];
		for(int i = 2 ; i <= 55555 ; i++) isPrime[i] = true;
		for(int i = 2 ; i <= 55555 ; i++) {
			for(int j = 2 ; j * j <= i ; j++) {
				if(i % j == 0) isPrime[i] = false;
			}
		}
		int cnt = 0;
		// 3で割って1余る素数を出力
		for(int i = 2 ; i <= 55555 ; i++) {
			if(i % 5 == 1 && isPrime[i]) {
				System.out.println(i);
				cnt++;
			}
			if(cnt == n) break;
		}
	}
}


Measured memory_bytes: 21716
S=input()
is_odd=len(S)%2
mid1=(len(S)-1)//2
mid2=(len(S))//2
ans=mid2
tmp=S[mid1]
for i in range(mid1+1):
    if tmp==S[mid1-i] and tmp==S[mid2+i]:
        ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()

import copy
def resolve():
    def drop(board_copy):
        change = True
        score = 0
        p = 0
        while change:
            change = False
            for i in range(2, H + 1):
                ser = 1
                for j in range(1, W + 1):
                    if board_copy[i][j] > 0 and board_copy[i][j] == board_copy[i][j - 1]:
                        ser += 1
                    else:
                        if ser >= K:
                            score += 2 ** p * board_copy[i][j - 1] * ser
                            change = True
                            for k in range(i, 0, -1):
                                board_copy[k][j - ser:j] = board_copy[k - 1][j - ser:j]
                        ser = 1
            p += 1
        return score

    H, W, K = map(int, input().split())
    mp = []
    mp.append([0] * (W + 1))
    mp += [list(map(int, input())) + [0] for _ in range(H)]

    ans = 0
    for i in range(1, H + 1):
        for j in range(W):
            mp_copy = copy.deepcopy(mp)
            for k in range(i, 0, -1):
                mp_copy[k][j] = mp_copy[k - 1][j]
            score = drop(mp_copy)
            ans = max(ans, score)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 57436
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n, m;
    cin >> n >> m;
    int r;
    cin >> r;
    vector<vector<P>> G(n);
    for (int i = 0; i < m; i++)
    {
        int s, t, d;
        cin >> s >> t >> d;
        G[s].push_back({d, t});
        // G[t].push_back({d, s});
    }
    priority_queue<P, vector<P>, greater<P>> que;
    int INF = 1001001001;
    vector<int> ans(n, INF);
    ans[r] = 0;
    que.push({0, r});
    while (!que.empty())
    {
        int d = que.top().fi;
        int v = que.top().se;
        que.pop();
        for (auto nv : G[v])
        {
            if (ans[nv.se] > d + nv.fi)
            {
                ans[nv.se] = d + nv.fi;
                que.push({ans[v] + nv.fi, nv.se});
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (ans[i] == INF)
        {
            cout << "INF" << endl;
        }
        else
        {
            cout << ans[i] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, num, ans=0;
  cin >> n;
  rep2(i, n) {
    cin >> num;
    if(i&num&1) ans++;
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int INF = 1e9;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int h,w,ans,c;
int fld[8][8];
bool pos(int x,int y){
      return 0<=x&&x<w&&0<=y&&y<h;
}
void rec(int a){
      int cnt=0,color=fld[0][0];
      //cout<<a<<endl;
      if(a==5){
            if(fld[0][0]!=c)return;
            bool used[w][h];
            memset(used,false,sizeof(used));
            queue<P> Q;
            Q.push(P(0,0));
            used[0][0]=true;
            cnt++;
            while(!Q.empty()){
                  P p=Q.front();Q.pop();
                  REP(j,4){
                        int nx=p.first+dx[j],ny=p.second+dy[j];
                        if(!pos(nx,ny))continue;
                        if(fld[nx][ny]==color&&!used[nx][ny]){
                              used[nx][ny]=true;
                              cnt++;
                              Q.push(P(nx,ny));
                        }
                  }
            }
            ans=max(ans,cnt);
            return;
      }
      for(int i=1;i<=6;i++){
            if(fld[0][0]==i)continue;
            int tmp[w][h];
            REP(j,h)REP(k,w)tmp[k][j]=fld[k][j];
            bool f=false,used[w][h];
            queue<P> Q;
            memset(used,false,sizeof(used));
            while(!Q.empty())Q.pop();
            Q.push(P(0,0));
            while(!Q.empty()){
                  P p=Q.front();Q.pop();
                  used[p.first][p.second]=true;
                  fld[p.first][p.second]=i;
                  REP(j,4){
                        int nx=p.first+dx[j],ny=p.second+dy[j];
                        if(!pos(nx,ny))continue;
                        if(fld[nx][ny]==color&&!used[nx][ny]){
                              Q.push(P(nx,ny));
                        }
                  }
            }
            rec(a+1);
            REP(i,h)REP(j,w)fld[j][i]=tmp[j][i];
      }
}
int main(){
      while(cin>>h>>w>>c&&(h||w||c)){
            REP(i,h)REP(j,w)cin>>fld[j][i];
            ans=0;
            rec(0);
            cout<<ans<<endl;
      }
}

Measured memory_bytes: 1256
X, N = map(int, input().split()) 
p = list(set(range(-100,150)).difference(map(int, input().split())))[::-1]

abs_num = abs(X - 150)
result = 100

for x in p:
  tmp_abs = abs(X - x)
  if tmp_abs <= abs_num:
    abs_num = tmp_abs
    result = x
    
print(result)
    

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Vi a(n);
    vin(a);
    
    int l=0,r=0,sum=0,ans=0;
    for(; l<n; l++){
        while(r<n && sum+a[r]==(sum^a[r])){
            sum+=a[r];
            r++;
        }
        ans += (r-l);
        if(l==r) r++;
        else sum -= a[l];
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

void op(vi& a){
    REP(i,sz(a)) a[i]++;
    auto it = max_element(all(a));
    *it -= sz(a)+1;

}

signed main(){
    int n;
    vi a;
    I(n);
    a.resize(n);
    REP(i,n) I(a[i]);

    int ret = 0;

    auto maxi = max_element(all(a));
    while(*maxi >= 2*n){
        int rep = (*maxi - n) / n;
        *maxi -= rep*(n+1);
        REP(i,n) a[i] += rep;
        ret += rep;
        maxi = max_element(all(a));
    }

    while(*maxi > n-1){
        ret++;
        op(a);
        maxi = max_element(all(a));
    }

    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

vector<ll> prime;

void setPrime(ll x) {
    for (ll i=2; i<=x; i++) {
        bool ok = true;
        for (ll e: prime) {
            if (i%e==0) {
                ok = false;
                break;
            }
            if (e*e>i) {
                break;
            }
        }
        if (ok) prime.push_back(i);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    //setPrime(1000005);
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(whole(a));
    if (mp[1]!=0) {
        if (mp[1]==1) {
            cout << 1 << endl;
            return 0;
        }
        else {
            cout << 0 << endl;
            return 0;
        }
    }
    int ans = 0;
    
    rep(i, n) {
        if (mp[a[i]]!=1) continue;
        int v = a[i];
        //debug(v);
        vector<int> fac;
        for (int j=2; j*j<=v; j++) {
            if ((v%j)==0) {
                fac.push_back(j);
                if (j*j!=v) fac.push_back(v/j);
            }
        }
        //for (int e: fac) debug(e);
        bool ok = true;
        //debug(v);
        for (int e: fac) {
            //if (i==2) debug(e);
            if (mp[e]!=0) ok = false;
        }
        if (ok) {
            ans++;
            //debug(i);
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 32612
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = [int(i) for i in STR()]
l = len(s)
arr = [-1 for _ in range(l)]
tmp = 0
for i in range(l):
    tmp += s[i] * pow(10, l - i, 2019)
    tmp %= 2019
    arr[i] = tmp
arr.sort()
tmp = arr[0]
cnt = 1
ans = 0
for i in range(1, l):
    if tmp == arr[i]:
        cnt += 1
    else:
        ans += cnt * (cnt - 1) // 2
        if tmp == 0:
            ans += cnt
        cnt = 1
        tmp = arr[i]
ans += cnt * (cnt - 1) // 2
if tmp == 0:
    ans += cnt
print(ans)


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

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int n, ans;
	vector<pair<int, int>> a(100010), b(100010);
	REP(i, 100010) {
		a[i] = make_pair(0, i);
		b[i] = make_pair(0, i);
	}
	cin >> n;
	REP (i,n) {
		int v;
		cin >> v;
		if (i % 2 == 0)a[v].first++;
		else b[v].first++;
	}

	SORT(a);
	SORT(b);
	if (a[100009].second == b[100009].second)ans = min(n - a[100009].first - b[100008].first, n - a[100008].first - b[100009].first);
	else ans = n - a[100009].first - b[100009].first;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
def bubblesort(a)
    swapcount = 0
    flag = true
    while flag do
        flag = false
        (a.size-1).downto(1){|j|
            a[j], a[j-1], flag, swapcount = a[j-1], a[j], true, swapcount+1 if a[j]<a[j-1]
        }
    end
    return swapcount
end

gets
a = gets.split.map(&:to_i)
ct = bubblesort a
puts a.join(' '), ct


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

#define MOD 10000007
#define f first
#define s second
#define pb push_back
#define es " "
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main(){
    fastio;
    char a;
    cin >> a;
    int sla=(int)a+1;
    cout << (char)sla << endl;
    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

ans = 0

if X == 3:
    ans += 100000

if Y == 3:
    ans += 100000

if X == 2:
    ans += 200000

if Y == 2:
    ans += 200000

if X == 1:
    ans += 300000

if Y == 1:
    ans += 300000

if X == 1 and Y == 1:
    ans += 400000
print(ans)


Measured memory_bytes: 3316