akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 1000005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
string s;
int dp[N][2];
int calc(int idx,int carry)
{
    if(idx == s.length())
        return carry;
    if(dp[idx][carry]!=-1)return dp[idx][carry];
    int ans=1e9;
    int val=s[idx]-'0'+carry;
    if(val<10)ans=min(ans,calc(idx+1,0)+val);
    ans=min(ans,calc(idx+1,1)+(10 - val));
    return dp[idx][carry]=ans;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   cin>>s;
   reverse(all(s));
   memset(dp,-1,sizeof(dp));
   cout<<calc(0,0)<<endl;
}



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

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

int solution_sort(vector<pair<int,int>>& dish, int T)
{
    int N = dish.size();
    sort(dish.begin(), dish.end());
    
    int ans = 0;
    vector<int> dp(T, 0);
    for(int i = 0; i < N; ++i){
        int A = dish[i].first;
        int B = dish[i].second;
        ans = max(ans, dp[T-1]+B);
        for(int j = T-1; j >= A; --j) dp[j] = max(dp[j], dp[j-A]+B);
    }
    return ans;
}

int solution_dp(vector<pair<int,int>>& dish, int T)
{
    int N = dish.size();
    
    vector<vector<int>> dp(N+1, vector<int>(T, 0)), dpr(N+1, vector<int>(T, 0));
    for(int i = 1; i < N+1; ++i){
        int A = dish[i-1].first;
        int B = dish[i-1].second;
        for(int j = 0; j < T; ++j) dp[i][j] = dp[i-1][j];
        for(int j = T-1; j >= A; --j) dp[i][j] = max(dp[i][j], dp[i][j-A]+B);
    }
    for(int i = N-1; i >= 1; --i){
        int A = dish[i].first;
        int B = dish[i].second;
        for(int j = 0; j < T; ++j) dpr[i-1][j] = dpr[i][j];
        for(int j = T-1; j >= A; --j) dpr[i-1][j] = max(dpr[i-1][j], dpr[i-1][j-A]+B);
    }
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int B = dish[i].second;
        for(int j = 0; j < T; ++j) ans = max(ans, dp[i][j]+dpr[i][T-j-1]+B);
    }
    
    return ans;
}

int main()
{
    int N, T;
    cin >> N >> T;
    vector<pair<int,int>> dish(N);
    REP(i, N) cin >> dish[i].first >> dish[i].second;

    cout << solution_dp(dish, T) << endl;

    return 0;
}

Measured memory_bytes: 70784
while True:
    points = list(map(int,input().split()))

    if points == [-1,-1,-1]:
        break

    gou = points[0] + points[1]
    if points[0]==-1 or points[1]==-1:
        print("F")
    elif gou >= 80:
        print("A")
    elif 65 <= gou < 80:
        print("B")
    elif 50 <= gou < 65:
        print("C")
    elif 30 <= gou < 50:
        if points[2] >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		System.out.println((a<=8 && b<=8)? "Yay!":":(");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
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--------------------*/

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

