akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int MAX_M = 1000000;

    ll N;
    in1(N);

    int X, M;
    in2(X, M);

    vll F(MAX_M);
    F[0] = X;
    rep(i, MAX_M - 1) F[i + 1] = (F[i] * F[i]) % M;

    int start = -1;
    int end = -1;
    map<ll, int> m;
    rep(i, MAX_M)
    {
        if (m.count(F[i]) == 0)
        {
            m[F[i]] = i;
        }
        else
        {
            start = m[F[i]];
            end = i;
            break;
        }
    }

    ll ans = 0;
    if (end == -1)
    {
        //ループなし
        ans = accumulate(F.begin(), F.begin() + N, 0LL);
    }
    else
    {
        //ループあり
        auto itr = F.begin() + start;

        //開始～ループ開始前
        ans += accumulate(F.begin(), itr, 0LL);

        //ループ中
        N -= start;

        int loopLength = end - start;
        ll loopCount = N / loopLength;

        ans += loopCount * accumulate(itr, itr + loopLength, 0LL);

        //残り
        int r = N % loopLength;
        ans += accumulate(itr, itr + r, 0LL);
    }

    outl(ans);

    return 0;
}


Measured memory_bytes: 13948
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
 int a,b,t;
int main(){
  cin >> a >> b >> t;
  cout << (t/a)*b << endl; 
}


Measured memory_bytes: 256
N, X = map(int, input().split())

all, pate = [1], [1]
for i in range(N):
  all.append(all[i]*2 + 3)
  pate.append(pate[i]*2 + 1)

def f(N, X):
  if N == 0:
    return 1
  elif X == 1:
    return 0
  elif X <= 1 + all[N-1]:
    return f(N-1, X-1)
  elif X == 2 + all[N-1]:
    return 1 + pate[N-1]
  elif X < 3 + 2 * all[N-1]:
    return 1 + pate[N-1] + f(N-1, X-2-all[N-1])
  elif X == 3 + 2 * all[N-1]:
    return 2 * pate[N-1] + 1
print(f(N, X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  
  ll add=0;
  for(ll i=n-1; i>=0; i--) {
    a[i] += add;
    add += (b[i]-a[i]%b[i])%b[i];
  }
  cout << add << newl;
  return 0;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll dp[k+1]={0};
    for(ll i=1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(i>=a[j] && dp[i-a[j]]==0)
            {
                dp[i]=1;

            }
        }
    }
    if(dp[k]) cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 4424
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    
    ll ans = 0, mn = 2;
    ans += a[0] - 1;
    //cout << ans << endl;
    for (int i = 1; i < n; i++) {
        if (a[i] == mn) mn++;
        else if (a[i] > mn) ans += (a[i] - 1) / mn;
        //cout << mn << " " << ans << endl;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int n,d;cin >> n >> d;
    cout << (n+d*2)/(d*2+1) << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IO std::ios::sync_with_stdio(false);std::cin.tie(0)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
#define fi first
#define se second
#define pb push_back
int dp[2][200000];
int main(){
	string s;
	ll ans=0;
	cin>>s;
	int len=s.size();
	rep(i,0,len-1){
		int x=s[i]-'0';
		rep(j,0,2019){
			dp[1][(x+(j*10))%2019]+=dp[0][j];
		}
		dp[1][x]++;
		rep(j,0,2019){
			dp[0][j]=dp[1][j];
			dp[1][j]=0;
		}
		ans+=dp[0][0];
	}
	cout<<ans<<'\n';
}
	

Measured memory_bytes: 3760
import java.io.PrintWriter;
import java.util.*;

public class Main {

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

        int s = in.nextInt(), n = in.nextInt(), t = in.nextInt();
        boolean weekday = !"All".equals(in.next());
        Time time = Time.parse(in.next());
        int p = in.nextInt(), m = in.nextInt();

        while (time != Time.NONE) {
            //System.out.println(weekday + " " + time);

            int maxCount = 0;
            for (int start = 0; start < 10080; start++) {
                int now = start, count = 0;
                for (int i = 0; i < m; i++) {
                    int from = now, end = from + s;
                    boolean success = true;
                    if (time == Time.DAY) {
                        if (from % 1440 < 360 || from % 1440 >= 1080 || end % 1440 < 360 || end % 1440 >= 1080) success = false;
                    } else if (time == Time.NIGHT) {
                        if (from % 1440 >= 360 && from % 1440 < 1080) success = false;
                        if (end % 1440 >= 360 && end % 1440 < 1080) success = false;
                    }
                    if (weekday) {
                        if (from % 10080 >= 1440 || end % 10080 >= 1440) success = false;
                    }
                    if (success) count++;
                    now += t;
                }
                maxCount = Math.max(maxCount, count);
            }
            out.printf("%.10f\n", 1.0 - Math.pow(1.0 - 1.0 / p, maxCount * n));
            //out.println(maxCount);

            s = in.nextInt();
            n = in.nextInt();
            t = in.nextInt();
            weekday = !"All".equals(in.next());
            time = Time.parse(in.next());
            p = in.nextInt();
            m = in.nextInt();
        }

        out.flush();
    }

    enum Time {
        ALL, DAY, NIGHT, NONE;
        static Time parse(String s) {
            return Time.valueOf(s.toUpperCase());
        }
    }

}



Measured memory_bytes: 29096
#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 rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  vector<ll>s(n);
  rep(i, n)cin>>s[i];

  ll q;cin>>q;

  vector<ll>t(q);
  rep(i, q)cin>>t[i];

  ll result = 0;
  for(auto p: t){
    auto c = *lower_bound(s.begin(), s.end(), p);
    if(c==p)result++;
    // cout<<c<<' '<<p<<endl;
  }

  cout<<result<<endl;

  return 0;
}



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

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

  long int ans = 0 ;
  for (int i = 1; i <= n; i++) {
    long int j = n / i ;
    ans += i * (j+1) * j / 2 ;
  }

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    ll x;
    cin >> x;
    cout << 10-x / 200 << endl;
}

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

