akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;
const ll use =1e18;
int main()
{ 
	
fast;
ll n;
cin>>n;

ll prod=1;

ll a[n];
ll zero=0;

for(ll i=0;i<n;i++)
{
	cin>>a[i];
	if(a[i]==0)zero++;
}

if(zero)
cout<<0<<endl;
else
{
	for(ll i=0;i<n;i++)
	{
		ld z=(ld)use/prod;
		ld y=(ld)a[i];

		if(y>z)
		{
			prod=-1;
			break;
		}
		else prod=prod*a[i];
	}
cout<<prod<<endl;
}
}


Measured memory_bytes: 4436
from math import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))

xx = list()
for i in range(N):
    xx.append(abs(X-x[i]))
num = xx[0]
for i in range(1,N):
    num = gcd(num,xx[i])
print(num)

Measured memory_bytes: 20452
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#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 REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

ll mpow(ll x,ll n);
ll comb(ll n, ll a);
int main(void);

// a / b -> a * b^(MOD-2) -> a * mpow(b,MOD-2)
__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}



ll mpow(ll x, ll n){
    ll ans = 1;
    while(n>=1){
        if(n%2 == 0){
            x = x * x %MOD;
            n = n/2;
        }else{
            ans = ans * x %MOD;
            n = n-1;
        }
    }
    
    return ans;
}

ll comb(ll n, ll a){
    ll ans = 1;
    ll b = a;
    rep(i,a){
        ans *= n;
        ans %=MOD;
        n--;
    }
    rep(i,a){
        ans = ans * mpow(b,MOD-2);
        ans %=MOD;
        b--;
    }
    return ans;
}

int main(void){
	ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    ll ca = comb(n,a)%MOD;
    ll cb = comb(n,b)%MOD;

    ans = mpow(2,n)%MOD-1;
    ans -= ca;
    ans %= MOD;
    ans -= cb;
    ans %= MOD;
    ans += MOD;

    cout << ans%MOD << endl;

    return 0;
}


Measured memory_bytes: 256
fun readLongs() = readLine()!!.split(' ').map(String::toLong)

fun main(args: Array<String>) {
    val (x, y) = readLongs()
    var a = x
    var cnt = 0
    while (a <= y) {
        a = a shl 1
        cnt++
    }
    println(cnt)
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i=0; i<N; ++i) cin >> X[i];
  int cnt=0;

  sort(X.begin(), X.end());
  cnt = X[(N/2)] - X[(N/2)-1];
  cout << cnt << endl;
}