struct UnionFind
{
	vector<int> par;
	UnionFind(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
	void init()
	{
		REP(i, par.size()) par[i] = -1;
	}
};


int main()
{
	int n, m;
	while (cin >> n >> m, n)
	{
		vector<pii> p;
		REP(i, n)
		{
			int a; cin >> a;
			p.emplace_back(a, i);
		}
		sort(p.rbegin(), p.rend());
		Edges es;
		REP(i, m)
		{
			int a, b, c; cin >> a >> b >> c;
			a--; b--;
			es.push_back(Edge{ a, b, c });
		}
		sort(ALL(es));
		UnionFind uf(n);
		set<int> st;
		Edges ans;
		REP(i, n)
		{
			st.insert(p[i].second);
			while (i != n - 1 && p[i + 1].first == p[i].first)
			{
				i++;
				st.insert(p[i].second);
			}
			REP(i, es.size())
			{
				int l = es[i].from, r = es[i].to;
				if (st.count(l) && st.count(r) && !uf.same(l, r))
				{
					ans.push_back(es[i]);
					uf.unite(l, r);
				}
			}
			if (ans.size() != i)
			{
				ans.clear();
				uf.init();
			}
		}
		int sum = 0;
		REP(i, ans.size()) sum += ans[i].cost;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3524
import math
import sys
class Point:
    def __init__(self):
        self.x = 0
        self.y = 0

def koch(n,a,b):
    th = math.pi*(60.0/180.0)
    if n == 0:
        return
    s = Point()
    t = Point()
    u = Point()
    s.x = (2.0*a.x + 1.0*b.x)/3
    s.y = (2.0*a.y + 1.0*b.y)/3
    t.x = (1.0*a.x + 2.0*b.x)/3
    t.y = (1.0*a.y + 2.0*b.y)/3
    u.x = (t.x-s.x)*math.cos(th) - (t.y - s.y)*math.sin(th) + s.x
    u.y = (t.x-s.x)*math.sin(th) + (t.y - s.y)*math.cos(th) + s.y
    koch(n-1,a,s)
    print(s.x,s.y)
    koch(n-1,s,u)
    print(u.x,u.y)
    koch(n-1,u,t)
    print(t.x,t.y)
    koch(n-1,t,b)

if __name__ == "__main__":
    n = int(input())
    a = Point()
    b = Point()
    a.x = 0
    a.y = 0
    b.x = 100
    b.y = 0

    print(a.x,a.y)
    koch(n,a,b)
    print(b.x,b.y)


    


Measured memory_bytes: 5796
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;

int main(){                  
   string a, b; cin >> a >> b;
   for(int i = 0; i < a.length()+69; i++){
    	if(a == b){
    		cout << "Yes" << endl;
    		return 0;
    	}
    	string temp = a.substr(0, a.length()-1);
    	string temp2 = ""; temp2 += a[a.length()-1];
    	temp2 += temp;
    	a = temp2; 
   }
   cout << "No" << endl;
	return 0;
}                  


Measured memory_bytes: 3596
#include<stdio.h>

int main() {
   int n, q, i, j, key, a;
   int s[10000];
   int t[500];
   int count = 0;

   scanf("%d\n", &n);
   for (i = 0; i < n; i++)
	   scanf("%d", &s[i]);

   scanf("%d\n", &q);
   for (i = 0; i < q; i++)
	   scanf("%d", &t[i]);

   for (i = 0; i < q; i++) {
	   a = 1;
	   key = t[i];
	   j = 0;
	   while (s[j] != key && j != n) {
		   j++;
	   }
	   if (j == n)
		   a = 0;
	   if (a == 1)
		   count++;

   }
   printf("%d\n", count);

}

Measured memory_bytes: 1796
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 55
int x,y,z;
multiset<string> s;
int main(){
	cin>>x>>y>>z;
	rep (i,1,x) s.insert("a");
	rep (i,1,y) s.insert("b");
	rep (i,1,z) s.insert("c");
	while ((int)s.size()>1){
		string tmp=*s.begin()+*--s.end();
		s.erase(s.begin());
		s.erase(--s.end());
		s.insert(tmp);
	}
	cout<<*s.begin()<<'\n';
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){

	c := make([]int, 3)
	for i, _ := range c {
		fmt.Scan(&c[i])
	}
	if c[0] == 7 && c[1] == 5 && c[2] == 5 {
		fmt.Println("YES")
		return
	}
	if c[0] == 5 && c[1] == 7 && c[2] == 5 {
		fmt.Println("YES")
		return
	}
	if c[0] == 5 && c[1] == 5 && c[2] == 7 {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc068/tasks/arc079_a
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


from collections import defaultdict
N, M = ints()
# グラフを作ってたかだか2回でNに行けるかを探索する(深さ優先が楽かな？)
graph = defaultdict(lambda: [])
for _ in ra(M):
    a, b = mina(*ints())
    graph[a].append(b)
    graph[b].append(a)


def dfs(now, fr, d):
    if d == 2:
        return now == N - 1
    res = False
    for to in graph[now]:
        if fr == to:
            continue
        res = res or dfs(to, now, d + 1)
    return res


print('POSSIBLE' if dfs(0, -1, 0) else 'IMPOSSIBLE')


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

int main() {
  int n;
  cin >> n;
  
  long long a[n][2];
  string s = "";
  cin >> s;
  
  if (s[0] == 'W') {
    a[0][0] = 1;
    a[0][1] = 0;
  } else {
    a[0][0] = 0;
    a[0][1] = 1;
  }
  
  for(long long int i = 1; i < n; i++) {
    if (s[i] == 'W'){
      a[i][0] = a[i-1][0] + 1;
      a[i][1] = a[i-1][1];
    }else {
      a[i][0] = a[i-1][0];
      a[i][1] = a[i-1][1] + 1;
    }
  }
  
  long long int ans = 0;
  ans = min(a[n-2][0], a[n-1][1] - a[0][1]);

  for (long long int i=1; i<n-1; i++)
    ans = ans < a[i-1][0] + a[n-1][1] - a[i][1] ? ans : a[i-1][0] + a[n-1][1] - a[i][1];
  
  cout << ans << endl;
}

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

typedef long long ll;
 
int main(){
  int n, c;
  cin >> n >> c;
  vector<vector<int>> pro(c, vector<int>(100005, 0));
  for(int i=0; i<n; i++){
    int s, t, u;
    cin >> s >> t >> u;
    u--;
    pro[u][s] += 1;
    pro[u][t] -= 1;
  }
  int pro_t[100005] = {};
  for(int i=0; i<100005; i++){
    for(int j=0; j<c; j++){
      if(pro[j][i]==1) pro_t[i-1] += pro[j][i];
      else pro_t[i] += pro[j][i];
    }
  }
  int ans = 0;
  for(int i=0; i<100004; i++){
    pro_t[i+1] = pro_t[i] + pro_t[i+1];
    ans = max(ans, pro_t[i+1]);
  }
  cout << ans << endl;
  return 0;
}


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

const ll mod = 100000007;

const int N = 100010;
ll x[N], y[N];

int main(){
    x[0] = 1;
    rep(i,N){
        for(int j=1; j<=5; ++j)if(i+j<N) (x[i+j] += x[i]) %= mod;
        if(i-5>0) (x[i] += x[i-5]) %= mod;
    }
    y[0] = 1;
    rep(i,N){
        for(int j=1; j<=3; ++j)if(i+j<N) (y[i+j] += y[i]) %= mod;
        if(i-3>0) (y[i] += y[i-3]) %= mod;
    }

    string s;
    while(cin >>s,(s!="#")){
        int n = s.size();

        ll ans = 1;
        int i = 0;
        while(i<n){
            int nx = i;
            while(nx<n && s[nx]==s[i]) ++nx;

            int w = nx-i;
            if(s[i]=='8' || s[i]=='0') (ans *= y[w]) %= mod;
            else (ans *= x[w]) %= mod;

            i = nx;
        }

        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 4896
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        cout << 'x';
    }
    cout << endl;

    return 0;
}

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

int main() {
	// your code goes 
	int n;
	while(cin >>n){
	if(n==0)
	break;
	vector<int> cards;
	int field=0;
	char c;
	for(int i=0;i<n;i++){
		cards.push_back(0);
	}
	for(int i=0;i<100;i++){
		cin >> c;
		cards[i%n]++;
		if(c=='S'){
			field+=cards[i%n];
			cards[i%n]=0;
		}
		if(c=='L'){
			cards[i%n]+=field;
			field=0;
		}
		
		
	}
	
	sort(cards.begin(),cards.end());
	
	for(int i=0;i<n;i++)
	cout << cards[i] << " " ;
	cout << field << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[100100],y[100100],h[100100],g[100100];
ll aa[110][110];
string s,str;
int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  for(int i=0;i<m;i++){
    cin>>x[i]>>y[i];
  }
  for(int i=0;i<m;i++){
    if(h[x[i]-1]>h[y[i]-1]){
      g[y[i]-1]++;
    }else if(h[x[i]-1]==h[y[i]-1]){
      g[x[i]-1]++;
      g[y[i]-1]++;
    }else{
      g[x[i]-1]++;
    }
  } 
  for(int i=0;i<n;i++){
    if(g[i]==0)ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 6768
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b;
    cin>>a>>b;
    if(a>0)
	{
		cout<<"Positive";
	}      
    else if(b>=0)
	{
		cout<<"Zero";
	}             
    else if((a&1)^(b&1))
    {
    	cout<<"Positive";
	}
    else 
    {
    	cout<<"Negative";
	}
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnInts();
        var N = _[0];
        var M = _[1];
        var result = 0;
        switch (N)
        {
            case 0:
            case 1:
                break;
            default:
                result += N * (N - 1) / 2;
                break;
        }
        switch (M)
        {
            case 0:
            case 1:
                break;
            default:
                result += M * (M - 1) / 2;
                break;
        }
        print(result);
    }

    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	ll n,m;cin>>n>>m;
	vector<ll> a( n, 0 );
	REP(i,n) { cin>>a[i]; }
	sort( ALL(a) );
	using P = pair<ll,ll>;
	vector<P> cb( m, P() );
	REP(i,m)
	{
		ll b,c;cin>>b>>c;
		cb[i].first = c;
		cb[i].second = b;
	}
	sort( ALL(cb) );
	
	ll cnt = n;
	ll sum = 0;
	ll ai = n-1;
	BREP(i,m)
	{
		for( ; ai >= 0 && a[ai] >= cb[i].first; --ai )
		{
			if( cnt <= 0 ) break;
			sum += a[ai];
			--cnt;
		}
		if( cnt <= 0 ) break;
		if( cnt <= cb[i].second )
		{
			sum += cnt * cb[i].first;
			cnt=0;
			break;
		}
		sum += cb[i].second * cb[i].first;
		cnt -= cb[i].second;
	}
	if( cnt > 0 )
	{
		for( ; ai >= 0; --ai )
		{
			if( cnt <= 0 ) break;
			sum += a[ai];
			--cnt;
		}
	}

	cout << sum << endl;

	return 0;
}

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



int main(){
    ll n,a,b,c,d,e;
    cin >>n>>a>>b>>c>>d>>e;
    ll f =min(a,b); f=min(f,c); f=min(f,d); f=min(f,e);
    ll ans =5;
    if(n%f==0) n--;
    ans+= n/f;
    cout <<ans<<endl;
}




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

long long X,Y,i,mult;

int main () {
	cin >> X >> Y;
	for(i=1; i<100; i++){
		mult = pow(2, i)*X;
		//pake fungsi eksponen
		if (mult>Y){
			cout << i << endl;;
			break;
		}
	}	
}

Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
      ll n,m,X,Y;
      cin >> n >> m >> X >> Y;
      vector<int>x(n);
      vector<int>y(m);
      rep(i,n)  cin >> x.at(i);
      rep(i,m)  cin >> y.at(i);

      sort(x.begin(),x.end());
      sort(y.begin(),y.end());
     int maxx=x.at(n-1);
      int miny=y.at(0);

      for(int i=X+1;i<=Y;i++){
          if(maxx<i && i<=miny){
              cout << "No War" << endl;
              return 0;
          }
          continue;
      }
      cout << "War" << endl;

  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int X = Integer.parseInt(spl[0]);
		int A = Integer.parseInt(spl[1]);
		sc.close();

		if(X < A){
			System.out.println("0");
		}else{
			System.out.println("10");
		}
	}
}

Measured memory_bytes: 21076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    int N; cin >> N;
    int A, B; cin >> A >> B;
    int a = 0;
    int b = 0;
    int c = 0;
    
    for(int i=0; i<N; i++){
        int p; cin >> p;
        if(p<=A) a++;
        else if(p<=B) b++;
        else c++;
    }
    cout << min(min(a, b),c) << endl;
    return 0;
}


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

int main(void) {
	int a; 

	std::cin >> a;

	if (a == 1) {
		std::cout << "Hello World" << std::endl;
	}
	else {
		int b, c;
		std::cin >> b >> c;

		std::cout << b + c << std::endl;
	}

	return 0;
}

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

using namespace std;
            
vector < int > edge [100009];
vector < int > cost [100009];
bool used[100009] = {0};
int current_value[100009];
bool overall_result = true;

void dfs(int v) {
    used[v] = true;
   // cout << v << " " << current_value[v] << "\n";
    for (int i = 0 ; i < (int)edge[v].size() ; ++i) {
        int to = edge[v][i];
        int d = cost[v][i];
        //cout << "here " << d << " " << to << "\n";
        
        if (used[to] == true) {
            //cout << "it is used " << to << " " << current_value[to]<< "\n";
            if (current_value[to] != d + current_value[v]) {
                overall_result = false;
            }    
        }
        else {
            //cout << "we go here " << d + current_value[v] << "\n";
            
            current_value[to] = d + current_value[v];
            dfs(to);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0 ; i < m ; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        edge[l].push_back(r);
        cost[l].push_back(d);
        
        edge[r].push_back(l);
        cost[r].push_back(-d);
           
    }
    
    for (int i = 1 ; i <= n ; ++i) {
        if(used[i] == false) {
            current_value[i] = 0;
            dfs(i);
        }
    }
    
    if (overall_result == true) {
        
        //for (int i = 1 ; i <= n ; ++i){
          //  cout << current_value[i] << " ";
        //} cout << "\n";
        
        sort(current_value + 1, current_value + n + 1);
        if (current_value[n] - current_value[1] > (long long)1e9) {
            //overall_result = false;
        }    
    }
    
    cout << (overall_result == true ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 17664
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


#print(make_divisors(50))

i= 0

A = int(input())
A_d = make_divisors(A)
count = 0

while A_d[i]<= A**0.5:
    if A == 1:
        count = 0
        break
    count = i
    i += 1

result = []
result.append(A_d[count])
result.append(int(A / A_d[count]))

#print(result)

result_sum = result[0] + result[1] - 2

print(result_sum)


Measured memory_bytes: 3296
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let s = input_line_str().to_charvec();
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int fact(int n){
	if(n < 1) return 1;
	return n*fact(n-1);
}

int main()
{
	int n;
	cin >> n;
	vi x(n),y(n),z;
	rep(i,n) cin >> x[i] >> y[i];
	rep(i,n) z.push_back(i);
	double sum = 0;
	do{
		for(int i = 1; i < n; i++){
			sum += sqrt(pow(x[z[i-1]]-x[z[i]],2)+pow(y[z[i-1]]-y[z[i]],2));
		}
	}while(next_permutation(all(z)));
	cout << fixed << sum/fact(n) << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(m)]
c,ans = [[float("inf") for i in range(n+1)] for i in range(n+1)],0
for i in range(n+1): c[i][i] = 0
for i,j,k in x: c[i][j],c[j][i] = k,k
for k in range(1,n+1):
	for i in range(1,n+1):
		for j in range(1,n+1): c[i][j] = min(c[i][k]+c[k][j],c[i][j])
for i,j,k in x:
	if c[i][j] != k: ans += 1
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1005;
const char END = '\n';

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N;
	cin >> N;
    ll B[150];
	rep(i, N - 1)
		cin >> B[i];
	ll Ans;

	Ans = B[0];
	rep1(i, N - 1) {
		if (B[i] > B[i - 1])
			Ans += B[i - 1];
		else
			Ans += B[i];
//		cout << Ans << END;
	}
	Ans += B[N - 2];
	
	cout << Ans << END;
	return 0;
}


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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(vs) (ll)(vs.size())
#define rep(i,a,b) for (ll i = a; i < b; ++i)
#define rep_(i,a,b) for (ll i = a; i > b; --i)
#define endl '\n'
const ll mod = 1e9 + 7;

const ll maxn = 1e5;

ll n, x;

// #include "debug.h"
void solve() {
	cin >> n;
	ll sum = 0, sum_sq = 0;
	rep(i, 0, n) {
		cin >> x;
		sum = (sum + x) % mod;
		sum_sq = (sum_sq + x * x) % mod;
	}
	int ans2 = ((((sum * sum) % mod - sum_sq + mod) % mod) + mod) % mod;
	if (ans2 & 1) {
		cout << (((ans2 + mod) / 2) % mod) << endl;
	}
	else {
		cout << (ans2 / 2) << endl;
	} 
}

void aux() {
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout<<fixed<<setprecision(10);
	aux();
	ll _ = 1;
	// cin>>_;
	while(_--) {
		solve();
	}
	return 0;
}

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

int main() {
  int D;
  cin>>D;
  if (D==25) {
    cout<<"Christmas"<<endl;
  }
  else if (D==24) {
    cout<<"Christmas Eve"<<endl;
  }
  else if (D==23) {
    cout<<"Christmas Eve Eve"<<endl;
  }
  else {
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  
}


Measured memory_bytes: 764
n = gets.chomp
max_password = "#{n}#{n}#{n}"
password = '111'
min_n = '1'
count = 0
loop.with_index(1) do |_, i|
  if max_password <= password
    count = i
    break
  end
  if password[2] < n
    password = password.to_i.succ.to_s
    next
  elsif password[1] < n
    password[2] = min_n if password[2] == n
    password = (password.to_i + 10).to_s
    next
   elsif password[0] < n
    password[2] = min_n if password[2] == n
    password[1] = min_n if password[1] == n
    password = (password.to_i + 100).to_s
    next
  end
end
  
puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1e9+7;
int main(){
    ll a,b,c;cin>>a>>b>>c;
    if(a+b<c){
        cout<<a+b+1LL+b<<endl;
    }else{
        cout<<b+c<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class UnionFind {
    public:
    int n;
    vector<int> par, rank, size;  //親, 深さ, その木の要素数

    UnionFind(int n): n(n) {
        for(int i=0;i<n;++i){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }

    //根を求める
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int p = find(par[x]);
            size[x] = size[p];
            return par[x] = p;
        }
    }

    //xとyの属する集合の併合
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        
        size[x] += size[y];
        size[y] = size[x];
        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //同じ集合に属するか否か
    bool is_same(int x, int y){
        return find(x) == find(y);
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int a, b;
    UnionFind uf = UnionFind(n);
    for(int i=0;i<m;++i) {
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
        ans = max(ans, uf.size[uf.find(i)]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5812
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(){
	int n,y; cin>>n>>y;
	int val10000=-1, val5000=-1, val1000=-1;

	for(int i=0;i<=n;i++){
		for(int j=0;i+j<=n;j++){
			int k = n - i - j;
			int sum = 10000*i + 5000*j + 1000*k;
			if(sum == y){
				val10000 = i;
				val5000 = j;
				val1000 = k;
			}
		}
	}

	cout<<val10000<<" "<<val5000<<" "<<val1000<<endl;

	return 0;
}

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

int main(){
    int64_t n,q ;
    int64_t k ;
    cin >> n >> k >> q ;
    vector<int> right(n,0) ;
    vector<int> attack(q) ;
    for (size_t i = 0; i < q ; i++)
    {
        cin >> attack.at(i) ;
    }
    for (size_t i = 0; i < q; i++)
    {
        right.at(attack.at(i)-1) ++ ;
    }
    for (size_t i = 0; i < n; i++)
    {
        if (k-(q-right.at(i)) > 0 )
        {
            cout << "Yes" << endl ;
        }else
        {
            cout << "No" << endl ;
        }
        
        
    }
    
    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
void printer (int num, char a) {
  for(int i = 0; i < num; i++) {
    cout << a;
  }
}
int main () {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int xdis = tx - sx, ydis = ty - sy;
  printer(ydis, 'U');
  printer(xdis, 'R');
  printer(ydis, 'D');
  printer(xdis, 'L');
  cout << 'L';
  printer(ydis + 1, 'U');
  printer(xdis + 1, 'R');
  cout << 'D';
  cout << 'R';
  printer(ydis + 1, 'D');
  printer(xdis + 1, 'L');
  cout << 'U' << endl;
  return 0;
}

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

#define int long long int
#define ps push_back
#define mod 1000000007
#define fi first
#define so second
#define pii pair<int,int>
#define TT int tt;cin>>tt;for(int kt=1;kt<=tt;kt++)

int ceil(int a,int b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}

int dp[101][5][5][5];

int solve(int n,int i,int j,int k)
{
    if(i==1 && j==3 && k==2) return 0;
    if(i==1 && j==2 && k==3) return 0;
    if(i==3 && j==1 && k==2) return 0;
    if(dp[n][i][j][k]!=0) return dp[n][i][j][k];
    if(n==3) {dp[3][i][j][k]=1;return 1;}
    int ans=0;
    for(int a=1;a<=4;a++)
    {
        if(a==1 && j==3 && k==2) continue;
        if(a==1 && i==3 && k==2) continue;
        //if(a==3 && j==1 && i==2) continue;
        ans+=solve(n-1,a,i,j);
        ans%=mod;
    }
    dp[n][i][j][k]=ans;
    return ans;
}

signed main()
{
    int n,i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=4;i++) for(j=1;j<=4;j++) for(k=1;k<=4;k++) {sum+=solve(n,i,j,k);sum%=mod;}
    cout<<sum<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility> // pair, tuple, swap
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N+1);//partial sum
  B.at(0) = 0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    B.at(i+1) = B.at(i) + A.at(i);
  }
  map<long long, long long> cnt;
  for(int i=0;i<=N;i++){
    long long num = B.at(i);
    if(cnt.count(num)){
      cnt.at(num)++;
    }else{
      cnt[num] = 1;
    }
  }
  long long result = 0;
  for(pair<int, long long> p : cnt){
    result += p.second*(p.second-1)/2;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string a;
	cin >> a;
	if (a[0] == a[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;

	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;

inline int add(int x, int y)
{
	if (x + y < mod)
		return x + y;
	return x + y - mod;
}

inline int sub(int x, int y)
{
	if (x >= y)
		return x - y;
	return x - y + mod;
}

inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

inline int power(int x, int y)
{
	int r = 1;
	while(y)
	{
		if (y & 1)
			r = mult(r, x);
		x = mult(x, x);
		y >>= 1;
	}
	return r;
}

const int N = 1 << 20;
int n;
int a[N];
int s[N];
VI pos[N];
int cnt0[N];

VI dp;

int solve(VI& v, bool OK)
{
	if (SZ(v) == 1)
		return 1;
		
	int sz = SZ(v);
	VI nuli(sz, 0);
	FOR(i, 0, sz)
		nuli[i] = cnt0[v[i]];
	
	dp.assign(sz, 0);
	
	dp.back() = 1;
	int suma = 1, suma_cnt = nuli.back();
	RFOR(i, sz - 1, 0)
	{
		dp[i] = suma_cnt;
		dp[i] = sub(dp[i], mult(suma, nuli[i]));	
		if (OK)
			dp[i] = add(dp[i], 1);
			
		suma = add(suma, dp[i]);
		suma_cnt = add(suma_cnt, mult(dp[i], nuli[i]));	
	}
	
	/*FOR(i, 0, sz)
		cout << dp[i] << ' ';
	cout << endl;
	FOR(i, 0, sz)
		cout << nuli[i] << ' ';
	cout << endl;*/
	
	int ans = 0;
	FOR(i, 0, sz)
		ans = add(ans, dp[i]);
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("in", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	cin >> n;
	int nuli = 0;
	FOR(i, 1, n + 1)
	{
		cin >> a[i];
		s[i] = a[i] ^ s[i - 1];
		pos[s[i]].PB(i);
		nuli += !s[i];
		cnt0[i] = nuli;
	}
	
	int ans = 0;
	if (s[n] == 0)
		ans = power(2, nuli - 1);	
	
	FOR(i, 1, N)
	{
		if (SZ(pos[i]) == 0)
			continue;
		
		if (s[n] && (i != s[n]))
			continue;
		
		if (s[n])
			ans = add(ans, solve(pos[i], 0));
		else
			ans = add(ans, solve(pos[i], 1));
			
		//debug(ans);
	} 	
	
	cout << ans << endl;
//	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 40564
#include<stdio.h>
#include<math.h>
int main(void){
	int a,i,max = 1,j;
	scanf("%d",&a);
	for(i = 2;i < a;i++){
		for(j = 2;j < a;j++){
			if(pow(i, j) >=  max && pow(i , j) <= a){
				max = pow(i , j);
			}
			else continue;
		}
	}
	printf("%d\n",max);
	return 0;
}


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

using namespace std;

const int mod = 1e9+7;

#define int long long

long long exp(long long b, long long p){

    long long resp = 1;

    b = b % mod;

    while(p > 0){
        if(p & 1){
            resp = (resp * b)%mod;
        }
        p = p >> 1;
        b = (b * b)%mod;
    }

    return resp;
}

long long inverse(long long x){
    return exp(x, mod-2);
}

int binomialCoeff(int n, int k)
{
    int res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (int i = 0; i < k; ++i)
    {
        res = (res*(n - i))%mod;
        res = (res*inverse(i + 1))%mod;
    }

    return res;
}

main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    long long n, a, b;

    cin >> n >> a >> b;

    long long ans = (exp(2, n) + mod - 1)%mod;

    ans = (ans - binomialCoeff(n, a) + mod - binomialCoeff(n, b) + mod)%mod;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import math
[a,b] = [int(i) for i in input().split()]

a_cand = list(range(math.ceil(a * 100 / 8), (a+1)* 100 // 8))
b_cand = list(range(math.ceil(b * 100 /10), (b+1)* 100 // 10))

if min(a_cand) > max(b_cand) or min(b_cand) > max(a_cand):
    print(-1)
else:
    print(max(min(a_cand),min(b_cand)))


Measured memory_bytes: 38512
import java.util.*;

public class Main{
  public static long dp[]=new long[100001];
  public static long go(long a[],int i,int k){
    if(i==a.length-1)
    {
      return 0;
    }
    if(i>a.length-1)
    {
      return 1000000000;
    }
    if(dp[i]!=-1)
    return dp[i];
    long min=1000000000;
    for(int j=i+1;j<=i+k;j++){
      long cost;
      if(j<=a.length-1){
      cost=Math.abs(a[i]-a[j])+go(a,j,k);
      min=Math.min(cost,min);
      dp[i]=min;
      }
    }
    return dp[i];
  }
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in); 
    int n=sc.nextInt();
    int k=sc.nextInt();
    long a[]=new long[n];
    for(int i=0;i<n;i++){
    dp[i]=-1;
    a[i]=sc.nextLong();
    }
    dp[n]=-1;
    System.out.print(go(a,0,k));
  }
}

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 1e3 + 7;
char s[N];
char t[N];
int main()
{
	fastio;

	cin >> s >> t;
	int slen = strlen(s);
	int tlen = strlen(t);

	int res = tlen;
	for (int i = 0; i <= slen - tlen; ++i)
	{
		int ctr = 0;
		for (int j = 0; j < tlen; ++j)
			ctr += (t[j] != s[i + j]);
		res = min(res, ctr);
	}
	cout << res << '\n';

	return 0;
}


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

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    bool eq = 1;
    string s,t;
    cin >> s >> t;
    int n = s.size();
    for(int i=0;i<n;i++) if(s[i]!=t[i]) eq = 0;
    cout << (eq ? "Yes":"No") << '\n';
    return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef struct{
    int v;
    int prev;
}edge_t;

edge_t edges[400005];
int head[200005]={0};
bool vis[200005]={false};

int N, M;

int main(){
    scanf("%d%d", &N, &M);
    int u, v;
    for(int i=1; i<=M; i++){
        scanf("%d%d", &u, &v);
        edges[2*i-1].v=v; edges[2*i-1].prev=head[u];head[u]=2*i-1;
        edges[2*i].v=u; edges[2*i].prev=head[v];head[v]=2*i;
    }

    vis[1]=true;
    for(int k=head[1]; k!=0; k=edges[k].prev){
        if(edges[k].v==N){
            printf("POSSIBLE\n");
            return 0;
        }
        vis[edges[k].v]=true;
    }

    for(int i=2; i<=N; i++){
        if(vis[i]){
            for(int k=head[i]; k!=0; k=edges[k].prev){
                if(edges[k].v==N){
                    printf("POSSIBLE\n");
                    return 0;
                }
            }
        }
    }

    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 4352
import collections
n = int(input())
v = list(map(int, input().split()))

odd = [v[i] for i in range(n) if i % 2 == 0]
even = [v[i] for i in range(n) if i % 2 == 1]

t = collections.Counter(odd).most_common()
t2 = collections.Counter(even).most_common()


t.append([0, 0])
t2.append([0, 0])
ans = t[0][1] + t2[0][1]
if t[0][0] == t2[0][0]:
    ans = max(t[0][1] + t2[1][1], t[1][1]+t2[0][1])
print(n - ans)


Measured memory_bytes: 21084
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
for i in range(X):
    r.append(p[i])
for i in range(Y):
    r.append(q[i])
r.sort(reverse=True)
sum = 0
for i in range(X + Y):
    sum += r[i]
print(sum)

Measured memory_bytes: 23328
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n)cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    rep(i, n){
        rep(j, W+1){
            dp[i+1][j] = dp[i][j];
            if(j >= w[i]){
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 83088
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int x,y,xf,yf;
    cin>>x>>y;
    switch (x)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            xf=1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            xf=2;
            break;
        default:
            yf=3;
    }
    switch (y)
    {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            yf=1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            yf=2;
            break;
        default:
            yf=3;
    }
    cout<<(xf==yf?"Yes":"No")<<endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) cout << setfill('0') << setw(len) << right << a << endl;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    int n;
    cin >> n;
    vi a = vi(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a));
    cout << abs(a[0] - a[a.size() - 1]) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c,k,n;

int main(){
	cin>>a>>b>>c>>k;
	n=max(a,max(b,c));
	for(int i=0;i<k;i++){
		n=n*2;
	}
	cout<<a+b+c+n-max(a,max(b,c))<<endl;
	return 0;
}

Measured memory_bytes: 256