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

using namespace std;

int main() {
  string S;
  int X, Y;
  cin >> S >> X >> Y;
  vector<int> vx, vy;
  int startx = -1;
  bool dirx = true;
  int tmp = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'F') {
      tmp++;
    }
    if (S[i] == 'T' or i == S.length() - 1) {
      if (dirx) {
        if (startx == -1) {
          startx = tmp;
        } else {
          vx.push_back(tmp);
        }
      } else {
        vy.push_back(tmp);
      }
      dirx ^= 1;
      tmp = 0;
    }
  }

  int smax = 8000;
  vector<vector<bool>> dp_x(vx.size() + 1, vector<bool>(smax * 2 + 10));
  dp_x[0][smax + startx] = true;
  for (int i = 0; i < vx.size(); i++) {
    for (int x = 0; x <= smax * 2; x++) {
      if (!dp_x[i][x]) continue;
      if (x - vx[i] >= 0) dp_x[i + 1][x - vx[i]] = true;
      if (x + vx[i] <= smax * 2) dp_x[i + 1][x + vx[i]] = true;
    }
  }

  vector<vector<bool>> dp_y(vy.size() + 1, vector<bool>(smax * 2 + 10));
  dp_y[0][smax + 0] = true;
  for (int i = 0; i < vy.size(); i++) {
    for (int y = 0; y <= smax * 2; y++) {
      if (!dp_y[i][y]) continue;
      if (y - vy[i] >= 0) dp_y[i + 1][y - vy[i]] = true;
      if (y + vy[i] <= smax * 2) dp_y[i + 1][y + vy[i]] = true;
    }
  }

  if (dp_x[vx.size()][smax + X] and dp_y[vy.size()][smax + Y]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void permutation() {
    // plz set a appropriate vector
    vector<int> vec = {3, 2, 1, 0};
    sort(vec.begin(), vec.end());
    do {
        // implement me
    } while (next_permutation(vec.begin(), vec.end()));
}

void Main() {
	int N; cin >> N;
	vector<double> x(N);
	vector<double> y(N);
	vector<int> perm(N);
	REP(i, N) {
		cin >> x[i];
		cin >> y[i];
		perm[i] = i;
	}
	long double cnt = 0;
	long double sum = 0;
	do {
		cnt++;
		REP(i, N - 1) {
			sum += sqrtl(pow(x[perm[i + 1]] - x[perm[i]], 2) + pow(y[perm[i + 1]] - y[perm[i]], 2));
		}
        // debug(perm);
    } while (next_permutation(perm.begin(), perm.end()));
	// debug(cnt);
	cout << sum / cnt << endl;
}

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


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

class mydict {
	vector<bool> m_table;

public:
	mydict(): m_table( 244140625 ) {} // 5^12

	void insert( const string& key ) {
		int x = hash( key );
		m_table.at( x ) = true;
	}

	bool find( const string& key ) const {
		int x = hash( key );
		return m_table.at( x );
	}

private:
	static int hash( const string& s ) {
		int tb[26] = {};
		tb['A' - 'A'] = 1;
		tb['C' - 'A'] = 2;
		tb['G' - 'A'] = 3;
		tb['T' - 'A'] = 4;

		int r = 0;

		for( auto ch: s ) {
			int x = tb[ch - 'A'];
			r = (r*5) + x;
		}

		return r;
	}
};

int main() {
	ios_base::sync_with_stdio( false );

	mydict d;

	int n;
	cin >> n;

	for( int i = 0; i < n; ++i ) {
		string cmd, key;
		cin >> cmd >> key;

		if( cmd == "insert" ) {
			d.insert( key );
		}
		else {
			cout << (d.find( key ) ? "yes" : "no") << '\n';
		}
	}
}



Measured memory_bytes: 32560
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

int main(){

    int N, M;
    cin >> N >> M;
    ll ans = 0;
    vector<P>vec(N);
    for(int i = 0; i< N; i++){
        cin >> vec[i].first >> vec[i].second;
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i< N;i++){
        while(M && vec[i].second){
            M--;
            vec[i].second--;
            ans += vec[i].first;
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
string s; int n;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>s;
  n = s.length();

  int x=-2; int y=-2;
  
  for (int i=0; i+1<n; i++) {
    if (s[i] == s[i+1]) {
      x=i;
      y=i+1;
      break;
    }
    if (i+2<n && s[i]==s[i+2]) {
      x=i;
      y=i+2;
      break;
    }
  }

  cout<<x+1<<" "<<y+1<<endl;
  return 0;
}


Measured memory_bytes: 512
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define fi first
#define se second


#define alli(a, n, k) (a+k),(a+n+k)
#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define repi(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)


#define endl '\n'


typedef pair<int, int> pii;


class Solution {
public:
    const int static MAX = 2e5 + 5;
    const int static MOD = 998244353;
    pair<ll, ll> p[MAX];
    ll dp[MAX];
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        rep(i, 0, n, 1) {
            in >> p[i].fi >> p[i].se;
            p[i].se += p[i].fi;
        }
        sort(alli(p, n, 0));
        stack<pii> stk;
        stk.push({n, 2e9});
        dp[n] = 1;
        repi(i, n-1, -1, 1) {
            while (stk.top().se < p[i].se) stk.pop();
            int x = stk.top().fi;
            dp[i] = (dp[x] + dp[i+1]) % MOD;
            stk.push({i, p[i].fi});
        }
        out << dp[0] << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define all(x) x.begin(),x.end()
#define len(x) (int)(x).size()
//#define endl "\n"
#define m_p make_pair
#define int long long


using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pari;

ld PI = 3.14159265358979323846;


struct Circle{
    int x,y,r;
};

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

void volodya22(){
    #ifdef THERE
        freopen("input.txt", "r", stdin);
    //    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
}


int n;
const int N = 1e6+7;
const int alphabet = 256;
const int INF = 1e18;
const ll MOD = 1e9+7;
const ld eps = 1e-19;
const int L = 30;

int m1 = 137*137*137*137*13;
int m2 = 1e9+9;
//int p = 347;


void input(){

}


void solve(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    for(int i = 0;i < n;i++){
        if(i == k-1){
            if(s[i] == 'A') cout << 'a';
            else if(s[i] == 'B') cout << 'b';
            else if(s[i] == 'C') cout << 'c';
        }else cout << s[i];
    }
}

signed main(){
    volodya22();
    input();
    solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
	int N,i,score[4]={0,0,0,0};
	char str[6];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%s",str);
		if(strcmp(str,"AC")==0){
			score[0]++;
		}else if(strcmp(str,"WA")==0){
			score[1]++;
		}else if(strcmp(str,"TLE")==0){
			score[2]++;
		}else{
			score[3]++;
		}
	}
	printf("AC x %d\n",score[0]);
	printf("WA x %d\n",score[1]);
	printf("TLE x %d\n",score[2]);
	printf("RE x %d\n",score[3]);
	return 0;
}

Measured memory_bytes: 1728
N, Q = [int(i) for i in input().split()]
S = input()
lr = []
for i in range(Q):
    l, r = input().split(" ")
    lr.append((int(l)-1, int(r)-1))
    
# i番目を含む右部分文字列中に"AC"が何回現れるか
c = [0 for _ in range(N)]
for i in range(N-1)[::-1]:
    if S[i] == "A" and S[i+1] == "C":
        c[i] = c[i+1] + 1
    else:
        c[i] = c[i+1]
        
for i in range(Q):
    l, r = lr[i]
    a = c[l] - c[r]
    if r < len(S) - 1 and c[r] == "A" and c[r] == "C":
        a -= 1
    print(a)

Measured memory_bytes: 19760
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var B = new long[N];
            var fro = 0L;
            var bac = 0L;

            if(N%2 == 0)
            {
                bac = N / 2;
                fro = (N / 2) -1;
                for (int i = 0; i < N; i++)
                {
                    if (i%2 == 0)
                    {
                        B[bac] = A[i];
                        bac++;
                    }
                    else
                    {
                        B[fro] = A[i];
                        fro--;
                    }
                }
                
            }
            else
            {
                bac = N / 2;
                fro = (N / 2) - 1;
                for (int i = 0; i < N; i++)
                {
                    if (i % 2 == 0)
                    {
                        B[bac] = A[i];
                        bac++;
                    }
                    else
                    {
                        B[fro] = A[i];
                        fro--;
                    }
                }
                B = B.Reverse().ToArray();
            }

            Console.WriteLine(String.Join(" ", B));
            
        }


    }

}