Measured memory_bytes: 640
#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 = 1e-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 main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 1;
	for(int i = 1; i < n; i++){
		if(s[i-1] != s[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int m,r,p;
  
  for(int i=0;;i++){
    cin >> m >> p >> r;
    if(m==-1 && p==-1 && r==-1) break;
    if(m==-1 || p==-1){
      cout << "F" << endl;
      continue;
    }
    if(m+p >= 80){
      cout << "A" << endl;}
    else if(m+p >= 65){
       cout << "B" << endl;}
    else if(m+p >=50){
       cout << "C" << endl;}
      else if(m+p>=30 && r >= 50){
      cout << "C" << endl;}

    else if(m+p >=30){
       cout << "D" << endl;}
  
    else{
      cout << "F" << endl;}
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  typedef long long int ll;
int A, B, C;
cin >> A >> B;
int ans = 0;
bool two = false;
int gr = 0;
if(A == 4 || A == 6 || A == 9 || A == 11)ans++;
else if(A != 2)gr++;
if(B == 4 || B == 6 || B == 9 || B == 11)ans++;
else if(B != 2)gr++;
if(ans == 2 || gr == 2)cout << "Yes" << endl;
else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
AC = [0] * N

for i in range(1, len(S)):
    if S[i-1] == 'A' and S[i] == 'C':
        AC[i] = AC[i-1] + 1
    else:
        AC[i] = AC[i-1]


for i in range(Q):
    start, end = map(lambda x:int(x)-1, input().split())
    print(AC[end] - AC[start])

Measured memory_bytes: 6060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
void judge(int len){
    string ss=s;
    reverse(ss.begin(),ss.end());
    string s1=s.substr(0,(len-1)/2);
    string ss1=s1;
    reverse(ss1.begin(),ss1.end());
    string s2=s.substr((len+3)/2-1,len-(len+3)/2+1);
    string ss2=s2;
    //cout<<s1<<" "<<s2<<endl;
    reverse(ss2.begin(),ss2.end());
    if(s1==ss1 && s2==ss2 && ss==s) {puts("Yes");return;}
    else {puts("No");return;}
}
int main(){
    cin>>s;
    int len=s.size();
    judge(len);
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int N;
	cin >> N;
	vector<bool> visited(N, false);
	vector<int> color(N);
	queue<int> que;
	vector<vector<pair<int, ll>>> edge(N);
	REP(i, N-1){
		int u, v;
		ll w;
		cin >> u >> v >> w;
		edge[u-1].push_back(pair<int, ll>(v, w));
		edge[v-1].push_back(pair<int, ll>(u, w));
	}
	que.push(1);
	color[1-1] = 0;
	while(not que.empty()){
		int u = que.front();
		que.pop();
		visited[u-1] = true;
		for(auto p : edge[u-1]){
			if(not visited[p.F-1]){
				que.push(p.F);
				if(p.S %2 == 0){
					color[p.F-1] = color[u-1];
				}else{
					color[p.F-1] = color[u-1] xor 1;
				}
			}
		}
	}
	REP(i, N){
		cout << color[i] << endl;
	}
}


Measured memory_bytes: 8320
#include <iostream>

using namespace std;

void calc(int types[], int D, int c[], int s[][27])
{
    int last[27];
    for (int i = 1; i <= 26; i++)
    {
        last[i] = 0;
    }
    int satisfy = 0;
    for (int d = 1; d <= D; d++)
    {
        int today = types[d];
        satisfy += s[d][today];
        last[today] = d;
        for (int i = 1; i <= 26; i++)
        {
            satisfy -= c[i] * (d - last[i]);
        }
        cout << satisfy << endl;
    }
    //return satisfy;
}

int main()
{
    int D;
    cin >> D;
    int c[26 + 1];
    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }
    int s[D + 1][26 + 1];
    for (int d = 1; d <= D; d++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[d][j];
        }
    }
    int types[D+1];
    for(int d=1;d<=D;d++){
        cin >> types[d];
    }

    /*
    int types[D + 1];
    for (int d = 1; d <= D; d++)
    {
        int i_max = 1;
        int s_max = 0;
        for (int i = 1; i <= 26; i++)
        {
            if (s[d][i] > s_max)
            {
                s_max = s[d][i];
                i_max = i;
            }
        }
        cout << i_max << endl;
        types[d] = i_max;
    }
    */
    calc(types, D, c, s);
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a,b;
	cin >> a >> b;
	int max = -1000;
	if(a+b > max) max = a+b;
	if(a-b > max) max = a-b;
	if(a*b > max) max = a*b;
	cout << max << "\n";
	return 0;
}

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

int main(){
    int n, i, j, m = 0;
    string s;
    cin >> n >> s;
    for(i=0; i<n; i++){
        int c = 0;
        int a[26] = {}, b[26] = {};
        for(j=0; j<i; j++){
            a[(int)s[j]-'a'] = 1;
        }
        for(; j<n; j++){
            b[(int)s[j]-'a'] = 1;
        }
        for(j=0; j<26; j++){
            if(a[j] == 1 && b[j] == 1){
                c++;
            }
            m = max(m, c);
        }
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define fst first
#define snd second
#define mp make_pair
#define fore(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;

int n;
vector<pair<int,int> > r;

int main(){
    scanf("%d",&n);
    if(n%2){
        fore(i,1,n)r.pb(mp(i,n));
        n--;
    }
    fore(i,1,n+1){
        fore(j,i+1,n+1)if(j!=n+1-i)r.pb(mp(i,j));
    }
    printf("%d\n",SZ(r));
    for(auto p:r)printf("%d %d\n",p.fst,p.snd);
    return 0;
}


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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
int main()
{
    FASTIO;
    ll n,i,j,count=0;
    cin>>n;
    std::map<string,ll> Map;
    string s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        Map[s]=i;
    }


    cout<<Map.size()<<"\n";
}



Measured memory_bytes: 19280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class abc141_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String S = in.next();
            String aS[] = S.split("");
            boolean acceptable = true;
            for (int i = 0; i < aS.length; i += 2) {
                if ((aS[i].compareTo("R") == 0) ||
                        (aS[i].compareTo("U") == 0) ||
                        (aS[i].compareTo("D") == 0)) {
                } else {
                    acceptable = false;
                    break;
                }
            }
            if (!acceptable) {
                out.println("No");
                return;
            }
            for (int i = 1; i < aS.length; i += 2) {
                if ((aS[i].compareTo("L") == 0) ||
                        (aS[i].compareTo("U") == 0) ||
                        (aS[i].compareTo("D") == 0)) {
                } else {
                    acceptable = false;
                    break;
                }
            }
            if (acceptable) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 22612
n=int(input())
l=[*map(int,input().split())]
ans=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if abs(l[i]-l[j])<l[k]<l[i]+l[j] and l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]: ans+=1
print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

int l[105];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < 2*n; ++i)
		cin >> l[i];
	sort(l,l+2*n);
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		ans += l[i*2];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
ll dp[100100];

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[5]==s[4]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  int N, c=0, p=0, w=0, g=0, y=0;
  
  cin >> N;
  
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if(s == "Y"){
      c++;
      break;
    }
  }
  
  if(c==0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

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

int main(){
  ll n,up,ans;
  cin >> n;
  vector<ll> v(100);
  vector<ll> buy;
  vector<ll> sell;
  cin >> v[0] >> v[1];
  if(v[1]>v[0]){
    up=1;
    buy.push_back(0);
  }
  else if(v[1]<=v[0]){
    up=-1;
  }
  rep(i,n-2){
    cin >> v[i+2];
    if(up==1){
      if(v[i+2]<v[i+1]){
        sell.push_back(i+1);
        up=-1;
      }
    }
    else if(up==-1){
      if(v[i+2]>v[i+1]){
        buy.push_back(i+1);
        up=1;
      }
    }
  }
  if(up==1){
    sell.push_back(n-1);
  }
  ans = 1000;
  rep(i,(int)buy.size()){
    ans += (v[sell[i]]-v[buy[i]])*(ans/v[buy[i]]);
  }
  cout << ans << endl;
}

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

int main() {
  long long Q, H, S, D, N;
  scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);
  S = min({Q * 4, H * 2, S});
  printf("%lld\n", S * 2 <= D ? S * N : D * (N / 2) + S * (N % 2));
  return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;


int main(){FAST;   
int n;
bool b =false;
    cin >> n;
    for(int i = 0; i * 7 <= n; i++){
        if(b)
            return cout << "Yes" ,0;
        if( (n - i*7) % 4 == 0)
            b = 1;
    }
    b ? cout << "Yes" : cout << "No";

return 0;
}
 










Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<thread>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define show(x, y); cout << x << " " << y << endl;
using namespace std;

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

    int n;
    cin >> n;
    vector<vector<int>> c(n + 1, vector<int>(n, 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> c[i][j];
        }
    }
    vector<int> dp(1<<n, 0);
    dp[0] = 1;
    for(int i = 0; i < (1 << n); i++){
        int x = __builtin_popcount(i);
        for(int j = 0; j < n; j++){
            if(c[x][j] == 1 && !(i & (1 << j))){
                int mask = i ^ (1 << j);
                dp[mask] = (dp[mask] + dp[i]) % mod;
            }
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


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

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

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

int main() {
    int32_t n;
    cin >> n;

    int64_t m, a, r, c, h;
    m = a = r = c = h = 0;

    for (int32_t i = 0; i < n; i++) {
        string s;
        cin >> s;
        switch (s.at(0)) {
            case 'M':
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C':
                c++;
                break;
            case 'H':
                h++;
        }
    }
    int64_t answer = m * a * (r + c + h) + m * r * (c + h) + m * c * h + a * r * (c + h) + a * c * h + r * c * h;
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

#define MOD  1000000007
#define SIZE 100000

using ll = long long;

ll N;
std::map<ll, ll> mp;

ll factorial(ll n) {
    ll ans = 1;
    if (n <= 1) return 1;
    for (int i=2; i<=n; ++i) {
        ans *= i;
        ans %= MOD;
    }
    return ans;
}

bool possible() {
    std::map<ll, ll>::iterator itr = mp.begin();
    if (mp.find(0) != mp.end() && mp[0] > 1) return false;
    while (itr != mp.end()) {
        if (itr->first != 0 && itr->second % 2 != 0)
            return false;
        ++itr;
    }
    return true;
}

void solve() {
    if (!possible()) {
        std::cout << 0 << std::endl;
        return;
    }
    ll ans = 1;
    std::map<ll, ll>::iterator itr = mp.begin();
    while (itr != mp.end()) {
        if (itr->second > 1) {
            ans *= factorial(itr->second);
            ans %= MOD;
        }
        ++itr;
    }
    std::cout << ans << std::endl;
}

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        ll a;
        std::cin >> a;
        ++mp[a];
    }
    solve();
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
    int i=0;
    for(i=0;i<5;i++)
    {
        if(a[i]==0)
        {
            break;
        }
    }
    cout<<i+1<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,d; cin>>n>>d;
	ll cnt=0;
	while(n--)
	{
		ll x,y; cin>>x>>y;
		ll v=(x*x)+(y*y);
	//	cout<<v;
		double dd=(double)sqrt(v);
	//	cout<<dd<<" ";
		if(dd<=d)cnt++;
		
		
	}
	cout<<cnt;

}

Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[200010];
long long sumx,sum;
long long ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r=0;
	for (int i=1;i<=n;i++)
	{
		sum+=a[i];sumx^=a[i];
		if (sum!=sumx)
		{
			//ans+=i-l;
			while (sum!=sumx)
			{
				sum-=a[l];sumx^=a[l];
				ans+=i-l;
				l++;
			}
		}
	}
	int len=n-l+1;
	ans+=1ll*len*(len+1)/2;
	printf("%lld",ans);
}

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

int main() {
  int64_t w,h;
  int x,y;
  cin>>w>>h>>x>>y;

  double ans = w/2.0*h;
  bool only;
  if(x*2==w && y*2==h) {
    only = false;
  }
  else only = true;
 
  cout<<fixed<<setprecision(10)<<ans<<' '<<(!only)<<endl;


  return 0;
}

Measured memory_bytes: 3760
fun main() {
    val n = readLine()!!.toInt()
    var cnt = 0
    (0 until n).forEach {
        val d = readLine()!!.split(" ")
        if(d[0] == d[1]) {
            if((++cnt) == 3){
                print("Yes")
                return
            }
        } else {
            cnt = 0
        }
    }
    print("No")
}

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

int solve(int K){
  
  if(K % 2 == 0 || K % 5 == 0){
    return -1;
  }
  
  else{
    int pre_amari = 0;
    for(int i=1;i<=K;i++){
      int amari = (pre_amari * 10 + 7) % K;
      if(amari == 0)
        return i;
      pre_amari = amari;
  	}
  }
  
  return -1;
}

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

  cout << solve(K);
  return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

bool dp1[26];
bool dp2[26][26];
bool dp3[26][26][26];
bool dp4[26][26][26][26];

void print(int i) {
  cout << (char)('a'+i);
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int n = s.size();
  debug(n);

  vector<bool> used(26);
  int cnt = 0;
  int r = 1;
  map<int, int> mp;
  for(int i=n-1; i>=0; i--) {
    int p = s[i]-'a';
    if (!used[p]) {
      cnt++;
      used[p] = true;
    }
    if (cnt==26) {
      cnt=0;
      mp[r] = i;
      r++;
      rep(k, 26) used[k] = false;
    }
  }
  rep(k, 26) used[k] = false;

  r--;
  int start = 0;
  while(r>0) {
    priority_queue<P, vector<P>, greater<>> que;
    int med = mp[r];
    debug(r, mp[r]);
    rep(k, 26) used[k] = false;
    cnt = 0;
    for(int i=start; i<n; i++) {
      int p = s[i]-'a';
      if (!used[p]) {
        cnt++;
        used[p] = true;
        if (i >= med) {
          debug(p, i);
          que.emplace(p, i);
        }
      }
      if (cnt==26) {
        P pa = que.top();
        while(!que.empty()) {
          que.pop();
        }
        cout << (char)('a'+pa.first);
        start = pa.second+1;
        break;
      }
    }
    r--;
  }

  rep(k, 26) used[k] = false;
  for(int i=start; i<n; i++) {
    int p = s[i] - 'a';
    used[p] = true;
  }
  rep(i, 26) {
    if (!used[i]) {
      cout << (char)('a'+i);
      break;
    }
  }
  cout << endl;
}

Measured memory_bytes: 788
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> robots(n);
    for (int i=0; i<n; i++) {
        cin >> robots.at(i).first >> robots.at(i).second;
    }
    vector<pair<ll, ll>> ran(n);
    for (int i=0; i<n; i++) {
        ran.at(i) = make_pair(robots.at(i).first + robots.at(i).second, robots.at(i).first - robots.at(i).second);
    }
    sort(ran.begin(), ran.end());
    ll cur = -LINF;
    int cnt = 0;
    for (int i=0; i<n; i++) {
        if (ran.at(i).second >= cur) {
            cnt++;
            cur = ran.at(i).first;
        }
    }
    cout << cnt << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 3328
n,m,q = map(int, input().split())

a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q

for i in range(q):
  a[i], b[i], c[i], d[i] = map(int, input().split())
  a[i] -= 1
  b[i] -= 1

def num(A):
  x = 0
  for ai, bi, ci, di in zip(a, b, c, d):
    if(A[bi] - A[ai] == ci):
      x += di

  return x

def dfs(A):
  if(len(A) == n):
    return num(A)
  s = 0
  x = A[-1] if len(A) > 0 else 0
  for i in range(x, m):
    A.append(i)
    s = max(s, dfs(A))
    A.pop()

  return s
 
print(dfs([]))


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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<vector<int>> d(n, vector<int>(n,0));
    int ans = 0;
    for(int i=n-1; i>0; i--){
        for(int j=i-1; j>-1; j--){
            if(s[i]==s[j]){
                if(i==n-1){
                    d[i][j] = 1;
                    ans = max(ans, min(d[i][j],i-j));
                }else{
                    d[i][j] = d[i+1][j+1] + 1; 
                    ans = max(min(d[i][j],i-j),ans);
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  uint64_t Ans = 0;  // 回答：最小攻撃回数
  int N; cin >> N; // モンスターの数
  int K; cin >> K; // 必殺技の数
  vector<int> H(N); // 各モンスターの体力
  rep(i,N) {cin>>H.at(i);}

  // 体力を大きい順に並べて、必殺技の数だけ倒して、
  // 残ったモンスターの体力の合計が答え

  sort(H.begin(),H.end());
  reverse(H.begin(),H.end());

  rep(i,N){
//    cout << "i:" << i << " H:at(i):" << H.at(i) << " Ans:" << Ans << endl;
    if ( i>K-1 ){ Ans += H.at(i); }
  }
  cout << Ans << endl;

}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}
func main() {
	var A, B int
	fmt.Scanf("%d %d\n", &A, &B)
	cnt := 0
	sum := 1
	for sum < B {
		sum = sum + A - 1
		cnt++
	}
	fmt.Println(cnt)

}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    int N;
    cin >> N;

    string S;
    cin >> S;
    
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }


    int half = N / 2;

    string f, l;
    f = S.substr(0, half);
    l = S.substr(half,half);

    if(f == l) cout << "Yes" << endl;
    else cout << "No" << endl;
    

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  LL a;cin >> a;
  LL ans = 0;
  for(LL i=2;i*i<=a;i++){
    if(a%i==0){
      int cnt = 0;
      while(a%i==0){
        cnt++;
        a/=i;
      }
      for(int j=1;j<=cnt;j++){
        ans++;
        cnt -= j;
      }
    }
  }
  if(a!=1) ans++;
  cout << ans << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3864
#include<stdio.h>
int main()
{
	int a[105],n,i,j,sum;
	while(~scanf("%d",&n))
	{sum=0;
	for(i=0;i<n;i++)
	{scanf("%d",&a[i]);
	}
	for(i=0;i<n-1;i++)
	{for(j=i+1;j<n;j++)
	 sum+=a[i]*a[j];
	}
	printf("%d\n",sum);
	}
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String a = S.substring(5,7);
    
      if(a.equals ("04")||a.equals ("03")||a.equals ("02")||a.equals ("01")){
	System.out.println("Heisei");
      }else{
	System.out.println("TBD");
    }
      }
}

Measured memory_bytes: 22740
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll f(ll H) {
  if(H==1)
    return 1;
  else {
    ll x = f(H/2);
    return x+x+1;
  }
}

void solve(long long H){
  std::cout << f(H) << std::endl;
}

int main(){
  long long H;
  scanf("%lld",&H);
  solve(H);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define N 20
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
const double g = 1.0;
int p[N],h[N];


double calcX(double radian,double v){
  double vix = v * cos(radian);
  double viy = v * sin(radian);
  double t = 2 * viy / g;
  return vix * t;
}

double calcV(double x,int n,int b,double radian){
  double L = 0, R = 1e10, cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcX(radian,M) > x) R = M;
    else L = M;
  }
    
  double v = L,pos = 0;
  for(int i=0;i<b;i++, pos += x){
    for(int j=0;j<n;j++){
      //if(pos == p[j] || p[j] == pos+x) return INF;
      if(!(pos <= p[j] && p[j] <= pos+x)) continue;
      double vix = v * cos(radian);
      double viy = v * sin(radian);
      double t = (p[j] - pos)/vix;
      double y = -(g*t/2 - viy) * t;
      if(y-h[j]+EPS < 0) return INF;
    }
  }
  return v;  
}

