akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define LINF		((ll)1 << 63 -1)
#define INF 		(1<<29)
#define MINF		-2000000007
#define MAX 		100050

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//



//
int main(){
	int N;cin>>N;
	V X(N),Y(N),H(N);
	int x,y,h;
	REP(i,N){
		cin>>X[i]>>Y[i]>>H[i];
		if(H[i]>0){x=X[i];y=Y[i];h=H[i];}
	}

	REP(CX,101)REP(CY,101){
		ll Hi = (ll)h + abs(CX-x) + abs(CY-y);
		Hi = max(Hi,0LL);
		if(Hi<=0)continue;
		REP(itr,N){
			if(H[itr]==0){
				int t = max(0LL , Hi - abs(CX-X[itr])-abs(CY-Y[itr]));
				if(t != H[itr]){
					Hi = -1;
					break;
				}
			}
			else if(Hi != max(0LL,(ll)H[itr] + abs(CX-X[itr]) + abs(CY-Y[itr]))){
				Hi = -1;
				break;
			}
		}
		if(Hi >= 0){
			printf("%d %d %lld\n",CX,CY,Hi);
			break;
		}
	}


	return 0;
}




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

using namespace std;

int main()
{
    int n,miss=0,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a!=i+1)
        miss++;
    }
    string ans=(miss<=2)?"YES":"NO";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//最小全域木
