akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.nextLine());
    int R = 0;
    int B = 0;
    String s = sc.nextLine();
    
    for (int i = 0; i < N;i++){
        if("R".equals(s.substring(i,i+1))){
            R++;
        } else {
            B++;
        }
    }

    if(R>B){
        System.out.println("Yes");
    } else {
        System.out.println("No");
    }
  }

}


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

ll MOD = 1e9 + 7;
// ll MOD = 998244353;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}

constexpr ll gcd(ll a, ll b) {
  ll dummy1 = 0;
  ll dummy2 = 0;
  return eGCD(a, b, dummy1, dummy2);
}

struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};

class Comb {
  int nMax;
  vector<Fp> vFact;
  vector<Fp> vInvFact;
public:
  Comb(int nm) : nMax(nm), vFact(nm+1), vInvFact(nm+1) {
    vFact.at(0) = 1;
    for (int i = 1; i <= nMax; i++) vFact.at(i) = i * vFact.at(i-1);
    vInvFact.at(nMax) = vFact.at(nMax).inv();
    for (int i = nMax; i >= 1; i--) vInvFact.at(i-1) = i * vInvFact.at(i);
  }
  Fp fact(int n) { return vFact.at(n); }
  Fp comb(int n, int r) {
    return vFact.at(n) * vInvFact.at(r) * vInvFact.at(n-r);
  }
  // The number of permutation extracting r from n.
  Fp perm(int n, int r) {
    return vFact.at(n) * vInvFact.at(n-r);
  }
};

/* 
   Power function    power(a, b) == a^b
   Speed is O(log b).
   The same source code can be used for integers by replacing
   Fp with int etc.  Unfortunately, replacing Fp with auto does not
   make the function generic for int and Fp.
 */
Fp power(Fp a, int b) {
  Fp twoPow = a;
  Fp rv = 1;
  while (b > 0) {
    if (b & 1) rv *= twoPow;
    twoPow *= twoPow;
    b >>= 1;
  }
  return rv;
}

int solve() {
  int X, Y; cin >> X >> Y;
  if ((X + Y) % 3 != 0) return 0;
  int x = (2 * X - Y) / 3;
  int y = (-X + 2 * Y) / 3;
  if (x < 0 || y < 0) return 0;
  Comb cmb(x+y);
  return (int)(cmb.comb(x+y, x));
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  cout << solve() << endl;

  return 0;
}



Measured memory_bytes: 10624
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        final int H = sc.nextInt();
        final int W = sc.nextInt();

        final String[] c = new String[H];

        for (int i = 0; i < H; i++) {
            c[i] = sc.next();
        }

        for (int i = 0; i < H; i++) {
            System.out.println(c[i]);
            System.out.println(c[i]);
        }
    }
}