int main() {
 int N , A , B ;
  cin >> N >> A >> B ;
  if(N * A > B){
    cout << B << endl ;
  } 
  if(N * A < B){  
	cout << N * A << endl ;
  }
  if(N * A == B){  
	cout << N * A << endl ;
  }  
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,k;
    cin >> n >> k;
    int num = 0;
    n-=k;
    num++;
    num += (n+(k-2))/(k-1);
    COUT(num);
    return 0;
} 


Measured memory_bytes: 256
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2,int(n**(1/2))+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end="")
    if L==[]:
        pass
    print()
    return L
n=int(input())
factorization(n)



Measured memory_bytes: 5624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String n = null;

		if (N.equals("000")) {
			n = "0";
			System.out.println(n);
		} else if (N.equals("001")) {
			n = "1";
			System.out.println(n);
		} else if (N.equals("010")) {
			n = "1";
			System.out.println(n);
		} else if (N.equals("100")) {
			n = "1";
			System.out.println(n);
		} else if (N.equals("011")) {
			n = "2";
			System.out.println(n);
		} else if (N.equals("101")) {
			n = "2";
			System.out.println(n);
		} else if (N.equals("110")) {
			n = "2";
			System.out.println(n);
		} else if (N.equals("111")) {
			n = "3";
			System.out.println(n);
		} else {
			System.out.println("a");

		}

	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 21972
s = input()


init_c = 'a'
ans_len = 101
for i in range(26):
    max_len = 0
    l = 0
    tc = chr(ord(init_c) + i)
    for c in s:
        if c == tc:
            l = 0
        else:
            l += 1
        if l > max_len:
            max_len = l
    if ans_len > max_len:
        ans_len = max_len

print(ans_len)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int N){
        par.assign(N,0);
        rank.assign(N,0);
        REP(i,N) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) swap(x,y);
 
        //x becomes root
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
};


