akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int> Team;
int AC[50][10],WA[50][10];
int main() {
    int T,P,R;
    while(cin>>T>>P>>R,T) {
        memset(AC,0,sizeof(AC));
        memset(WA,0,sizeof(WA));
        for(int i=0;i<R;i++) {
            int tID,pID,time;
            string mes;
            cin>>tID>>pID>>time>>mes;
            tID--;pID--;
            if(mes=="CORRECT") {
                AC[tID][pID]=time;
            }else {
                WA[tID][pID]++;
            }
        }
        vector<Team> v;
        for(int i=0;i<T;i++) {
            int solved=0,penalty=0;
            for(int j=0;j<P;j++) {
                if(AC[i][j]) solved++,penalty+=AC[i][j]+WA[i][j]*1200;
            }
            v.push_back(make_tuple(-solved,penalty,i+1));
        }
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++) {
            printf("%d %d %d\n",get<2>(v[i]),-get<0>(v[i]),get<1>(v[i]));
        }
    }
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  long long int S[n + 1];
  for (int i = 0; i < n; i++) {
    long long int s;
    cin >> s;
    S[i] = s;
  }

  int q;
  cin >> q;
  long long int T[q + 1];
  for (int i = 0; i < q; i++) {
    long long int t;
    cin >> t;
    T[i] = t;
  }

  int total = 0;

  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T[i] == S[j]) {
        total++;
        break;
      }
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll n,m;
Vi a;
vector<PLL> v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    a.resize(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll b,c;
    rep(i,m){
        cin>>b>>c;
        v.pb(mp(b,c));
    }
    auto comp_pq = [](pair<ll,ll> x,pair<ll,ll> y){return x.second > y.second;};
    sort(v.begin(),v.end(),comp_pq);
    ll r=0,l=0;
    rep(i,v.size()){
        if(a[l]>v[i].second)break;
        while((a[r]<v[i].second ) && ((r-l) < v[i].first)){
            a[r]=v[i].second;
            r++;
        }
        l = r;
    
    }
    ll ans = 0;
    rep(i,a.size()){
        ans += a[i];
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int a, b;
    cin >> a >> b;
    if (a <= 5)
    {
        cout << 0 << endl;
    }
    else if (a <= 12)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/***
 ** " Experience is the name everyone gives to their mistakes. "
 ** 	-- Oscar Wilde
***/

/**
  *  Author: dhruv_gheewala
  *  Date:   14.03.2020
  *  Time:   02:09:30
**/

#define DEBUG
#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;

    #define p(str) 42
    #define o(str) 108
    #define fundri 137
    #define d(...) 1729
#endif

typedef unsigned int ui;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define test int __T__=1;if(testcases)cin>>__T__;while(__T__--)
#define nl cout<<'\n'
#define pb push_back
#define pop pop_back
#define all(s) s.begin(),s.end()
#define ff first
#define ss second
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;~i;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>l;i--)

ll seed;auto random_address=[]{char *p=new char;delete p;return (uint64_t)p;};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()*(random_address()|1));
inline int rnd(int l=0,int r=INT_MAX){return uniform_int_distribution<int>(l,r)(rng);}

template<typename T,typename U>inline bool exist(T cont,U val){return cont.find(val)!=cont.end();}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename TAIL>inline void inp(TAIL& T){cin>>T;}
template<typename HEAD,typename... TAIL>inline void inp(HEAD &H,TAIL&... T){cin>>H;inp(T...);}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}
template<typename T,typename U>inline istream& operator >>(istream& in,pair<T,U> &a){in>>a.ff>>a.ss;return in;}
template<typename T>inline istream& operator >>(istream& in,vector<T> &a){for(auto &x : a)in>>x;return in;}

