akhauriyash/Code-Regression huggingface dataset:
/* while(!success_achieved())
      work_hard();

   code by:aman_ayush
  */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
    fast;
    int n,k;
    cin>>n>>k;
    str s;
    cin>>s;
    s[k-1]+=32;
    cout<<s;
     return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static bool isTargetDigit(ref string input)
        {
            var chars = input.ToCharArray();
            foreach (var c in chars)
            {
                if (char.IsDigit(c) == false)
                {
                    return false;
                }
            }
            return true;
        }
        static void Main(string[] args)
        {
            for (; ; )
            {
                var inputLine = Console.In.ReadLine();
                if (isTargetDigit(ref inputLine) == false)
                {
                    return;
                }
                if (inputLine == "0")
                {
                    break;
                }

                var chars = inputLine.ToCharArray();
                int sum = 0;

                foreach (int c in chars)
                {
                    sum += c - '0'; // 問題の意図が文字コードについても知ってほしいということに思える
                }

                Console.Out.WriteLine(sum);
            }
        }
    }
}



Measured memory_bytes: 15852
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class Ruiwa():
    def __init__(self, a):
        self.H = h = len(a)
        self.W = w = len(a[0])
        self.R = r = a
        for i in range(h):
            for j in range(1,w):
                r[i][j] += r[i][j-1]

        for i in range(1,h):
            for j in range(w):
                r[i][j] += r[i-1][j]

    def search(self, x1, y1, x2, y2):
        x2 -= 1
        y2 -= 1
        if x1 > x2 or y1 > y2:
            return 0

        r = self.R
        rr = r[y2][x2]
        if x1 > 0 and y1 > 0:
            return rr - r[y1-1][x2] - r[y2][x1-1] + r[y1-1][x1-1]
        if x1 > 0:
            rr -= r[y2][x1-1]
        if y1 > 0:
            rr -= r[y1-1][x2]

        return rr

def main():
    rr = []

    def f(h,w,s):
        a = [LI() for _ in range(h)]
        rui = Ruiwa(a)
        ss = rui.R[-1][-1] - s

        fm = {}
        def _f(x1,y1,x2,y2):
            key = (x1,y1,x2,y2)
            if key in fm:
                return fm[key]
            t = rui.search(x1,y1,x2,y2)
            if t < ss:
                fm[key] = (-1,-1)
                return (-1,-1)
            r = (1, t)
            for x in range(x1+1,x2):
                r1 = _f(x1,y1,x,y2)
                if r1[0] < 0:
                    continue
                r2 = _f(x,y1,x2,y2)
                if r2[0] < 0:
                    continue
                tr = (r1[0]+r2[0], min(r1[1], r2[1]))
                if r < tr:
                    r = tr
            for y in range(y1+1,y2):
                r1 = _f(x1,y,x2,y2)
                if r1[0] < 0:
                    continue
                r2 = _f(x1,y1,x2,y)
                if r2[0] < 0:
                    continue
                tr = (r1[0]+r2[0], min(r1[1], r2[1]))
                if r < tr:
                    r = tr
            fm[key] = r
            return r

        r,rs = _f(0,0,w,h)

        return '{} {}'.format(r, rs - ss)

    while 1:
        n,m,s = LI()
        if n == 0 and m == 0 and s == 0:
            break
        rr.append(f(n,m,s))
        # print('rr', rr[-1])

    return '\n'.join(map(str,rr))


