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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    vector<char> res;
    for (Int i = 0; i < (Int)s.size(); i++) {
        if (s[i] == 'B') {
            if (not res.empty()) {
                res.pop_back();
            }
        } else {
            res.push_back(s[i]);
        }
    }
    for (Int i = 0; i < (Int)res.size(); i++) {
        cout << res[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fo(i,n)   for(i=0;i<n;i++)
#define mod       1000000007
using namespace std;

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif

	int n, x;
	cin >> n >> x;

	int a[n];
	int i;
	fo(i, n)
	cin >> a[i];
	int cnt = 0;
	sort(a, a + n);
	fo(i, n)
	{
		if (x < a[i])
			break;
		x -= a[i];
		cnt++;
	}
	if (x > 0 && cnt == n)
		cnt--;
	cout << cnt << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  ll n, x;
  cin >>n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  for(int i = 0 ;i < n - 1; ++i){
    int s = a[i] + a[i + 1];
    if(s > x) {
      ans += s - x;
      a[i + 1] = max(a[i + 1] - (s - x), 0LL);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    int n, k;
    cin >> n >> k;

    int a[10] = {0};
    int v;

    for (int i = 0; i < k; i++) {
        cin >> v;
        a[v] = 1;
    }

    int last, cur;
    bool keep;

    for (int start = n; start <= 100000; start++) {
        cur = start;
        keep = true;

        while (cur > 0) {
            last = cur % 10;
            if (a[last] == 1) {
                keep = false;
                break;
            } else {
                cur = (cur-last) / 10;
            }
        }

        if (keep) {
            cout << start << endl;
            break;
        }
    }
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3660
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		loop: while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] k = new int[n];
			Map<String, Integer>[] tbl = new Map[n];
			for (int i = 0; i < n; i++)
				tbl[i] = new HashMap<String, Integer>();
			Map<String, Integer> minPrice = new HashMap<String, Integer>();
			int[][] ad = new int[n + 1][n + 1];
			for (int i = 0; i < n; i++) {
				k[i] = scanner.nextInt();
				for (int j = 0; j < k[i]; j++) {
					String b = scanner.next();
					int p = scanner.nextInt();
					tbl[i].put(b, p);
					if (!minPrice.containsKey(b) || minPrice.get(b) > p)
						minPrice.put(b, p);
				}
			}
			int q = scanner.nextInt();
			String[] req = new String[q];
			for (int i = 0; i < q; i++)
				req[i] = scanner.next();
			int m = scanner.nextInt();
			for (int i = 0; i < m; i++) {
				int s = scanner.nextInt();
				int t = scanner.nextInt();
				int d = scanner.nextInt();
				ad[s][t] = ad[t][s] = d;
			}
			int sum = 0;
			for (int i = 0; i < q; i++) {
				if (!minPrice.containsKey(req[i])) {
					System.out.println("impossible");
					continue loop;
				}
				sum += minPrice.get(req[i]);
			}
			PriorityQueue<Pair> deque = new PriorityQueue<Pair>();
			int[][] dp = new int[n + 1][1 << q];
			for (int[] dp1 : dp)
				Arrays.fill(dp1, 1 << 20);
			dp[0][0] = 0;
			deque.offer(new Pair(0, 0, 0));
			int ans = 0;
			while (!deque.isEmpty()) {
				Pair pair = deque.poll();
				int c = pair.f;
				int cbit = pair.s;
				int nbit = cbit;
				int cost = pair.cost;
				if (c == 0 && nbit == (1 << q) - 1) {
					ans = cost;
					break;
				}
				if(dp[c][nbit]<cost)
					continue;
				dp[c][nbit] = cost;

				if (c > 0)
					for (int i = 0; i < q; i++) {
						if (tbl[c - 1].containsKey(req[i])
								&& tbl[c - 1].get(req[i]).equals(
										minPrice.get(req[i]))) {
							nbit |= 1 << i;
						}
					}
				for (int i = 0; i < n + 1; i++) {
					if (ad[c][i] == 0)
						continue;
					deque.offer(new Pair(i, nbit, cost + ad[c][i]));
				}
			}
			System.out.println(sum + " " + ans);
		}

	}

	class Pair implements Comparable<Pair> {
		int f, s, cost;

		public Pair(int f, int s, int cost) {
			super();
			this.f = f;
			this.s = s;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Pair [f=" + f + ", s=" + s + ", cost=" + cost + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return cost - o.cost;
		}

	}
}

Measured memory_bytes: 28404
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int dp[100010];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        dp[i] = 100000;
    }
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    dp[3] = abs(a[1] - a[3]);
    for(int i = 4; i <= n; i++)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]),
                    dp[i-2] + abs(a[i] - a[i-2]));
    }
    printf("%d\n", dp[n]);
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
int a1,a2,a3,a4,a5,a6,a7,a8,a9;
int main()
{
	a1=read(),a2=read(),a3=read(),a4=read(),a5=read(),a6=read(),a7=read(),a8=read(),a9=read();
	if(a1+a2+a3+a4+a5+a6+a7+a8+a9!=(a1+a5+a9)*3) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

A,B = map(int,input().split())

A_prime = set(prime_decomposition(A))
B_prime = set(prime_decomposition(B))
union = A_prime & B_prime
print(len(union)+1)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;
#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define FOR(I,A,B) for(ll I=(A);I<(B);++I)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

int main() {
   ll A, B;
   cin >> A >> B;
   cout << max({A + A-1, B+B-1, A+B}) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
          int H,W,i,j,k;

          for(k=0;;k++)
          {
                    scanf("%d %d",&H,&W);
           if(H==0&&W==0)
                    {
                              break;
                    }
          for(i=0;i<H;i++)
          {
                    for(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: 2096
#include<bits/stdc++.h>
using namespace std;
 map<string,int> mp;
int main()
{
    int n;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

void show(int A[],int n){
	int i;
	for(i=1;i<=n;i++){
		if(i>1)      
		printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}
int main(void){
	int n,i,j,p;
	int A[100+1];
	scanf("%d",&n); 
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	show(A,n);
	for(j=2;j<=n;j++){
		p=A[j];
		i=j-1;
		while(i>0 && A[i]>p){
			A[i+1]=A[i];
			i--;
		}
		A[i+1]=p; 
		show(A,n); 
	}
	return 0;
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////
#define N 10
ll n,x,y,z;
ll l[N];

ll dfs(ll p,ll a,ll b,ll c){
    if(p==n){
        if(a*b*c==0)return inf;
        ll res=abs(a-x)+abs(b-y)+abs(c-z)-30;
        return res;
    }
    ll res=inf;
    Min(res,dfs(p+1,a,b,c));
    Min(res,dfs(p+1,a+l[p],b,c)+10);
    Min(res,dfs(p+1,a,b+l[p],c)+10);
    Min(res,dfs(p+1,a,b,c+l[p])+10);
    return res;
}

int main(){fastio;
    cin>>n>>x>>y>>z;
    rep(i,0,n-1)cin>>l[i];
    cout<<dfs(0,0,0,0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;



int main()
{
    int a,b;
    cin>>a>>b;
    if (a >= 13) {
        cout<<b<<endl;
    } else if (a >= 6) {
        cout<<b / 2<<endl;
    } else
        cout<<0<<endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long K = GetLong();
		var a = GetLongs(N);
		var ans = new List<string>();
		for(long i = K; i < N; i++)
			ans.Add((a[i] > a[i - K]) ? "Yes" : "No");

		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 53356
#include<cstdio>

int a,b,i,j,n;

int main(){
    scanf("%d %d",&a,&b);
    if(a<=0&&b>=0){
        printf("Zero\n");
    }
    else if(a<0&&(b-a+1)%2==1){
        printf("Negative\n");
    }
    else{
        printf("Positive\n");
    }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }

    let mut v = vec![0; n + 1];
    for i in 0..n {
        v[p[i]] = v[p[i] - 1] + 1;
    }
    println!("{}", n - v.iter().max().unwrap());
}


Measured memory_bytes: 8444
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w;
vector<vector<char>> c;

int calc(int x) {
    vector<vector<char>> d(2, vector<char>(h));
    rep(i, h) {
        d[0][i] = c[i][x], d[1][i] = c[i][x + 1];
    }
    vector<vector<int>> e(h + 1, vector<int>(h + 1, 0));
    for(int i = 0; i <= h; ++i) {
        for(int j = 0; j <= h; ++j) {
            if(j + 1 <= h && j + 1 + i <= h) e[j + 1][j + 1 + i] = e[j][j + i] + (d[0][j] == d[1][j + i]);
        }
    }
    for(int i = 0; i <= h; ++i) {
        for(int j = 0; j <= h; ++j) {
            if(j + 1 <= h && j + 1 + i <= h) e[j + 1 + i][j + 1] = e[j + i][j] + (d[0][j + i] == d[1][j]);
        }
    }
    vector<vector<int>> dp(h + 1, vector<int>(h + 1, INF));
    dp[h][h] = 0;
    for(int i = h; i >= 0; --i) {
        for(int j = h; j >= 0; --j) {
            if(i + 1 <= h) chmin(dp[i][j], dp[i + 1][j] + e[i + 1][j]);
            if(j + 1 <= h) chmin(dp[i][j], dp[i][j + 1] + e[i][j + 1]);
        }
    }
    return dp[0][0];
}

void solve() {
	cin >> h >> w;
    c.assign(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(i, w - 1) {
        ans += calc(i);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1864
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int kaijou(int n){
    if(n==1) return 1;
    return n*kaijou(n-1);
}

int main(){
    int N;
    cin >> N;
    int x[10],y[10];
    for(int i=1;i<=N;i++){
        cin >> x[i] >> y[i];
    }

    vector<int> v(N);
    for(int i=0;i<N;i++) v[i]=i+1;

    double total=0;

    for(int i=0;i<kaijou(N);i++){
        double sum=0;
        for(int j=0;j<N-1;j++){
            sum += sqrt( (x[v[j]]-x[v[j+1]])*(x[v[j]]-x[v[j+1]]) + (y[v[j]]-y[v[j+1]])*(y[v[j]]-y[v[j+1]]) );
        }
        total += sum;
        next_permutation(v.begin(),v.end());
    }

    double mean=total/kaijou(N);

    printf("%lf",mean);
    printf("\n");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = n / (a+b);
    ans *= a;
    ans += min(n%(a+b), a);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n];
  string check = "APPROVED";
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
      	check = "DENIED";
      }
    }
  }
  cout << check << endl;
  return 0;
}
  


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

int main(){
  int n, k,q;
  cin >> n >> k >> q;
  vector<int> a (n,-q);
  vector<int> nn(n,k);
  for(int i = 0; i < q; i++){
    int b;
    cin >> b;
    a[b-1]++;
  }
  for(int i = 0; i < n; i++){
    if(nn[i]+a[i] < 1){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define int ll int
#define OOK order_of_key  //no of elements less than
#define FBO find_by_order //iterator pointing kth element;indexing starts from 0
#define CK3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define CK4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
   int a,b;
   cin>>a>>b;
  for(int i=0;i<=10000;i++)
  {
      if((i*8)/100==a&&(i*10)/100==b)
      {
          cout<<i<<endl;return 0;
      }
  }
  cout<<-1<<endl;
}


return 0;
}





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

N = int(input())
S = input()
Q = int(input())
k = list(map(int, input().split()))

DM_total = [(0,0,0)]
C_list = []

for i in range(N):
	if S[i] == "D":
		DM_total.append((DM_total[-1][0] + 1, DM_total[-1][1], DM_total[-1][2]))
	elif S[i] == "M":
		DM_total.append((DM_total[-1][0], DM_total[-1][1] + 1, DM_total[-1][2] + DM_total[-1][0]))
	else:
		DM_total.append(DM_total[-1])
	if S[i] == "C":
		C_list.append(i)


for q in range(Q):
	ans = 0
	for c in C_list:
		if k[q] > c:
			ans += DM_total[c + 1][2]
		else:
			ans += DM_total[c + 1][2] - DM_total[c + 1 - k[q]][2]
			ans -= DM_total[c + 1 - k[q]][0] * (DM_total[c + 1][1] - DM_total[c + 1 - k[q]][1])

	print(ans)


Measured memory_bytes: 143060
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    int i = 1;
    int x;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    while(++i <= n){
        x = i;
        if(x % 3 == 0){
            System.out.print(" " + i);
            continue;
        }
        while(true){
            if(x % 10 == 3){
                System.out.print(" " + i);
                break;
            }else{
                x /= 10;
                if(x != 0) continue;
                else break;
            }
        }

    }
    System.out.print("\n");
    }
}

Measured memory_bytes: 24308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

vvll pl(51, vll(2501, 0));
vvll mn(51, vll(2501, 0));


int main(){
    ll N, A;
    cin >> N >> A;
    vll x(N), px, mx;
    int zerocnt = 0;
    rep(i, N){
        cin >> x[i];
        x[i] -= A;
        if(x[i] > 0){
            px.emplace_back(x[i]);
        }else if(x[i] < 0){
            mx.emplace_back(-x[i]);
        }else{
            zerocnt++;
        }
    }
    ll zeroptn = 1LL << zerocnt;
    pl[0][0] = 1;
    mn[0][0] = 1;
    rep(i, SZ(px)){
        rep(j, 2501){
            pl[i+1][j] += pl[i][j];
            if(j >= px[i]) pl[i+1][j] += pl[i][j-px[i]];
        }
    }
    rep(i, SZ(mx)){
        rep(j, 2501){
            mn[i+1][j] += mn[i][j];
            if(j >= mx[i]) mn[i+1][j] += mn[i][j-mx[i]];
        }
    }
    ll ans = zeroptn - 1;
    if(!px.empty() && !mx.empty()){
        rea(i, 1, 2501){
            ans += pl[SZ(px)][i] * mn[SZ(mx)][i] * zeroptn;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2304
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/arc071/editorial.pdf
・各辺を加減する回数には規則性があるので、ループを1つ減らせる。
"""

import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)

MOD = 10 ** 9 + 7

N, M = map(int, input().split())
xN = list(map(int, input().split()))
yM = list(map(int, input().split()))

# 辺の長さの合計を出す
x_sm = 0
for i in range(N):
    x_sm = (x_sm + i * xN[i] - (N-i-1) * xN[i]) % MOD
y_sm = 0
for i in range(M):
    y_sm = (y_sm + i * yM[i] - (M-i-1) * yM[i]) % MOD

print(x_sm * y_sm % MOD)


Measured memory_bytes: 18624
from collections import Counter
from math import ceil

n = int(input())
s = input()

c = Counter(s)
res = c['R'] * c['G'] * c['B']
for i in range(n-2):
    for j in range(i+1, i+ceil((n-i)/2)):
        k = j + j - i
        if len({s[i], s[j], s[k]}) == 3:
            res -= 1

print(res)


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

int main(){
    long N;
    cin >> N;
    if(N > 4){
        if(N & 1){
            cout << 2 * (N - 1) << "\n";
            cout << "1 " << N << "\n" << N - 1 << " " << N << "\n";
            cout << N / 2 << " " << N << "\n" << (N + 1) / 2 << " " << N << "\n";
            for(long i = 1; i * 2 + 1 != N; ++i){
                cout << i << " " << i + 1 << "\n";
                cout << i << " " << N - (i + 1) << "\n";
                cout << N - i << " " << i + 1 << "\n";
                cout << N - i << " " << N - (i + 1) << endl;
            }
        }else{
            cout << 2 * N << "\n";
            cout << "1 " << N / 2 << "\n1 " << (N + 2) / 2 << "\n";
            cout << N << " " << N / 2 << "\n" << N << " " << (N + 2) / 2 << "\n";
            for(long i = 1; i * 2 != N; ++i){
                cout << i << " " << i + 1 << "\n";
                cout << i << " " << N - i << "\n";
                cout << N - i + 1 << " " << i + 1 << "\n";
                cout << N - i + 1 << " " << N - i << endl;
            }
        }
    }else if(N == 3){
        puts("2\n1 3\n2 3");
    }else if(N == 4){
        puts("4\n1 2\n2 4\n3 4\n3 1");
    }
}

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

namespace ABC
{
    class ABC173A
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var N = RI();
            if ((N % 1000) == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1000 - (N % 1000));
            }


#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


Measured memory_bytes: 27236
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  string s;
  cin >> s;
  bool a = true;
  if(s.size() % 2 == 0) {
    a = false;
  }
  int mid = (s.size()-1) / 2;
  rep(i, mid) {
    if(s[i] != s[i+mid+1]) {
      a = false;
      break;
    }
  }

  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int L[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%d", &L[i]);
  }
  int big=0;
  int sum=0;
  for (size_t i = 0; i < N; i++) {
    if (big<L[i]) {
      big=L[i];
    }
    sum=sum+L[i];
  }
  sum=sum-big;
  if (sum>big) {
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()

typedef pair<int, int> P;

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; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, Q, M;
    while( cin >> N >> Q, N | Q ){
        map<int, int> date;
        REP( i, N ){
            cin >> M;
            REP( j, M ){
                int d; cin >> d;
                date[d]++;
            }
        }

        int ok = 0, ans = 0;
        for( auto v : date ){
            if( v.second >= Q && chmax( ok, v.second ) ){
                ans = v.first;
            }
        }

        cout << ans << endl;
    }
}



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

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

int main(){
char a[3][3];
rep(i,3){ rep(j,3){
char tmp;
cin >> tmp;
if(i==j) cout<<tmp;
}}
cout <<endl;


return 0;
}

Measured memory_bytes: 256
# 高橋君は 2 で割れる数が好きです。
# 正整数 N が与えられるので、1 以上 N 以下の整数のうち、
# 最も 2 で割れる回数が多いものを求めてください。
# 答えは必ず 1 つに定まります。
# なお、2 で割っていき、何回あまりが出ずに割れるかを、
# 2 で割れる回数と呼ぶことにします。
# 例えば
#   6 ならば、6 -> 3で、1 回 2 で割れます。
#   8 ならば、8 -> 4 -> 2 -> 1で、3 回 2 で割れます。
#   3 ならば、0 回 2 で割れます。

n = gets.chomp.to_i

break_count_top = 0
break_count_top_num = 1

(1..n).each do |num|
  break_count = 0
  num_sandbox = num
  
  loop do
    if num_sandbox % 2 == 0
      break_count += 1
      num_sandbox /= 2
    else
      break
    end
  end
  
  if break_count > break_count_top
    break_count_top = break_count
    break_count_top_num = num
  end
end

puts break_count_top_num

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l,s,c;
    cin>>n;
    long long arr[n+10];
    cin>>arr[0];
    k=arr[0];
    s=-10000;
    c=0;
    for(i=1;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]<=k)
        {
            k=arr[i];
            c++;
        }
        else if(arr[i]>k)
        {
            if(c>s)
            {
                s=c;
            }
            c=0;
            k=arr[i];
        }

    }
    if(c>s)
    {
        s=c;
    }

    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1024
"use strict"
function main(arg) {
    let [X,N] = arg.trim().split("\n")[0].split(" ").map(Number)
    let P = []
    // console.log(arg.trim().split("\n").length)
    if (arg.trim().split("\n").length > 1) {
        P = arg.trim().split("\n")[1].split(" ").map(Number)
    }
    const range = 100 + 1
    let minValue = 1000
    let minKey = 1
    for (let i = 0; i <= range; i++) {
        if (P.includes(i)) {
            continue
        }
        let a = Math.abs(i-X)
        // console.log([i,a])
        if (a < minValue) {
            minKey = i
            minValue = a
        }
    }
    
    console.log(minKey)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

string solve(string S)
{
    if (S[0] != 'A')
        return "WA";
    int n = 0;
    FOR(i, S.length(), 1)
    {
        if (S[i] == 'C')
        {
            if (i == 1 || i == S.length() - 1)
                return "WA";
            n++;
            continue;
        }

        if (S[i] - 'a' < 0 || S[i] - 'a' > 26)
            return "WA";
    }
    return n == 1 ? "AC" : "WA";
}

int main()
{
    string S;
    cin >> S;
    cout << solve(S) << endl;
    return 0;
}

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


int main()
{
	char p[]={'A','T','G','C'};
	int ind=0,ans=0,mx=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		for(int j=0;j<4;j++)
		{
//			cout<<s[i]<<" "<<p[j]<<'\n';
			if(s[i]==p[j])
			{
//				cout<<"ATCODER "<<ans<<'\n';
				ans++;
				goto here;
			}
		}
		mx=max(mx,ans);
		ans=0;
		here:;
	}
	mx=max(mx,ans);
	cout<<mx<<'\n';
}

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

int main(){
  int N;
  cin >> N;
  cout << "ABC" + to_string(N) << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n,s;
long long a[300100];
int main(){
    cin>>n;
	for(int i=1; i<=n; i++){
		cin>>a[i];
	}
	long long suma=0,sumb=0,j=0,cnt=0;
	for(int i=1; i<=n; i++){
		while(j+1<=n&&((suma^a[j+1])==(sumb+a[j+1]))){
			sumb+=a[j+1];
			suma^=a[j+1];
			j++;
		}
		if(suma==sumb)
		  cnt+=j-i+1;
		suma^=a[i];
		sumb-=a[i];
	}
    cout<<cnt<<endl;
	return 0;
}
// 当a^b<a+b时，说明a跟b的二进制有重复，那么后面不管再异或多少，a^b^.. <a+b+...
// ^的优先级比==低！！！！！！要加括号！！！！maya,卡了好久
//还是尺取法，枚举左端点，同时移动右端点




Measured memory_bytes: 1792
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll 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; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num%2 == 0) return false;
  
  for (int i = 3; i*i <= num; i+=2){
    if (num%i == 0){
      return false;
    }
  }
  return true;
}


int Is_2017_like[101000];
int ruiseki[101000];

int main(void) {
  int Q; cin >> Q;
  for (int i = 1; i <= 100000; i+=2){
    if (IsPrime(i) && IsPrime((i+1)/2)) Is_2017_like[i] = 1;
  }
  for (int i = 1; i <= 100000; i++){
    ruiseki[i] += ruiseki[i-1] + Is_2017_like[i];
  }
  
  rep(q,Q){
    int l,r; cin >> l >> r;
    cout << ruiseki[r] - ruiseki[l-1] << "\n";
  }
  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

struct UF {
	vector<int> par, rank, sz;
	
	void init(int n){
		par = rank = vector<int>(n, 0);
		sz = vector<int>(n, 1);
		for(int i = 0; i < n; i++){
			par[i] = i;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	int size(int x){
		return sz[find(x)];
	}
	
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}else{
			par[y] = par[x];
			if(rank[x] == rank[y]) rank[y]++;
			sz[x] += sz[y];
		}
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

map<ll, ll> mk_comp(const vector<P> &x){
	map<ll, ll> dc;
	vector<ll> y; y.reserve(x.size()*2);
	for(auto p: x){
		y.pb(p.fst);
		y.pb(p.snd);
	}
	sort(all(y)); UNIQUE(y);
	rep(i, y.size()) dc[y[i]] = i;
	return dc;
}

int main(){
	int n;
	cin>>n;
	vector<ll> a[2];
	rep(i, 2) a[i] = vector<ll>(n+1, 0);
	rep(i, 2) rep(j, n) cin>>a[i][j];
	rep(i, 2) rep(j, n) a[i][n] ^= a[i][j];



	//auto dc = mk_comp(a[0]);
	//rep(i, 2) rep(j, n) a[i][j] = dc[a[i][j]];

	vector<P> v; v.reserve(n+1);
	rep(i, n+1) if(i==n||a[0][i]!=a[1][i]) v.pb(P(a[1][i], a[0][i]));
	auto dc = mk_comp(v);
	for(auto &p: v) p = P(dc[p.fst], dc[p.snd]);

	ll res = v.size();
	if(a[0][n]==a[1][n]) res--;
	else res--;
	//cerr<<res<<endl;
	rep(i, 2) sort(all(a[i]));
	if(a[0]!=a[1]){
		cout<<-1<<endl;
		return 0;
	}
	//for(auto x: v) cerr<<x.fst<<" "<<x.snd<<endl;
	//cerr<<"A"<<endl;
	UF uf;
	uf.init(dc.size());
	for(auto x: v) uf.unite(x.fst, x.snd);
	rep(i, dc.size()){
		if(uf.find(i)==i) res++;
		//cerr<<i<<" "<<uf.find(i)<<endl;
	}
	if(!v.empty()) res--;
	chmax(res, 0LL);
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 11748
import java.util.Scanner;
     
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		if (A==B) {
    			System.out.println("Draw");
    		} else if (A==1&&B==13) {
    			System.out.println("Alice");
    		} else if (A==13&&B==1) {
    			System.out.println("Bob");
    		} else if (A<B) {
    			System.out.println("Bob");
    		} else {
    			System.out.println("Alice");
    		}
    	}
    }

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <algorithm>
#include <set>
using namespace std;
long long fac[2800100], finv[2800100], inv[2800100]; 
long long MOD = 998244353; 
int MAX = 2800050; 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() { 
	long long int N, M; cin >> N >> M; COMinit();
	long long int ALL = COM(N + M * 3 - 1, N - 1); 
	long long int impo = 0; 
	for(int i = 0; i < M; i++){
		long long int tmp = COM(N + i - 2, i); 
		impo += tmp; impo %= MOD; 
	}
	impo *= N; impo %= MOD;
	long long int impo2 = 0; 
	for(int i = 0; i < M; i++){
		long long int tmp = (COM(N + i - 1, i) * COM(N, 3 * M - i * 2)) % MOD; 
		impo2 += tmp; impo2 %= MOD; 
	}
	cout << (MOD * 2 + ALL - impo - impo2) % MOD << endl; 
}

Measured memory_bytes: 65920
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 300000
#define debug cout << "asfasf" << endl;
#define READ freopen("input.txt", "r", stdin)
#define PRINT freopen("output.txt", "w", stdout);
#define MOD 1e7
#define print(a, b) printf("Case %d: %d\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}
/// string to INT
int convert_number(string s)
{
   int n;
   stringstream(s) >> n;
   return n;

   // int v=atoi(ss.c_str());
   // atoi is better than this function in case of complexity
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;
   ll n;
   cin >> n;

   if (n < 1000)
      cout << (1000 - n) << endl;

   else
   {
      ll m = 1000, i = 1;
      while (m < n)
      
         m+=1000;
        
      

      cout << (m - n) << endl;
   }

   return 0;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

signed main()
{
    int R, C; cin >> R >> C;

    if (R == 1 or C == 1) {
        if (C == 1) swap(R, C);

        // R == 1
        if (C == 1) cout << 1 << endl;
        if (C == 2) cout << 0 << endl;
        if (C > 2) cout << C - 2 << endl;
        return 0;
    } 

    cout << R * C - 2 * R - 2 * C + 4 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int H,W;
	scanf("%d %d",&H,&W);

	int table[H][W];

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++)scanf("%d",&table[row][col]);
	}

	int ans = BIG_NUM,tmp_sum;

	for(int tate = 0; tate < H; tate++){
		for(int yoko = 0; yoko < W; yoko++){
			tmp_sum = 0;
			for(int row = 0; row < H; row++){
				for(int col = 0; col < W; col++){
					tmp_sum += table[row][col]*min(abs(row-tate),abs(col-yoko));
				}
			}
			ans = min(ans,tmp_sum);
		}
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 3204