Measured memory_bytes: 24468
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n), b(n), c(n-1);
    int tmp;
    rep(i, n) {
        cin >> tmp;
        tmp--;
        a[i] = tmp;
    }
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = b[a[0]];
    srep(i, n, 1) {
        ans += b[a[i]];
        if (a[i] - a[i-1] == 1) ans += c[a[i-1]];
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  if((int)s.size()==2) cout << s << endl;
  else{
    reverse(all(s));
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
#define MAX 100010
#define CLEAR 0
#define GRAY 1
#define OLD 2

vector<pair<int,int> > adj[MAX];


void ds(int n,int from){

  priority_queue<pair<int,int> >pq;
  int weight[MAX];
  int state[MAX];
  for(int i=0 ;i<n;i++){
    weight[i] = __INT_MAX__;;
    state[i] = CLEAR;
  }

  weight[from] = 0;
  state[from] = GRAY;
  pq.push(make_pair(0,from));

  while(!pq.empty()){
    pair<int,int> first = pq.top();
    pq.pop();

    int u = first.second;
    state[u] = OLD;
    if(weight[u]<first.first*(-1)) continue;

    for(int i=0; i<adj[u].size(); i++){
      int v = adj[u][i].first;
      if(state[v] == OLD)continue;
      if(weight[v] > weight[u] + adj[u][i].second){
	weight[v] = weight[u] + adj[u][i].second;
	pq.push(make_pair(weight[v] * -1, v));
	state[v] = GRAY;
      }
    }
  }

  for(int i=0; i<n; i++){
    if(weight[i] ==  __INT_MAX__){cout << "INF" << endl;}
    else{cout << weight[i] << endl;}
  }
}

int main(){
    int V,E,r;
    int s,t,d;
    cin >>V>>E>>r;
    for(int i=0; i<E;i++){
      cin >> s >> t >> d;
      adj[s].push_back(make_pair(t,d));
    }
    ds(V,r);
}


Measured memory_bytes: 13336
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);++i)
#define pb(x) push_back(x)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
const int M = 1200000;
const int inf = 0x3f3f3f3f;
int n,m,k;
int main() {
	int a[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<a[k-1]<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #define int long long
    int X,Y,B,C,D,N,M;
    string S,T;
    cin >> N >> M >> X;
    vector<vector<int>> A(N,vector<int>(M+1));
    for(int j=0;j<N;j++){
        for(int k=0;k<M+1;k++){
            cin >> A[j][k];
        }
    }
    int rs = 100000000;

    int b = 1;
    int mask,c,value;
    int pat = pow(2,N);
    for(int i=1;i<pat;i++){
        mask = i;
        value = 0;
        vector<int>skill(M,0);
        for(int j=0;j<N;j++){
            c = mask & 1;
            value += c*A[j][0];
            for(int k=0;k<M;k++){
                skill[k] += c*A[j][k+1];
            }
            
            mask = mask >> 1;
        }
        //cout << *std::max_element(skill.begin(), skill.end()) <<endl;
        //cout << *std::min_element(skill.begin(), skill.end()) <<endl;
        if((*std::min_element(skill.begin(), skill.end()) >= X) && (value < rs)){
            rs = value;
        }
    }
    
    
    if(rs == 100000000){
        rs = -1;
    }
    cout << rs << endl;
    
    
}






Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int len_S = S.size();
    int ans = 0;
    if (len_S % 2 == 0){
        int l = len_S / 2;
        rep(i,l){
            if (S[i] != S[len_S - 1 - i]){
                ans++;
            }
        }
    }
    else{
        int l = (len_S - 1) / 2;
        rep(i,l){
            if (S[i] != S[len_S - 1 - i]){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
s = int(input())
a = []
 
for i in range(1000000):
    if s in a:
        break
    elif s%2 == 0:
        a.append(s)
        s = int(s/2)
    else:
        a.append(s)
        s = s*3+1 
print(len(a)+1)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i, a, b, c, d;
  
  scanf("%d %d", &a, &b);
  
    for( i = 0; i < 10000; i++ ){
        c = i * 0.08;
        d = i * 0.10;
        if( a == c && b == d ){
            printf("%d\n", i);
            
            return 0;
        }
  }
  
  printf("-1\n");
  return 0;
}

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

int main()
{
    ll N, K, Q;
    cin >> N >> K >> Q;
    // vector<ll> A(N);
    // rep(i, N) cin >> A[i];
    vector<ll> cnt(N + 1, 0);
    ll idx;
    rep(i, Q)
    {
        cin >> idx;
        cnt[idx]++;
    }

    rep(i, N)
    {
        if (0 < cnt[i + 1] - Q + K)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1408
// AOJ 1173

#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(void)
{
	while (1){
		string str;
		getline(cin, str);
		if (str == "."){
			break;
		}
		
		stack <char> st;
		bool flag = true;
		for (int i = 0; i < str.length(); i++){
			if (str[i] == '(' || str[i] == '['){
				st.push(str[i]);
			}
			if (str[i] == ')'){
				if (st.size() == 0 || st.top() == '['){
					flag = false;
				}
				else if (st.top() == '('){
					st.pop();
				}
			}
			if (str[i] == ']'){
				if (st.size() == 0 || st.top() == '('){
					flag = false;
				}
				else if (st.top() == '['){
					st.pop();
				}
			}
		}
		if (st.size() == 0 && flag){
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
using namespace std;

pair<int, int> team[1000000];
//team[i].firstはかかった時間[s]
//team[i].secondはチーム番号

int main()
{
	int n;
	int m, s;
	while (cin >> n)
	{
		if (n == 0)
		{
			return 0;
		}

		for (int i = 0; i < n; i++)
		{
			team[i].first = 0;
			cin >> team[i].second;
			for (int j = 0; j < 4; j++)
			{
				cin >> m >> s;
				team[i].first += m * 60 + s;
			}
		}

		int first = 0, worst = 0;
		int second = 0, booby = 0;

		for (int i = 0; i < n; i++)
		{
			if (team[first].first > team[i].first)
			{
				second = first;
				first = i;
			}
			else if (team[second].first > team[i].first)
			{
				second = i;
			}

			if (team[worst].first < team[i].first)
			{
				booby = worst;
				worst = i;
			}
			else if (team[booby].first < team[i].first)
			{
				booby = i;
			}

			if (i == 1)
			{
				second = worst;
				booby = first;
			}
		}
		cout << team[first].second << endl;
		cout << team[second].second << endl;
		cout << team[booby].second << endl;
	}
}

Measured memory_bytes: 8972
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,ans,a[220005],b[220005],dp[4405][4405],fac[8805],inv[8805];
int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)r=1ll*r*a%mod;return r;}
int C(int a,int b){return a<b||a<0||b<0?0:1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;}
int main()
{
	for(int i=fac[0]=1;i<=8800;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[8800]=pw(fac[8800],mod-2);
	for(int i=8799;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%d%d",&a[i],&b[i]);dp[2200-a[i]][2200-b[i]]++;}
	for(int i=1;i<=4400;i++)for(int j=1;j<=4400;j++)(dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod)%=mod;
	for(int i=1;i<=n;i++)(ans+=dp[2200+a[i]][2200+b[i]])%=mod;
	for(int i=1;i<=n;i++)(ans+=mod-C(2*a[i]+2*b[i],a[i]*2))%=mod;
	printf("%d\n",1ll*ans*pw(2,mod-2)%mod);
	return 0;
} 

Measured memory_bytes: 77568
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans;
    ans = d[n / 2] - d[n / 2 - 1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[101][2];
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1];
    bool ans = false;
    if(n<3)
    {
        cout<<"No\n";
        return 0;
    }
    for(int i=0;i<=n-3;i++)
    {
        if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1])
        {
            ans = true;
            break;
        }
    }
    if(ans)
    cout<<"Yes\n";
    else
    {
        cout<<"No\n";
    }
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i=0;i<n;++i)
#define int long long
namespace mp=boost::multiprecision;
using namespace std;
typedef mp::cpp_int bint;
typedef pair<int,int> P;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
struct edge{
    int to,cost;
};
class dijkstra{
    int V;
    int d[100002];
    priority_queue<P,vector<P>,greater<P>>que;
    void update(int s,vector<edge> G[]){
        fill(d,d+V+1,100000000000ll);
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            rep(i,G[v].size()){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
public:
    dijkstra(int v,int s,vector<edge> G[]){
        V=v;
        update(s,G);
    }
    int find(int e){
        return d[e];
;    }
};
int dp[111][4][4][4];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string ans,a,b,c;
    cin>>a>>b>>c;
    ans=a[0];
    ans+=b[0];
    ans+=c[0];
    string ans2=ans;
    transform(ans.begin(),ans.end(),ans2.begin(),[](char c){return (char)toupper((int)c);});
    cout<<ans2<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = acos(-1); // cos(pi) = -1 <=> pi = arccos(-1)

/* global variables */
vector<int> dice(6);
/* function */

struct Dice{

  int s[6];

  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0]; s[0]=s[3]; s[3]=s[5]; s[5]=s[2]; s[2]=b;
    }
    if(c=='W'){
      b=s[0]; s[0]=s[2]; s[2]=s[5]; s[5]=s[3]; s[3]=b;
    }
    if(c=='N'){
      b=s[0]; s[0]=s[1]; s[1]=s[5]; s[5]=s[4]; s[4]=b;
    }
    if(c=='S'){
      b=s[0]; s[0]=s[4];s[4]=s[5]; s[5]=s[1]; s[1]=b;
    }
  }

  int top() {
    return s[0];
  }

};

int D[7][4] = {
    {0, 0, 0, 0},
    {2, 3, 5, 4},
    {6, 3, 1, 4},
    {6, 5, 1, 2},
    {6, 2, 1, 5},
    {1, 3, 6, 4},
    {5, 3, 2, 4}};

/* main */

int main(){

    map<int, int> hund_to_six;
    map<int, int> six_to_hund;
    for (int i = 1; i <= 6; i++) {
        int a; cin >> a;
        hund_to_six[a] = i;
        six_to_hund[i] = a;
    }
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int up, front;
        cin >> up >> front;
        int up_six = hund_to_six[up];
        int front_six = hund_to_six[front];
        
        int ind = 0;
        for (; ind < 4; ind++)
            if (D[up_six][ind] == front_six)
                break;

        ind++; ind %= 4;
        int ans = six_to_hund[D[up_six][ind]];
        cout << ans << '\n';
    }
}




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

int main()
{	
	int build[4][3][10] = {{{}}};

	int n,b,f,r,v;
	cin >> n;
	while(n--){
		cin >> b >> f >> r >>v;
		build[b-1][f-1][r-1] +=v;
	}

	for(int i=0;i<4;i++){
		for(int j=0; j<3;j++){
			for(int k=0;k<10;k++){
				cout << " ";
				cout << build[i][j][k];
			}
			cout << endl;
		}
		if(i<3)
			cout << "####################" << endl;
	}



    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>    //Vectorの検索機能に必要

using namespace std;

int main (void){
    int a,b,c;
    vector<int> Divisor;
    cin >> a >> b >> c;
    for (int i = 1; i < c+1; i++) if (c % i == 0) Divisor.push_back(i);
    int Out_Count=0;
    for (int i = 0; i < Divisor.size(); i++)
    {
        if (Divisor[i]>=a && Divisor[i]<=b)
        {
            Out_Count++;
        }
    }
    cout << Out_Count << endl;
}


Measured memory_bytes: 3164
#include <stdio.h>

void E (int dice[6]){
    int t = dice[2];
    dice[2] = dice[0];
    dice[0] = dice[3];
    dice[3] = dice[5];
    dice[5] = t;
}

void S (int dice[6]){
    int t = dice[1];
    dice[1] = dice[0];
    dice[0] = dice[4];
    dice[4] = dice[5];
    dice[5] = t;
}

void R (int dice[6]){
    int t = dice[3];
    dice[3] = dice[1];
    dice[1] = dice[2];
    dice[2] = dice[4];
    dice[4] = t;
}


int main(int argc, const char * argv[]) {
    
    int dice[6];
    int i,j,n,x,y;
    
    for(i=0; i<6; i++){
        scanf("%d",&dice[i]);
    }
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d %d", &x,&y);
        for(j=0; j<4; j++){
            if(dice[1] == y)break;
            S(dice);
        }
        
        if(dice[1] != y){
            for(j=0; j<4; j++){
                if(dice[1] == y)break;
                R(dice);
            }
        }
        for(j=0; j<4; j++){
            if(dice[0] == x)break;
            E(dice);
        }
        printf("%d\n",dice[2]);
    }
    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    map<int, int> m;
    int ans = 0;
    For(i, 0, n){
        int a; cin>>a;
        ans += a;
        m[a]++;
    }
    int q; cin>>q;
    while(q--){
        int b, c; cin>>b>>c;
        int x = m[b];
        ans -= (x*b);
        ans += (x*c);
        m.erase(b);
        m[c]+=x;
        cout<<ans<<"\n";
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 7556
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <utility>
#include <vector>
#include <queue>

constexpr int MAX_H = 1000;
constexpr int MAX_W = 1000;
char S[MAX_H + 10][MAX_W + 10];
int dp[MAX_H * MAX_W];

constexpr std::array<int, 4> dx{0, 1, 0, -1};
constexpr std::array<int, 4> dy{1, 0, -1, 0};

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);

    int H, W; std::cin >> H >> W;
    int Sh, Sw; std::cin >> Sh >> Sw; --Sh; --Sw;
    int Gh, Gw; std::cin >> Gh >> Gw; --Gh; --Gw;
    for(int i = 0; i < H; ++i) std::cin >> S[i];

    std::fill(dp, dp + H * W, 0x3fffffff);
    dp[Sh * W + Sw] = 0;
    std::deque<std::pair<int, int>> dQ;
    dQ.emplace_back(Sh, Sw);
    while(not dQ.empty()){
        const auto [x, y] = dQ.front(); dQ.pop_front();
        const int idx = x * W + y;
        for(int i = 0; i < 4; ++i){
            const int nx = x + dx[i]; if(nx < 0 or nx >= H) continue;
            const int ny = y + dy[i]; if(ny < 0 or ny >= W) continue;
            if(S[nx][ny] == '#') continue;
            const int nidx = nx * W + ny;
            if(dp[nidx] > dp[idx]){ dp[nidx] = dp[idx]; dQ.emplace_front(nx, ny); }
        }
        for(int dx = -2; dx <= 2; ++dx){
            const int nx = x + dx; if(nx < 0 or nx >= H) continue;
            for(int dy = -2; dy <= 2; ++dy){
                const int ny = y + dy; if(ny < 0 or ny >= W) continue;
                if(S[nx][ny] == '#') continue;
                const int nidx = nx * W + ny;
                if(dp[nidx] > dp[idx] + 1){ dp[nidx] = dp[idx] + 1; dQ.emplace_back(nx, ny); }
            }
        }
    }
    const int Gidx = Gh * W + Gw;
    if(dp[Gidx] == 0x3fffffff) std::cout << "-1\n";
    else std::cout << dp[Gidx] << '\n';
    return 0;
}

Measured memory_bytes: 8540
num = []
r, c = gets.split.map(&:to_i)
sum_line = Array.new(c, 0)
r.times do
  num << gets.split.map(&:to_i)
end

num.each_with_index do |m, i|
  puts num[i].join(" ") + " " + num[i].inject(:+).to_s
  sum_line.map!.with_index {|arr, j| arr + num[i][j]}
end
 puts sum_line.join(" ") + " " + sum_line.inject(:+).to_s

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    string N;
    cin >> N;
    int x = N.size();
    
    ll sum = 0;
    REP(i,x){
        int a = N[i] - '0';
        sum += a;
    }
    
    int rem = sum % 9;
    
    if ( rem == 0 ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3676
my ($a, $b, $c, $d) = split(/ /, <STDIN>);
if (abs($a-$c) <= $d){
        print "Yes";
} elsif ( (abs($a-$b) <= $d) and (abs($b-$c) <= $d) ) {
        print "Yes";
} else {
        print "No";
}

Measured memory_bytes: 512
import collections as c
import sys

n = int(input())
a = list(map(int, input().split()))

A = c.Counter(a)

if list(A.keys()) == [0]:
	print("Yes")
	sys.exit()

if len(A.keys()) == 2:
	if 0 not in A.keys():
		print("No")
		sys.exit()
	else:
		if list(A.values())[0]*2 == list(A.values())[1]:
			print("Yes")
			sys.exit()
		else:
			print("No")
			sys.exit()

if len(A.keys()) != 3:
	print("No")
	sys.exit()

x,y,z = A.keys()
if x^y != z:
	print("No")
	sys.exit()

x,y,z = A.values()
if x == y == z:
	print("Yes")
else:
	print("No")

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int mi = INF;
    For(i, 1, 1000003) if (n % i == 0) chmin(mi, i + n / i - 2);
    print(mi);

    return 0;
}


Measured memory_bytes: 256
/* ABC108 */
/* A */
#include <iostream>
#include <string>
using namespace std;

int main(void){

    int K;
    cin >> K;

    /* 偶数と奇数がいくつあるかを算出し、それぞれを積するだけでよい */
    int N;
    if (K%2 == 1){
        N = (K/2) + 1;
    }
    else {
        N = (K/2);
    };
    cout << N * (K-N) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   int n;cin>>n;
   vector<ll> v;
   int ans=200000;
   for(int i=0;i<n;i++){
       ll a;cin>>a;
       auto j=upper_bound(v.begin(),v.end(),a,greater<int>());
       if(j==v.end())v.push_back(a);
       else v[j-v.begin()]=a;
   }
   cout<<v.size();
}


Measured memory_bytes: 1400
n = int(input())
t, a = map(int, input().split())
h = list(map(int , input().split()))

ans = 0
min_t = 10 ** 10
for i in range(n):
    hi = h[i]
    ti = abs(a - (t - hi * 0.006))
    if ti < min_t:
        ans = i
        min_t = ti
print(ans + 1)


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
pair<double,pair<int,int> > edge[1000000];
int UF[10010];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
int x[10010];
int y[10010];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		UF[i]=-1;
		scanf("%d%d",x+i,y+i);
	}
	double ret=0;
	for(int i=0;i<b;i++){
		int p,q;
		scanf("%d%d",&p,&q);
		p--;q--;
		double D=sqrt((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]));
		ret+=D;
		edge[i]=make_pair(-D,make_pair(p,q));
	}
	std::sort(edge,edge+b);
	for(int i=0;i<b;i++){
		if(FIND(edge[i].second.first)!=FIND(edge[i].second.second)){
			ret+=edge[i].first;
			UNION(edge[i].second.first,edge[i].second.second);
		}
	}
	printf("%f\n",ret);
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	vector<ll> v(10);
	rep(i, 10) cin >> v[i];
	sort(all(v));
	reverse(all(v));
	rep(i, 3) cout << v[i] << endl;
}