#include <stdio.h>
#define X 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int G[100][100];//行列の生成
int n;//行(列)の数
int Span(){
  int i,u,v,minv;
  int d[100];//
  int p[100];
  int color[100];//
  int weight=0;

  for(i=0;i<n;i++){//d,p,cの初期化
    d[i]=X;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=WHITE;//一番最初は0
  while(1){
    minv=X;
    u=-1;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<minv){
	minv=d[i];
	u=i;
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(d[v]>G[u][v]){
	if(color[v]!=BLACK && G[u][v]!=X){
	  p[v]=u;
	  d[v]=G[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++)weight+=G[i][p[i]];
  return weight;
}
int main(){
  int i,j;
  int x;
  scanf("%d",&n);
  for(i=0; i<n; i++){//行列の中身の格納
    for(j=0; j<n; j++) {
      scanf("%d",&x);
      if(x==-1)x=X;
      G[i][j]=x;
    }
  }
  printf("%d\n",Span());//重みの出力
  return 0;
}



Measured memory_bytes: 2060
n, m = map(int, input().split())
ct = [0] * (n+1)
A = [True] * n
for _ in range(m):
    A[int(input())-1] = False

ct[0] = 1
mod = 1000000007
for i in range(1, n+1):
    if A[i-2] == True:
        ct[i] += ct[i-1]
    if i > 1 and A[i-3] == True:
        ct[i] += ct[i-2]
    ct[i] %= mod
print(ct[-1])

Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>dp(n,1<<30);
    dp[0] = 0;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<n)dp[i+j] = min(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main(){
    int64_t n;
    cin >> n;

    string s;
    cin >> s;

    std::unordered_map<char, int64_t> counts;
    for (auto c : s) {
        ++counts[c];
    }

    constexpr auto M = 1000000007;

    int64_t ans = 1;
    for (auto kv : counts) {
        ans = ans * (kv.second + 1) % M;
    }

    // empty string
    --ans;
    if (ans < 0) {
        ans += M;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
    int a,p;
    cin >> a >> p;
    int b=3*a+p;
    int ans=0;
    while(b>=2){
        b-=2;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1005][1005];
char arr[1009][1009];
const int mod=1000000007;
int main() {
    
   // cin >> a >> b;
    /*
   int nxt[3001][26];  int nxt2[3001][26];
   int sa,sb;
   sa=a.size();
   for(int i=sa-1;sa>=0;sa--){
       for(int j=0;j<=26;j++){
           nxt[i][j]=nxt[i][j+1];
       }  nxt[i][a[i]-'a']=i;
   } 
   for(int i=sa-1;sa>=0;sa--){
       for(int j=0;j<=26;j++){
           nxt2[i][j]=nxt2[i][j+1];
       }  nxt2[i][a[i]-'a']=i;
   }
   solve(nxt[0][i],nxt2[0][i]);*/
   ll h,w;cin>>h>>w;
   for(int i=1;i<=h;i++){
       for(int j=1;j<=w;j++){
           cin>>arr[i][j];
       }
   }
   dp[1][1]=1;
    for(int i=1;i<=h;i++){
       for(int j=1;j<=w;j++){
           if(i==1&&j==1){continue;}
           if(arr[i][j]=='#'){
            //   cout<<i<<j<<endl;
               dp[i][j]=0;
               continue;
           }
           if(i==1){
               dp[i][j]=(dp[i][j-1])%mod;
               
           }else if(j==1){dp[i][j]=(dp[i-1][j])%mod;}else{
               dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
           }
       }
   }cout<<dp[h][w]%mod;
}

Measured memory_bytes: 12392
def main():
    N = int(input())
    ans = 0
    for i in range(1, N+1, 2):
        cnt = 0
        for j in range(1, N+1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38768
n=int(input())
s=input()
if(n%2==1):
    print('No')
else:
    m=n//2
    s1=s[0:m]
    s2=s[m:]
    #print('s1:{} s2:{}'.format(s1,s2))
    if(s1==s2):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false; cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  string s; cin >> s;
  auto ans = "AC";
  if (s[0] != 'A' || !('a' <= s[1] && s[1] <= 'z') 
      || !('a' <= s.back() && s.back() <= 'z')) ans = "WA";
  bool a = false;
  for (int i=2; i<s.size()-1; ++i) {
    if (s[i] == 'C') { if (a) ans = "WA"; else a = true; }
    else if (!('a' <= s[i] && s[i] <= 'z')) ans = "WA";
  }
  if (!a) ans = "WA";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s=str(input())
k=int(input())

sl=list(s)

cnt0=0
cnt1=0
cnt2=0

for i in range(len(sl)-1):
    if sl[i]==sl[i+1]:
        cnt0+=1
        sl[i+1]="?"
ss=list("".join(sl)+s)

for i in range(len(sl)-1, len(ss)-1):
    if ss[i]==ss[i+1]:
        cnt1+=1
        ss[i+1]="?"

sss=list("".join(ss)+s)
for i in range(len(ss)-1, len(sss)-1):
    if sss[i]==sss[i+1]:
        cnt2+=1
        sss[i+1]="?"


if cnt0!=cnt1 and cnt1!=cnt2:
    print(k//2*(cnt0+cnt1)+cnt0)
elif cnt0!=cnt1 and cnt1==cnt2:
    print(cnt0+(k-1)*cnt1)
else:
    print(k*cnt0)


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

int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);
	long long int n;
	cin>>n;
	long long int arr[n],dp[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	//for(int i=0;i<n;i++)cout<<dp[i]<<" ";
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

typedef
tree<
	pair<int, int>,
	null_type,
	less<pair<int, int>>,
	rb_tree_tag,
	tree_order_statistics_node_update>
ordered_set;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll d[2001][2001];
vector<ll> v[2001];
bool vis[2001];
ll ans[2001];

int main()
{
    IOS;
    ll n,x,y;
    cin>>n>>x>>y;
    repf(i,1,n)
    {
        v[i].pb(i+1);
        v[i+1].pb(i);
    }
    v[x].pb(y);
    v[y].pb(x);
    repf(i,1,n+1)
    {
        memset(vis,false,sizeof vis);
        queue<ll> q;
        q.push(i);
        vis[i]=true;
        d[i][i]=0;
        while(!q.empty())
        {
            ll x=q.front();
            q.pop();
            for(auto j:v[x])
            {
                if(!vis[j])
                {
                    q.push(j);
                    vis[j]=true;
                    d[i][j]=d[i][x]+1;
                    ans[d[i][j]]++;
                }
            }
        }
    }
    repf(i,1,n)
    {
        cout<<ans[i]/2<<endl;
    }
}     

Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[100000],b[100000],c[100000];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    sort(a,a+n);
    sort(c,c+n);
    long long ans=0;
    for(int i=0;i<n;i++){
        auto Itr=lower_bound(a,a+n,b[i])-a;
        auto Itr2=c+n-upper_bound(c,c+n,b[i]);
        ans+=Itr*Itr2;
    }
    cout<<ans;
}

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

int main()
{
    string st;
    cin >> st;
    int n = st.length();
    if(n % 2 == 1)
    {
        cout << "No" << endl;
    }
    else
    {
        bool ok = true;
        for(int i = 0; i < n; i += 2)
        {
            if(st[i] != 'h' || st[i+1] != 'i')
            {
                ok = false;
                break;
            }
        }
        if(ok)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[3005], b[3005];
int pref[3005][3005], suff[3005][3005];
int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    for(int i=1;i<=n;i++) scanf("%d%d", &a[i], &b[i]);
    for(int i=1;i<=n;i++){
        for(int j=t;j>=1;j--){
            if(j-a[i] < 0) break;
            pref[i][j] = max(pref[i][j], pref[i-1][j-a[i]] + b[i]);
        }
        for(int j=1;j<=t;j++){
            pref[i][j] = max(pref[i][j], pref[i-1][j]);
            pref[i][j] = max(pref[i][j], pref[i][j-1]);
        }
    }
    for(int i=n;i>=1;i--){
        for(int j=t;j>=1;j--){
            if(j-a[i] < 0) break;
            suff[i][j] = max(suff[i][j], suff[i+1][j-a[i]] + b[i]);
        }
        for(int j=1;j<=t;j++){
            suff[i][j] = max(suff[i][j], suff[i+1][j]);
            suff[i][j] = max(suff[i][j], suff[i][j-1]);
        }
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=t-1;j++){
            ans = max(ans, pref[i-1][j] + suff[i+1][t-1-j] + b[i]);
        }
    }
    printf("%d\n", ans);
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int dist[n];
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        dist[i] = a[i + 1] - a[i];
        sum += dist[i];
    }
    dist[n - 1] = k - sum;

    int ma = 0;
    for (int i = 0; i < n; i++) {
        ma = max(dist[i], ma);
    }

    cout << k - ma << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = []
str = input().split()
for i in range(N):
    A.append(int(str[i]))

A.sort()
A.reverse()

Alice = 0
Bob = 0

for i in range(N):
    if i%2 == 0:
        Alice = Alice + A[i]
    else:
        Bob = Bob+A[i]

print(Alice - Bob)


Measured memory_bytes: 3060
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    let t: Vec<char> = itr.next().unwrap().chars().collect();

    let mut op = Vec::new();
    const MOD: u64 = 1_000_000_007;

    let mut i = 0;
    while i < n {
        if s[i] != t[i] {
            op.push(0);
            i += 1;
        } else {
            op.push(1);
        }
        i += 1;
    }

    let mut ans = 0u64;
    if op[0] == 0 {
        ans += 6;
    } else {
        ans += 3;
    }
    for i in 1..op.len() {
        if op[i - 1] == 0 {
            if op[i] == 0 {
                ans = ans * 3 % MOD;
            }
        } else {
            ans = ans * 2 % MOD;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#define M 200005

int sort1(int,int);
int sort2(int,int);

int main(void){
    int n,i,R[M];
    int j,v;
    int maxv,minv;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&R[i]);
    }
    maxv=R[1]-R[0];
    minv=R[0];
    for(j=1;j<n;j++){
        maxv=sort1(maxv,R[j]-minv);
        minv=sort2(minv,R[j]);
    }
    printf("%d\n",maxv);
    return 0;
}

int sort1(int j,int v){
    if(j <= v)return v;
    else return j;
}

int sort2(int j,int v){
    if(j>=v)return v;
    else return j;
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x[i]);
    }

    int l;
    scanf("%d", &l);

    vector<int> nxt(n);
    nxt[n - 1] = n - 1;
    for (int i = 0; i + 1 < n; ++i) {
        int bl = i + 1;
        int br = n - 1;
        int ba = i + 1;
        while (bl <= br) {
            int bm = (bl + br) >> 1;

            if (x[bm] - x[i] <= l) {
                ba = bm;
                bl = bm + 1;
            } else {
                br = bm - 1;
            }
        }
        nxt[i] = ba;
    }

    const int MAX_LOG = 20;

    vector<vector<int>> nxtDp(n, vector<int>(MAX_LOG));
    for (int i = 0; i < n; ++i) {
        nxtDp[i][0] = nxt[i];
    }
    for (int i = 1; i < MAX_LOG; ++i) {
        for (int j = 0; j < n; ++j) {
            nxtDp[j][i] = nxtDp[nxtDp[j][i - 1]][i - 1];
        }
    }

    int q;
    scanf("%d", &q);
    for (; q; --q) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;

        if (a > b) {
            swap(a, b);
        }

        int result = 0;
        for (int i = MAX_LOG - 1; i >= 0; --i) {
            if (nxtDp[a][i] < b) {
                a = nxtDp[a][i];
                result += (1 << i);
            }
        }

        ++result;

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

    return 0;
}

Measured memory_bytes: 13312
function Main(input){
    input=input.split("\n");
    tmp=input[0].split(" ");
    var a = parseInt(tmp[0], 10);
    var b = parseInt(tmp[1], 10);
    var c = parseInt(tmp[2], 10);
    if(b-a == c-b){
	console.log("YES");
    }else{
	console.log("NO");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
k, n = map(int, input().split())
a = list(map(int, input().split()))
# print(a)
b = sorted(a)
# print(k, n)
# print(max(a), min(a))
# 0,5,15
# 20,25,15
# print(b)
l = len(b)
dmin = 9999999999
for i in range(l - 1):
    # print(i, b[i], b[i + 1], b[i] + k - b[i + 1])
    d = b[i] + k - b[i + 1]
    if d < dmin:
        dmin = d
# print(b[l - 1] - b[0])
if b[l - 1] - b[0] < dmin:
    dmin = b[l - 1] - b[0]
print(dmin)


Measured memory_bytes: 25840
def main():
    S = input()
    a = int(S[:2])
    b = int(S[2:])
    if 1 <= a <= 12 and 1 <= b <= 12:
        print('AMBIGUOUS')
    elif 1 <= a <= 12 and (b == 0 or b >= 13):
        print('MMYY')
    elif (a == 0 or a >= 13) and 1 <= b <= 12:
        print('YYMM')
    else:
        print('NA')


main()


Measured memory_bytes: 3060
N = int(input())
S1 = input()
S2 = input()

result = 3
if N != 1:
    i=1
    while i < N:
        if S1[i-1] == S2[i-1]:
            result *= 2
        elif S1[i-1] != S1[i]:
            if S1[i] != S2[i]:
                result *= 3
        elif i == 1:
            result *= 2
        i += 1

print(result%1000000007)    

Measured memory_bytes: 3064
#include <stdio.h>
int main (void){
long long int  a[10000],max,min,sum=0;
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&a[i]);
}
for(i=0;i<n;i++){
 sum+=a[i];
}
max=a[0];
for(i=1;i<n;i++){
if(max<a[i]){
max=a[i];
}}
min=a[0];
for(i=1;i<n;i++){
if(min>a[i]){
min=a[i];}}

printf("%lld %lld %lld\n",min,max,sum) ;return 0 ;}

Measured memory_bytes: 680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();

		if(w >= s) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}
	}
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n;cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int a;cin>>a;
    if(i%2==1){
      if(a%2==1)ans++;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
		
		List<Long> aList = new ArrayList<>();
		// List<Long> bList = new ArrayList<>();
		List<Long> diffList = new ArrayList<>();
		long sumA =0;
		long sumB =0;

		for(long i=0;i<n;i++){
			long a =sc.nextLong();
			aList.add(a);
			sumA += a;
		}
		for(long i=0;i<n;i++){
			long b =sc.nextLong();
			// bList.add(b);
			sumB += b;
			diffList.add(b -aList.get((int)i));
		}

		if(sumA<sumB){
			System.out.println(-1);
		}else{

		Collections.sort(diffList);
			long totalNeed = diffList.stream()
			.filter(d->d>0)
			.mapToLong(x -> x)
			.sum();
			long resultCount = diffList.stream()
			.filter(d->d>0)
			.mapToLong(x -> x)
			.count();
			
			// System.out.println(diffList);
			// System.out.println(totalNeed);
			// System.out.println(resultCount);

			if(totalNeed ==0){
				System.out.println(0);
			}else{
				for (long i = 0; i <diffList.size(); i++) {
					// System.out.println("i "+i);
					long curSupplier = diffList.get((int)i);
					totalNeed += curSupplier;
					resultCount++;
					// System.out.println("curSup "+curSupplier);
					// System.out.println("resultCount "+resultCount);
					if(totalNeed<=0){
						break;
					}
					
				}
				
				System.out.println(resultCount);
			}



		}


	}

}

Measured memory_bytes: 96540
S = input()

for op1 in "+-":
    for op2 in "+-":
        for op3 in "+-":
            s = S[0] + op1
            s += S[1] + op2
            s += S[2] + op3
            s += S[3]

            if eval(s) == 7:
                print(s + "=7")
                exit()


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

#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
using namespace std;

int main() 
{	
	fast;
	string a,b; cin>>a>>b;
	if(a.length() > b.length()) 
		cout << "GREATER" << endl;
	else if(b.length() > a.length())
		cout << "LESS" << endl;
	else
	{
		ll t = a.length(); ll flag = 0;
		for(ll i = 0; i < t; i++)
		{
			if(a[i] - '0' == b[i] - '0')
			{
			
			}
			else if(a[i] - '0' < b[i] - '0')
			{
				flag = 1;
				break;
			}
			else if(a[i] - '0' > b[i] - '0')
			{
				flag = 2;
				break;
			}
		}
		if(flag == 1) cout << "LESS" << endl;
		else if(flag == 2)cout << "GREATER" << endl;
		else cout << "EQUAL" << endl;
	}
	return 0;
}

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

int yakusuu (int n) {

    int cnt = 0;

    for (int i = 1; i <= n; i++) {
        if (n % i == 0) cnt++;
    }

    return cnt;
}

int main () {

    int N;
    cin >> N;

    int ans = 0;

    for (int i = 1; i <= N; i++) {
        if (yakusuu(i) == 8 && i % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
  while (true) {
    int n,sum = 0;
    double m,alpha = 0;
    cin >> n;
    if(n == 0) break;
    vector<int> s(n);
    rep(i,n) {
      cin >> s[i];
      sum += s[i];
    }
    m = (double)sum/n;
    rep(i,n) {
      alpha += (s[i]-m)*(s[i]-m);
    }
    alpha /= n;
    alpha = sqrt(alpha);
    cout << fixed << setprecision(8) << alpha << endl;
  }
  return 0;
}


Measured memory_bytes: 3260
n,m= [int(i) for i in input().split()]

ab = []

for i in range(n):
    a = list(map(int,input().split()))
    ab.append(a)

ab.sort()

sum_size = 0
total = 0
for i in range(n):
    price = ab[i][0]
    size = ab[i][1]
    sum_size += size
    total += price*size
    if sum_size > m:
        total -= (sum_size-m)*price
        break
print(total)

Measured memory_bytes: 27876
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
cnt=0
for i in b:
  cnt+=bisect.bisect_left(a,i)*(n-bisect.bisect_right(c,i))
print(cnt)

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

using namespace std;


#define MAXN 101
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a[MAXN];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a+n);
  int A=0, B=0;
  for (int i = n-1; i >= 0; --i) {
    if ((n-1-i)%2) B += a[i];
    else A += a[i];
  }
  cout << A-B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    int a,b;
    cin>>a>>b;
    set<ll>s;
    ll x,y,val,val1;
    for(int i=1;i<=1000;i++)
    {
        x=(i*8)/100;
        y=i/10;
        if(x==a && y==b)
        {
            s.insert(i);
        }
    }
    if(s.size()!=0)
    {
        cout<<*s.begin()<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
 
const int N=2505;
int n,m,p,visit[N],f[N],c[N],ok[N];
vector <int> dis[N],v[N],vec[N];
queue <int> que;
 
inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
   	if(c=='-')t=-1,c=getchar();
   	while(c>='0'&&c<='9')s=s*10+c-'0',c=getchar();
   	return s*t;
}
 
void work_ok(){
	ok[n]=1;
	que.push(n);
	while(!que.empty()){
		int u=que.front();
		que.pop();
		int len=vec[u].size();
		for(int i=0;i<len;i++){
			if(!ok[vec[u][i]]){
				ok[vec[u][i]]=1;
				que.push(vec[u][i]);
			}
		} 
	}
} 
 
int main(void){
	scanf("%d %d %d",&n,&m,&p);
	for(int i=1;i<=m;i++){
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		c-=p;
		c=0-c;
		dis[a].push_back(b);
		v[a].push_back(c);
		vec[b].push_back(a);
	}
	work_ok();
	while(!que.empty())que.pop();
	memset(f,0x3f,sizeof(f));
	memset(visit,0,sizeof(visit));
	f[1]=0;
	que.push(1);
	visit[1]=1;
	c[1]=1;
	if(ok[1]==0){
		printf("-1");
		return 0;
	}
	while(!que.empty()){
		int u=que.front();
		que.pop();
		visit[u]=0;
		if(!ok[u])continue;
		int len=dis[u].size();
		for(int i=0;i<len;i++){
			if(f[dis[u][i]]>f[u]+v[u][i]&&ok[dis[u][i]]){
				f[dis[u][i]]=f[u]+v[u][i];
				c[dis[u][i]]=c[u]+1;
				if(c[dis[u][i]]>n&&ok[dis[u][i]]){
					printf("-1\n");
					return 0;
				}
				if(visit[dis[u][i]])continue;
				que.push(dis[u][i]);
				visit[dis[u][i]]=1;
			}
		}
	}
	if(f[n]>0)printf("0");
	else
	printf("%d\n",0-f[n]);
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include<string>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;
#define rep(i, n)   for(int i = 0; i < (int)(n); i++)
#define rrp(i, n)   for(int i = ((int)(n)); i >=0; i--)
#define mpp(i,j,k)  make_pair((int)(i),make_pair((int)(j),(int)(k)))
typedef pair<int,pair<int,int > > ppp;
typedef pair<int,int> pp;
typedef vector<int> vi;
typedef vector<vi>  vvi;
long long d[2000003];
long long k[2000003];
int c1,r1,r2,c2;
long long m=1000000007;
long long bp(long long a,long long n){
        long long r=1;
        while(n){
           if(n%2)r=r*a%m;
           a=a*a%m;
           
           n>>=1;}
        return r%m;
}

int main(){
cin>>r1>>c1>>r2>>c2;
d[0]=1;
d[1]=1;
for(int i=2;i<2000003;i++)d[i]=i,d[i]*=d[i-1],d[i]%=m;
for(int i=0;i<2000003;i++)k[i]=bp(d[i],1000000005);
long long x=0;

for(int i=c1;i<=c2;i++){
    x+=((d[r2+i+1]*k[r2])%m*k[i+1]-1)%m;
    x-=((d[r1+i]*k[r1-1])%m*k[i+1]-1)%m;
    x%=m;}

cout<<(x+100*m)%m<<endl;

  return 0;
}


Measured memory_bytes: 31488
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f("delicious", X, A, B) :- A >= B, !.
f("safe", X, A, B) :- B - A =< X, !.
f("dangerous", _, _, _).

main :-
    get_number(X, A, B),
    f(Z, X, A, B),
    writeln(Z).


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

const int MOD = 1e9 + 7;

vvi memo;
vi a;
int n;

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int k;
	while (cin >> n >> k) {
		a = vi(n);
		for (int i = 0; i < n; ++i) cin >> a[i];
		vi dp (k+1, 0);
		vi pref (k+1);
		for (int i = 0; i <= a[0]; ++i) dp[i] = 1;
		for (int i = 1; i < n; ++i) {
			pref[0] = dp[0];
			for (int j = 1; j <= k; ++j) pref[j] = (pref[j-1] + dp[j]) % MOD;
			for (int j = 0; j <= a[i]; ++j) dp[j] = pref[j];
			for (int j = a[i] + 1; j <= k; ++j) dp[j] = (pref[j] - pref[j - a[i] - 1] + MOD) % MOD;
		}
		cout << dp[k] << '\n';
	}
}




Measured memory_bytes: 1024
N,Y = gets.split.map(&:to_i)
a0,b0,c0 = [Y / 10000, Y % 10000 / 5000, Y % 5000 / 1000]
a = b = c = n = 0
(0..a0).each do |i|
   a,b1 = a0-i,b0+i*2
   (0..b1).each do |j|
      b,c = b1-j,c0+j*5
      n = a+b+c
      break if n >= N
   end
   break if n == N
end
a=b=c=-1 if n != N
puts '%d %d %d' % [a,b,c]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

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

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ll      	long long int
#define PI      	acos(-1)
#define read    	freopen("in.txt","r",stdin)
#define uu      	first
#define vv      	second
#define write   	freopen("out.txt","w",stdout)
#define pii     	pair<int,int>
#define pll         pair<ll,ll>
#define INF     	1e9
#define EPS     	1e-8
#define MAX     	1000006
#define MOD     	1000000007
#define fastRead 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int n , vis[4000][4000];
double ara[4000] , dp[4000][4000];

double solve(int id , int heads) {

    if( id == n) {
        if( heads > 0) return 1;
        return 0;
    }

    if( vis[id][heads] ) return dp[id][heads];

    vis[id][heads] = 1;

    double tmp = ara[id] * solve(id+1 , heads + 1) + (1- ara[id]) * solve(id+1 , heads-1);

    return dp[id][heads] = tmp;

}

int main()
{
    fastRead;
    cin>>n;
    for(int i =0 ; i < n ; i++ ) cin>>ara[i];
    double ans = solve(0, 0);
    cout<<setprecision(12)<<fixed<<ans<<endl;
    return 0;
}


Measured memory_bytes: 140032
N = int(input())

if N == 0:
    print(0)
def f(N):
    if N == 0:
        return ''
    if N % 2 == 0:
        return f(N//(-2)) + '0'
    else:
        return f((N-1)//(-2)) + '1'

answer = f(N)
print(answer)


Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def dfs(mx=0,s=[0]):
        if len(s)==n:
            ans.append(s)
            return
        for i in range(mx+2):
            dfs(max(mx,i),s+[i])

    n=II()
    ans=[]
    dfs()
    for ak in ans:
        print("".join(chr(a+97) for a in ak))

main()

Measured memory_bytes: 23580
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
using namespace std;
string s,t,sa;
void computeLPSArray(string pat, int M, int lps[]); 
  
// Prints occurrences of txt[] in pat[] 
bool KMPSearch(string pat, string txt) 
{ 
    int M = pat.length(); 
    int N = txt.length(); 
  
    // create lps[] that will hold the longest prefix suffix 
    // values for pattern 
    int lps[M]; 
  
    // Preprocess the pattern (calculate lps[] array) 
    computeLPSArray(pat, M, lps); 
  
    int i = 0; // index for txt[] 
    int j = 0; // index for pat[] 
    while (i < N) { 
        if (pat[j] == txt[i]) { 
            j++; 
            i++; 
        } 
  
        if (j == M) { 
           return true;
            j = lps[j - 1]; 
        } 
  
        // mismatch after j matches 
        else if (i < N && pat[j] != txt[i]) { 
            // Do not match lps[0..lps[j-1]] characters, 
            // they will match anyway 
            if (j != 0) 
                j = lps[j - 1]; 
            else
                i = i + 1; 
        } 
    }
    return false;
} 
  
// Fills lps[] for given patttern pat[0..M-1] 
void computeLPSArray(string pat, int M, int lps[]) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 

bool ch(ll x){
	string e="";
	for(ll i=0;i<x;i++){
		e+=t;
	}
		return KMPSearch(e,sa);
	
}

int main() {
	cin>>s>>t;
	sa=s;
	sa+=s;
	while(sa.length()<=2*t.length()){sa+=s;}
	sa+=s;
     ll in=0,fin=(sa.length()/t.length());
     ll me=0;
     while(fin>=in){
     	ll m=(fin+in)/2;
     	//cout<<m<<fin<<in<<endl;
     	
     	if(m==0||ch(m)){in=m+1;me=max(me,m);}
     	else fin=m-1;
     }
     //cout<<"what";
     while(sa.length()<=3*t.length()){sa+=s;}
	sa+=s;
//	cout<<me<<endl;
	if(ch(me+1))cout<<-1<<endl;
    else{cout<<me<<endl;}
	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 22252
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s;
	cin >> s;
	if (s[0] == 'A')cout << 'T' << endl;
	else if(s[0] == 'T')cout << 'A' << endl;
	else if(s[0] == 'G')cout << 'C' << endl;
	else if(s[0] == 'C')cout << 'G' << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
	cin >> s;
	sort(all(s));
	if(s=="abc") puts("Yes");
	else puts("No");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
def wf(this_graf):
    s = len(graf)
    for k in range(s):
        for i in range(s):
            for j in range(s):
                this_graf[i][j] = min(this_graf[i][j], this_graf[i][k] + this_graf[k][j])
    return this_graf

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
graf = [[10 ** 10 for i in range(n)] for j in range(n)]

for i, j in ab:
    graf[i - 1][j - 1] = 1
    graf[j - 1][i - 1] = 1

import copy
cnt = 0

for i, j in ab:
    this_graf = copy.deepcopy(graf)
    tmp = 0
    this_graf[i - 1][j - 1] = 10 ** 10
    this_graf[j - 1][i - 1] = 10 ** 10
    this_graf = wf(this_graf)
    for i in range(n):
        for j in range(n):
            if this_graf[i][j] == 10 ** 10:
                tmp = 1
                break
        if tmp:
            break
    cnt += tmp

print(cnt)

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


int main() {
  vector<int>bun(3);
  for (auto &i : bun)
    cin >> i;
  sort(bun.begin(),bun.end());
  if ( (bun.at(0) == 5) && (bun.at(1)==5) && (bun.at(2)== 7))
    cout << "YES";
  else
    cout << "NO";
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>m;
if(n!=m){
	 cout<<"No";
}
else{
	 cout<<"Yes";
}
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b, c, d;

	scanf("%d%d%d", &a, &b, &c);

	if (a > b) {
		d = a;
		a = b;
		b = d;
	}


	if (b > c) {
		d = b;
		b = c;
		c = d;
	}

	if (a > b) {
		d = a;
		a = b;
		b = d;
	}

	printf("%d %d %d\n", a, b, c);
	return 0;

}




Measured memory_bytes: 2700
n,m,s=map(int,input().split())
a=[]
q=[[0]]
while q:
  x=q.pop()
  if len(x)<=n:
    if x[-1]==0:
      for j in range(1,m+1):
        c=x+[j]
        q.append(c)
    else:
      for j in range(x[-1],m+1):
        c=x+[j]
        q.append(c)
  else:
    a.append(x)
li=[tuple(map(int,input().split())) for _ in  range(s)]

ans=0
for A in a:
  s=0
  for i,j,k,l in li:
    if A[j]-A[i]==k:
      s+=l
  ans=max(ans,s)
print(ans)

Measured memory_bytes: 89688
#coding:utf-8

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
formula1 = 0
formula2 = 0
lastRight = 0

for left in range(N):
    rightOut = False
    if left > 0:
        formula1 ^= A[left - 1]
        formula2 -= A[left - 1]
    for right in range(lastRight, N):
        formula1 ^= A[right]
        formula2 += A[right]
        if formula1 != formula2:
            rightOut = True
            formula1 ^= A[right]
            formula2 -= A[right]
            break

    lastRight = max(left, right - rightOut) + 1
    ans += lastRight - left
print(ans)

Measured memory_bytes: 23560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,x;
    cin>>a>>b>>x;
    int q=(a-1)/x;
    if(a==0) q=-1;
    int w=b/x;
    cout << w-q << endl;




}


Measured memory_bytes: 256
#include "stdio.h"

void swap(int *x, int *y){
    int tmp;
    tmp = *x;
    *x = *y;
    *y = tmp;
}


int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if(a>b){
        swap(&a, &b);
    }
    
    if(a>c){
        swap(&a, &c);
    }
    
    if(b>c){
        swap(&b, &c);
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<string> days =  { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	string s;
	cin >> s;
	int ans = 7 - (find(days.begin(), days.end(), s) - days.begin());
	cout << ans << "\n";
	return 0;
}


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

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 1e5 + 7;
SLL n, a, b;
SLL ans;

SLL fac[maxN * 2];
void init_fact() {
    fac[0] = 1;
    For(i, 1, 2 * maxN - 1) {
        fac[i] = (i * fac[i - 1]) % mod;
    }
}

void input(){
    cin >> n >> a >> b;
    init_fact();
}

// Calculate x^y % p
inline SLL pow_mod(SLL x, SLL y, ULL p = mod){
	SLL ret = 1;
	while(y){
		if(y & 1) {
			ret = (ret * x) % p;
		}
        x = (x * x) % p;
        y >>= 1;
	}
	return ret;
} 

//ax + by = gcd(a, b) = d
// 扩展欧几里德算法
/**
 *    a*x + b*y = 1
 *    如果ab互质，有解
 *    x就是a关于b的逆元
 *    y就是b关于a的逆元
 *     
 *    证明： 
 *        a*x % b + b*y % b = 1 % b
 *        a*x % b = 1 % b
 *        a*x = 1 (mod b)
 */
inline void ex_gcd(SLL a, SLL b, SLL &x, SLL &y, SLL &d){
    if(!b) {
        d = a, x = 1, y = 0;
    }
    else{
        ex_gcd(b, a % b, y, x, d);
        y -= x * (a / b);
    }
}

// 求a关于p的逆元，如果不存在，返回-1 
// a与p互质，逆元才存在 
inline SLL inv_mod(SLL a, SLL p = mod){
    SLL d, x, y;
    ex_gcd(a, p, x, y, d);
    return d == 1 ? (x % p + p) % p : -1;
}

// 使用条件：n非常大m非常小 
inline SLL comb_mod(SLL m, SLL n) {
    SLL ret;

    if(m > n) {
        swap(m, n);
    } 
    
    SLL X = 1;
	SLL Y = fac[m];
	
	For(i, n - m + 1, n) {
		X = (X * i) % mod;
	}
	
	ret = (X * inv_mod(Y)) % mod;
    return ret;
}

void solve(){
    ans = (pow_mod(2, n) - 1 - comb_mod(a, n) - comb_mod(b, n) + (mod << 2)) % mod;
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    output();
    return 0;
}

Measured memory_bytes: 1792
# include <iostream>
const int MAX = 3e5 + 2;
const long long MOD = 998244353;
using namespace std;

long long fm_table[MAX];
long long ifm_table[MAX];
long long bm_table[MAX];


long long pow_mod (long long x, long long m, long long mod) {
    if (m == 0){
        return 1;
    } else { 
        long long temp = pow_mod(x, m/2, mod);
        if (m % 2 == 0) {
            return temp * temp % mod;
        } else {
            return temp * temp % mod * x % mod;
        }
    }
}
 
long long inv_mod (long long x, long long mod) {
    return pow_mod(x, mod - 2, mod);
}
 
int main() {
    long long N, A, B, K;
    cin >> N >> A >> B >> K;
 
    long long ret = 0;
 
    long long temp = 1;
    for (int i = 0; i <= N; i++) {
        if (i == 0) {
            fm_table[0] = 1;
            ifm_table[0] = 1;
        } else {
            temp = temp * i % MOD;
            fm_table[i] = temp;
            ifm_table[i] = inv_mod(temp, MOD);
        }
    }
    for (int i = 0; i * 2 <= N; i++) {
        temp = fm_table[N] * ifm_table[i] % MOD
            * ifm_table[N - i] % MOD;
        bm_table[i] = temp;
        bm_table[N - i] = temp;
    }
 
    for (long long i = 0; i <= N; i++) {
        long long rest = K - i * A;
        if (rest >= 0 && rest <= B * N && rest % B == 0){
            long long j = rest / B;
            ret = (ret + bm_table[i] * bm_table[j] % MOD) % MOD;
        }
    }
    
    cout << ret << endl;
}

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

int main(){
    int i[3];cin >> i[0] >> i[1] >> i[2];
    sort(i,i+3);
    if (i[0]==5 && i[1] == 5 && i[2] == 7){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 60;

ll a[MAX_N], p[MAX_N];



ll dfs(ll l, ll k){
	if (l==0) return 1;
	if (k==1) return 0;
	if (1<k&&k<=1+a[l-1]) return dfs(l-1, k-1);
	else if (k==2+a[l-1]) return p[l-1]+1;
	else if (k<=2+2*a[l-1]) return p[l-1]+1+dfs(l-1, k-a[l-1]-2);
	else return 2*p[l-1]+1;
}

int main(int argc, char const *argv[])
{
	ll n, x;
	cin >> n >> x;
	p[0] = 1;
	a[0] = 1;
	for (int i = 1; i <= n; ++i){
		p[i] = 2*p[i-1] + 1;
		a[i] = 2*a[i-1] + 3;
	}

	cout << dfs(n, x) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def main():
    N = int(readline())
    A = list(map(int, read().split()))

    if N == 2:
        print(A[1] - A[0])
        exit()

    dp = [10 ** 10] * N
    dp[1] = abs(A[1] - A[0])
    dp[2] = abs(A[2] - A[0])

    for i in range(3, N):
        dp[i] = min(dp[i - 1] + abs(A[i] - A[i - 1]), dp[i - 2] + abs(A[i] - A[i - 2]))

    print(dp[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 13924
/** Author: Dwai
 *  Omae wa mou shindeiru!
**/

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define all(a) (a).begin(),(a).end()
#define fr(i,a,b) for (i = a; i <= b; i++)
#define frr(i,a,b) for (i = a; i >= b; i--)
#define rep(i,n) for (i = 0 ; i < n; i++)
#define repr(i,n) for (i = n - 1; i >= 0; i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define flushinput   cin.ignore(numeric_limits<streamsize>::max(),'\n');

void debug_out() { cerr << endl; }

void clock_out(){
  cerr<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
}

void fileio(){
  freopen("/home/dwai/Desktop/cp/input.txt","r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}

void ofileio(){
  freopen("input.txt","r", stdin);
  freopen("output.txt", "w", stdout); 
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define fio() fileio()
#define ofio() fileio()
#define clock() clock_out()
#else
#define debug(...) 42
#define fio() 42
#define ofio() ofileio()
#define clock() 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef map<ll,ll> mll;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;


void solve()
{
	ll n;cin>>n;
	ll ans=(n-1)/2;
	cout<<ans;
}

int main()
{
//	fio();
	fast
	ll t=1;
	//cin>>t;

	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256