double solve(double x,int n,int b){

  double L = PI/4,R = PI/2,cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcV(x,n,b,M) < INF) R = M; 
    else L = M;
  }
  return calcV(x,n,b,R);
}


signed main(){
  int D,n,B;
  cin>>D>>n>>B;
  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  double ans = INF;
  for(int i=1;i<=B+1;i++) Min(ans,solve(1.0*D/i,n,i));
  printf("%.5Lf\n",ans);
  return 0;
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int coun(int x){
	return __builtin_popcount(x);
}
ll dp[405][405];
int n;
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	cin>>n;
	ll arr[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	ll pre[n+1];
	memset(pre, 0, sizeof(pre));
	for(int i=1;i<=n;i++)
		pre[i]=pre[i-1]+arr[i];
	for(int i=n;i>=1;i--){
		for(int j=i;j<=n;j++)
		{
			if(i==j){
				dp[i][j]=0;
				continue;
			}
			dp[i][j]=INF;
			for(int k=i;k<j;k++){	
			dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+pre[j]-pre[i-1]);
			}
	//		cout<<dp[i][j]<<" "<<i<<" "<<j<<"\n";
		}
	}
	cout<<dp[1][n];
}

Measured memory_bytes: 3840
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
T = [[] for _ in range(N)]
ans = [0] * N

