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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string num;
  string str;
  getline(cin, num);
  getline(cin, str);
  
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

from math import gcd

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
a = [int(x) for x in input().split()]

primes = set()

flag = 1

for i in a:
    prime_factors = set(prime_factorize(i))
    for j in prime_factors:
        if j in primes:
            flag = 0
        else:
            primes.add(j)


if flag:
    print('pairwise coprime')
    sys.exit()
            
 
import math
from functools import reduce
 
def gcd(*numbers):
    return abs(reduce(math.gcd, numbers))
 
if gcd(*a) == 1:
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 205548
#include <stdio.h>
int main()
{
	int H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0||i==H-1||j==0||j==W-1)
					printf("#");
				else
					printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    targets = LI()
    MAX_INT = max(targets) + 1
    counter = cl.Counter(targets)
    targets = set(targets)
    is_pw = True

    num_1 = counter[1]
    if num_1 > 1:
        N -= num_1 - 1

    if len(targets) != N:
        is_pw = False

    if len(targets) == 1:
        if 1 in targets:
            print("pairwise coprime")
            return
        print("not coprime")
        return

    for i in range(2, MAX_INT):
        origin = i
        kosuu = 0
        while origin <= MAX_INT:
            if origin in targets:
                kosuu += 1
            origin += i

        if kosuu <= 1:
            continue
        elif kosuu < len(targets):
            is_pw = False
        else:
            print("not coprime")
            return

    if is_pw:
        print("pairwise coprime")
        return
    print("setwise coprime")


main()


Measured memory_bytes: 252824
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<double, int> PDI;
typedef vector<PDI> VD;

const int INF = 3e18;