int main()
{
    std::chrono::time_point<std::chrono::high_resolution_clock> start_time, end_time;
    start_time = std::chrono::high_resolution_clock::now();

    #ifdef DHRUV_GHEEWALA
        freopen("INPUT.txt","r",stdin);
        freopen("OUTPUT.txt","w",stdout);
        freopen("DEBUG.txt","w",stderr);
    #endif
    
    fast;
    int n,k;
    test{
    
    cin>>n>>k;
    vi h(n);
    cin>>h;

    vi dp(n+1,INT_MAX);
    dp[0]=0;
    rep(i,n)
    {
        rep(j,k)
        {
            if(j+1+i>=n)break;
            dp[i+j+1]=min(dp[i]+abs(h[i]-h[j+i+1]),dp[i+j+1]);
        }
        d(dp);
    }
    d(dp);
    cout<<dp[n-1],nl;
    fundri;
    
    }

    end_time = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
    o("\n\n======\n");
    o("Elapsed Time: "<<elapsed_time<<" ms\n");

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  string s,t;
  cin>>s>>t;
  cout<<t<<s<<endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int dp[1 << 20];
int cnt[20][101010];
int nui[101010];
int sum[20];
int main() {
	cin >> n >> m;
	REP(i, n) {
		cin >> nui[i];
		nui[i]--;
		for (int j = 0; j < m; j++)cnt[j][i + 1] = cnt[j][i] + (j == nui[i] ? 1 : 0);
	}
	REP(i, m)sum[i] = cnt[i][n];
	REP(i, (1 << m))dp[i] = HINF;
	dp[0] = 0;
	REP(i, (1 << m)) {
		int pos = 0;
		REP(j, m)if (i&(1 << j))pos += sum[j];
		REP(j, m) {
			if (i&(1 << j))continue;
			dp[i | (1 << j)] = min(dp[i | (1 << j)], dp[i] + sum[j] - cnt[j][pos + sum[j]] + cnt[j][pos]);
		}
	}
	cout << dp[(1 << m) - 1] << endl;
}


Measured memory_bytes: 15456
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
bool a[30],b[30];
int main() {
	int N,ans=0;
	std::string S;
	std::cin>>N>>S;
	for(int i=1;i<N;i++){
		memset(a,false,sizeof(a));
		memset(b,false,sizeof(b));
		std::string t=S.substr(0,i),r=S.substr(i,N-i);
		for(char c:t)a[c-'a']=true;
		for(char c:r)b[c-'a']=true;
		int cnt=0;
		for(int j=0;j<26;j++){
			if(a[j]&&b[j])cnt++;
		}
		ans=std::max(ans,cnt);
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var count = Console.ReadLine().Count(x => x == '1');
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#define inf 10000000000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;
// lower_bound 
 // it returns pos of the elmnt which is not less then the query elmnt
void permute(vector<int>& v,vector<float>& av, map<int, pair<int, int> >& mp,
    int l, int r, int n){
    double res = 0;
    if(l == r){
        for(int i = 0; i < n -1; i++){
            int x1 = mp[v[i]].first, y1 = mp[v[i]].second;
            int x2 = mp[v[i+1]].first, y2 = mp[v[i+1]].second;
            res += sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2) * 1.0);
        }
        av.push_back(res);
    }
    for(int i = l; i<=r; i++){
        swap(v[l],v[i]);// generate the permutation
        permute(v, av, mp, l+1, r, n);
        swap(v[l],v[i]); // backtrack to its original form
    }
}
int main(){
    int n; cin >> n;

    vector<int> v;
    vector<float> av;

    for(int i = 1; i <=n ;i++)
        v.pb(i);

    map<int, pair<int, int>> mp;
    for(int i = 0; i<n; i++){
        int x,y; cin >> x >> y;
        mp[i+1] = {x,y};
    }
    permute(v, av, mp, 0, v.size()-1, n);

    double sum = 0;

    for(int i = 0; i< av.size(); i++)
        sum += av[i];
    cout.precision(10);
    cout << fixed << sum / av.size() << endl;
}




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

// コンテスト中のみ
#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	vector<int>a(n); rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] != a[j] && a[j] != a[k]&&a[i]!=a[k]&& a[k] < a[i] + a[j]) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

ll gcd(ll a, ll b){
  if(b > a){
    ll c = a;
    a = b;
    b = c;
  }
  while(b != 0){
    ll c = b;
    b = a%b;
    a = c;
  }
  return a;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n = 0;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      for(int k = 1; k <= n; k++){
        ans += gcd(gcd(i, j), k);
      }
    }
  }
  cout << ans << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W<r+x || H<r+y || 0>y-r || 0>x-r){
	cout<<"No"<<endl;
	}
	else{
	cout<<"Yes"<<endl;
	}