Measured memory_bytes: 65672
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

void disp(string &s,int N){
  if(s.length()==N){
    cout<<s<<endl;
  }else{
    for(char c='a';c<=*max_element(ALL(s))+1;c++){
      s.push_back(c);
      disp(s,N);
      s.pop_back();
    }
  }
}

int main(){
  int N;
  cin>>N;
  string S="a";
  disp(S,N);
  return 0;
}


Measured memory_bytes: 1536
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long

# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG
typedef unsigned long long int ull;
using namespace std;
#include<string>
#include<cmath>
const int N = 1e5 + 7;
const int mod = 1e9 + 7;


int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins
    int n, t;
    cin>>n>>t;

    int a[n];
    for(int i = 0; i<n; i++)
    cin>>a[i];

    int s_1 = a[0];
    int e_1 = s_1 + t;
    int s_2, e_2;
    int r= 0;
    for(int  i = 1; i<n; i++)
    {
      s_2 = a[i];
      e_2 = a[i] + t;

      if( s_2 >= s_1 && s_2 <=e_1)
      {
      //  cout<<"inside the common block\n";
        r += s_2 - s_1;
      }
      else{
        //cout<<"inside the uncommon block\n";
       r += t;
     }
       s_1  = s_2;
       e_1 = e_2;
    }
  //  cout<<"value of r : "<<r<<endl;

    r += t;

    cout<<r<<"\n";






    return 0;
}


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