//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,M;
    cin >> N >> M;
    VI p(N);
    REP(i,N)
    {
        cin >> p[i];
        p[i]--;
    }
    UnionFind UF(N);
    REP(i,M)
    {
        int x,y;
        cin >> x >> y;
        x--; y--;
        UF.unite(x,y);
    }
    int ans = 0;
    REP(i,N)
    {
        if(UF.find(i) == UF.find(p[i])) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1408
import scala.io.StdIn.{readLine,readInt}
import scala.language.postfixOps

object Main {
  var cnt = 0
  val l = new Array[Int](250001)
  val r = new Array[Int](250001)

  def merge(a:Array[Int],left:Int,mid:Int,right:Int) = {
    val n1 = mid-left
    val n2 = right-mid
    Array.copy(a,left,l,0,n1)
    l(n1) = Int.MaxValue
    Array.copy(a,mid,r,0,n2)
    r(n2) = Int.MaxValue
    var i=0
    var j=0
    for(k<-left until right) {
      if(l(i)<=r(j)){
        a(k) = l(i)
        i += 1
      } else  {
        a(k)=r(j)
        j += 1
      }
      cnt += 1
    }
  }

 def getSortIndex(n:Int):Iterator[IndexedSeq[(Int,Int)]] = {
    var w = n
    var h = 0
    while(w>1) {
      h += 1
      w = w/2
    }

    def scan(h:Int,l:List[IndexedSeq[(Int,Int)]]):List[IndexedSeq[(Int,Int)]] = {
      if(h==0) l
      else
        scan(h-1,(for(i<-l.head;j<-List((i._1,(i._2+i._1)/2),((i._2+i._1)/2,i._2))) yield j)::l)
    }
    scan(h-1,List(IndexedSeq((0,n/2),(n/2,n)))).to[Iterator]
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val l = getSortIndex(n)
    for(e2<-l) {
      for(e<-e2) {
        val mid = (e._2+e._1)/2
        if(e._2-e._1>1)
          merge(a,e._1,mid,e._2)
      }
    }
    merge(a,0,n/2,n)
    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 318244
n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
v.insert(0, 0)
v.append(0)
l = [0, 0]
r = [0]
for i in range(n):
    l.append(l[i+1]+t[i])
    r.append(l[i+2])
r.append(r[n])
d = 0
vl = 0
for k in range(l[n+1]*2):
    now = k / 2 + 0.5
    vr = 1000
    for i in range(n+2):
        tv = 0
        if now < l[i]:
            tv = v[i] + l[i] - now
        elif now < r[i]:
            tv = v[i]
        else:
            tv = v[i] + now - r[i]
        vr = min(vr, tv)
    d += (vl+vr) * 0.25
    vl = vr
print(d)

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

vector<int>E[200000];
int id[200000];
int d[200000];

void dfs(int v,int k){
	id[v]=k;
	for(int u:E[v]){
		if(id[u]==-1){
			if(d[v]!=-1)d[u]=!d[v];
			dfs(u,k);
		}
		else{
			if(d[u]==d[v]){
				d[u]=-1;
			}
		}
	}
}
vector<int>v[200000];

int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	memset(id,-1,sizeof(id));
	int cnt=0;
	rep(i,n){
		if(id[i]==-1){
			dfs(i,cnt++);
		}
		v[id[i]].push_back(i);
	}
	ll c1=0,c2=0,c3=0;
	rep(i,cnt){
		if(v[i].size()==1){
			c1++;
			continue;
		}
		c2++;
		bool flag=true;
		for(int j:v[i]){
			if(d[j]==-1)flag=false;
		}
		if(flag)c3++;
	}
	cout<<c1*(n-c1)*2+c1*c1+c2*c2+c3*c3<<endl;
}

Measured memory_bytes: 18812
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long

using namespace std;

int n,k;
int ans=0;
int main(){
 cin>>n;
 if(n%2){
     double d;
     d=(double)(n+1)/(double)(2*n);
     cout<<d<<endl;
 }else{
     cout<<0.5<<endl;
 }
}


Measured memory_bytes: 256
#include<stdio.h>
long long x, y, z;
int main() {
	scanf("%lld%lld", &x, &y);
	z = x + y;
	if(x % 3 != 0 && y % 3 != 0 && z % 3 != 0) printf("Impossible\n");
    else printf("Possible\n");
    return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc173/tasks/abc173_b

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <boost/range/combine.hpp>
#include <boost/foreach.hpp>

const int N_MAX = 1e5;

int N;
std::vector<std::string> S;
std::vector<std::string> ans_key = {"AC","WA","TLE","RE"};

void solve() {
  std::vector<int> ans(4);
  for(int index = 0; index < ans_key.size(); index++){
    for(std::string s : S){
      if(s.compare(ans_key[index]) == 0)
        ans[index] += 1;
    }
  }
  std::string k;
  int v;
  BOOST_FOREACH(boost::tie(k,v), boost::combine(ans_key,ans)){
    std::cout << k << " x " << v << std::endl;
  }
}

void input() {
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    std::string s;
    std::cin >> s;
    S.push_back(s);
  }
}

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


Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // [9,223,372,036,854,775,807 to -9.....808] 19 digits
typedef long double ld;
#define inc(i, a, b) for (long long int i = a; i <= b; i++)
#define dec(i, a, b) for (long long int i = a; i >= b; i--)
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define lv vector<ll>
#define cv vector<char>
#define dv vector<ld>
#define rall(c) (c).rbegin(), (c).rend()
#define lpr pair<ll, ll>
#define mp make_pair
#define cin(c) \
    ll c;      \
    cin >> c;
#define lmap unordered_map<ll, ll>
#define vinp(a, n) \
    inc(i, 1, n)   \
    {              \
        cin(k);    \
        a.pb(k);   \
    }
#define LIM 1000000007
#define F first
#define S second
#define fr(i, n) inc(i, 0, n - 1)
#define fri(n, a) \
    inc(i, 0, n - 1) { cin >> a[i]; }
#define debug(p) cout << p;
#define umap unordered_map
#define uset unordered_set
#define fill(a, val, n) \
    inc(i, 0, n - 1) { a[i] = val; }
void i_love_Accepted()
{
    ll n;
    cin>>n;
    string s;
    ll a=0,w=0,t=0,r=0;
    inc(i,0,n-1)
    {
        cin>>s;
        if(s=="AC")
            a++;
        else if(s=="TLE")
            t++;
        else if(s=="WA")
            w++;
        else
            r++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<w<<"\n";
    cout<<"TLE x "<<t<<"\n";
    cout<<"RE x "<<r<<"\n";
}   
int main()
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        i_love_Accepted();
        cout<<"\n";
    } 
}


Measured memory_bytes: 3660
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0]*N
    for i in range(N):
        a = A[N - 1 - i]
        if i % 2 == 0:
            B[i//2] = a
        else:
            B[N - 1 - i//2] = a
    print(' '.join(map(str, B)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 29764
import bisect

b_left = bisect.bisect_left
b_right = bisect.bisect_right
n = 10**5

prime_list = []
is_prime = [True for _ in range(n+1)]
is_prime[0] = False
is_prime[1] = False
for i in range(2, n+1):
    f = is_prime[i]
    if f:
        prime_list.append(i)
        j = 2 * i
        while j <= n:
            is_prime[j] = False
            j += i
like_nums = []
for p in prime_list:
    if 2*p-1 >= n:
        break
    if is_prime[2*p-1]:
        like_nums.append(2*p-1)
#print(like_nums)
Q = int(input())
query = [input() for _ in range(Q)]
for line in query:
    l, r = map(int, line.split())
    a = b_left(like_nums, l)
    b = b_right(like_nums, r)
    print(b-a)


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

base = {chr(i): 0 for i in range(ord('a'), ord('a') + 26)}
S = input()
for s in S:
    base[s] += 1

for i in range(N - 1):
    cnt = {chr(i): 0 for i in range(ord('a'), ord('a') + 26)}
    S = input()
    for s in S:
        cnt[s] += 1
    for c in range(ord('a'), ord('a') + 26):
        base[chr(c)] = min(base[chr(c)], cnt[chr(c)])

base = [[c, v] for c, v in base.items() if v > 0]
base.sort()
ans = ""
for c, v in base:
    ans += c * v
print(ans)


Measured memory_bytes: 40944
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N), mochi(N,0);
   for (int i = 0; i < N; i++) {
     cin >> vec.at(i);
   }
  int x = 0;
   for (int i = 0; i < N; i++) {
     int a = 0;
     int b = vec.at(i);
     int c = i;
      for (int i = 0; i < N; i++) {
        if (i == c)
          break;
        if(vec.at(i) == b && mochi.at(i) == 0){
          mochi.at(i) = 1;
        }      
      }
      for (int i = 0; i < N; i++) {
        if(mochi.at(i) == 0)
          a ++;
      }
     x = a;
   }
  cout << x << endl;
}

Measured memory_bytes: 3628
S = input()
A = []
tmp = [0,0]
flag = "R"
for i in range(len(S)):
  if flag == "L" and S[i] == "R":
    A.append(tmp)
    flag = "R"
    tmp = [1,0]
    continue
  elif flag == "R" and S[i] == "L":
    flag = "L"
    
  if S[i] == "R":
    tmp[0]+=1
  elif S[i] == "L":
    tmp[1]+=1
A.append(tmp)
ans = []
for val in A:
  r, l = val
  if (r+l)%2==0:
    ans+=[0]*(r-1)+[(r+l)//2]+[(r+l)//2]+[0]*(l-1)
    continue
  ads = (r+l)//2
  ma = max(r,l)-1
  if r<l:
    if ma%2!=0:
      ans+=[0]*(r-1)+[ads+1]+[ads]+[0]*(l-1)
    else:
      ans+=[0]*(r-1)+[ads]+[ads+1]+[0]*(l-1)
  else:
    if ma%2!=0:
      ans+=[0]*(r-1)+[ads]+[ads+1]+[0]*(l-1)
    else:
      ans+=[0]*(r-1)+[ads+1]+[ads]+[0]*(l-1)
print(" ".join(map(str,ans)))

Measured memory_bytes: 84768
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
ans = 0
sa = sorted(a)
sc = sorted(c)

for x in b:
   ans += bisect.bisect_left(sa,x)*(n-bisect.bisect_right(sc,x)) 
    
print(ans)


Measured memory_bytes: 23232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int n, m, k;

template<class T>
T pow(T x, T n) {
	T res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}

ll dfs(int now_v,int cnt) {
	if (cnt == n) return max(now_v - k, 1);
	ll res = 0;
	REP(i, 1, m + 1) res += dfs(now_v + i, cnt + 1);
	return res;
}

signed main() {
	cout << setprecision(20) << fixed;
	while (cin >> n >> m >> k) {
		if (n == 0) break;
		cout << (double)dfs(0, 0) / pow(m, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3276
// ...

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

typedef long long int ll;
typedef long double ld;
#define endl "\n"
#define int long long
#define float long double
#define u_s unordered_set
#define mm multimap
#define pb push_back
#define ff first
#define ss second
#define beg begin()
#define end end()
#define siz size()
#define baahubali ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
const int mod = 1000000007;
void deb(int arg_count, ...){
    cout<<endl;
    va_list ap;va_start(ap, arg_count);for(int i=0;i<arg_count;i++){
    cout<<va_arg(ap, int)<<" ";}
    cout<<endl;
}
unsigned int countBits(int number) {
    unsigned int l=log2(number)+1;
    return l; 
}
bool at_position(int num,int pos) 
{   
    unsigned int go=(1ULL<<pos);
    bool bit = num & go; 
    return bit; 
} 

//-----------------------------------------------------------------------------------

signed main(){
    baahubali;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=0;
    if(k<=a)
        cout<<k;
    else if(k>a){
        sum=a;
        if(k-a<=b)
            cout<<sum;
        else {  
            sum-=k-a-b;
            cout<<sum;
        }
    }
    return 0;
}


Measured memory_bytes: 3692
import math
N = int(input())
xy = []
l = []
def comb(n,k):
  if n < k:
    n, K = k, N
  nu = 1
  de = 1
  for i in range(k):
    nu *= (N - i)
    de *= (K-i)
  return nu // de

for i in range(N):
  xy.append(list(map(int, input().split())))
for i in range(N-1):
  for j in range(i+1,N):
    l.append(math.sqrt((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1]) ** 2))

nu = math.factorial(N-2) * (N - 1) * 2
de = math.factorial(N)
ans = sum(l) * nu / de
print(ans)

Measured memory_bytes: 62224
#include <iostream>

using namespace std;


int main() {
	int n, y;
	cin >> n >> y;
	int a = 0;
	int b = 0;
	int c = 0;

	for (a = 0;; a++) {
		for (b = 0;; b++) {
			c = (n - a - b);
			if (c < 0) break; 
			if (a*10000 + b*5000 + c*1000 == y) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
		if (a*10000 > y) break;
	}

	cout << -1 << " " << -1 << " " << -1 << endl;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<deque>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m;
	int x[2*n],y[2*n],flag=1;
	for(int i=1;i<=2*n;i++){
		x[i-1]=i;
		y[i-1]=0;
	}
	for(int i=0;i<m;i++){
		cin>>k;
		if(k==0){
			if(flag){
				for(int j=0;j<n;j++)
				y[j*2]=x[j];
				for(int j=0;j<n;j++)
				y[j*2+1]=x[j+n];
				flag=0;
			}else{
				for(int j=0;j<n;j++)
				x[j*2]=y[j];
				for(int j=0;j<n;j++)
				x[j*2+1]=y[j+n];
				flag=1;
			}
		}else{
			if(flag){
				for(int j=k;j<2*n;j++)
				y[j-k]=x[j];
				for(int j=0;j<k;j++)
				y[2*n-k+j]=x[j];
				flag=0;
			}else{
				for(int j=k;j<2*n;j++)
				x[j-k]=y[j];
				for(int j=0;j<k;j++)
				x[2*n-k+j]=y[j];
				flag=1;
			}
		}
	}
	if(flag){
		for(int j=0;j<2*n;j++)
		cout<<x[j]<<endl;
		}else{
		for(int j=0;j<2*n;j++)
		cout<<y[j]<<endl;
		}
return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String a = scan.next();
        long k = scan.nextLong();
        int po = 0;
        for (int i=0;i<a.length();i++){
            if (a.charAt(i) != '1'){
                po = i;
                break;
            }
        }

        if (k < po+1){
            System.out.println(1);
        }
        else{
            System.out.println(a.charAt(po));
        }
        return;
        
    }
}

Measured memory_bytes: 35628
N=int(input())
A=[]
B=[]
for _ in range(N):
    x,y=map(int, input().split())
    A.append(x+y)
    B.append(x-y)

A=sorted(A)
B=sorted(B)

print(max(A[-1]-A[0],B[-1]-A[0],A[-1]-A[0],B[-1]-B[0]))

Measured memory_bytes: 27012
n, k, q = map(int, input().split())
res = [k - q] * n
for _ in range(q):
    c = int(input())
    res[c-1] += 1
for i in range(n):
    if res[i] <= 0:
        print("No")
    else:
        print("Yes")
#print(res)

Measured memory_bytes: 50904
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N;string S;cin>>N>>S;
    int ans=0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                char a='0'+i,b='0'+j,c='0'+k;
                int check=0;
                rep(l,N){
                    if(check==0){
                        if(S[l]==a)check++;
                    }
                    else if(check==1){
                        if(S[l]==b)check++;
                    }
                    else if(check==2){
                        if(S[l]==c)check++;
                    }
                }
                if(check==3)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int result = 0;

        for(int i = 1; i <= n; i++) {
            int sum = 0;
            int temp = i;
            for(int j = 0; j < 5; j++ ) {
                sum += temp % 10;
                temp = temp / 10;
            }
            if(a <= sum && sum <= b) {
                result += i;
            }
        }
        
        System.out.print(result);
    }
}

Measured memory_bytes: 21972
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unit(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] < self.rank[y]:
            self.par[x] = y
            return
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
        else:
            self.par[y] = x
            self.rank[x] += 1

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


n, m = map(int, input().split())
s = list(map(int, input().split()))
u = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    u.unit(a, b)

ans = 0
for i, p in enumerate(s):
    if u.same(i, p - 1):
        ans += 1
print(ans)


Measured memory_bytes: 94956
a,b,c,d = map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
lcm = int(c*d / gcd(c,d))
ans = (b-a+1 - (b//c - (a-1)//c) - (b//d - (a-1)//d) + (b//lcm - (a-1)//lcm))
print(int(ans))


Measured memory_bytes: 3060
h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            c = 0
            for iw in range(i-1,i+2):
                for jw in range(j-1,j+2):
                    if iw<0 or h<=iw or jw<0 or w<=jw:
                        continue
                    elif s[iw][jw]=="#":
                        c+=1
            s[i][j]=str(c)
for s_ in s:
    print(''.join(s_))

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)
#define pii pair<int,int>
#define mp make_pair

const ll INF=1e9+7;

int main(){
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	int N;
	vector<unsigned int> arr;

	cin>>N;
	arr.resize(N);

	REP(i,N)cin>>arr[i];

	unsigned int all_xor = arr[0];

	for(int i = 1; i < N; i++){
		all_xor ^= arr[i];
	}

	REP(i,N-1){
		cout<<(all_xor ^ arr[i])<<" ";
	}
	cout<<(all_xor ^ arr[N-1])<<endl;
	return 0;
}




Measured memory_bytes: 4056
import fractions

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

def main():
    n = int(input())
    t = []
    for i in range(n):
        t.append(int(input()))

    ans = 1
    for i in range(n):
        ans = lcm(ans, t[i])

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class C {
    static void Main(string[] args) {
        long N = int.Parse(Console.ReadLine());

        var S = new string[N];
        for (int i = 0; i < N; i++) {
            S[i] = Console.ReadLine();
        }

        var myTable = new Dictionary<string, int>();

        for (int i = 0; i < N; i++) {
            if (myTable.ContainsKey(S[i])) {
                myTable[S[i]]++;
            } else {
                myTable.Add(S[i], 1);
            }
        }

        int maxValue = 1;

        foreach (string element in myTable.Keys) {
            maxValue = Math.Max(maxValue, myTable[element]);
        }

        var ansList = new List<string>() { };
        foreach (string element in myTable.Keys) {
            if (myTable[element] == maxValue) {
                ansList.Add(element);
            }
        }

        //Array.Sort(ansList.ToArray());

        var ansArray = ansList.ToArray();

        StringComparer cmp = StringComparer.OrdinalIgnoreCase;
        Array.Sort(ansArray, cmp);

        foreach (var element in ansArray) {
            Console.WriteLine(element);
        }


        //var ansList = new List<string>() { };

        //var nowIndex = new long[N + 2];

        //long curMax = 0;
        //long thenMax = 0;

        //for (int i = 1; i < N; i++) {
        //    if (S[i] == S[i - 1]) {
        //        nowIndex[i] = nowIndex[i - 1] + 1;
        //    } else {
        //        nowIndex[i] = 0;
        //    }

        //    curMax = Math.Max(curMax, nowIndex[i]);

        //    if (nowIndex[i] == 0) {
        //        if (nowIndex[i - 1] == thenMax) {
        //            ansList.Add(S[i - 1]);

        //        } else if (nowIndex[i - 1] > thenMax) {
        //            ansList.Clear();
        //            ansList.Add(S[i - 1]);
        //            thenMax = curMax;
        //        }
        //    }

        //    if (i == N - 1) {
        //        if (nowIndex[i] == thenMax) {
        //            ansList.Add(S[i]);

        //        } else if (nowIndex[i] > thenMax) {
        //            ansList.Clear();
        //            ansList.Add(S[i]);
        //            thenMax = curMax;
        //        }
        //    }
        //}

        //foreach (var element in ansList) {
        //    Console.WriteLine(element);
        //}
    }
}

Measured memory_bytes: 48060
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int   length = sc.nextInt();
		
		String a = sc.next();
		String b = sc.next();
		
		sc.close();
		
		String c = new String("");
		
		for(int i=0; i< length; i++)
		{
			c += a.charAt(i);
			c += b.charAt(i);
		}
		
		System.out.println(c);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10;
int main()
{
  int N;
  cin >> N;
  int arr[MAX_N] = {};
  int Neven = 0;
  for (int i = 0; i < N; ++i) cin >> arr[i];
  for (int i = 0; i < N; ++i) if (arr[i]%2 == 0) ++Neven;
  int result = pow(3.0, N) - pow(2.0, Neven);
  cout << result << endl;
  return 0;
}

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

/*int n;
  cin >> n;
  vector<int> h(n);*/

int main() {

  int n;
  int count = 0;
  cin >> n;


  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      if(i*j == n){
        count ++;
      }
    }
  }

  if(count != 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
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)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	int ans = 0;
	rep(i,N){
		int t;
		cin>>t;
		while(t%2 == 0){
			++ans;
			t/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 2560
N = int(input())
b = input().split()
a = [int(n) for n in b]

c = 0
for i in range(N):
    minj = i
    for j in range(i,N):
        if a[j] < a[minj]:
            minj = j
    if i != minj:
        c+=1
    v = a[i]
    a[i] = a[minj]
    a[minj] = v
print(" ".join([str(n) for n in a]))
print(c)


Measured memory_bytes: 5604
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n,k,h,ans=0;
	in(n);
	in(k);
	rep(i, 0, n) {
		in(h);
		if (h >= k) {
			ans++;
		}

	}
	
	outn(ans);
	return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  ll a,b;
  cin>>a>>b;
  ll c = n/(a+b);
  ll ans = a*c;
  ll d = n%(a+b);
  ans += min(a,d);
  cout << ans << endl;
  return 0;
}

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

ans = 0
tmp = 0
for i in A:
    ans += B[i-1]
    if tmp == i-1 and i != 1:
        ans+=C[i-2]
    tmp = i
print(ans)



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



int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),b(n),c(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=0;i<n;i++)cin>>b[i];
    for(ll i=0;i<n;i++)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    for(ll i=0;i<n;i++){
        auto itr = upper_bound(c.begin(),c.end(),b[i]);
        auto itr1 = lower_bound(a.begin(),a.end(),b[i]);
        ll index1 = itr-c.begin();
        ll index2 = itr1-a.begin();
        ans += (n-index1)*(index2);
    }
    cout<<ans<<endl;
	return 0; 
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int x;
    char s[9];
    REP(i,9) cin >> s[i];
    cout << s[0] << s[4] << s[8] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		final String[] result = {"War", "No War"};
		Main dwt = new Main();
		if(dwt.Dimensional_World_Tale()) {
			System.out.println(result[1]);
		}else {
			System.out.println(result[0]);
		}
	}

	public boolean Dimensional_World_Tale() {
		/**
		 * <条件>
		 * X,Yの示す範囲 が x[],y[] の被っていない範囲 に含まれていればよい
		 *
		 */

		//入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int[] array_x = new int[n];
		int[] array_y = new int[m];
		for(int i = 0; i < n; i++) {
			array_x[i] = sc.nextInt();
		}
		for(int t = 0; t < m; t++) {
			array_y[t] = sc.nextInt();
		}

		/*
		 * x[]とy[]の被らない範囲を探索
		 * 昇順にソート→最小値と最大値を比べる
		 */
		Arrays.sort(array_x);
		Arrays.sort(array_y);
		int min = array_x[n-1];
		int max = array_y[0];

		/*
		 * XとYの範囲を比較
		 */
		if(min > x && max <= y) {
			if(min < max) {
				return true;
			}else {
				return false;
			}
		}else {
			return false;
		}
 	}
}


Measured memory_bytes: 23124
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let f i j = List.fold_left (fun c (dy, dx) -> let y, x = i + dy, j + dx in if 0 <= y && y < h && 0 <= x && x < w && ss.(y).[x] = '#' then c + 1 else c) 0 [-1, 0; -1, -1; 0, -1; 1, -1; 1, 0; 1, 1; 0, 1; -1, 1]
let _ = for i = 0 to h - 1 do for j = 0 to w - 1 do if ss.(i).[j] = '#' then print_char '#' else print_int @@ f i j done; print_newline () done

Measured memory_bytes: 1024
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return

#C
def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return

#D
def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    for i in range(29):
        t = 1 << i
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort()
        b2.sort()
        ansb = 0
        r1 = r2 = r3 = 0
        for A in reversed(a2):
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += r2 ^ r1 ^ N ^ r3
            ansb = ansb & 1
        ans += (ansb << i)
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 141176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  cin >> N >> K;
  vector<int> li(N);
  for(int i=0;i<N;i++){
    cin >> li.at(i);
  }
  int a = 0;
  int b = 0;
  for(int i=0;i<N;i++){
    a = li.at(i);
    b = i-1;
    while(b>=0&&li.at(b)>a){
      li.at(b+1) = li.at(b);
      b -= 1;
    }
    li.at(b+1) = a;
  }
  int ans = 0;
  for(int i=0;i<K;i++){
    ans += li.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628