int n, k, a[100010], ruiseki[100010], p_ruiseki[100010];
int ans = 0;
signed main()
{
  cin >> n >> k;

  for(int i = 1; i <= n; i++){
    cin >> a[i];
    ruiseki[i] = ruiseki[i - 1] + a[i];
    p_ruiseki[i] = p_ruiseki[i - 1];
    if(a[i] > 0){
      p_ruiseki[i] += a[i];
    }
  }
  
  for(int i = k; i <= n; i++){
    ans = max(ans, ruiseki[i] - ruiseki[i - k] + p_ruiseki[i - k] + p_ruiseki[n] - p_ruiseki[i]);
    ans = max(ans, p_ruiseki[i - k] + p_ruiseki[n] - p_ruiseki[i]);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
# coding: utf-8
import math
import numpy
#N = int(input())
a, b, c = map(int,input().split())
#A = list(map(int,input().split()))
K =int(input())
flg = False
i = 0
while a >= b:
    if i == K:
        break
    b *= 2
    i += 1
    
    #print(i,a,b,c)
while b >= c:
    if i == K:
        break
    c *= 2
    i += 1
    #print(a,b,c)
#print(a, b, c)
if a < b < c:
    print("Yes")
else:
    print("No")

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

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<int> max_index(n + 1), min_index(n + 1);
    int minimum = 1000000000;
    int index = 0;
    for (int i = 0; i < n - 1; i++) {
        if (minimum >= a.at(i)) {
            minimum = a.at(i);
            index = i;
        }
        min_index.at(i + 1) = index;
    }
    int maximum = 0;
    index = n - 1;
    for (int i = n - 1; i >= 1; i--) {
        if (maximum <= a.at(i)) {
            maximum = a.at(i);
            index = i;
        }
        max_index.at(i) = index;
    }
    
    int max_diff = 0;
    for (int i = 1; i <= n - 1; i++) {
        max_diff = max(max_diff, a.at(max_index.at(i)) - a.at(min_index.at(i)));
    }
    set<int> s;
    for (int i = 1; i <= n - 1; i++) {
        if (a.at(max_index.at(i)) - a.at(min_index.at(i)) == max_diff) {
            s.insert(min_index.at(i));
        }
    }
    cout << s.size() << endl;
}   

Measured memory_bytes: 3712
s=input()

for i in range(2**3):
    S=s[0]
    Sum=int(s[0])
    for j in range(3):
        if (i>>j)&1:
            S+='+'+s[j+1]
            Sum+=int(s[j+1])
        else:
            S+='-'+s[j+1]
            Sum-=int(s[j+1])
    if Sum == 7:
        print(S+'=7')
        exit()

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;

int a[1000][1000]={{0}};
int b[1000]={0};

int main (void)
{
	int n, m, i, j, x, y, sum=0;

	scanf("%d %d", &x, &y);

	for (i=0; i<x; i++){
		for (j=0; j<y; j++)
			scanf("%d", &a[i][j]);
	}

	for (i=0; i<y; i++)
		scanf("%d", &b[i]);

	for (i=0; i<x; i++){
		sum = 0;
		for (j=0; j<y; j++){
			sum += a[i][j]*b[j];
		}
		printf("%d\n", sum);
	}
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<vector<int>>xl(n, vector<int>(2));
	for (int i = 0; i < n; i++)cin >> xl.at(i).at(0) >> xl.at(i).at(1);
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	sort(xl.begin(), xl.end());
	ll ans = 0;
	ll l = -10000000000, r = -10000000000;
	for (int i = 0; i < n; i++) {
		ll nl = xl.at(i).at(0) - xl.at(i).at(1);
		ll nr = xl.at(i).at(0) + xl.at(i).at(1);
		if (r <= nl) {
			ans++;
			l = nl;
			r = nr;
		}
		else if (nr <= r) {
			l = nl;
			r = nr;
		}
		//cout << ans << nl << nr << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
 struct card{char suit,value;};

void bubble(struct card A[],int N){
for(int i=0;i<N;i++){
for(int j=N-1;j>=i;j--){
if(A[j].value<A[j-1].value){
card t=A[j];
A[j]=A[j-1];
A[j-1]=t;
}
}
}
}

void select(struct card A[],int N){
for(int i=0;i<N;i++){
int minj=i;
for(int j=i;j<N;j++){
if(A[j].value<A[minj].value)minj=j;
}
card t=A[i];
A[i]=A[minj];
A[minj]=t;
}
}

void print(struct card A[],int N){
for(int i=0;i<N;i++){
if(i>0)cout<<" ";
cout<<A[i].suit<<A[i].value;
}
cout<<endl;
}

bool stable(struct card c1[],struct card c2[],int N){
for(int i=0;i<N;i++){
if(c1[i].suit !=c2[i].suit)return false;
}
return true;
}

int main(){
card c1[100],c2[100];
int N;
char ch;

cin>>N;
for(int i=0;i<N;i++){
cin>>c1[i].suit>>c1[i].value;
}

for(int i=0;i<N;i++)c2[i]=c1[i];

bubble(c1,N);
select(c2,N);

print(c1,N);
cout<<"Stable"<<endl;
print(c2,N);
if(stable(c1,c2,N)){
cout<<"Stable"<<endl;
}else{cout<<"Not stable"<<endl;
}

return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for(int i = 0; i < (1<<(n-1)); ++i) {
        ll t = s[0] - '0';
        for(int j = 0; j < n-1; ++j) {
            if(i & (1 << j)) {
                ans += t;
                t = s[j+1] - '0';
            }
            else {
                t*=10;
                t+=s[j+1]-'0';
            }
        }
        ans += t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;

long long gcd(long long a, long long b) { // 2つの場合の最大公約数
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}
 
long long gcd_vec(vector<long long> const &A) { // N個の要素に対する最大公約数
    int size = (int)A.size();
    long long ret = A[0];
    for (int i = 1; i < size; i++) {
        ret = gcd(ret, A[i]);
    }
    return ret;
}

int main() {

int N;
cin>>N;
vector<ll> A(N);
rep(i,N){
    cin>>A[i];
}

cout<<gcd_vec(A)<<endl;



return 0;
}

Measured memory_bytes: 1024
fun main(arg: Array<String>){
    val (N, A, B, C, D) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!
    val A_last = S.substring(A - 1, listOf(C, D).max()!! - 1)
    val common_S = S.substring(listOf(A, B).max()!! - 2, listOf(C, D).min()!!)

    if(A_last.contains("##")){
        System.err.println("double ##")
        println("No")
    }else{
        if(C < D){
            System.err.println("C < D")
            println("Yes")
        }else{
            System.err.println("S[D - 2]: ${S[D - 2]}, S[D} = ${S[D]}")
            val sideX = S[D - 2] == '#' || if(D < N) '#' == S[D] else false
            if(sideX && !common_S.contains("...")){
                System.err.println("cannot cross")
                println("No")
            }else{
                System.err.println("sideX: ${sideX}")
                println("Yes")
            }
        }
    }

}


Measured memory_bytes: 41476
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-08-07 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

template<class T> ll upper(T n,T m){return (n+m-1)/m;};
template<class T> ll rounding(T n){return (long double)n+0.5;};

template<class T> bool inG(T x,T n){return 0<=x && 0<n;}
template<class T> bool outG(T x,T n){return x<0 || n<=x;}

inline int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  cout<<c-d+b<<" "<<d+c-a<<" "<<a-d+b<<" "<<b+c-a<<endl;

  return 0;

}


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

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
  string s; cin>>s;
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++)reverse(divide[i].begin(),divide[i].end());
  
  bool can = true;
   for(int i=0;i<s.size();){
     bool can2=false;
     for(int j=0;j<4;j++){
       string d = divide[j];
       if(s.substr(i,d.size()) == d){
         can2=true;
         i+=d.size();
       }
     }
     if(!can2){
       can=false;
       break;
     }
   }
  cout<<(can ? "YES" : "NO")<<endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

VI dx[2] = {{1,0,-1,0}, {1,1,0,-1,-1,-1,0,1}};
VI dy[2] = {{0,1,0,-1}, {0,1,1,1,0,-1,-1,-1}};

void dfs(int y, int x, int h, int w, int id, VVI& xs, VS& vs){
  xs[y][x] = id;
  int c = (vs[y][x] == '.'? 0: 1);
  REP(d,SZ(dx[c])){
	int tx = x + dx[c][d];
	int ty = y + dy[c][d];
	if(tx < 0 || w <= tx || ty < 0 || h <= ty
	   || vs[ty][tx] != vs[y][x] || xs[ty][tx] != -1) continue;
	dfs(ty, tx, h, w, id, xs, vs);
  }
}

void build(int h, int w, VS& vs, VVI& G){
  VVI num(h, VI(w, -1));
  int gid = 0;
  REP(y,h) REP(x,w)
	if(num[y][x] != -1) continue;
	else dfs(y, x, h, w, gid++, num, vs);

  G.resize(gid);
  vector<bool> ok(gid);
  ok[0] = true;
  REP(y,h) REP(x,w){
	if(ok[num[y][x]]) continue;
	int c = (vs[y][x] == '.'? 0: 0);
	REP(d,SZ(dx[c])){
	  int tx = x + dx[c][d];
	  int ty = y + dy[c][d];
	  if(tx < 0 || w <= tx || ty < 0 || h <= ty
		 || vs[ty][tx] == vs[y][x] || !ok[num[ty][tx]]) continue;

	  G[num[y][x]].PB(num[ty][tx]);
	  G[num[ty][tx]].PB(num[y][x]);
	  ok[num[y][x]] = true;
	  break;
	}
  }
}

const LL B1 = 1009;
const LL M1 = 1000000007;
const LL B2 = 1007;
const LL M2 = 1000000009;
LL rnd[100000];
PLL thash(int u, int p, VVI& G){
  PLL res(SZ(G[u]), SZ(G[u]));
  vector<PLL> xs;
  for(auto&& v: G[u]){
	if(v == p) continue;
	xs.PB(thash(v, u, G));
  }
  SORT(xs);
  REP(i,SZ(xs)){
	auto& x = xs[i];
	res.FF = (res.FF * B1 + x.FF * rnd[i]) % M1;
	res.SS = (res.SS * B2 + x.SS * rnd[i]) % M2;
  }

  return res;
}

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

  random_device rd;
  REP(i,10000)
	rnd[i] = rd();

  int H1, W1;
  while(cin>>H1>>W1,H1){
	VS xs(H1+2);
	xs[0] = xs[H1+1] = string(W1+2, '.');
	REP(y,H1){
	  string in;
	  cin >> in;
	  xs[y+1] = "." + in + ".";
	}
	VVI G1;
	build(H1+2, W1+2, xs, G1);
	
	int H2, W2;
	cin >> H2 >> W2;
	VS ys(H2+2);
	ys[0] = ys[H2+1] = string(W2+2, '.');
	REP(y,H2){
	  string in;
	  cin >> in;
	  ys[y+1] = "." + in + ".";
	}
	VVI G2;
	build(H2+2, W2+2, ys, G2);

	cout << (thash(0,-1,G1) == thash(0,-1,G2)? "yes": "no") << endl;
  }

  return 0;
}

Measured memory_bytes: 3424
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for(int i = 0; i < n; i++) {
            String res = sc.next();
			if(res.equals("AC"))
			AC++;
			else if(res.equals("WA"))
			WA++;
			else if(res.equals("TLE"))
			TLE++;
			else if(res.equals("RE"))
			RE++;
		}
		System.out.println("AC x " + AC);
		System.out.println("WA x " + WA);
		System.out.println("TLE x " + TLE);
		System.out.println("RE x " + RE);
	}
}