return 0;
}


Measured memory_bytes: 3080
import string


S = input()

N = len(S)
if N == 1:
    print(0)
    exit()

se = set(list(S))
if len(se) == 1:
    print(0)
    exit()

ans = 1e9
for target in string.ascii_lowercase:
    new_S = list(S)
    tmp = 0
    while True:
        if len(set(new_S)) == 1:
            ans = min(ans, tmp)
            break
        tmp_S = []
        for i in range(N - tmp - 1):
            if new_S[i] == target or new_S[i + 1] == target:
                tmp_S.append(target)
            else:
                tmp_S.append(new_S[i + 1])
        new_S = list(tmp_S)
        tmp += 1
print(ans)


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

int calc_mille( int y, int m, int d )
{
  int day = 0;
  for(int i=1; i<y; i++) {
    if( i % 3 == 0 ) day += 200;
    else day += 195;
  }
  if( y % 3 == 0 ) {
    day += (m-1) * 20 + d;
  } else {
    for(int i=1; i<m; i++) {
      if( i % 2 ) day += 20;
      else day += 19;
    }
    day += d;
  }

  return day;
}

int main()
{
  int mille = calc_mille( 1000, 1, 1 );
  int n;
  cin >> n;
  while( n-- ) {
    int Y, M, D;
    cin >> Y >> M >> D;
    cout << mille - calc_mille( Y, M, D ) << endl;
  }
}

Measured memory_bytes: 3080
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int A = Integer.parseInt(tokens[1]);
		int B = Integer.parseInt(tokens[2]);

		int max = Math.min(A, B);
		int min = Math.max(A + B - N, 0);
		System.out.println(max + " " + min);

		in.close();
	}

}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int W = 1e6;
signed main() {
	vector<int>c(1, 0), odd(1, 0);
	for (int i = 1; i*(i + 1)*(i + 2) / 6 < W; i++) {
		c.push_back(i*(i + 1)*(i + 2) / 6);
		if (c[i] & 1)odd.push_back(c[i]);
	}
	vector<int>v1(W, INF), v2(W, INF); v1[0] = v2[0] = 0;
	rep(i, 1, c.size()) {
		rep(j, c[i], W) {
			v1[j] = min(v1[j], v1[j - c[i]] + 1);
		}
	}
	rep(i, 1, odd.size()) {
		rep(j, odd[i], W) {
			v2[j] = min(v2[j], v2[j - odd[i]] + 1);
		}
	}

	int n;
	while (cin >> n, n) {
		cout << v1[n] << " " << v2[n] << endl;
	}
	return 0;
}

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

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

    map<string,set<int>> den;
    rep(i,n){
        string c;
        int d;
        cin >>c >>d;
        den[c].insert(d);
    }

    int m;
    cin >>m;
    vector<string> o(m);
    rep(i,m) cin >>o[i];

    bool ok = true;
    int x = 0;
    rep(i,m){
        if(!den.count(o[i])){
            ok = false;
            break;
        }

        auto itr = den[o[i]].upper_bound(x);
        if(itr == den[o[i]].end()){
            ok = false;
            break;
        }

        x = *itr;
    }

    cout << (ok?"Yes":"No") << endl;
    return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────

int main() {
	int n, k;
	cin >> n >> k;
	vi a(3);
	rep(i, 3) cin >> a[i];
	vi ctoi(256);
	ctoi['r'] = 2;
	ctoi['s'] = 0;
	ctoi['p'] = 1;

	string s;
	cin >> s;

	int ans = 0;
	rep(i, k) {
		vi x;
		for (int j = i; j < n; j += k) {
			x.push_back(ctoi[s[j]]);
		}

		int pre = -1;
		vi dp(2);
		for (int nx : x) {
			vi p(2);
			swap(dp, p);

			dp[0] = max(p[0], p[1]);

			if (pre == nx) {
				dp[1] = p[0] + a[nx];
			}
			else {
				dp[1] = p[1] + a[nx];
			}
			pre = nx;
		}
		ans += max(dp[0], dp[1]);
	}
	cout << ans << endl;
}

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