for _ in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)

cnt = [0] * N
for _ in range(Q):
  p, x = map(int, input().split())
  p -= 1
  cnt[p] += x

def dfs(x, d, s): # x:計算する頂点（上側）, d:計算済み(0)か否か(1), s:頂点xの値
  for y in T[x]: # 頂点xとつながる各頂点yの計算を行う
    if d[y] == 1: # 頂点yが計算未了の場合
      s += cnt[y] # 頂点xの値sに頂点yの値を足す
      ans[y] = s # 頂点yの値はsに確定
      d[y] = 0 # 頂点yの計算は終わったのでd[y]=0とする
      dfs(y, d, s) # 頂点yの下層についても再帰的に計算
      s -= cnt[y] # 頂点yの下層の計算が終わったので、sを頂点xの値に戻す

d = [1] * N
d[0] = 0

ans[0] = cnt[0]
s = cnt[0]

dfs(0, d, s)

print(*ans)

Measured memory_bytes: 238536
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    for(int i=0;i<m;++i) cin >> b[i];
    for(int i=0;i<n;++i) {
        for(int j=0;j<m;++j) {
            cin >> a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;++i) {
        int sum=0;
        for(int j=0;j<m;++j) {
            sum+=a[i][j]*b[j];
        }
        sum+=c;
        if(sum>0) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
M,N = map(int,input().split())
ans=set(range(1,M+1))
START=0
END=10**5
for s in range(N):
  S,Z = map(int,input().split())
  if START <= S:
    START = S
  if END >= Z:
    END = Z
ans = range(START,END+1)
print(len(ans))

Measured memory_bytes: 11884
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

ll MOD = 1000000007;
ll dp[100010][2];

ll solver(string s)
{
int L = s.size();
rep(i, 0, 100001)rep(j, 0, 1)dp[i][j] = 0;
dp[0][0] = 1;
rep(i, 0, L - 1) {
int D = s[i] - '0';
rep(j, 0, 1)rep(d, 0, (j ? 1 : D)) {
if (d) {
dp[i + 1][j || (d < D)] += dp[i][j] * 2;
dp[i + 1][j || (d < D)] %= MOD;
}
else {
dp[i + 1][j || (d < D)] += dp[i][j];
dp[i + 1][j || (d < D)] %= MOD;
}
}
}
return (dp[L][0] + dp[L][1]) % MOD;
}

int main()
{
string s; cin >> s;
cout << solver(s) << endl;
}


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

std::vector<int> find_all(const std::string str, const std::string subStr) {
    std::vector<int> result;

    int subStrSize = subStr.size();
    size_t pos = str.find(subStr);

    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }

    return result;
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  std::vector<int> findVec = find_all(s, "ABC");
  cout << findVec.size() << endl;
}


Measured memory_bytes: 3632
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=1e5+5;
int ans[N],h[N];
using namespace std;
int main()
{
    ahmocs
    int n; cin>>n;
    for (int i=0; i<n; ++i) cin>>h[i];
    ans[0]=0; ans[1]=abs(h[1]-h[0]);
    for (int i=2; i<n; ++i)
        ans[i]=min(abs(h[i-2]-h[i])+ans[i-2],abs(h[i-1]-h[i])+ans[i-1]);
    cout<<ans[n-1];
    return 0;
}



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

int main(){
    int k, s; cin >> k >> s;

    int ans = 0;
    for(int x=0; x<=k; x++){
        for(int y=0; y<=k; y++){
            if(x+y <= s && (s-x-y)<=k)
                ans++ ;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;
const int mod = 998244353;
int l[maxn] , r[maxn];
int n;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    priority_queue<ll> lo;
    priority_queue<ll,vector<ll>,greater<ll>> hi;
    cin >> n;
    for(int i = 0 ; i < n ; ++i)cin >> l[i] >> r[i];
    ll res = 0;
    lo.push(l[0]);hi.push(l[0]);
    ll xl = 0 , xr = 0;
    for(int i = 1 ; i < n ; ++i){
        xl += r[i] - l[i];
        xr += r[i - 1] - l[i - 1];
        ll cl = lo.top() - xl;
        ll cr = hi.top() + xr;
        if(cl <= l[i] && l[i] <= cr){
            lo.push(l[i] + xl);
            hi.push(l[i] - xr);
        }else if(cr < l[i]){
            res += l[i] - cr;
            hi.pop();
            lo.push(cr + xl);
            hi.push(l[i] - xr);
            hi.push(l[i] - xr);
        }else{
            res += cl - l[i];
            lo.pop();
            hi.push(cl - xr);
            lo.push(l[i] + xl);
            lo.push(l[i] + xl);
        }
    }
    cout << res << endl;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  cout << accumulate(p.begin(), p.end() - 1, 0) + p.back() / 2 << endl;
}


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

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

int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n%d\n",(a+b+c+d)/60, (a+b+c+d)%60);
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var b = new Stack<int>();
            var c = new Stack<int>();

            for (int i = 0; i < n; i++)
            {
                var ar = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                b.Clear(); c.Clear();
                b.Push(0); c.Push(0);
                bool isClear = true;

                foreach (var v in ar)
                {
                    int bv = v - b.Peek();
                    int cv = v - c.Peek();
                    if (bv < 0 && cv < 0) { isClear = false; break; }

                    if (bv < cv || cv < 0) { b.Push(v); } else { c.Push(v); }
                }
                Console.WriteLine(isClear ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 5968
#include<algorithm> 
#include<cstdio>
#include<iostream>
#define inver(a) power(a,mod-2)
using namespace std;
typedef long long LL;
const int mod=1e9+7;
int fac[2050];
int fac_inv[2050];
int add(int x)
{
	return x>=mod?x-mod:x; 
}
LL power(LL x,LL y)
{
	LL re=1;
	while(y)
	{
		if(y&1) re=re*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return re;
}
LL C(int x,int y)
{
	return (LL)fac[x]*fac_inv[y]%mod*fac_inv[x-y]%mod;
}
int n,m;
int p2[2050];
bool mark[2050];
LL X;
LL v[2050];
namespace us
{
	int fa[1050];
	void init()
	{
		for(int i=1;i<=n;++i)
		{
			fa[i]=i;
		}
	}
	int find(int a)
	{
		return fa[a]==a?a:fa[a]=find(fa[a]); 
	}
	bool merge(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a==b)
		{
			return false;
		}
		fa[a]=b;
		return true;
	}
}
struct edge
{
	int u,v,w;
	bool operator <(const edge &other) const
	{
		return w<other.w;
	}
} e[2050];
LL kruskal(int ban)
{
	LL MST=0;
	us::init();
	if(ban)
	{
		us::merge(e[ban].u,e[ban].v);
		MST+=e[ban].w;
	}
	for(int i=1;i<=m;++i)if(i!=ban)
	{
		if(us::merge(e[i].u,e[i].v))
		{
			MST+=e[i].w;
			if(ban==0)
			{
				mark[i]=1;
			}
		}
	}
	return MST;
}
void init(int n)
{
	p2[0]=1;
	for(int i=1;i<=n;++i)
	{
		p2[i]=add(p2[i-1]<<1);
	}
	fac[0]=1;
	for(int i=1;i<=n;++i)
	{
		fac[i]=(LL)fac[i-1]*i%mod;
	}
	fac_inv[n]=inver(fac[n]);
	for(int i=n;i>=1;--i)
	{
		fac_inv[i-1]=(LL)fac_inv[i]*i%mod;
	} 
}
int calc()
{
	int p=n-1;
	int re=0;
	for(int i=1;i<p;++i)
	{
		re=add(re+C(p,i));
	}
	re=(LL)re*p2[m-p]%mod;
	return re;
}
int solve()
{
	init(m);
	for(int i=0;i<=m;++i)
	{
		v[i]=kruskal(i);
	}
	int an=0;
	if(v[0]==X)
	{
		an=calc();
	}
	for(int i=1;i<=m;++i) if(!mark[i])
	{
		if(v[i]==X)
		{
			int t=1;
			for(int j=1;j<=m;++j) if(!mark[j])
			{
				if(v[j]>v[i]||(v[j]==v[i]&&j>i))
				{
					++t;
				}
			}
			an=add(an+p2[t]);
		}
	}
	return an;
}
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%lld",&X);
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
	}
	sort(e+1,e+m+1);
	printf("%d\n",solve());
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int cnt4 = 0, cnt2 = 0, cnt0 = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x % 4 == 0)
            cnt4++;
        else if (x % 2 == 0)
            cnt2++;
        else
            cnt0++;
    }
    if (cnt4 >= cnt0)
        cout << "Yes" << endl;
    else if (cnt4 == cnt0 - 1)
    {
        if(cnt2==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else if(cnt0==0&&cnt2>=2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

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

int m, n;
int w[111];

bool f(ll x) {
    ll step = 1, len = 0;
    for (int i = 0; i < n; i++) {
        if (len + w[i] <= x) len += w[i];
        else {
            step++;
            if (w[i] <= x) len = w[i];
            else return false;
        }
        if (step > m) return false;
    }
    return true;
}

int main() {
    while (cin >> m >> n && (m != 0 || n != 0)) {
        for (int i = 0; i < n; i++) cin >> w[i];
        ll ng = 0, ok = 1515151;
        while (ok - ng > 1) {
            ll md = (ok + ng) / 2;
            if (f(md)) ok = md;
            else ng = md;
        }
        cout << ok << endl;
    }
}


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

struct ModInt {
  using M = ModInt;
  long long v;
  ModInt(long long _v = 0) : v(_v % MOD + MOD) { norm(); }
  M& norm() {
    v = (v < MOD) ? v : v - MOD;
    return *this;
  }
  M operator+(const M& x) const { return M(v + x.v); }
  M operator-(const M& x) const { return M(v + MOD - x.v); }
  M operator*(const M& x) const { return M(v * x.v % MOD); }
  M operator/(const M& x) const { return M(v * x.inv().v); }
  M& operator+=(const M& x) { return *this = *this + x; }
  M& operator-=(const M& x) { return *this = *this - x; }
  M& operator*=(const M& x) { return *this = *this * x; }
  M& operator/=(const M& x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    return input >> x.v, x.norm(), input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(long long n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return this->pow(MOD - 2); }

  static long long MOD;
  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    finv.assign(n + 1, fact[n].inv());
    for (int i = n; i > 0; i--) finv[i - 1] = finv[i] * M(i);
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
  static M extgcd(int a, int b, int* x, int* y) {
    M d(a);
    if (b) {
      d = extgcd(b, a % b, y, x);
      *y -= (a / b) * *x;
    } else {
      *x = 1, *y = 0;
    }
    return d;
  }
};
vector<ModInt> ModInt::fact = vector<ModInt>();
vector<ModInt> ModInt::finv = vector<ModInt>();
long long ModInt::MOD = 998244353;

int main() {
  int n;
  cin >> n;
  ModInt::build(n);
  ModInt u = ModInt(3).pow(n);
  ModInt c = 0;
  ModInt p = 1;
  for (int i = n; i > n / 2; i--) {
    c += ModInt::comb(n, i) * p;
    p *= 2;
  }
  cout << u - c * 2 << endl; 
}


Measured memory_bytes: 156544
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

const int INF=1e7+777;

inline int get_index(int x, int y, int W) {
	return x*W+y;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H,W; cin>>H>>W;
	int Ch,Dh,Cw,Dw; cin>>Ch>>Dh>>Cw>>Dw; Ch--; Dh--; Cw--; Dw--;
	vector<string> g(H);
	for (int i=0; i<H; i++)
		cin>>g[i];
	int n=H*W;
	vector<vector<ii>> adj(n);
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if(g[i][j]!='.') continue;
			int cur=get_index(i,j,W);
			for (int ii=-1; ii<=1; ii++) {
				for (int jj=-1; jj<=1; jj++) {
					if(abs(ii)+abs(jj)!=1) continue;
					int x=i+ii, y=j+jj;
					if(x<0||x>=H||y<0||y>=W) continue;
					if(g[x][y]!='.') continue;
					int nxt=get_index(x,y,W);
					adj[cur].push_back({nxt,0});
				}
			}
			for (int ii=-2; ii<=2; ii++) {
				for (int jj=-2; jj<=2; jj++) {
					if(abs(ii)+abs(jj)<=1) continue;
					int x=i+ii, y=j+jj;
					if(x<0||x>=H||y<0||y>=W) continue;
					if(g[x][y]!='.') continue;
					int nxt=get_index(x,y,W);
					adj[cur].push_back({nxt,1});
				}
			}
		}
	}
	vector<int> dist(n,INF);
	int init=get_index(Ch,Dh,W);
	dist[init]=0;
	deque<int> q; q.push_back(init);
	while(!q.empty()) {
		int cur=q.front(); q.pop_front();
		for (auto nxt : adj[cur]) {
			int val=dist[cur]+nxt.second;
			if(dist[nxt.first]>val) {
				dist[nxt.first]=val;
				if(nxt.second==0) q.push_front(nxt.first);
				else q.push_back(nxt.first);
			}
		}
	}
	int query=get_index(Cw,Dw,W);
	cout<<(dist[query]==INF ? -1 : dist[query])<<"\n";
	return 0;
}

Measured memory_bytes: 101372