Measured memory_bytes: 3116
# include <bits/stdc++.h>
# define FILE

using namespace std;

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif

    long long n, a, b;
    cin >> n >> a >> b;
    if( a > b )
    	swap( a, b );

    if( (b-a) % 2 == 0 ){
    	cout << (b-a)/2;
    	return 0;
    }
    cout << min( (b-a)/2+a, (n-a-(n-b+1))/2+n-b+1 );
}	




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	cin>>a>>b>>c;
	cin>>a;
	cout<<(a^n^m)<<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n; cin>>n;
    int t,a; cin>>t>>a;

    vector<pair<double,int>> v(n);
    rep(i,n)
    {
        v[i].second=i;
        cin>>v[i].first;
        v[i].first=(double)t-v[i].first*0.006;
        v[i].first=abs(v[i].first-a);
    }

    sort(all(v));

    cout<<v[0].second+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

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

int main() {

    
    ll a, b;
    cin >> a >> b;
    
    if (a % 2)
    {
        if ((b - a + 1) % 4 == 0)
        {
            cout << (a ^ b ^ 1) << endl;
        }
        else if ((b - a + 1) % 4 == 1)
        {
            cout << a << endl;
        }
        else if ((b - a + 1) % 4 == 2)
        {
            cout << (a ^ b) << endl;
        }
        else
        {
            cout << (1 ^ a) << endl;
        }
    }
    else
    {
        if ((b - a + 1) % 4 == 0)
        {
            cout << 0 << endl;
        }
        else if ((b - a + 1) % 4 == 1)
        {
            cout << b << endl;
        }
        else if ((b - a + 1) % 4 == 2)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << (1 ^ b) << endl;
        }
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long f(int N){
   long long ans=0;
   for(int i=1;i<=sqrt(N);i++){
      for(int j=1;j<=i;j++){
         for(int k=1;k<=j;k++){
            if(i*i+j*j+k*k+i*j+j*k+k*i==N){
               if(i==j&&j==k) ans++;
               else if(i!=j&&j!=k&&k!=i) ans+=6;
               else ans+=3;
            }
         }
      }
   }
   return ans;
}
int main(void){
   int N;
   cin>>N;
   for(int i=1;i<=N;i++){
      cout<<f(i)<<endl;
   }
   return 0;
}


Measured memory_bytes: 3572
n,a,b=map(int,input().split(" "))
def check(x):
    sum=0
    while x>0: 
        sum = sum + x % 10 
        x=int(x/10); 
    return sum

total=0
for i in range(n+1): #1-10 1,2,10
    sum=check(i)
    if sum<=b and sum>=a:
        #print(i)
        total=total+i

print(total)

Measured memory_bytes: 3060
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
h, w = map(int, input().split())
a = [[] for i in range(h)]
for i in range(h):
    a[i] = input().split()
for i in range(w + 2):
    print("#", end="")
print()
for i in range(h):
    print("#", end="")
    print(*a[i], end="")
    print("#")
for i in range(w + 2):
    print("#", end="")
print()

Measured memory_bytes: 5184
X, N = map(int, input().split())
i = list(map(int, input().split()))
if X not in i:
    print(X)
else:
    n = 1
    while n <=N+1:
        if X - n not in i:
            print(X - n)
            break
        else:
            if X+n not in i:
                print(X+n)
                break
        n +=1

Measured memory_bytes: 9192
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n + 1), b(n);
	for (int i = 0; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	ll ans  = min(a[0], b[0]);
	ll prev = b[0] - ans;
	for (int i = 1; i <= n; i++) {
		ans += min(prev, a[i]);
		a[i] -= min(prev, a[i]);
		if (i == n) break;
		ans += min(a[i], b[i]);
		prev = b[i] - min(a[i], b[i]);
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 1792
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread!ulong();
    auto add = new ulong[](N + 1);
    auto xor = new ulong[](N + 1);
    foreach (i; 0 .. N)
    {
        add[i + 1] = add[i] + A[i];
        xor[i + 1] = xor[i] ^ A[i];
    }
    long ans;
    long j;
    foreach (i; 0 .. N)
    {
        while (j + 1 < N && (add[j + 2] - add[i]) == (xor[j + 2] ^ xor[i]))
            j++;
        ans += j - i + 1;
    }
    writeln(ans);
}


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

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

	int q;cin>>q;
	while(q--){
		int b,e,k;cin>>b>>e>>k;
		cout<<count(next(a.begin(),b),next(a.begin(),e),k)<<endl;
	}
  return 0;
}



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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(s[i]!='h'||s[i+1]!='i'){
			cout<<"No"<<endl;
			return 0;;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,h);
    h.pb(0);
    ll ans = 0;
    rep(i,0,n){
        if(h[i]>h[i+1])ans+=h[i]-h[i+1];
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long 
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define pw(x) (1<<(x))
#define inf 1000000005
#define MOD 1000000007 
#define N 100005
#define M 1000003
#define LOG 19
#define KOK 250
#define EPS 0.0000001
using namespace std;

char s[17];
int n;

int main() {

	scanf("%s",s+1);

	n=strlen(s+1);

	int cnt=15-n;

	for(int i=1;i<=n;i++) cnt+=(s[i]=='o');

	if(cnt>=8) printf("YES");
	else printf("NO");

}

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

using namespace std;
int main(){
   int n;
   string s;
   std::cin>>n>>s;
   if(n%2!=0){
       std::cout<<"No";
       return 0;
   }
   else{
       int i;
       for(i=0;i<n/2;i++){
           if(s[i]!=s[i+n/2]){
               std::cout<<"No";
                return 0;
           }
       }
       std::cout<<"Yes";
   }

    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = new string[n];
        for (int i = 0; i < n; i++) a[i] = Console.ReadLine().Trim();
        Array.Sort(a);
        Console.WriteLine(string.Join("",a));
    }
}


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