int main(){
	string s;
	cin >> s;
	
	int a = s[0] -'0';
	int b = s[1] - '0';
	int c = s[2] - '0';
	int d = s[3] -'0';
	
	int num = 10*a+b;
	int num2 = 10*c+d;
	
	if(1<= num && num <= 12){
		if(1<= num2 && num2 <= 12){
			cout << "AMBIGUOUS" << endl;
		}else{
			cout << "MMYY" << endl;
		}
	}else if(1<= num2 && num2 <= 12){
		cout << "YYMM" << endl;
	}else{
		cout << "NA" << endl;
	}
	
    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A, B;

void solve(int s, int t, int mask, vector<int> &ret)
{
	if (__builtin_popcount(mask) == 1) {
		ret.push_back(s);
		ret.push_back(t);
		return;
	}
	int d = (s ^ t) ;
	vector<int> ones, zeros;
	for (int i = 0; i < N; ++i) if ((mask >> i) & 1) {
		if ((d >> i) & 1) {
			ones.push_back(i);
		} else {
			zeros.push_back(i);
		}
	}
	//printf("%d %d %d %d %d\n", s, t, mask, ones.size(), zeros.size());
	if (ones.size() >= 2) {
		solve(s, t ^ (1 << ones[0]) ^ (1 << ones[1]), mask ^ (1 << ones[0]), ret);
		solve(t ^ (1 << ones[1]), t, mask ^ (1 << ones[0]), ret);
	} else {
		solve(s, s ^ (1 << zeros[0]), mask ^ (1 << ones[0]), ret);
		solve(s ^ (1 << zeros[0]) ^ (1 << ones[0]), t, mask ^ (1 << ones[0]), ret);
	}
}

int main()
{
	scanf("%d%d%d", &N, &A, &B);

	if ((__builtin_popcount(A) % 2) == (__builtin_popcount(B) % 2)) {
		puts("NO");
		return 0;
	}

	vector<int> ans;
	solve(A, B, (1 << N) - 1, ans);
	puts("YES");
	for (int i = 0; i < ans.size(); ++i) {
		printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
	}
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int gcd(int a, int b) {
    int temp;
    
    while (1) {
      if (b < a) {
        temp = a;
        a = b;
        b = temp;
      }
  
      b = b % a;
  
      if (b == 0) {
        break;
      }
    }
  
    return a;
  }

int main() {
  int i, j;
  int a, b, c;
  int gcdnum;

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

  gcdnum = gcd(a, b);

  if (c % gcdnum == 0) {
    printf("YES");
  }
  else {
    printf("NO");
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	char num[1000];
	
	while (gets(num) != NULL){
		if (num[0] == '0'){
			break;
		}
		int score = 0;
		int f = 0;
		int i = 0;
		
		int len = strlen(num);
		
		while (i < len){
			if (num[i] == '1' && (num[i + 1] >= '0' && num[i + 1] <= '3')){
				score += 10;
				i += 3;
			}
			else if (num[i] == '1'){
				score++;
				f = 1;
				i += 2;
			}
			else if ('2' <= num[i] && num[i] <= '9'){
				score += (num[i] - '0');
				i += 2;
			}
		}
		if (score > 21){
			score = 0;
		}
		else if (f == 1 && score + 10 <= 21){
			score += 10;
		}
		cout << score << endl;
	}
	return (0);
}

Measured memory_bytes: 1124
#include<cstdio>
#include<vector>
#include<deque>
#include<algorithm>
using namespace std;
void solve(int ama,int prev,deque<int> res){
    if(ama==0){
        for(int i=0;i<res.size()-1;i++){
            printf("%d ",res[i]);
        }
        printf("%d\n",res.back());
    }
    int mn=min(ama,prev);
    for(int i=mn;i>=1;i--){
        res.push_back(i);
        solve(ama-i,i,res);
        res.pop_back();
    }
}
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        solve(n,n+1,deque<int>());
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

ll a, b, n;

ll func1(ll x){
    return (a * x / b);
}

ll func2(ll x){
    return a * (x / b);
}


int main(){

    cin >> a >> b >> n;
    /*
    for(int i = 0; i <= 100; i++){
        cout << func1(i) - func2(i) << " ";
    }
    cout << endl;
    */
   if(n >= b - 1){
       cout << func1(b - 1) - func2(b - 1) << endl;
   }
   else{
       cout << func1(n) - func2(n) << endl;
   }

    return 0;
}

Measured memory_bytes: 3632
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include<random>
#include<ctime>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const int Max_n = 1e6 + 10;
using namespace std;
int main(){
    int a,b,c;
    cin >> a >>b>>c;
    int cnt = 0;
    if(a == b)cnt ++;
    if(a == c) cnt ++;
    if(b == c) cnt ++;
    if(cnt == 1) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
import numpy as np

def surprise(x):
    #x!を計算
    res = 1
    for i in range(1, x +1):
        res = res * i
    return res

def zyun(x, N):
    num = 0
    for i in range(N):
        x = np.where(x >x[0], x -1, x)
        num += (x[0] -1) * surprise(x.size -1) #最初の数字*{(xの長さ-1)!}
        x = x[1:] #最初の数字を削除
    return num   

N = int(input())
P = map(int, input().split())
Q = map(int, input().split())

x_1 = np.empty(0, dtype = np.int32)
x_2 = np.empty(0, dtype = np.int32)

for i in P:
    x_1 = np.append(x_1, i)
for i in Q:
    x_2 = np.append(x_2, i)

print(np.abs(zyun(x_1, N) -zyun(x_2, N)))

Measured memory_bytes: 13420
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

int bubbleSort(int *A,int N){
  int count=0;
  bool flag=1;
  while(flag){
    flag = 0;
    for(int j=N-1;j>0;j--){
      //printf("%d %d\n",A[j],A[j-1]);
      if(A[j] < A[j-1]) {
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag=1;
        count++;
       }
      }
  }
  return count;
}

int main(){
  int n,*A;

  scanf("%d\n",&n);

  A=(int *)malloc(n*sizeof(int));

  for(int i=0;i<n;i++){
    scanf("%d ",&A[i]);
  }
  int count = bubbleSort(A,n);
  for(int i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)
      putchar(' ');
  }
  printf("\n%d\n",count);
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string x, y;
    cin >> x >> y;

    auto check1 = [&](string a){
        return regex_search(a, regex("^1$|^3$|^5$|^7$|^8$|^10$|^12$"));
    };
    auto check2 = [&](string a){
        return regex_search(a, regex("^4$|^6$|^9$|^11$"));
    };

    if(check1(x)&&check1(y)){
        cout << "Yes" << endl;
        return 0;
    } else if(check2(x) && check2(y)){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3736
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <bitset>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	while (true) {
		double x, h; cin >> x >> h;
		if (x == 0 && h == 0)break;
		double h2 = sqrt((x / 2)*(x / 2) + h * h);
		double ans = x * x + x * h2 * 2;
		printf("%.20f\n", ans);
	}
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

void solve() {
    ll d, t, s;
    cin >> d >> t >> s;
    (t*s>=d) ? puts("Yes"):puts("No");
}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    double x[n], y[n];
    rep(i, n){
        cin >> x[i] >> y[i];
    }

    double s = 0;
    rep(i, n){
        rep(j, n){
            if(i<j){
                s += sqrt(pow(x[i]-x[j], 2) + pow(y[i]-y[j], 2));
            }
        }
    }
    // cout << s*2/n << endl;
    printf("%.10lf\n", s*2/n);
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
EDGE=[list(map(int,input().split())) for i in range(N-1)]

EDGELIST=[[] for i in range(N+1)]

for x,y in EDGE:
    EDGELIST[x].append(y)
    EDGELIST[y].append(x)

from collections import deque
H=[-1]*(N+1)
H[1]=0

QUE=deque([1])

while QUE:
    x=QUE.pop()
    for to in EDGELIST[x]:
        if H[to]==-1:
            H[to]=H[x]+1
            QUE.append(to)


QUE=deque([H.index(max(H))])

H=[-1]*(N+1)
H[QUE[0]]=0

while QUE:
    x=QUE.pop()
    for to in EDGELIST[x]:
        if H[to]==-1:
            H[to]=H[x]+1
            QUE.append(to)

HEIGHT=max(H)

if HEIGHT%3!=1:
    print("First")
else:
    print("Second")


Measured memory_bytes: 113320
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){ cin >> a[i]; }

    mint sum = 0;
    rep(i, n) sum+=a[i];

    mint ans = 0;
    rep(i, n){
        sum-=a[i];
        ans += sum*a[i];        
    }

    cout << ans.x << endl;
}



Measured memory_bytes: 4784
N, M = map(int,input().split())
L = [None]*M
R = [None]*M
for i in range(M):
    L[i], R[i] = map(int,input().split())
l,r = L[0],R[0]
for i in range(1,M):
    if l < L[i]:
        l = L[i]
    if r > R[i]:
        r = R[i]
print(max(r-l+1,0))

Measured memory_bytes: 10868
import sys
N=int(sys.stdin.readline())
xs = []
s = 0
for x in map(int,sys.stdin.readline().split()):
    s += x
    xs.append(s)
s = 0
for i, x in enumerate(map(int,sys.stdin.readline().split())):
    s = max(s, xs[i]) + x
print(s)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define N 1000005
#define BB(V) V[V.size()-2]
#define ex(V) return printf(V),0
using namespace std;
int s[2005][2005];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		int t1,t2;
		char t[2];
		scanf("%d%d%s",&t1,&t2,t);
		if(t[0]=='B')t1+=k;
		s[t1%(2*k)+1][t2%(2*k)+1]++;
	}
	for(int i=1;i<=2*k;i++){
		for(int j=1;j<=2*k;j++){
			s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];
		}
	}
	int mx=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			int t=s[2*k][2*k]-s[i+k][2*k]-s[2*k][j+k]+s[i+k][j+k]
			+s[i+k][j+k]-s[i][j+k]-s[i+k][j]+s[i][j]
			+s[i][j]-s[0][j]-s[i][0]+s[0][0]
			+s[2*k][j]-s[i+k][j]-s[2*k][0]+s[i+k][0]
			+s[i][2*k]-s[i][j+k]-s[0][2*k]+s[0][j+k];
			mx=max(mx,max(t,n-t));
		}
	}
	printf("%d",mx);
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;