Measured memory_bytes: 58096
#include<iostream>
using namespace std;
int main()
{
	int n,a,b,x,s=0,t=0,y;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		x=i;
		while(x!=0)
		{
			y=x%10;
			t+=y;
			x/=10;
		}
		if(t>=a&&t<=b)s+=i;
		t=0;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX =100;
static const int INFTY = (1<<21);
static const int WHITE =0;
static const int GRAY = 1;
static const int BLACK = 2;
int n,M[MAX][MAX];
void dijkstra(){
  int minv;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0; i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
        if(d[v] > d[u] + M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY ? -1 : d[i]) << endl;
  }
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  int k,c,u,v;
  for(int i=0;i<n;i++){
       cin >> u >>k;
    for(int j=0;j<k;j++){
      cin >> v >>c;
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}





Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

// vector<int> DP;

// ll saiki(ll H) {

//   // cout << H << endl;
//   if (DP[H] != -1) {
//     return DP[H];
//   }

//   ll index = floor((long double)H / 2.0);

//   if (DP[index] == -1) {
//     DP[index] = saiki(index); // calc DP[index] and store it to DP[]
//   }

//   DP[H] = DP[index] * 2 + 1;

//   return DP[H];

// }

int main() {

  ll H;
  cin >> H;

  // for(ll i=0; i<=H; i++) {
  //   DP.push_back(-1);
  // }

  // use DP
  // DP[0] = 0;
  // DP[1] = 1;

  // saiki(H);

  // REP(i, 2, H+1) {
  //   ll index = floor((long double)i / 2.0);
  //   DP[i] = DP[index] * 2 + 1;
  // }

  // cout << DP[H] << endl;

  ll ans = 0;
  ll mons_num = 1;
  while (H > 0) {
    H = H/2;
    ans = ans + mons_num;
    mons_num = mons_num * 2;
  }

  cout << ans << endl;

  return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); i++)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

void print(const vi& num) {
    int n = num.size();
    rep(i, 0, n) {
        cout << num[i];
        if (i != n - 1) { cout << " "; }
        else { cout << endl; }
    }
}

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

    vi num(n);
    rep(i, 0, n) { cin >> num[i]; }

    int cnt = 0;
    rep(i, 0, n) {
        int min_index = i;
        int min_val = num[i];

        rep (j, i + 1, n) {
            if (min_val > num[j]) {
                min_val = num[j];
                min_index = j;
            }
        }
        if (i != min_index) {
            swap(num[i], num[min_index]);
            ++cnt;
        }
    }

    print(num);
    cout << cnt << endl;
    return 0;
}


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