int main(){
    int M, K;
    cin >> M >> K;
    if(M == 1){
        if(K == 0){
            cout << "0 0 1 1" << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if((1<<M) <= K){
        cout << -1 << endl;
        return 0;
    }

    vector<int> order;
    for(int i=0; i<(1<<M); i++) if(i != K) order.push_back(i);
    vector<int> ans = order;
    ans.push_back(K);
    reverse(order.begin(), order.end());
    for(int a : order) ans.push_back(a);
    ans.push_back(K);
    for(int a : ans) cout << a << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 4464
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;

void solve()
  {
   string s;
   cin>>s;
   int n = s.size();
   int sum = 0;
   loop(i,0,n)
    sum += s[i] - '0';
   cout<<(sum%9 == 0 ? "Yes" : "No");
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

public class Main{

	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt(),m=sc.nextInt();
		int [][]a=new int [m][2];
		for(int i=0;i<m;i++)
			for(int j=0;j<2;j++)
				a[i][j]=sc.nextInt()-1;
		DSU dsu=new DSU(n);
		long []ans=new long [m];
		long pairs=n*1L*(n-1)/2;
		for(int i=m-1;i>=0;i--) {
			int u=a[i][0],v=a[i][1];
			ans[i]=(pairs);
			pairs-=dsu.unionSet(u, v);
		}
		for(long x:ans)
			out.println(x);
		out.close();

	}
	static class DSU {                                              
		int[] p, rank, setSize;
		int numSets;

		public DSU(int N) 
		{
			p = new int[numSets = N];
			rank = new int[N];
			setSize = new int[N];
			for (int i = 0; i < N; i++) {  p[i] = i; setSize[i] = 1; }
		}

		public int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }

		public boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }

		public long unionSet(int i, int j) 
		{ 
			if (isSameSet(i, j)) 
				return 0;
			numSets--; 
			int x = findSet(i), y = findSet(j);
			long a=setSize[x],b=setSize[y];
			if(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
			else
			{	p[x] = y; setSize[y] += setSize[x];
				if(rank[x] == rank[y]) rank[y]++; 
			} 
			return a*b;
		}

		public int numDisjointSets() { return numSets; }

		public int sizeOfSet(int i) { return setSize[findSet(i)]; }
	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		
	}
}


Measured memory_bytes: 51648
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
typedef pair<ll,ll> ipair;
#define F first
#define S second
 
/*
//functions from gfg
 
long long int power(long long int x,long long int y,long long  int p)
{
    long long int res = 1;     // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            {//d=(long double)x/p;
            res = (res*x) % p;
            }
 
        // y must be even now
        y = y>>1; // y = y/2
        x=(x*x)%p;
        
    }
    return res%p;
}
 
long long int gcd(long long int a,long long int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
 
long long int binomialCoeff(long long int n, ll k) 
{ 
    ll res = 1; 
  
    // Since C(n, k) = C(n, n-k) 
    if (k > n - k) 
        k = n - k; 
  
    // Calculate value of [n*(n-1)*---*(n-k+1)] / [k*(k-1)*---*1] 
    for (ll i = 0; i < k; ++i) 
    { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
  
    return res; 
} 
 

void sieve(int n, vector<ll> &primes) 
{ 
    vector<int> prime(n,1);
    ll p;
    for ( p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == 1) 
        { 
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = 0; 
        } 
    } 
  
    for(p=2;p<=n;p++)
    {
        if(prime[p])
        primes.pb(p);
    }
   
} 

 
*/

int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    
    
	ll n,i,j,p,k,m,ans=0,tmp1,tmp2;
    string s;
  	cin>>s;
  	n=s.length();
    for(i=0;i<n;i++)
    {
        tmp1=0;tmp2=0;
        // if(i==0)
        // {
        //     k=1;
        // }
        // else k=0;
        
      	while(i<n&&s[i]=='<')
        {
        	tmp1++;i++;
        }
    //     if(i==n-1&&k==1)
    //   	ans++;
    //   	if(i==0)
    //     {
    //         k=1;
    //     }
    //     else k=0;
      	while(i<n&&s[i]=='>')
        {
        	tmp2++;i++;
        }
    //     if(i==n-1&&k==1)
    //   	ans++;
      	
      	if(tmp1<tmp2)
      	tmp1--;
      	else// if(tmp1>tmp2)
      	tmp2--;
      	
      	
      	tmp1*=(tmp1+1);
      	tmp1/=2;
      	tmp2*=(tmp2+1);
      	tmp2/=2;
      	i--;
      	ans+=tmp1+tmp2;
      	
    }
  	//ans--;
    cout<<ans<<endl;
    
    
    
    
    
    // for(i=0;i<n;i++)
    // {
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;
    
	return 0;
}

Measured memory_bytes: 1172
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a <= c)
    {
        cout << max(min(d - c, b - c), 0) << endl;
    }
    else
    {
        cout << max(min(b - a, d - a), 0) << endl;
    }
    return 0;
}

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