using namespace std;

int main()
{



  IOS;

  string s;
  cin >> s;

  reverse(s.begin(), s.end());


  if (s[0] == '3')
  {
    cout << "bon" << endl;
  }

  else if (s[0] == '0' || s[0] == '1' || s[0] == '6' || s[0] == '8')
  {
    cout << "pon" << endl;
  }

  else
  {
    cout << "hon" << endl;
  }



}

Measured memory_bytes: 3652
using System;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var r = Array.ConvertAll(new int[n], _ => int.Parse(Console.ReadLine()));

		int M = 1 << 31, m = r[0];
		for (int i = 1; i < n; i++)
		{
			M = Math.Max(M, r[i] - m);
			m = Math.Min(m, r[i]);
		}
		Console.WriteLine(M);
	}
}



Measured memory_bytes: 21120
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with(false); cin.tie(0);cout.tie(0);
#define PI = acos(-1)
using namespace std ;
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
int main(){
	 ll n ; cin >> n ;
	 vector<ll> v(n);
	 ll x = 0 ;
	 for(int i = 0 ; i < n ; i++){
	 	    cin >> v[i];
	 	    x ^= v[i];
	 }
	 for(int i = 0 ; i < n ; i++){
	 	  cout << (x^v[i]) << " " ;
	 }
	 cout << endl;
}