using namespace std;	

int main() 
{
	int n;
	cin >> n;
	int array1[n],array[n];
	for (int i=0;i<n;i++)
	{
		cin >> array1[i];
	}
	sort(array1,array1+n);

	for (int i=0;i<n;i++)
	{
		array[i] = array1[n-1-i];
	}

	int alice=0,bob=0;

	for (int i=0;i<n;i+=2)
	{
		alice += array[i];
	}
	for (int i=1;i<n;i+=2)
	{
		bob += array[i];
	}
	cout << alice-bob;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EB emplace_back
#define gcd std::__gcd

typedef std::vector <int> vector;
const int N = 2054, M = N * N;

int n, E = 0;
int a[N], to[M], first[N], next[M], deg[N];
bool used[N];
vector G[N];
std::priority_queue <int> pq;

inline void addedge(int u, int v) {to[++E] = v, next[E] = first[u], first[u] = E, ++deg[v];}
inline void dfs(int x) {used[x] = true; for (int y : G[x]) if (!used[y]) addedge(x, y), dfs(y);}

int main() {
	int i, j, x, y;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", a + i);
	std::sort(a + 1, a + (n + 1));
	for (i = 1; i < n; ++i)
		for (j = i + 1; j <= n; ++j)
			if (gcd(a[i], a[j]) > 1) G[i].EB(j), G[j].EB(i);
	for (i = 1; i <= n; ++i) if (!used[i]) dfs(i);
	for (i = 1; i <= n; ++i) if (!deg[i]) pq.emplace(i);
	for (i = 1; i <= n; ++i) {
		printf("%d%c", a[x = pq.top()], i == n ? 10 : 32), pq.pop();
		for (j = first[x]; j; j = next[j])
			if (!--deg[y = to[j]]) pq.emplace(y);
	}
	return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1);
	vector<int> c(n-1);
	long long ans=0;

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

	for (int i=1; i<=n; i++)
		cin >> b[i];

	for (int i=1; i<=n-1; i++)
		cin >> c[i];

	a[0] = -1;
	for (int i=1; i<=n; i++) {
		if (a[i] == a[i-1]+1)
			ans += c[a[i-1]];
		ans += b[a[i]];
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    map<int, int> A;
    rep(i, N){
        int a;
        cin >> a;
        if(A.count(a)) A[a]++;
        else A[a] = 1;
    }

    ll ans1 = 0, ans2 = 0;
    for(auto i : A){
        if(i.second / 2 == 0) continue;
        else if(i.second / 2 == 1){
            ans2 = ans1;
            ans1 = i.first;
        }
        else if(i.second / 2 >= 2){
            ans1 = i.first;
            ans2 = i.first;
        }
    }

    cout << ans1 * ans2 << endl;

}

Measured memory_bytes: 4992
i = gets.chomp.split.map(&:to_i)
if ((i[0]**2 )* i[1]) <= i[2]*2 
    ans = Math.atan(2*(i[0]*i[0]*i[1]-i[2]).to_f/i[0]**3)
    print ans * 180.0 / Math::PI.to_f
else
    a = (2*(i[0]*i[1]-i[2])/(i[0]*i[1]).to_f)-i[0]
    ans = Math::PI/2 - Math.atan(2*i[2] / (i[0]*i[1]*i[1]).to_f)
    print ans * 180.0 / Math::PI.to_f
end

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

using namespace std;

int main(){
    int count = 0;
    string s,t;
    cin >> s >> t;

    for(int i = 0;i < s.size();i++){
        if(s[i] == t[i]) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
P = list(map(int,input().split()))

cnt = 0
for i in range(1,n-1):
    if min(P[i-1],P[i],P[i+1]) < P[i] and max(P[i-1],P[i],P[i+1]) > P[i]:
        cnt += 1

print(cnt)

Measured memory_bytes: 9188
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < N; i++){
        set<int> mae;
        set<int> ushiro;
        for(int j = 0; j < i; j++){
            mae.insert(S.at(j) - 'a');
        }
        for(int j = i; j < N; j++){
            ushiro.insert(S.at(j) - 'a');
        }
        int cnt = 0;
        for(int i = 0; i < 30; i++){
            if(mae.count(i) && ushiro.count(i)){
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	int a, b, c, d;
	int r, l;
	cin >> a >> b >> c >> d;
	l = a + b;
	r = c + d;
	if (r > l){
		cout << "Right" << endl;
	}
	else if (r < l){
		cout << "Left" << endl;
	}
	else{
		cout << "Balanced" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

int main() {FIN
    
    int n, b, f, r, v, i, j, k;
    cin >> n;
    vvvi nh(5, vvi(4, vi(11)));
    for (i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        nh[b][f][r] += v;
    }
    for (i = 1; i <= 4; i++) {
        if (i > 1)
            cout << string(20, '#') << "\n";
        for (j = 1; j <= 3; j++) {
            for (k = 1; k <= 10; k++)
                cout << " " << nh[i][j][k];
            cout << "\n";
        }
    }
    
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<int,int> a, const pair<int,int> b) {
    return a.second < b.second;
}

ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
    ll A,B;
    int ans = 1;

    cin >>A>>B;
    ll lower = gcd(max(A,B),min(A,B));
    ll GCD = gcd(max(A,B),min(A,B));
    vector<int>primesA;

    for(int i = 2; i <= (ll)sqrt(GCD) + 2; i++){
      if(lower % i == 0){
        primesA.push_back(i);
        while(lower % i == 0){
        lower /= i;
        }
      }
    }
    if(lower > 1){
      primesA.push_back(lower);
    }

    cout <<1 + primesA.size()<<endl;

    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;

*/

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  int n; cin >> n;
  vector<int> a(n+1);
  rep(i, n) cin >> a[i+1];
  vector<int> b(n+1);

  for(int i = n; i >= 1; i--) {
    int sum = 0;
    for(int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }

  vector<int> ans;
  for(int i = 1; i <= n; i++) {
    if(b[i] == 1) ans.push_back(i);
  }
  cout << ans.size() << '\n';
  rep(i, ans.size()) {
    cout << ans[i] << (i == ans.size()-1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 3192
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    n = 5;
    int a[5],ans;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            {
                ans =i;
                break;
            }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i=a; i<=b; i++){
        if(i<=a+k-1 || b-k+1<=i){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int x,y;
  while(1){
    scanf("%d%d",&x,&y);
    if(x==0 && y==0)break;
    if(x < y)printf("%d %d\n",x,y);
    else printf("%d %d\n",y,x);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iomanip>
#include <iostream>
using namespace std;
int n, m, d;
int main() {
	cin >> n >> m >> d;
	cout << fixed << setprecision(15) << 1.0 * (d == 0 ? n : (n - d) * 2) * (m - 1) / n / n << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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; }
using ll = long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
int main()
{
  int q; cin >> q;
  vector<int> f(q);
  vector<ll> a(q),b(q);
  rep(i,q) {
    cin >> f[i];
    if(f[i] == 1) cin >> a[i] >> b[i];
  }

  multiset<pl> st;
  ll lsize = 0, rsize = 0;
  ll size = 0;
  ll piv,idx;
  ll sum = 0, lsum = 0, rsum = 0;
  rep(i,q) {
    if(f[i] == 1) {
      sum += b[i];
      if(size == 0) {
	size++;
	piv = a[i];
	idx = i;
	st.insert({a[i], i});
      }
      else if(piv <= a[i]) {
	if(size % 2 == 0) {
	  st.insert({a[i], i}); size++;
	  auto it = st.find({piv, idx});
	  it++;
	  lsum += piv; lsize++;
	  rsum += a[i] - (*it).first;
	  piv = (*it).first; idx = (*it).second;
	}
	else {
	  st.insert({a[i], i}); size++;
	  rsum += a[i]; rsize++;
	}
      }
      else {
	if(size % 2 == 0) {
	  st.insert({a[i], i}); size++;
	  lsum += a[i]; lsize++;	  
	}
	else {
	  st.insert({a[i], i}); size++;	  
	  auto it = st.find({piv, idx});
	  it--;
	  rsum += piv; rsize++;
	  lsum += a[i] - (*it).first;	  
	  piv = (*it).first; idx = (*it).second;	  
	}
      }
    }
    else {
      ll res = sum + piv*lsize - lsum + rsum - piv*rsize;
      cout << piv << " ";
      cout << res << "\n";      
    }
  }
  
  return 0;
}


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

int main()
{
  unsigned int k,i;
  string s,ne;
  cin>>k>>s;
  if(s.length()>k)
  {
    ne=s.substr(0,k);
    ne=ne+"...";
    cout<<ne;
  }
  else cout<<s;
  return 0;
}

Measured memory_bytes: 3612
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n = input()
    aida = len(n) - 1
    for i in range(2 ** aida):
        kigo = ['-'] * aida
        for j in range(aida):
            if ((i >> j) & 1):
                kigo[-1 - j] = '+'
    
        kigo.append('')
     
        siki = ''
        for kazu, seifu in zip(n, kigo):
            siki += (kazu + seifu)
      
        if eval(siki) == 7:
            print(siki + '=7')
            break

resolve()

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min(a, b) + Math.min(c, d));
    }
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main()
{
    int a,b,r1,r2,r3;
    cin>>a>>b;
    r1=a+b;
    r2=a-b;
    r3=a*b;



    if (r1 > r2)
    {
        if (r1 > r3)
        {
             cout<<r1<<endl;
        }
        else
        {
             cout<<r3<<endl;
        }
    }
    else if (r2 > r3)
         cout<<r2<<endl;
    else
         cout<<r3<<endl;



    return 0;
        }













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

#define int long long

const int M = 8000000;
vector<bool> used;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int m, n;
  while ( cin >> m >> n, m ) {
    used = vector<bool>(M, false);    
    int cnt = 0;
    for ( int i = m; i < M; i++ ) {
      if ( used[i] ) continue;
      for ( int j = i; j < M; j += i ) {
	used[j] = true;	
      }
      cnt++;
      if ( cnt == n ) break;      
    }

    for ( int i = m; i < M; i++ ) {
      if ( !used[i] ) {
	cout << i << endl;
	break;
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 4788
#include<bits/stdc++.h>
#include<iomanip>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;
int main(){
 	long double a,b,k;
 	cin>>a>>b>>k;
 	long double t=a*a*b;
	long double l=t-k;
	if(l<=t/2){
		long double h=l*2/(a*a);
    	long double tb=sqrt(h*h+a*a);
    	cout<<fixed<<setprecision(8)<<asin(h/tb)/M_PI*180<<endl;
  	}
	else{
	  	l=k;
	  	double h=l*2/(b*a);
	  	double tb=sqrt(h*h+b*b);
	  	cout<<fixed<<setprecision(8)<<90-asin(h/tb)/M_PI*180<<endl;
	}
	re 0;
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    int64_t ans = 0, tmp = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'B')
        {
            ans += (i - tmp);
            tmp++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
 
using namespace std;
 
#define mp make_pair
#define pb push_back
#define ll long long
 
#define maxN 400011
 
int n, i, ans;
int a[maxN], b[maxN], xoro, dif;
map<int, int> M, M_a, M_b, pp;
vector<int> vals;
 
vector<int> neg, poz;
vector<int> list[maxN];
bool us[maxN], any;
 
void no_sol() {
    printf("-1");
    exit(0);
}
 
void give_sol(int x) {
    printf("%d", x);
    exit(0);
}

void dfs(int node) {
    us[node] = true;
    
    for (auto to : list[node]) {
        any = true;
        if (!us[to]) dfs(to);
    }
    
}
 
int main()
{
  //  freopen("test.in","r",stdin);
 
    scanf("%d", &n);
    for (i = 1; i <= n; i++) scanf("%d", &a[i]), xoro ^= a[i], vals.pb(a[i]), M[a[i]]++;
    for (i = 1; i <= n; i++) scanf("%d", &b[i]), vals.pb(b[i]), M[b[i]]--, dif += (a[i] != b[i]);
 
    for (i = 1; i <= n; i++) {
        if (a[i] == b[i]) continue;
        M_a[a[i]]++;
        M_b[b[i]]++;
    }
 
    vals.pb(xoro);
    sort(vals.begin(), vals.end());
    vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
    
    for (i = 0; i < vals.size(); i++) pp[vals[i]] = i + 1;
 
    for (auto e : vals) {
        if (M[e] < -1 || M[e] > 1) no_sol();
        if (M[e] == -1)
            neg.pb(e);
        if (M[e] == 1)
            poz.pb(e);
    }
 
    if (neg.size() > 1) no_sol();
    if (poz.size() > 1) no_sol();
    if (neg.size() == 1)
        if (neg[0] != xoro)
            no_sol();
    
    n++;
    a[n] = xoro;
    for (i = 1; i < n; i++) b[n] ^= b[i];
    
    for (i = 1; i <= n; i++) {
        if (a[i] == b[i]) continue;
        list[pp[a[i]]].pb(pp[b[i]]);
        list[pp[b[i]]].pb(pp[a[i]]);
    }
    
    ans = dif;
    for (i = 1; i <= vals.size(); i++) {
        if (us[i]) continue;
        any = false;
        dfs(i);
        if (any) ans++;
        
        if (any == false && a[n] == b[n] && i == pp[a[n]])
            ans++;
    }
    
    cout << max(0, ans - 1);

 
    return 0;
}

Measured memory_bytes: 38004
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/



signed main() {
	int a[2];
	cin>>a[0]>>a[1];
	sort(a,a+2);
	if(a[0]==1&&a[1]==2)cout<<3<<endl;
	else if(a[0]==1&&a[1]==3)cout<<2<<endl;
	else cout<<1<<endl;
}


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

int main(void)
{
	int s;
	int h, m;
	
	cin >> s;
	
	h =  s / 3600;
	s %= 3600;
	m = s / 60;
	s %= 60;
	
	cout << h << ":" << m << ":" << s << endl;
	
	return (0);
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 1000000020
#define INF 1001001001

int main(int, char**)
{
  int x;
  cin >> x;

  cout << 10-x/200 << endl;

  return 0;
}


Measured memory_bytes: 3632
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

l = ni()

print("{:.12f}".format((l / 3) * (l / 3) * (l / 3)))

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

class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        if (n % 2 != 0)
        {
            Console.WriteLine("No");
            return;
        }
        var m = n / 2;
        for (int i = 0; i < m; i++)
        {
            if (s[i] != s[i + m])
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

constexpr ll INF = 1e15;

constexpr ll mod = 1e9 + 7;

template<typename T>
void cmpmax(T& reference, T value) {
	reference = max(reference, value);
}

template<typename T>
void cmpmin(T& reference, T value) {
	reference = min(reference, value);
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<bool>> grid(h, vector<bool>(w, false));
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) {
			grid[i][j] = s[j] == '.';
		}
	}
	vector<vector<ll>> path(h, vector<ll>(w, 0));
	path[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			if (!grid[i][j]) continue;
			{
				int nx = j + 1;
				if (nx < w) 
				if (grid[i][nx]) {
					path[i][nx] += path[i][j];
					path[i][nx] %= mod;
				}
			}
			{
				int ny = i + 1;
				if (ny < h) 
				if (grid[ny][j]) {
					path[ny][j] += path[i][j];
					path[ny][j] %= mod;
				}
			}
		}
	}
	cout << path[h - 1][w - 1] << endl;
	return 0;
}


Measured memory_bytes: 8320
h,w=map(int,input().split())
lists=[list(input()) for i in range(h)]
visited=[[False for i in range(w)] for j in range(h)]
from collections import deque

ans=0
dif=[(-1,0),(1,0),(0,-1),(0,1)]

def solve(i,j):
    global ans 
    ans=ans
    black=0
    white=0
    if visited[i][j]==False:
        if lists[i][j]=="#":
            black+=1
        else:
            white+=1
        visited[i][j]=True
        
    d=deque()
    e=deque()
    d.append((i,j))
    while d:
        while d:
            p=d.popleft()
            x,y=p
            color=lists[x][y]
            for que in dif:
                dx,dy=que
                if 0<=dx+x<h and 0<=dy+y<w:
                    if visited[dx+x][dy+y]==False and lists[dx+x][dy+y]!=color:
                        visited[dx+x][dy+y]=True
                        e.append((dx+x,dy+y))
                        if color=="#":
                            white+=1
                        else:
                            black+=1
        if e:
            d=e
            e=deque()
    ans+=(white)*(black)
flag=True
while flag:
    sub=False
    for i in range(h):
        for j in range(w):
            if visited[i][j]==False:
                solve(i,j)
                sub=True
    if sub==False:
        flag=False
print(ans)
              

Measured memory_bytes: 6128
#
A = input()
a_len = len(A)

answer = 0
for i in range(2**(a_len-1)):
  a_tmp = A
  total = 0
  bin_index = format(i, 'b').zfill(a_len-1)
  for j in range(a_len-1):
    a_tmp = list(a_tmp)
    if bin_index[j] == '1':
      a_tmp.insert(2*j+1, '+')
    else:
      a_tmp.insert(2*j+1, '#')
    a_tmp = ''.join(a_tmp)
  a_tmp = a_tmp.replace('#', '')
  a_tmp = map(int, a_tmp.split('+'))
  answer += sum(a_tmp)
print(str(answer))

Measured memory_bytes: 9212
use std::io;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

fn main(){
    let s_in = read_line();
    let mut s_out = String::new();
    
    let y2018 = "2018";

    for i in 0..s_in.len() {
        if i < 4 {
            s_out.push(y2018.chars().nth(i).unwrap());
        }
        else{
            s_out.push(s_in.chars().nth(i).unwrap());
        }
    }

    println!("{}", s_out);
    
}


Measured memory_bytes: 4352