int main (){
  int N;
  string S;
  cin >> N >> S;
  int ans;
  ans=0;
  for(int i=0;i<N;i++){
    if (i==0||i==1){
    }
    else {
      if (S.at(i-2)=='A'){
        if (S.at(i-1)=='B'){
          if (S.at(i)=='C'){
            ans+=1;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int n = s.length();
	vector<int> a(n, 0);
	vector<int> b(2, 0);
	
	for(int i=0; i < n; i++){
		swap(b[0], b[1]);
		if(s[i] == 'R'){
			b[0]++;
		}else{
			a[i] += b[0];
			a[i-1] += b[1];
			b[0] = b[1] = 0;
		}
	}
	b[0] = b[1] = 0;
	for(int i=n-1; i >= 0; i--){
		swap(b[0], b[1]);
		if(s[i] == 'L'){
			b[0]++;
		}else{
			a[i] += b[0];
			a[i+1] += b[1];
			b[0] = b[1] = 0;
		}
	}
	for(int i=0; i < n; i++)cout << a[i] << " ";
	cout << endl;
	return 0;
}

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

int main() {
	long long n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) cin >> A[i];
	long long ans = 0;
	int s_xor = 0, s_plus = 0;
	for (int l = 0, r = 0; l < n; l++) {
		while (r < n) {
			int ns_xor = s_xor ^ A[r], ns_plus = s_plus + A[r];
			if (ns_xor == ns_plus) {
				s_xor = ns_xor; s_plus = ns_plus;
				r++;
			} else break;
		}
		ans += r - l;
		s_xor ^= A[l]; s_plus -= A[l];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main(void){
  long int K;
  int c = 0;
  scanf("%ld",&K);
  for(int i = 0;i < 3;i++){
    if(K%10==7){
      c++;
    }
    K=K/10;
  }
  if(c > 0){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;

#define REP(i, n) for ((i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



const int MAX = 110;
const ll INF = 1LL<<50;
int n;
int h[MAX], l[MAX];
ll dp[MAX][MAX];

int main() {
    while (cin >> n) {
        int i, j, k, b;

        for (i = 0; i < n; ++i) cin >> h[i] >> l[i];
        for (i = 0; i < MAX; ++i) for (j = 0; j < MAX; ++j) dp[i][j] = INF;
        
        for (i = 0; i < n; ++i) {
            dp[i][i+1] = 0;
            dp[i][i+2] = h[i] * l[i] * h[i+1] * l[i+1];
        }
        for (b = 3; b <= n; ++b) {
            for (i = 0; i + b <= n; ++i) {
                j = i+b;
                for (k = i+1; k+1 <= j; ++k) {
                    chmin(dp[i][j], dp[i][k] + dp[k][j] + h[i] * l[k-1] * h[k] * l[j-1]);
                }
            }
        }
        
        cout << dp[0][n] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1252
n = int(input())
dic = {i:[] for i in range(n)}

for ni in range(n):
  a = int(input())
  for ai in range(a):
    x,y = map(int,input().split())
    dic[ni].append((x-1,y))

ans = 0    
    
for i in range(2**n):
  p = [0]*n
  for j in range(n):
    if i>>j & 1:
      p[j]=1  
  
  flag = True
  for j in range(n):    
    if p[j]:
      for h,tf in dic[j]:
        if (tf==1 and p[h]==1) or (tf==0 and p[h]==0):
          pass
        else:
          flag = False          
  if flag:
    ans = max(ans,sum(p))
    
print(ans)  

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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    double a, b;
    int c;
    cin >> a >> b >> c;
    double crad = c * PI / 180;
    cout << a * b * sin(crad) / 2.0 << endl << a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(crad)) << endl << a * b * sin(crad) / a << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = list(range(self.n))
        self.rank = [1] * n
        self.cnt = n
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        p = self.find(x)
        q = self.find(y)
        if p == q:
            return None
        if p > q:
            p, q = q, p
        self.rank[p] += self.rank[q]
        self.par[q] = p
        self.cnt -= 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def size(self, x):
        return self.rank[x]
    def count(self):
        return self.cnt
n, m = map(int, input().split())
UF = UnionFind(n)
for _ in range(m):
    a, b = map(int, input().split())
    UF.unite(a - 1, b - 1)
print(UF.count() - 1)

Measured memory_bytes: 13628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]%2 == 0){
            if(a[i]%3 != 0){
                if(a[i]%5 !=0){
                    cout<<"DENIED"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"APPROVED"<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int n,m;
vector<vector<int>> g(100010);
vector<bool> used(100010,false);
vector<int> dp(100010,-1);

void dfs(int v){
  if(used[v]) return ;
  used[v]=true;
  if(g[v].empty()) dp[v]=0;
  for(auto itr:g[v]){
    dfs(itr);
    dp[v]=max(dp[v],dp[itr]+1);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
      int x,y;
      cin>>x>>y;
      g[x].push_back(y);
    }
    FOR(i,1,n+1) if(!used[i]) dfs(i);
    cout<<*max_element(begin(dp),end(dp))<<endl;
}

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

int main()
{
	int x, y;
	cin >> x >> y;
	while (true) {
		if (x > y) {
			x = x%y;
			if (x == 0) {
				cout << y << endl;
				break;
			}
		}
		else if (x < y) {
			y = y%x;
			if (y == 0) {
				cout << x << endl;
				break;
			}
		}
		else {
				cout << x << endl;
				break;
			}
		
	}
    return 0;
}

Measured memory_bytes: 1164
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}

const int mod = 1e9+7;
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
char s[1000111];
bool calc(char c)
{
	bool ret = 0;
	for (int i=0; i<n; i++)
	{
		if (s[i]==c&&((n-1)&i)==i)
		{
			ret ^= 1;
		}
	}
	return ret;
}
int main()
{
	scanf("%d", &n);
	scanf("%s", s);
	bool f = false;
	for (int i=0; i<n; i++)
	{
		f |= s[i]=='2';
	}
	if (f)
	{
		cout<<calc('2')<<endl;
	}
	else
	{
		cout<<calc('3')*2<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
N = int(input())
A_list = list(map(int, input().split()))

approve = True

for a in A_list:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            approve = False
            break

if approve:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
k, x = map(int, input().split())

res = []
if k == 1:
    print(x)
else:
    for i in range(1, k):
        res.append(x + i)
    for i in range(1, k):
        res.append(x - i)
    res.append(x)
    res = sorted(res)
    print(*res)


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

int main() {
    int N;
    cin >> N;
    int V[N];
    int C[N];
    int X[N];
    int ans = 0;

    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    for(int i = 0; i < N; i++){
        X[i] = V[i] - C[i];
    }

    for(int i = 0; i < N; i++){
        if(X[i] > 0){
            ans += X[i];
        }
    }

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

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

int main(){
    int N;
    int C[20];
    int V[20];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    int sum = 0;
    for(int i=0;i<N;i++){
        if(V[i] - C[i] > 0){
            sum += V[i] - C[i];
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector> 
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>nums(n);
	for(int i=0;i<n;++i){
		cin>>nums[i];
	}
	vector<int>left(n,0);
	for(int i=0;i<n-1;++i){
		left[i+1]=left[i]^nums[i];
	}
	vector<int>right(n,0);
	for(int i=n-1;i>0;--i){
		right[i-1]=right[i]^nums[i];
	}
	for(int i=0;i<n-1;++i){
		cout<<(left[i]^right[i])<<' ';
	}
	cout<<(left[n-1]^right[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 5124
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
int main(){
    LL ans=0;
    int n;
    scanf("%d",&n);
    LL tot=0;
    for(int i=  0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(x==0)ans+=tot/2,tot=0;
        else tot+=x;
    }
    ans+=tot/2;
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int> >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int a,b;
    cin >> a >> b;
    cout << a * b - a - b + 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int a[100010], b[100010];
int memo[300000];//累積和

int main(void){
	cin >> N;
	rep(i, N) cin >> a[i] >> b[i];
	int T = 0;
	rep(i, N){
		T += a[i];
		T %= 86400;
		rep(j, 3){
			memo[T + j * 86400]++;
			// printf("%d\n", T + j * 86400);
		}

		T += b[i];
		T %= 86400;
	}
	reps(i, 1, 300000) memo[i] += memo[i - 1];
	// rep(i, 300000)if(memo[i]) printf("%d\n", memo[i]);
	int ans = 0;
	rep(t, 86401){
		int d = memo[t + 14400 + 10800] - memo[t + 14400 - 1];
		chmax(ans, d);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
template<class T>bool chmax(T &a,const T &b){if(a<b){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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll INF = 100000007;
#define REP10(i, j, M) for(ll i = j; i <= M; i++)



int main() {
  IN(ll, X);
  vector<ll> pow5(121);
  REP(i,121){
    pow5.at(i) = pow(i,5);
  }
  REP(i,121){
    REP(j,i+1){
      if(pow5.at(i) - pow5.at(j) == X){
        cout << i << " " << j;
        goto OUT;
      }
      if(pow5.at(i) + pow5.at(j) == X){
        cout << i << " -" << j;
        goto OUT;
      }
    }
  }
  OUT:
  cout << endl;
}





Measured memory_bytes: 4100
dayToInt "SUN" = 0
dayToInt "MON" = 1
dayToInt "TUE" = 2
dayToInt "WED" = 3
dayToInt "THU" = 4
dayToInt "FRI" = 5
dayToInt "SAT" = 6

main = do
  s <- getLine
  putStrLn $ show $ 7 - dayToInt s


Measured memory_bytes: 380
from itertools import accumulate
from decimal import Decimal
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[0]
tmp=0
for i in range(n):
    p[i]=Decimal((p[i]+1)/2)
    tmp+=p[i]
    l.append(tmp)
ans=0
for i in range(k,n+1):
    tmp=l[i]-l[i-k]
    if tmp>ans:
        ans=tmp
print(Decimal(ans))

Measured memory_bytes: 295572
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
signed main(){
  int a,b,d,w,f=0;
  int c[1000][1000]={};
  int e[1000]={};
  cin>>a>>b;
  w=b;
  for(int i=0;i<a;i++){
    cin>>b;
    for(int j=0;j<b;j++){
      cin>>d;
      c[i][d]=1;
    }
  }
  for(int i=0;i<=a;i++){
    for(int j=0;j<=w;j++){
      e[j]+=c[i][j];
    }
  }
  for(int i=0;i<=w;i++){
   // cout<<e[i]<<" "<<a<<"\n";
    if(e[i]==a) f++;
  }
  cout<<f<<"\n";
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
//using G = vector<vector<int>>;
const long long INF = 1LL << 60;

//解説記事写経
using Graph = vector<vector<int>>;
int n,m,k;
int id;
//dfs
vector<int> cc_id; //どの連結成分か
vector<int> cc_size; //連結成分のサイズ

void dfs(Graph &G ,int v, int &cnt){
  //G:グラフ，v:今いるノード番号，cnt:連結成分数
  cc_id[v] = id;//番号を振る
  cnt++;//連結成分数のカウント
  //次の場所へ
  for(auto e: G[v]){
    if(cc_id[e] == -1){
      dfs(G, e, cnt);
    }
  }
}

int main(){
  cin >> n>>m>>k;
  Graph G(n);
  rep(i, m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }  
    vector<int> c(k),d(k);

  rep(i,k){
    cin >> c[i] >> d[i];
    c[i]--;d[i]--;
  }
//どの連結成分に属し，サイズがいくつなのかを求める
cc_id.assign(n,-1);//初期化,どの連結成分なのか
id = 0;
  rep(i,n){
    //まだidがふられていなかったら
    if(cc_id[i] == -1){
      int cnt = 0;//連結成分数，参照渡しをする
      dfs(G,i,cnt);
      cc_size.push_back(cnt);
      id+=1;//同一グループは探索し終わったのでidを１つずらす
    }
  }

vector<int> ans(n);//友達候補
rep(i,n) ans[i] = cc_size[cc_id[i]/*nodeに振られている番号*/]-1-(int)G[i].size();
rep(i,k) {
  if(cc_id[c[i]] == cc_id[d[i]]){
    ans[c[i]]--;
    ans[d[i]]--;
  }
}
  int end = ans.size()-1;
  rep(i,(int)ans.size()){
    cout << ans[i] << ((i==end)? "\n":" ");
  }
return 0;
}

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

using namespace std;

class A {
	int a, b, c, ans{ 1 };

public:
	void solve()
	{
		cin >> a >> b >> c;

		if (a != b)
		{
			ans += 1;
			if (a != c && b != c)
				ans += 1;
		}
		else
		{
			if (a != c)
				ans += 1;
		}

		cout << ans << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

using namespace std;

const int P = 1e9+7;
const int maxn = 1e6+1;
long long inv[maxn];
int cnt[maxn];

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

long long fp(int a, int n){
    if(n==0)
        return 1;
    long long h = fp(a, n/2);

    return n & 1 ? h * h % P * a % P : h * h % P;
}

int main(){
    int n;

    cin >>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }

    inv[1] = 1;
    for(int i=2;i<maxn;i++){
        inv[i] = fp(i, P - 2);
    }

    for(int i=0;i<n;i++){
        int t = v[i];
        for(int j=2;j*j<=t;j++){
            int c = 0;
            while(t % j==0){
                c++;
                t /= j;
            }
            cnt[j] = max(cnt[j], c);
        }
        if(t > 1)
            cnt[t] = max(cnt[t], 1);
    }

    long long lcm = 1;
    for(int i=2;i<maxn;i++){
        lcm = lcm * fp(i, cnt[i]) % P;
    }

    int ans = 0;
    for(int i=0;i<n;i++){
        ans += lcm * inv[v[i]] % P;
        ans %= P;
    }
    cout << ans;
}


Measured memory_bytes: 11776
#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>;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  if (n <= x) {
    cout << t << endl;
    return 0;
  }
  int c = (n + x - 1) / x;
  int ans = 0;
  ans += c * t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

#define MAX_P 200010
int fact[MAX_P]; //n! mid p

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
//n! = a p^e -> a mod p
void make_fact()
{
    fact[1] = 1;
    for (int i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
//nCk mod p
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    make_fact();
    int ans = 0;
    rep(i, n)
    {
        int Max = (a[i] * mod_comb(i, k - 1, mod)) % mod;
        (ans += Max) %= mod;
        int Min = (a[i] * mod_comb(n - i - 1, k - 1, mod)) % mod;
        (ans -= Min) %= mod;
        //cout << i << " " << Max << " " << Min << endl;
    }
    if (ans < 0)
        ans += mod;
    cout << ans << endl;
}


Measured memory_bytes: 5544
#include <iostream>
#include <vector>

using namespace std;

int fact(int n, int p) {
    int res = 1;
    while(p) {
        res *= n;
        p--;
    }
    return res;
}

int main(void) {
    int N;
    cin >> N;
    vector<int> v;
    v.push_back(1);
    for(int i=1; i<=6; i++) {
        v.push_back(fact(6, i));
        v.push_back(fact(9, i));
    }

    vector<int> dp(N+1);
    for(int i=1; i<=N; i++) {
        dp[i] = INT32_MAX;
    }
    for(auto e: v) {
        for(int i=0; i<N; i++) {
            if(i+e <= N) {
                dp[i+e] = min(dp[i+e], dp[i] + 1);
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    int n,k; cin >> n >> k;
    int l[60];
    rep(i,n) cin >> l[i];

    sort(l, l + n, greater<int>());
    
    int ans = 0;
    rep(i,k){
        ans += l[i];
    }
    print(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    char b;
    cin >> b;

    if (b == 'A') {
        cout << "T" << endl;
    } else if (b == 'C') {
        cout << "G" << endl;
    } else if (b == 'G') {
        cout << "C" << endl;
    } else {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import itertools






from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    a = list(range(1,n+1))
    p = li()
    q = li()
    pc = 0
    qc = 0
    for e,i in enumerate(itertools.permutations(a)):
        
        lli = list(i)
        if lli == p:
            pc = e

        if lli == q:
            qc = e

    print(abs(pc-qc))


    
main()


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	int i, j, n, m;
	char str[10];
	scanf("%s", str);
	for (i=0; i<3; i++)
	{
		if (str[i] == str[i+1])
		{
			printf("Bad");
			return 0;
		}
		    
	}
	printf("Good");
	return 0;
}

Measured memory_bytes: 1712
(setq a(read))(setq b(read))
(setq s(concatenate 'list(read-line)))
(setq c 0)
(dotimes(i(1+(+ a b)))
  (if(not(or(and(= i a)(char=(nth i s)#\-))(and(/= i a)(digit-char-p(nth i s)))))(incf c)))
(princ(if(> c 0)"No""Yes"))


Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    string ans = "No";
    for(int i = 0; i <=n; i++){
        for(int j = 0; j <= m; j++){
            int b = m * i + (n-2*i) * j;
            if(b == k) ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
int A[3333333];
typedef long long ll;
int main() {
  cin >> N;
  for (int i = 0; i < 3*N; i++) cin >> A[i];
  sort(A, A + 3*N);
  ll res = 0;
  for (int i = 3*N-1;i>=N;i-=2){
    res += A[i-1];
  }
  cout << res << endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  string in;
  int res = 0;
  int J,O,I;
  cin >> in;
  rep(i,in.size()){
    if(in[i] != 'J')continue;
    for(J = 0 ; in[i] == 'J' ; i ++) J ++;
    for(O = 0 ; in[i] == 'O' ; i ++) O ++;
    if(in[i] == 'J'){
      i --; continue;
    }
    for(I = 0; in[i] == 'I' ; i ++) I ++;
    if(J>=O && I>=O)res = max(res,O);
       if(in[i]=='J'){
      i --; continue;
    }

  }
  cout<<res<<endl;

}

Measured memory_bytes: 2052