Measured memory_bytes: 4748
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	REP(i, n - 1)if (s[i] == s[i + 1]) {
		cout << i + 1 << " " << i + 2 << endl;
		return 0;
	}
	REP(i, n - 2)if (s[i] == s[i + 2]) {
		cout << i + 1 << " " << i + 3 << endl;
		return 0;
	}
	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
#!/usr/local/gnu/bin/bash
read a b c d
ac=`echo $((c-a)) | tr -d -`
if((ac<=d))
then
    echo Yes
else
    ab=`echo $((b-a)) | tr -d -`
    bc=`echo $((c-b)) | tr -d -`
    if((ab<=d&&bc<=d))
    then
        echo Yes
    else
        echo No
    fi
fi


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

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

using namespace std;

#define MAX 100010

int par[MAX];

int find(int x) {
  if( par[x] == x ) return x;
  return par[x] = find(par[x]);
}

void unit(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

int N,M;
deque<int> deq[MAX];

int main(){
  cin >> N >> M;
  rep(i,N) par[i] = i;
  rep(i,N) {
    int k,l;
    cin >> k;
    rep(j,k) {
      cin >> l;
      deq[l].push_back(i);
    }
  }

  rep(i,M+1) {
    REP(j,1,(int)deq[i].size()) {
      unit(deq[i][j-1],deq[i][j]);
    }
  }

  set<int> S;
  rep(i,N) {
    S.insert(find(i));
    if( (int)S.size() >= 2 ) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}


Measured memory_bytes: 69760
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[101000];int a[101000];int n;long long L;
int son[101000][2];long long ans=0;int cnt=1;
long long lowbit(long long x){return x&(-x);}
void build(int x,int k,int len)
{
	if(k>len)return;
	if(!son[x][a[k]])son[x][a[k]]=++cnt;
	build(son[x][a[k]],k+1,len);
}
void dfs(int x,int d)
{
	if(!son[x][0]&&!son[x][1])return;
	if(!son[x][0]&&son[x][1])ans^=lowbit(L-d),dfs(son[x][1],d+1);
	if(son[x][0]&&!son[x][1])ans^=lowbit(L-d),dfs(son[x][0],d+1);
	if(son[x][0]&&son[x][1])dfs(son[x][0],d+1),dfs(son[x][1],d+1);
}
int main()
{
	scanf("%d%lld",&n,&L);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s);int len=strlen(s);
		for(int j=1;j<=len;j++)a[j]=s[j-1]-'0';
		build(1,1,len);
	}
	dfs(1,0);
	if(ans)puts("Alice");else puts("Bob");
	return 0;
 } //考虑两个儿子一个有，一个没有的节点，没有的那棵树高为x，
 //则sg(0)=0 sg(1)=1 sg(2)=2 sg(3)=1 sg(4)=4 sg(5)=1... sg(x)=lowbit(x)
 //所有空子树的sg值异或起来就好了 

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, m = 0;
  cin >> k >> n;
  v1i v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i, n-1) m = max(m, v[i+1] - v[i]);
  cout << min(k - m, v[n-1] - v[0]) << endl;
  return 0;
}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
	// init
    int n, a, b;
    int sum_sum = 0;

    // input
    cin >> n >> a >> b;

    // check
    for (int i = 0; i < n; ++i){
        int sum = findSumOfDigits(i+1);
        if (a <= sum && sum <= b){
            sum_sum += i+1;
        }
    }

    // output
    cout << sum_sum << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