using namespace std;

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

  int a[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (a[i][j] == x) {
          a[i][j] = -1;
        }
      }
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1) {
      cout << "Yes";
      return 0;
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1) {
      cout << "Yes";
      return 0;
    }
  }
  if (a[0][0] == -1 and a[1][1] == -1 and a[2][2] == -1) {
    cout << "Yes";
    return 0;
  }
  if (a[2][0] == -1 and a[1][1] == -1 and a[0][2] == -1) {
    cout << "Yes";
    return 0;
  }
  cout << "No";

  return 0;
}

Measured memory_bytes: 256
n, l = map(int, input().split())
if l<= 0 and l+n-1>=0:
    print(sum(list(range(l, n+l))))
elif l<0:
    print(sum(list(range(l, n+l)))-(n+l-1))
else: 
    print(sum(list(range(l, n+l)))-l)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int d = 'a' - 'A';
	int n, k; cin >> n >> k;
	string s; cin >> s;
	rep(i, n) {
		if (i == k - 1) {
			cout << (char)(s.at(i) + d);
		}
		else {
			cout << s.at(i);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def GCD(a, b):
    while b:
        a, b = b, a % b
    return a

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n = n // i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return list(set(table))


gcd = GCD(A, B)
divs = prime_decomposition(gcd)
print(1 + len(divs))

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int INF = 1<<29;

int dp[256][16][128];
int stones[256][16][2];
int col[256];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
  
    REP(i, N) {
      cin >> col[i];
      REP(j, col[i]) {
	REP(k, 2) cin >> stones[i][j][k];
      }
    }

    REP(i, N) REP(j, col[i]) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, col[0]) dp[0][j][0] = 0;
    REP(j, col[1]) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, col[i]) {
	int x_now = stones[i][j][0], d_now = stones[i][j][1];
	REP(m, M+1) {
	  if (dp[i][j][m] == INF) continue;
	  REP(k, col[i+1]) {
	    int x_next = stones[i+1][k][0], d_next = stones[i+1][k][1];
	    int safe = (d_now + d_next) * abs(x_now - x_next);
	    dp[i+1][k][m] = min(dp[i+1][k][m], dp[i][j][m] + safe);
	  }
	}
	if (i < N-2) {
	  REP(m, M) {
	    REP(k, col[i+2]) {
	      int x_next = stones[i+2][k][0], d_next = stones[i+2][k][1];
	      int safe = (d_now + d_next) * abs(x_now - x_next);
	      dp[i+2][k][m+1] = min(dp[i+2][k][m+1], dp[i][j][m] + safe);
	    }
	  }
	}
      }
    }

    int ans = INF;
    REP(j, col[N-1]) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, col[N-2]) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2416
import java.util.*;
public class Main{
	public static void main(String args[]){
     Scanner sc=new Scanner(System.in);
     int row=sc.nextInt();
     int col=sc.nextInt();
     int n=sc.nextInt();
     int m=sc.nextInt();
     row=row-n;
     col=col-m;
     System.out.println(row*col); 
    } 
}

Measured memory_bytes: 23124