print(main())



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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=1; i<n+1; i++){
    string t = to_string(i);
    if(t.size()%2!=0){ans++;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int sum=0;
  for (int i=N-K;i<N;i++){
    sum+=v[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    import collections
    counter = collections.Counter(S)
    answers = []
    maxcnt = 0
    for k, v in counter.items():
        if maxcnt < v:
            maxcnt = v
            answers = [k]
        elif maxcnt == v:
            answers.append(k)
    [print(s) for s in sorted(answers)]

if '__main__' == __name__:
    resolve()

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

using namespace std;

const int MAXN = 1e5 + 10;
int f[18][MAXN] , x[MAXN] , n , l , q;

int main(){
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> x[i];
	cin >> l;
	int nl = 1 , nr = 1 , sum = 0;
	while(nl <= n){
		while(nr < n && sum + x[nr + 1] - x[nr] <= l){
			sum += x[nr + 1] - x[nr];
			nr ++;
		}
		f[0][nl] = nr;
		sum -= (x[nl + 1] - x[nl]);
		nl ++;
	}
	f[0][n] = n + 1; f[0][n + 1] = n + 1;
	for(int i = 1 ; i < 18 ; ++ i)
		for(int j = 1 ; j <= n + 1 ; ++ j)
			f[i][j] = f[i - 1][f[i - 1][j]];
	cin >> q;
	for(int i = 1 ; i <= q ; ++ i){
		int x , y;
		cin >> x >> y;
		if(x > y) swap(x , y);
		int ans = 0;
		for(int j = 17 ; j >= 0 && x != y ; -- j){
			if(f[j][x] <= y){
				ans += (1 << j);
				x = f[j][x];
			}
		}
		cout << ans + (x != y) << endl;
	}
	return 0;
}

Measured memory_bytes: 8320
a, b, c = map(int, input().split())
f = a
s = b
t = c
if f > s:
 w = f
 f = s
 s = w
if s > t:
 x = s
 s = t
 t = x
if f > s:
 y = f
 f = s
 s = y
print(f, s, t)



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

int num_rev(int N){
    int reverse = 0;
    while (N > 0) {
        reverse = reverse * 10 + N % 10;
        N /= 10;
    }
    return reverse;
}

int last(int N){
    int last = 0;
    last = N % 10;
    return last;
}

int first(int N){
    int first = 0;
    while (N > 0) {
        first = N % 10;
        N /= 10;
    }
    return first;
}

unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int fact(int N){
    int ans = 1;
    for (size_t i = 1; i <= N; i++)
    {
        ans = ans * i;
    }
    return ans;
}
int Par(int n, int r){
    return fact(n)/fact(n-r);
}

int Con(int n, int r){
    return Par(n, r)/fact(r);
}

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    vector<vector<int>> C(10,vector<int>(10));
    for (size_t i = 1; i <= N; i++)
    {
        C[first(i)][last(i)]++;

    }

    for (size_t i = 1; i <= 9; i++)
    {
        for (size_t j = 1; j <= 9; j++)
        {
            ans += C[i][j] * C[j][i];
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  
  int W , H , x , y , r;
  
  cin >> W >> H >> x >> y >> r;
  
  if(x < r || y < r || H - r < y || W - r < x){
    
    cout << "No" << endl;
    
  }else{
    
    cout << "Yes" << endl;
  }   
}


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

using namespace std;

typedef pair <int, int> ii;

const int Maxn=105;

    int n,res;
    ii A[Maxn],B[Maxn];
    bool tk[Maxn];


int main(){

    scanf("%d",&n);

    for(int i=0;i<n;i++)
        scanf("%d %d",&A[i].first,&A[i].second);

    for(int i=0;i<n;i++)
        scanf("%d %d",&B[i].first,&B[i].second);

    sort(A,A+n);
    sort(B,B+n);

    for(int i=n-1;i>=0;i--){
        int bj=-1;
        for(int j=0;j<n;j++)
            if(A[i].first < B[j].first && A[i].second < B[j].second && !tk[j])
                if(bj==-1 || B[j].second < B[bj].second) bj=j;
        if(bj!=-1){
            res++;
            tk[bj]=true;
        }
    }

    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long MAX = 1000000000000000000;

int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 0; i < n; i++){
		long long a;
		cin >> a;
		if (a == 0) {ans = 0; break;}
		if (ans != -1 && MAX / a + 1 >= ans) ans *= a;
		else ans = -1;
		if (ans > MAX || ans < 0) {ans = -1;}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << nl;
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
const int MAXN = 100005;
ll mod=1000000007;


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  // cin>>t;
  while(t--){
    int n, m, k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    vector<ll> pre1(n+1,0), pre2(m+1,0);
    rep(i,0,n-1){
      cin>>a[i];
      pre1[i+1]+=pre1[i]+a[i];
    }
    rep(j,0,m-1){
      cin>>b[j];
      pre2[j+1]+=pre2[j]+b[j];
    }
    ll mx = 0;
    rep(i,0,n){
      if(k < pre1[i])continue;
      ll x = upper_bound(pre2.begin(), pre2.end(), k - pre1[i]) - pre2.begin();
      if(x == 0)continue;
      x--;
      if(pre1[i] + pre2[x] <= k){
        mx = max(mx, x + i);
      }
    }
    cout<<mx<<nl;
  }
  return 0;
}


Measured memory_bytes: 9484
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int dp[maxn],a[maxn],ans,n;

int main()
{
	n=read(); rep(i,1,n) a[i]=read(),dp[a[i]]=dp[a[i]-1]+1;
	rep(i,1,n) ans=max(ans,dp[i]); cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 5164
#include<iostream>
#include<cmath>
using namespace std;
int A[11][11];
int main() {
	int a,b,i,j,k,w,m=0,t;
	cin >> a >> b;
	for(i=1; i<=a; i++)
        for(j=1; j<=b; j++)
            cin >> A[i][j];

	for(i=1; i<a; i++) {
        for(j=i+1; j<=a; j++) {
			w = 0;
			for(k=1; k<=b; k++) {
                w += (A[i][k]-A[j][k]) * (A[i][k]-A[j][k]);
            }
			t = sqrt(w);
			if(t*t == w) m++;
		}
    }
	cout << m;
}


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


int main()
{
	int n, cnt = 0;

	cin >> n;
	
	vector<int> a(n), ans(n);

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

	for (int i = n; i > 0; i--) {
		int sum = 0;
		for (int j = i * 2; j <= n; j += i)
			sum += ans[j - 1];

		ans[i - 1] = (sum + a[i - 1]) % 2;
		cnt += ans[i - 1];
	}
	
	cout << cnt << endl;

	for (int i = 0; i < n; i++) {
		if(ans[i] == 1)
			cout << i + 1 << " ";
	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 2432
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

const int nax = 10000, maxx = 100;
int n, k, dp[nax][maxx][2];
string s;

int count(int ind, int c, int strict){
	if(ind==n){		
		// if(c%k==0)trace(c);
		return (c==0);
	}
	int &ans = dp[ind][c][strict];
	if(ans!=-1)return ans;
	ans=0;
	int st=0, e=9;
 	if(strict)e=s[ind]-'0';
 	for(int i=st; i<=e; i++){
 		if(i==e && strict)(ans += count(ind+1, (c+i)%k, 1))%=MOD;
 		else (ans += count(ind+1, (c+i)%k, 0))%=MOD;
 	}
 	return ans;
}

signed main() {
	tezz
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	cin >> s;
	n=s.length();
	cin >> k;
	ini(dp, -1);
	cout << (count(0, 0, 1)-1+MOD)%MOD << endl;
 
	return 0;
}  

Measured memory_bytes: 20196
#!/usr/bin/env python3

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

nns = len([x for x in a if x < 0])

ans = sum(abs(x) for x in a)
if nns % 2 != 0:
    m = min(abs(x) for x in a)
    ans -= m * 2

print(ans)


Measured memory_bytes: 14412
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N+2];
        arr[0] = 0;
        arr[N+1] = 0;
        int sumArr = 0;
        for(int i = 1; i <=N; i++) {
            arr[i] = sc.nextInt();
            sumArr += Math.abs(arr[i-1] - arr[i]);
        }
        sumArr += Math.abs(arr[N+1] - arr[N]);
        for(int i = 1; i <= N; i++) {
            int diff = Math.abs(arr[i] - arr[i-1]) + Math.abs(arr[i+1] - arr[i]) - Math.abs(arr[i+1] - arr[i-1]);
            System.out.println(sumArr - diff);
        }
    }
}


Measured memory_bytes: 59844
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; --i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;


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

    double r; cin >> r;
    Dcout(2*M_PI*r);

    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rep(i, n) for(int i = 0; i < n; i++)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

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

int a[20000] = {};

int sosuu() {
	a[0] = 0;
	int k = 1, z;
	for (int i = 2; i<100000 || k<10001; i++) {
		z = 0;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i%j == 0) {
				z++;
				break;
			}
		}
		if(z==0){
			a[k] = i;
			k++;
		}
	}
	return 0;
}

int main(){
	sosuu();
	int in;
	long int ans;
	while (cin >> in){
		if (in == 0) { break; }
		ans = 0;
		for(int i = 1; i<=in;i++){
			ans += a[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//c
int main(){

    int64_t a;
    double b;
    cin >> a >> b;
    b+=0.001;
    b*=100;
    int B=(int)b;

    cout << (int64_t)B*a/100 << endl;

}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n, m, r, ans = 1e9;
    vector<int> ord;
    vector< vector<int> > dst;
    cin >> n >> m >> r;
    ord.assign(r, 0);
    dst.assign(n, vector<int>(n, 1e9));
    for(int i=0;i<r;i++){
        cin >> ord[i];
        ord[i]--;
    }
    for(int i=0;i<n;i++){
        dst[i][i] = 0;
    }
    for(int i=0;i<m;i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dst[a][b] = dst[b][a] = c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dst[i][j] = min(dst[i][j], dst[i][k] + dst[k][j]);
            }
        }
    }
    sort(ord.begin(), ord.end());
    do{
        int scr = 0;
        for(int i=1;i<r;i++){
            scr += dst[ord[i-1]][ord[i]];
        }
        ans = min(ans, scr);
    }while(next_permutation(ord.begin(), ord.end()));
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> ans(N);
    rep(i, N) rep(j, i + 1, N) {
        int a = j - i;
        int b = abs(i - X) + 1 + abs(Y - j);
        ans[min(a, b)]++;
    }
    rep(i, 1, N) {
        output(ans[i]);
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  string S;
  cin >> S;
  if(S == "ABC") cout << "ARC" << endl;
  if(S == "ARC") cout << "ABC" << endl;
}

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

int main() {
  int d, n, m;
  while(cin >> d >> n >> m, d) {
    vector<int> store(n - 1), k(m);
    for(auto& i: store) cin >> i;
    for(auto& i: k) cin >> i;

    store.insert(begin(store), {0, d});
    sort(begin(store), end(store));

    int sum = 0;

    for(const auto& i: k) {
      auto candidate = upper_bound(begin(store), end(store), i);
      sum += min(*candidate - i, i - *(candidate - 1));
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  int sum=x;
  for (int i=0; i<n;i++){
    cin >> a[i];
    sum+=(d-1)/a[i]+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
/**
 *   Praveen Fulera    
**/

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;
#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>

const int mod = 1e9 + 7;
const int mex = 2e6 + 10;
int fact[mex+5], inv[mex+5];

int toPower(int a, int p){
    int res = 1;
    while (p){
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x){ 
    return toPower(x, mod - 2); 
}

void initialize(){
    inv[0] = Inv(fact[0]);fact[0] = inv[0] = 1;
    
    for(int i = 1; i < mex; i++){
        fact[i] = (ll(i) * fact[i - 1]) % mod;
        inv[i] = Inv(fact[i]);
    }
}

int C(int n, int k){
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fact[n]) * inv[k] % mod * inv[n - k] % mod;                 
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  initialize();
  int x1, x2, y1, y2, ans = 0;
  cin >> x1 >> y1 >> x2 >> y2;

  for(int i = x1; i <= x2; i++){
        ans += ((C(i+y2+1,i+1)-C(i+y1,i+1)+mod)%mod);
        ans %= mod;
  } 
  cout << ans << '\n';
}


Measured memory_bytes: 31488
N=gets.to_i
p=gets.chomp.split.map(&:to_i)
ans=0
1.upto(N-2) do |i|
  if (p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]) then
    ans+=1
  end
end
puts ans

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		if(n == 1){
			System.out.println(1);
			return;
		}

		int[] count = new int[1001];

		for(int i = 2; i <= n; i++){
			int tmp = i;
			int div = 2;

			while(tmp != 1){
//				System.out.println(tmp);
				if(tmp % div == 0){
					count[div]++;
					tmp /= div;
				}
				else {
					div++;
				}
			}
		}

		long result = 1;
		int mod = 1_000_000_000 + 7;

		for(int i = 2; i < count.length; i++){
			if(count[i] >= 1){
				result *= count[i] + 1;
				result %= mod;
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 22868
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

signed main(){
    int n;cin>>n;
    V<int> v(n);
    rep(i,n) cin>>v[i];
    int s,t;
    s=t=n/2;
    set<int> ss,tt;
    map<int,int> mp1,mp2;
    for(int i=0;i<n;i++){
        if(i%2!=0){
            ss.insert(v[i]);
            mp1[v[i]]++;
        }else{
            tt.insert(v[i]);
            mp2[v[i]]++;
        }
    }
    int fir=ss.size();
    int sec=tt.size();
    V<pair<int,int>> p(fir),q(sec);
    int b=0;
    for(auto a:ss){
        p[b]=make_pair(s-mp1[a],a);
        b++;
    }
    b=0;
    for(auto a:tt){
        q[b]=make_pair(t-mp2[a],a);
        b++;
    }
    sort(all(p));
    sort(all(q));
    int ans;
    if(p[0].sc!=q[0].sc) ans=p[0].ft+q[0].ft;
    else{
        if(fir==1&&sec==1) ans=n/2;
        else if(fir==1){
            ans=q[1].ft;
        }else if(sec==1){
            ans=p[1].ft;
        }else{
            ans=min(p[0].ft+q[1].ft,p[1].ft+q[0].ft);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10752
H,W,D = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
Q = int(input())

L = [0]*(H*W+1)
for i in range(H):
    for j in range(W):
        L[A[i][j]] = [i, j]
        
E = [0]*(H*W+1)
for i in range(D+1, H*W+1):
    E[i] = E[i-D] + abs(L[i][0]-L[i-D][0])+abs(L[i][1]-L[i-D][1])
    
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    ans = E[r] - E[l]
    print(ans)

Measured memory_bytes: 20668
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

N,M = map(int,input().split())
L = []
for i in range(N):
  tmp = list(map(int,input().split()))
  L.append(tmp[1:])
#print(L)

# 人(0~N-1)と言語(N~M-1)の間で二部グラフを作る
E = [set() for _ in range(N+M)]
for i in range(N):
  for l in L[i]:
    E[i].add(l+N-1)
    E[l+N-1].add(i)
#print(E)

# 人のノードすべてに到達可能であればYES
Visited = [0 for _ in range(N+M)]
def dfs(v):
  Visited[v] = 1
  for u in E[v]:
    if Visited[u] == 0:
      dfs(u)
dfs(0)
print('YES' if sum(Visited[:N]) == N else 'NO')


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

sosuu = []

def next_sosuu():
    if len(sosuu) == 0:
        sosuu.append(2)
        return 2
    if len(sosuu) == 1:
        sosuu.append(3)
        return 3
    curr = sosuu[-1] + 2

    while True:
        flag = True
        for s in sosuu:
            if curr % s == 0:
                flag = False
                break
        if flag:
            sosuu.append(curr)
            return curr
        curr += 2

results = []
while len(results) < N:
    n = next_sosuu()
    if n % 5 == 1:
        results.append(n)

txt = ""
for r in results:
    txt += str(r) + " "
txt = txt[0:-1]
print(txt)

Measured memory_bytes: 3064
// atcoder/abc055/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    lli mod = 1e9 + 7;
    lli x = 1;
    for (lli i = 0; i < n; ++i) {
      (x *= i + 1) %= mod;
    }
    cout << x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

struct UnionFind{
	vector<int> par;
	UnionFind(int n): par(n, -1){}
	void init(int n){
		par.assign(n, -1);
	}

	int root(int x){
		if(par[x]<0){
			return x;
		}else{
			return par[x] = root(par[x]);
		}
	}

	bool issame(int x, int y){
		return root(x)==root(y);
	}

	bool merge(int x, int y){
		x = root(x);
		y = root(y);
		if(x==y) return false;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x){
		return -par[root(x)];
	}
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);
  vector<int> frnum(n, 0);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    uf.merge(a - 1, b - 1);
    frnum[a - 1]++;
    frnum[b - 1]++;
  }

  vector<int> tmp;
  vector<vector<int>> bl(n, tmp);
  rep(i, k) {
    int c, d;
    cin >> c >> d;
    bl[c - 1].push_back(d - 1);
    bl[d - 1].push_back(c - 1);
  }

  rep(i, n) {
    int ans = uf.size(i) - frnum[i] - 1;
    int blsize = bl[i].size();
    rep(j, blsize) {
      if (uf.issame(i, bl[i][j])) {
        ans--;
      }
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

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

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int ans = H;
  vector<pair<int, int>> XY(N);
  for (int i=0; i<N; i++){
    cin >> XY[i].first >> XY[i].second;
  }
  sort(XY.begin(), XY.end(), [](const auto& a, const auto& b){return (a.first==b.first)? a.second < b.second : a.first < b.first;});
  int curX = 0;
  int posY = 0;
  bool flag = false;
  for (int i=0; i<N; i++){
    // cout << i << endl;
    if (curX < XY[i].first) {
      if (curX==0) posY--;
      posY += XY[i].first - curX;
      curX = XY[i].first;
    }
    if (XY[i].second <= posY) {
      flag = true;
      break;
    }
    if (XY[i].second == posY+1&&XY[i].first!=1) posY--;
  }
  if (flag) cout << curX-1 << endl;
  else cout << H << endl;
}


Measured memory_bytes: 1792
###最大値
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))

a.sort()
f.sort(reverse = True)

mx = max(a)*max(f)
mn = -1
while mx-mn>1:
    mid = (mx+mn)//2
    shugyo = 0
    for i in range(n):
        a_ = mid//f[i]
        shugyo += max(a[i]-a_,0)
    if shugyo<=k:
        mx = mid
    else:
        mn = mid

print(mx)



Measured memory_bytes: 119500
a,b=map(int,input().split())
ab=[str(i) for i in range(a,b+1)]

ans_list=[]
for j in range(len(ab)):
    if ab[j][0]==ab[j][4] and ab[j][1]==ab[j][3]:
        ans_list.append(ab[j])

print(len(ans_list))


Measured memory_bytes: 8728
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,k;
char s[maxn];
int main(){
	n=read(),k=read();
	scanf("%s",s+1);
	for(int i=2;i<n;i++){
		if(s[i-1]!=s[i]&&s[i+1]!=s[i]){
			s[i]=s[i-1];
			k--;
		}
		if(k==0)break;
	}
	if(k==0){
		int ans=0;
		for(int i=1;i<=n;i++){
			if(s[i]=='L'&&s[i-1]=='L')ans++;
			if(s[i]=='R'&&s[i+1]=='R')ans++;
		}
		printf("%d\n",ans);
		return 0;
	}
	int l=1,len=1;
	for(int i=2;i<=n;i++){
		if(s[i]!=s[i-1]){
			if(len%2==0){
				for(int j=l;j<=i-1;j++)
				s[j]=s[i];
				k--;
				if(k==0)break;
			}
			len++;
			l=i;
		}
	}
	if((len%2==0)&&(k!=0)){
		for(int j=l;j<=n;j++)
		s[j]=s[l-1];
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='L'&&s[i-1]=='L')ans++;
		if(s[i]=='R'&&s[i+1]=='R')ans++;
	}
	puts("");
	printf("%d\n",ans);
	return 0;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    int N;
    cin >> N;
    int num[30] = {0};

    rep(i, N) {
      string s;
      cin >> s;
      num[s[0]-'A']++;
    }

    string march_s = "MARCH";
    ll march[5];
    rep(i, 5) {
      march[i] = num[march_s[i]-'A'];
    }

    ll ans = 0;
    rep(i, 3) {
      REP(j, i+1, 4) {
        REP(k, j+1, 5) {
          ans += march[i] * march[j] * march[k];
        }
      }
    }

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


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,count=0,flag=0;
  cin>>n;
  vint a(n,0);
  rep(i,n){
    cin>>a[i];
  }
  while(true){
    count++;
    if(a[flag]==2){
      cout<<count<<'\n';
      break;
    }
    else{
      flag=a[flag]-1;
      if(count==n){
	cout<<-1<<'\n';
	break;
      }
    }
  }
  return(0);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    int now = 1;
    int res = 0;
    rep (i, n) {
        if (a[i] == now) {
            now++;
            continue;
        }
        res++;
    }
    if (res == n) cout << -1 << endl;
    else cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 1024
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>
#define ll long long int
#define l long int
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
	  start;
	  cout.precision(20);
	   int R;
	   cin >> R;
	   cout << 2*3.14159*R << endl;

	  return 0;
}


Measured memory_bytes: 3800
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        //var N = long.Parse(Console.ReadLine());
        var RGBN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var S = Console.ReadLine();
        long ans = 0;
        var R = RGBN[0];
        var G = RGBN[1];
        var B = RGBN[2];
        var N = RGBN[3];

        for (long i = 0; i <= N; i += R)
        {
            for (long j = 0;i + j <= N; j += G)
            {
                if ((N - i - j)%B == 0)
                {
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);

    }
        

    
}


Measured memory_bytes: 28240
#include <stdio.h>
#include <math.h>
double answer();
double searchY(double X);
double search(double X, double Y);

int n;
double x[10]; double y[10]; double l[10];

int main(void)
{
    while(1)
    {
        int i;
        scanf("%d", &n);
        if(n == 0) break;
        for(i = 0; i < n; i++)
        { scanf("%lf%lf%lf", &x[i], &y[i], &l[i]); }
        printf("%.6f\n", answer());
    }
    return 0;
}

double answer()
{
    int j;
    double l = -100.0, r = 100.0;
    double a, b;
    for(j = 50; j >= 0; j--)
    {
        a = (2*l + r) / 3;
        b = (l + 2*r) / 3;
        if(searchY(a) > searchY(b)) r = b; else l = a;
    }
    return sqrt(searchY(l));
}

double searchY(double X)
{
    int j;
    double l = -100.0, r = 100.0, a, b;
    for(j = 50; j >= 0; j--)
    {
        a = (2*l + r) / 3;
        b = (l + 2*r) / 3;
        if(search(X, a) > search(X, b)) r = b; else l = a;
    }
    return search(X, l);
}

double search(double X, double Y)
{
    int j;
    double t, s = 100000000;
    for(j = 0; j < n; j++)
    {
        t = l[j]*l[j] - (X-x[j])*(X-x[j]) - (Y-y[j])*(Y-y[j]);
        if(t < s) s = t;
    }
    return s;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define MAXIM 1000003

ll mod = 1e9 + 7;

void solve(){
    ll n;
    cin >> n;
    vll a(n),b(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    reverse(all(b));
    ll c = 0;
    vll ind;
    rep(i,0,n){
        if(a[i] == b[i]){
            c++;
            ind.pb(i);
        }
    }
    if(c == 0){
        cout << "Yes" << br;
        for(auto x:b) cout << x << " ";
        return;
    }
    ll l=1e9;
    ll r=0;
    rep(i,0,n){
        if(a[i] == a[ind[0]] || b[i] == b[ind[0]]){
            l = min(l,i);
            r = max(r,i);
        }
    }
    r++;
    if(l + n - r < c){
        cout << "No" << br;
        return;
    }
    cout << "Yes" << br;
    rep(i,0,l){
        if(c == 0) break;
        swap(b[i],b[ind[c - 1]]);
        c--;
    }
    rep(i,r,n){
        if(c == 0) break;
        swap(b[i],b[ind[c - 1]]);
        c--;
    }
    for(auto x:b) cout << x << " ";





}
	

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}	

Measured memory_bytes: 8436
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
const int N=2e5+100;
int a[N],b[N],c[N];
int fa[N];inline int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); }
int main()
{
	int n=gi(),i,m=0;map<int,int>tot;
	for (i=1;i<=n;i++) a[0]^=a[i]=gi();
	for (i=1;i<=n;i++) b[0]^=b[i]=gi();
	for (i=0;i<=n;i++) if (a[i]^b[i]) tot[c[m++]=a[i]]++,tot[c[m++]=b[i]]--;
	
	for (auto p:tot) if (p.second) return puts("-1"),0;

	sort(c,c+m);
	m=unique(c,c+m)-c;

	for (i=0;i<m;i++) fa[i]=i;
	int ans=m;
	for (i=1;i<=n;i++)
		if (a[i]^b[i]) {
			a[i]=lower_bound(c,c+m,a[i])-c;
			b[i]=lower_bound(c,c+m,b[i])-c;
			if (find(a[i])==find(b[i])) ans++;
			else fa[find(a[i])]=find(b[i]);
		}
	for (i=0;i<m;i++) if (c[i]==a[0]) ans--;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7808
/*
	Created by Faisal Ahmed
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	string str;
	
	cin >> str;
	
	string rev = str;
	
	reverse(rev.begin(), rev.end());
	
	if(rev != str){
		cout << "No" << endl;
		return 0;
	}
	
	int n = str.size();
	int d = (n - 1) / 2;
	
	str = "#" + str;
	
	string temp = "";
	for(int i = 1; i <= d; i++){
		temp += str[i];
	}
	
	rev = temp;
	
	reverse(rev.begin(), rev.end());
	
	if(rev != temp){
		cout << "No" << endl;
		return 0;
	}
	
	d = (n + 3) / 2;
	
	temp = "";
	for(int i = d; i <= n; i++){
		temp += str[i];
	}
	
	rev = temp;
	
	reverse(rev.begin(), rev.end());
	
	if(rev != temp){
		cout << "No" << endl;
		return 0;
	}
	
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
//3_2(1_1_A) ?????\?????????
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int printArray(int data[],int num){
	int i;
	for(i=0;i<num;i++){
		if(i!=0)printf(" ");
		printf("%d",data[i]);
	}
	printf("\n");
	return 0;
}

int main(){
	int data[100],n;
	int j,v;
	
	cin >> n;
	for(int i=0;i<n;i++)cin >> data[i];
	
	for(int i=0;i<n;i++){
		v=data[i];
		j=i-1;
		while(j>=0 && data[j]>v){
			data[j+1]=data[j];
			j--;
		}
		data[j+1]=v;
		printArray(data,n);
	}

	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;

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

int main(){
    int N;cin >> N;
    int A[N];
    int minv = INF, maxv = 0;
    rep(i, N){
        cin >> A[i];
    }
    sort(A, A + N);
    int ans = A[0];
    rep(i, N){
        ans = euclid(A[i], ans);
    }
    cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
using namespace std;
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; }
ll MOD = 1000000007;
ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
    ll N,M;
    cin >> N >> M;
    ll cs = M/2;
    if(cs <= N) cout << cs << endl;
    else
    {
        ll lestC = (M - N*2);
        ll makableScc = lestC/4;
        cout << N + makableScc << endl;
    }
}

Measured memory_bytes: 256
//前置き
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main(){
    // ========================================================
    string a, b;
    cin >> a >> b;
    cout << b << a << endl;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

int64_t getVal(int64_t d){
  int64_t ans = 1;
  for(int i=1;i<d;i++){
    ans *= 10;
  }
  return ans;
}



signed main() {
  int n;
  cin >> n;
  
  for(int i=1;i<=9;i++){
    if(n%i==0){
      if(n/i<=9){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
  
}




Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
		{
			long a = long.Parse(Console.ReadLine());
      		if (a==1) {
              Console.WriteLine(1);
              return;
            }
      		long i = 0;
      		while(a!=1){
              i++;
              a = a/2;
            }
      		Console.WriteLine((Math.Pow(2,i+1)-1).ToString());
		}
}

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

int main()
{
    int n, k, min = 1;
    cin >> n >> k;

    for (size_t i = 0; i < n; i++)
    {
        if (min * 2 < min + k)
        {
            min *= 2;
        }
        else
        {
            min += k;
        }
    }

    cout << min << endl;
}


Measured memory_bytes: 256
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def distanceTo(self, point):
        dist = math.fabs(self.x - point.x) + math.fabs(self.y - point.y)
        return dist

students = []
checkpoints = []

N, M = map(int, raw_input().split(" "))
for i in range(0, N):
    x, y = map(int, raw_input().split(" "))
    students.append(Point(x, y))

for i in range(0, M):
    x, y = map(int, raw_input().split(" "))
    checkpoints.append(Point(x, y))


for student in students:
    minDist = 1000000000
    minIndex = 0
    for i in range(0, M):
        dist = student.distanceTo(checkpoints[i])
        if dist < minDist:
            minDist = dist
            minIndex = i
    print minIndex + 1

Measured memory_bytes: 2696