const ll MOD = 1e9 + 7;

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	ll n; cin >> n;
	ll ans = 0;
	vector<ll> a; a.resize(n);
	for (int i = 0; i < n; i++) cin >>a[i];
	vector<ll> prefix; prefix.resize(n); prefix[0] = a[0]%MOD;
	for (int i = 1; i < n; i++) {
		prefix[i] = (a[i] + prefix[i - 1])%MOD;
	}

	for (int i = 0; i < n-1; i++) {
		ans += ((a[i] % MOD) * (prefix[n - 1] - prefix[i] + MOD) % MOD) % MOD;
	}
	ans %= MOD;
	cout << ans;

}


int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 6344
#include <iostream>

using namespace std;

bool graph[55][55];
bool flag[55][55];
bool visit[55];


int isConnect(int n);
int dfs(int now, int n);

int main()
{
    int ans = 0;
    int n, m;
    int a, b;
    
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;

        --a; --b;
        graph[a][b] = true;
        graph[b][a] = true;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (flag[i][j] == false && graph[i][j]) {
                
                graph[i][j] = false;
                graph[j][i] = false;
                flag[i][j] = true;
                flag[j][i] = true;
                
                ans += isConnect(n);

                graph[i][j] = true;
                graph[j][i] = true;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

int isConnect(int n)
{
    for (int i = 0; i < n; i++) {
        visit[i] = true;
    }

    return (dfs(0, n) == n ? 0 : 1);
}

int dfs(int now, int n)
{
    visit[now] = false;

    int rec = 0;
    for (int i = 0; i < n; i++) {
        if (visit[i] && graph[now][i]) {
            rec += dfs(i, n);
        }
    }

    return rec + 1;
}


Measured memory_bytes: 256