akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main(){

    input!{
        x: i64,
        n: i64,
        p: [i64;n],
    }

    if n == 0 {
        println!("{}", x);
        return;
    }
    if n==100 && x <=50 {
        println!("0");
        return;
    }
    if n==100 && x > 50 {
        println!("101");
        return;
    }
    let mut min_abs = 200;
    let mut value = 0;
    let mut flag: bool = false;
    for i in 1..102 {
        for &j in &p {
            if i == j {
                flag = true;
            }
        }
        if flag==false{
            let mut tmp = (x-i).abs();
            if tmp <= min_abs {
                min_abs = tmp;
                value = i;
            }
        } else {
            flag = false;
        }
    }

    for i in p {
        if i==x-(value-x) {
            println!("{}", value);
            return;
        }
    }

    println!("{}", x-(value-x));
    //println!("{}", value);

}

Measured memory_bytes: 2176
ARG_H, ARG_W = gets.split.map(&:to_i)
map = Array.new(ARG_H+2)
(ARG_H+2).times do |i|
  if i == 0 || i == ARG_H+1
    map[i] = Array.new(ARG_W+2, false)
    next
  end
  line = Array.new(ARG_W+2)
  line[0] = false
  line[ARG_W+1] = false
  str = gets.chomp.split('')
  j = 1
  str.each do |chr|
    line[j] = chr == '#' ? false : true
    j+=1
  end
  map[i] = line
end

dxylist = [[0,1], [0,-1], [1,0], [-1,0]]
start_list = []
for start_h in 1..ARG_H do
  for start_w in 1..ARG_W do
    next unless map[start_h][start_w]
    start_list.push([start_h, start_w])
  end
end
max_distance=0
start_list.each do |start|
  q = [[start[0], start[1], 0]]
  visit = Array.new(ARG_H+2){Array.new(ARG_W+2)}
  visit[start[0]][start[1]] = true
  while(qq=q.shift) do
    if qq[2] > max_distance
      max_distance = qq[2]
    end
    dxylist.each do |dxy|
      h, w = qq[0]+dxy[0], qq[1]+dxy[1]
      next unless map[h][w]
      next if visit[h][w]
      visit[h][w] = true
      q.push([h,w, qq[2]+1])
    end
  end
end

puts max_distance

Measured memory_bytes: 2044
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <math.h>
using namespace std;
string s;
int sum=0;
 int main()
{
    cin >> s;
    for(int i=0; i<s.length(); i++) {
        sum+= int(s[i] - '0');
    }
    if(sum % 9 == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3700
#include <cstdio>
    #include <cmath>
     
    int main(void){
      long long a, b, c;
      scanf("%ld %ld %ld", &a, &b, &c);
      
      if(2*sqrtl(a*b) < c-a-b){
        printf("Yes");
      }else{
        printf("No");
      }
      
      
      return 0;
    }

Measured memory_bytes: 128
from math import gcd,sqrt,floor
a,b = map(int,input().split())
c = gcd(a,b)
x = []
for i in range(1,floor(sqrt(c))+1):
    if c % i == 0:
        x.append(i)
        x.append(c//i)
x.sort()
y = []
i = 1
while c > 1 and i < len(x):
    if c % x[i] == 0:
        y.append(x[i])
        c = c // x[i]
    else:
        i += 1
print(len(set(y))+1)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,a;
	cin >> h >> a;
	cout << ceil(ld(h)/ld(a)) << endl;
} 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1LL<<60;

struct edge {
  int from, to, cost;
};

vector<edge> es;
vector<vector<int>> g1(2510);
vector<vector<int>> gn(2510);
vector<bool> r1(2510, false);
vector<bool> rn(2510, false);

void dfs(int s)
{
  if (r1[s]) return;
  r1[s] = true;
  for (auto v:g1[s]) dfs(v);
}

void rdfs(int s)
{
  if (rn[s]) return;
  rn[s] = true;
  for (auto v:gn[s]) rdfs(v);
}

int main()
{
  int n, m, p; cin >> n >> m >> p;
  rep(i, m) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    es.push_back(edge{a, b, p-c});
    g1[a].push_back(b);
    gn[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);

  if (!(r1[n-1]&&rn[0])) {
    cout << -1 << endl;
    return 0;
  }

  vector<ll> d(n, INF);
  d[0] = 0;
  bool upd = true;
  int step = 0;
  while (upd) {
    upd = false;
    for (int j=0; j<(int)(es.size()); j++) {
      edge e = es[j];
      if (!(r1[e.from]&&rn[e.from]) || !(r1[e.to]&&rn[e.to])) continue;
      if (d[e.from] == INF) continue;
      if (d[e.to] > d[e.from]+e.cost) {
        upd = true;
        d[e.to] = min(d[e.to], d[e.from]+e.cost);
      }
    }
    step++;
    if (step > n) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << max(0LL, -d[n-1]) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int D = 0, N = 0;
    long long ans = 1;
    cin >> D >> N;

    if(N==100){
        N = 101;
    }

    if(D==0){
        ans = N;
    }else if(D==1){ 
        ans=100*N;
    }else{
        ans = 10000 * N;
    }

    cout << ans << endl;
}

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

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static long[][] C = new long[51][51];

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	int A = Integer.parseInt(scan.next());
	int B = Integer.parseInt(scan.next());
	
	long[] v = new long[N];
	for (int i = 0; i < N; i++) {
	    v[i] = Long.parseLong(scan.next());
	}
	Arrays.sort(v);
	for (int i = 0; i < N/2; i++) {
	    long tmp = v[i];
	    v[i] = v[N-1-i];
	    v[N-1-i] = tmp;
	}
	
	long[] sum = new long[N];
	sum[0] = v[0];
	for (int i = 1; i < N; i++) {
	    sum[i] = sum[i-1] + v[i];
	}

	double max = sum[A-1] / (double)A;
	long count = 0;
	int X = 0;
	for (int i = 0; i < N; i++) {
	    if(v[A-1] == v[i]) X++;
	}
	if(v[0] != v[A-1]) {
	    int Y = 0;
	    for (int i = 0; i < A; i++) {
		if(v[i] == v[A-1]) {
		    Y++;
		}
	    }
	    count = combination(X, Y);
	    
	} else {
	    for (int i = A; i <= B; i++) {
		if(v[i-1] == v[A-1])
		    count += combination(X, i);
	    }
	}

	System.out.println(String.format("%.6f", max));
	System.out.println(count);
	scan.close();
    }

    private static long combination(int n, int r) {
	if(C[n][r] > 0) return C[n][r];
	
	if(n-r < r) return C[n][r] = combination(n, n-r);
	if(r-1 >= 0) return C[n][r] = n * combination(n-1, r-1) / r;

	return C[n][r] = 1;
    }
}


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

queue <int>que;
int mas[12][6];
int h;
int cheak;
int a,t;
int p;
int size;

int bfs(int y){
  int ans=0;
  if(mas[y][1]==mas[y][2] && mas[y][1]==mas[y][3]){
    ans=mas[y][2]*3;
    if(mas[y][0]==mas[y][1] && mas[y][1]==mas[y][4]){
      ans=mas[y][2]*5;
      mas[y][0]=0;
      mas[y][4]=0;
    }
    else if(mas[y][0]==mas[y][1]){
      ans=mas[y][2]*4;
      mas[y][0]=0;
    }
    else if(mas[y][4]==mas[y][1]){
      ans=mas[y][2]*4;
      mas[y][4]=0;
    }
    mas[y][1]=0;
    mas[y][2]=0;
    mas[y][3]=0;
  }

  else if(mas[y][0]==mas[y][1] && mas[y][0]==mas[y][2]){
    ans=mas[y][2]*3;
    mas[y][0]=0;
    mas[y][1]=0;
    mas[y][2]=0;
  }
  else if(mas[y][2]==mas[y][3] && mas[y][2]==mas[y][4]){
    ans=mas[y][2]*3;
    mas[y][2]=0;
    mas[y][3]=0;
    mas[y][4]=0;
  }

  return ans;
}


main(){
  while(cin >> h,h){
    a=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++){
	cin >> mas[i][j];
      }
    }
    
    while(1){
      cheak=0;
      t=0;
      for(int i=0;i<h;i++){
	t=bfs(i);
	if(t!=0)cheak=1;
	a+=t;
      }

      if(cheak==0)break;

      for(int i=0;i<5;i++){
	int d=0;
	for(int j=0;j<h;j++){
	  if(mas[j][i]>0)que.push(mas[j][i]);
	}
	size=que.size();

	for(int j=0;j<h-size;j++){
	  mas[j][i]=0;
	} 
	for(int j=h-size;j<h;j++){
	  mas[j][i]=que.front();
	  que.pop();
	}
      }

    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1216
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>vector<T> vec(int len, T elem) { return vector<T>(len, elem); } // auto dp = vec(52, vec(103, vec(103, INF)));
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << '\n'; for (auto v : vec) os << v << ' '; os << '\n'; return os;}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ','; os << ']'; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << '{'; for (auto v : vec) os << v << ','; os << '}'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << '(' << pa.first << ',' << pa.second << ')'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << '{'; for (auto v : mp) os << v.first << "=>" << v.second << ','; os << '}'; return os; }
//-------------------
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    string s,t; cin >> s >> t;
    int ans = INF;
    rep(i, s.size()) {
        if(i+t.size()-1 < s.size()) {
            int cur = 0;
            rep(j,t.size()) {
                if(s[i+j]!=t[j]) cur++;
            }
            chmin(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;
#define mp make_pair
#define pb push_back
void solve();
void read_input(){

}
void solve(){

}
int a[1005][2];
int leftsum[1005];
int rightsum[1005];
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>a[i][0];
	}
	for(int i=0;i<N;i++){
		cin>>a[i][1];
	}
	leftsum[0] = a[0][0];
	for(int i=1;i<N;i++){
		leftsum[i] = leftsum[i-1]+a[i][0];
	}
	rightsum[N-1] = a[N-1][1];
	for(int i=N-2;i>=0;i--){
		rightsum[i] =rightsum[i+1]+a[i][1];
	}
	int res = 0;
	for(int i=0;i<N;i++){
		res = max(res, leftsum[i]+rightsum[i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0" && line[1] == "0" && line[2] == "0") break;
            var n = int.Parse(line[0]);
            var p = getTime(line[1]);
            var q = getTime(line[2]);
            var time = new int[24 * 60 + 1];
            for (int i = 0; i < n; i++)
            {
                var wn = int.Parse(Console.ReadLine().Trim());
                line = Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < wn; j++)
                {
                    time[getTime(line[2 * j])]++;
                    time[getTime(line[2 * j + 1])]--;
                }
            }
            var ans = getAns(time, n, p, q);
            Console.WriteLine(ans );
        }
    }
    static int getAns(int[] time, int n, int p, int q)
    {
        var timec = time.Length;
        for (int i = 1; i < timec; i++)
            time[i] += time[i - 1];
        var count = 0; var maxc = 0;
        //if (time[0] < n) count = 1;
        for (int i = p; i < q; i++)
            if (time[i] < n) count++;
            else { maxc = Max(maxc, count ); count = 0; }
        return Max(maxc, count );
    }
    static int getTime(string s)
    {
        if (s.Length == 4)
            return int.Parse(s.Substring(0, 2)) * 60 + int.Parse(s.Substring(2));
        else return int.Parse(s.Substring(0, 1)) * 60 + int.Parse(s.Substring(1));
    }
}



Measured memory_bytes: 13824
S = input()
ACGT = ['A', 'C', 'G', 'T']
nagasatachi = []
nagasa = 0
for i in S:
	if i in ACGT:
		nagasa += 1
	else:
		nagasatachi.append(nagasa)
		nagasa = 0
nagasatachi.append(nagasa)
print(max(nagasatachi))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main() {
  string s;
  cin >> s;
  rep(bit,(1<<3)){
    ll sum = s[0]-'0';
    string ans= "";
    ans += s[0];
    rep(i,3){
      if (bit & (1<<i)) {
        sum += s[i+1]-'0';
        ans += "+" + s.substr(i+1,1);
      } else {
        sum -= s[i+1]-'0';
        ans += "-" + s.substr(i+1,1);
      }
    }
    if(sum == 7){
      cout << ans <<  "=7" << endl;
  		return 0;
    } 
  }
  return 0;
}


Measured memory_bytes: 3624
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class RangeSpannedGraph(object):
    def __init__(self, n, weighted = False):
        self.n = n
        self.N = N = 1 << (n - 1).bit_length()
        self._weighted = weighted
        N2, N3 = N * 2, N * 3
        ref, add_edge = self._reflect, self._add_edge
        E = [[] for _ in range(N3)]
        self.E = E
        for i in range(N - 1, 0, -1):
            cl, cr = i << 1, i << 1 | 1
            add_edge(i, cl)
            add_edge(i, cr)
            add_edge(ref(cl + N2), i + N2)
            add_edge(ref(cr + N2), i + N2)

    def _reflect(self, v):
        return v if v < 3 * self.N else v - 2 * self.N

    def _add_edge(self, u, v, w = 0):
        self.E[u].append((v, w)) if self._weighted else v

    def add_range_edge(self, l0, r0, l1, r1, w):
        N, E = self.N, self.E
        E.append([])
        v = len(E) - 1
        self._add_range_edge(l0 + N, r0 + N, v, w, to = True)
        self._add_range_edge(l1 + N, r1 + N, v, 0, to = False)

    def _add_range_edge(self, l, r, v, w, to):
        E, N2 = self.E, self.N * 2
        ref, add_edge = self._reflect, self._add_edge
        while l < r:
            if l & 1:
                add_edge(ref(l + N2), v, w) if to else add_edge(v, l, w)
                l += 1
            if r & 1:
                r -= 1
                add_edge(ref(r + N2), v, w) if to else add_edge(v, r, w)
            l >>= 1
            r >>= 1

    def to_index(self, v):
        return v + self.N

from heapq import heappop, heappush
def resolve():
    n, m = map(int, input().split())
    rsg = RangeSpannedGraph(n, weighted = True)
    for _ in range(m):
        u, v, w = map(int, input().split())
        u -= 1
        rsg.add_range_edge(u, v, u, v, w)

    # Dijkstra
    E = rsg.E
    dist = [INF] * len(E)
    dist[rsg.to_index(0)] = 0
    heap = [(0, rsg.to_index(0))]
    while heap:
        d, v = heappop(heap)
        if dist[v] != d:
            continue
        for nv, w in E[v]:
            if dist[nv] > d + w:
                dist[nv] = d + w
                heappush(heap, (d + w, nv))

    ans = dist[rsg.to_index(n - 1)]
    if ans == INF:
        ans = -1
    print(ans)
resolve()

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

ll dp[100005][13];

int main(){
    string s;
    cin >> s;
    int n = s.size();
    
    ll mod = 1e9+7;
    dp[0][0] = 1;
    
    for(int i = 0;i <= n;i++){
        for(int j = 0;j < 10;j++){
            if(s[i]-'0' != j && s[i] != '?')continue;
            
            for(int l = 0;l < 13;l++){
                dp[i+1][(l * 10 + j) % 13] += dp[i][l];
                dp[i+1][(l * 10 + j) % 13] %= mod;
            }
        }
    }
    
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 13916
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve(){
	int p,q; cin >> p >> q;
	int r = p*p + q*q;
	int cnt = 0;
	for(int m=-150; m<=150; m++){
		for(int n=-150; n<=150; n++){
			if(m==0 && n==0) continue;
			int s = m*m + n*n;
			if(r % s != 0) continue;
			int t = r / s;
			bool f = false;
			for(int x=0; x<=150; x++){
				int Y = t - x*x;
				int y = sqrt(Y);
				if(y*y != Y) continue;
				f = true; break;
			}
			if((m*p + n*q) % s == 0 && (m*q - n*p) % s == 0) cnt++;
		}
	}
	if(cnt == 8) puts("P");
	else puts("C");
}

int main(){
	int t; cin >> t;
	while(t--){
		solve();
	}
}


Measured memory_bytes: 3092
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

long long power(long long x, long long n, long long mod) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

int main() {
    int n;
    cin >> n;
    VI a(n), cnt(n,0);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) {
        ++cnt[(n-a[i])/2];
        ++cnt[(n+a[i])/2];
    }
    REP(i,0,(n+1)/2) {
        if (!(cnt[i] == 2 || (2 * i + 1 == n && cnt[i] == 1))) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << power(2,n/2,1000000007) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define INF 100000000
#define dis first
#define v second.first
#define m second.second
using namespace std;
typedef pair <int, pair <int,int> > P;
int N,M,L,K,A,H;
vector <P> mp[101];
int ice[101];

void dijkstra(int start,int goal) {
  int visited[101][101] = {},D[101][101];
  for(int i=0;i<=M;i++)
    for(int j=0;j<=N;j++) D[i][j] = -INF;
  P t;
  t.dis = 0,  t.v = start ,t.m = 0;
  priority_queue <P> Q;
  Q.push(t);
  while(!Q.empty()){
    t = Q.top(),Q.pop();
    visited[t.m][t.v] = 1;

    if(ice[t.v] == 1) 
      for(int i=t.m-1;i>=0;i--) {
	P nt = t;
	nt.m = i;
	nt.dis = t.dis - (t.m - i);
	if(nt.m <= M &&visited[nt.m][nt.v] == 0 && D[nt.m][nt.v]<nt.dis) Q.push(nt) , D[nt.m][nt.v]=nt.dis;
      }

    for(int i=0;i<mp[t.v].size();i++){
      P nt;
      nt.dis = t.dis-mp[t.v][i].dis;
      nt.v = mp[t.v][i].v;
      nt.m = t.m + mp[t.v][i].dis;
      if(nt.m <= M && visited[nt.m][nt.v] == 0 && D[nt.m][nt.v] < nt.dis) Q.push(nt),D[nt.m][nt.v] = nt.dis;
    }
  }
  int ans = -INF;
  for(int i=0;i<=M;i++) ans = max(ans,D[i][goal]);

  if(ans == -INF) cout <<"Help!"<<endl;
  else cout << -ans <<endl;
}

int main() {
  while(1){
    cin >> N >> M >> L >> K >> A >> H;
    if(N==0&&M==0&&L==0&&K==0&&A==0&&H==0)break;

    for(int i=0;i<=N;i++) ice[i] = 0,mp[i].clear();
    for(int i=0;i<L;i++) {
      int a;
      cin >> a;
      ice[a] = 1;
    }

    for(int i=0;i<K;i++){
      int x,y,cost;
      cin >> x >> y >> cost;
      P t;
      t.v = y,   t.dis = cost,   t.m=cost;
      mp[x].push_back(t);
      t.v = x,   t.dis = cost,   t.m=cost;
      mp[y].push_back(t);
    }
    dijkstra(A,H);
  }
  return 0;
}

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

#define N 300010 

using namespace std;

typedef long long ll;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
    int x = 0, f = 1;
    char c = nc();
    while (c < 48) {
        if (c == '-')
            f = -1;
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x * f;
}

ll a[N], b[N], c[N], s[N], ans;

int main() {
    int n = rd();
    ll bfr1 = 0, bfr2 = 0;
    for (int i = 1; i <= n; i ++ ) {
        a[i] = rd(), b[i] = rd();
        c[2 * i - 1] = a[i], c[2 * i] = b[i];
        bfr1 += a[i], bfr2 += b[i];
    }

    ans = min(bfr1, bfr2);
    sort(c + 1, c + 2 * n + 1);
    for (int i = 1; i <= n; i ++ ) {
        s[i] = s[i - 1] + c[i];
    }
    for (int i = 1; i <= n; i ++ ) {
        ll x = a[i], y = b[i];
        if (x > y) {
            swap(x, y);
        }
        if (lower_bound(c + 1, c + 2 * n + 1, x) - c <= n - 2) {
            if (lower_bound(c + 1, c + 2 * n + 1, y) - c <= n - 1) {
                ans = min(ans, s[n]);
            }
            else {
                ans = min(ans, y + s[n - 1]);
            }
        }
        else {
            ans = min(ans, x + y + s[n - 2]);
        }
    }

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

Measured memory_bytes: 7296
#include <iostream>


using namespace std;

int money[] = {300000, 200000, 100000};

int main()
{
    int x,y;
    cin >> x >> y;
    
    int result = 0;
    if(x < 4)
    {
        result += money[x - 1];
    }

    if(y < 4)
    {
        result += money[y - 1];
    }

    if(x == 1 && y == 1)
    {
        result += 400000;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
static const int N = 100;

int main(){
    int n,p[N+1],m[N+1][N+1];
    cin >> n;
    for(int i = 1; i <= n; i++)cin >> p[i - 1] >> p[i];
    for(int i = 1; i <= n; i++)m[i][i] = 0;
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for(int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1]* p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;    
    
    return 0;
}


Measured memory_bytes: 3112
// Try diverta 2019 Programming Contest
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let mut ans = 0;
    let mut rem = vec![0; 4];
    for _ in 0..n {
    	let s = get().as_bytes();
        for i in 1..s.len() {
        	if s[i-1]==b'A' && s[i]==b'B' {
                ans += 1;
            }
        }
        let a = if s[s.len()-1]==b'A' { 1 } else { 0 };
        let b = if s[0]==b'B' { 1 } else { 0 };
        rem[a*2+b] += 1;
    }
    if rem[3] > 0 {
        ans += rem[3] - 1;
        if rem[1] > 0 {
            rem[1] -= 1;
            ans += 1;
        }
        if rem[2] > 0 {
            rem[2] -= 1;
            ans += 1;
        }
    }
    ans += std::cmp::min(rem[1], rem[2]);
    println!("{}", ans);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
	class Program
	{
		static void Main(string[] args)
		{
			string[]values  = Console.ReadLine().Split(' ');
			int n =int.Parse(values[0]);
			int x = int.Parse(values[1]);
			string [] stepvalues = Console.ReadLine().Split(' ');
			int[] steps = new int[n];
			for (int i = 0; i < n; i++)
			{
				steps[i] = int.Parse(stepvalues[i]);
			}
			int position = 0;
			int count = 1;


			for (int i = 0; i < n;i++ )
			{
				position += steps[i];

				if (position<=x)
				{
					count++;
					
				}
			}
			Console.WriteLine(count.ToString());
	}
}


Measured memory_bytes: 13140
n, a, b = map(int, input().split())

c = 0
for _n in range(n+1):
  s = 0
  temp_n = _n
  for i in reversed(list(range(0,5))):
    m = _n // (10**i)
    s = s + m
    _n = _n - m * (10**i)
  if (s >= a and s <= b):
    c = c + temp_n
    
print("{}".format(c))

Measured memory_bytes: 3316
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    double N,M;
    cin>>N>>M;
    vector<double>A(N);
    double C=0;
    double D=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        C+=A[i];
    }
    for(int i=0;i<N;i++){
        double E=A[i]/C;
        double F=1/(4*M);
        if((E*100)>=(F*100)){
            D++;
        }
    }


    if(M<=D){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N + 1);
    int a;
    for(int i = 0; i < N; i++){
        cin >> a;
        A.at(a)++;
    }
    int b = 0;
    for(int i = 0; i < A.size(); i++){
        if(A.at(i) != 0){
            b++;
        }
    }
    int c = b - K;
    sort(A.begin(), A.end());
    int sum = 0;
    if(c > 0){
        for(int i = 0; i < A.size(); i++){
            if(A.at(i) != 0){
                sum += A.at(i);
                c--;
            }
            if(c == 0){
                break;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3988
"use strict"

function Main(input) {
  // const nums = input.split("\n");
  // nums.shift()
  const args = input.split('\n');
  const N = args[0],
    nums = args.slice(1, args.length - 1);

  console.log(nums.filter((n, i) => nums.indexOf(n) === i).length);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    ll K; cin >> K;
    queue<ll> q;
    for (int i = 1; i < 10; ++i) q.push(i);
    for (int i = 1; i <= K - 1; ++i) {
        ll a = q.front();
        ll one_digit = a % 10;
        q.pop();
        if (one_digit % 10 != 0) q.push(10 * a - 1 + one_digit);
        q.push(10 * a + one_digit);
        if (one_digit % 10 != 9) q.push(10 * a + 1 + one_digit);
    }
    cout << q.front() << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>
#include <stack>
#include <limits>
#include <list>

using namespace std;
using ll = long long;
const ll INF = numeric_limits<ll>::max();
const int MOD = 1000000007;

void chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
    }
}
void chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
    }
}

int main()
{
    ll N, W;
    cin >> N >> W;
    vector<ll> ws = vector<ll>(N + 1);
    vector<ll> vs = vector<ll>(N + 1);
    for (int i = 1; i <= N; i++)
    {
        ll w, v;
        cin >> w >> v;
        ws[i] = w;
        vs[i] = v;
    }

    vector<vector<ll>> dp = vector<vector<ll>>(N + 1, vector<ll>(W + 1, 0));

    for (int i = 1; i <= N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j == 0)
            {
                continue;
            }
            // i番目を一切使わない場合、i番目までを用いて重さj以下の最大価値はdp[i-1][j]と等しい
            chmax(dp[i][j], dp[i - 1][j]);

            // i番目を用いて重さjを実現できる場合
            if (ws[i] <= j)
            {
                // NOTE: なぜdp[i-1][j-ws[i]]ではなく
                // dp[i][j-ws[i]]をベースにするのか
                // -> 同じ商品を複数選択できる状態なので、i番目を加えられる時点ではすでに一回以上iを加えている可能性がある
                // chmax(dp[i][j], dp[i][j - ws[i]] + vs[i]);

                chmax(dp[i][j], dp[i - 1][j - ws[i]] + vs[i]);
            }
        }
    }

    // for (auto row : dp)
    // {
    //     for (auto cell : row)
    //     {
    //         cout << cell << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if (a > b || (n == 1 && a != b)){
        cout << 0 << endl;
        return 0;
    }
    ll sa = (n-1)*a+b, sb = (n-1)*b+a;
    cout << (sb-sa+1) << endl;


    
    return 0;
}

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

int main(){
    int D; cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }


    vector<int> day(26,0);
    vector<int> contest_no;
    rep(z,D){
        int contest=1;
        int score=-1;

        int n_contest=1;
        int n_score=0;
        rep(i,26){
            if(n_score < c[i] * ((z+1) - day[i])){
                n_score= c[i] * ((z+1) - day[i]);
                n_contest = i+1;   
            }
        }
        day[n_contest - 1] = z+1;

        rep(i,26){
            if(score < s[z][i]){
                score = s[z][i];
                contest = i+1;
            }
        }


        contest_no.push_back(n_contest);
    }

    //解の出力
    for(int i:contest_no){
        cout << i << endl;
    }
}


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

void p(int a[], int n) {
  int i;
  for (i = 0; i < n; i++) {
    cout << a[i];
    if (i != n - 1) {
      cout << ' ';
    }
  }
  cout << endl;
}

int main() {
  int a[100], n, i, j, k, t;

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

  p(a, n);

  for (i = 1; i < n; i++) {
    k = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > k) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = k;

    p(a, n);
  }

  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll status[1000005];
void siv(){
    ll N = 1000000;
    ll i, j;
    for (i = 2; i <= N;i++){
        if(status[i]==0){
            status[i] = i;
            for (j = i * i; j <= N; j += i){
                if(status[j]==0){
                    status[j] = i;
                }
            }
        }
    }
    status[1] = 1;
}
ll fre[1000005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    siv();
    ll i,j,k,l,n,m;
    cin>>n;
    ll data[n + 1];
    for (i = 1; i <= n;i++)
        cin >> data[i];
    ll GCD = 0;
    for (i = 1; i <= n;i++){
        ll temp = data[i];
        GCD = __gcd(temp, GCD);
        ll pre = -1;
        while(temp!=1){
            if(pre!=status[temp]){
                pre = status[temp];
                fre[pre]++;
            }
            temp /= status[temp];
        }
    }
    if(GCD!=1){
        cout << "not coprime\n";
    }
    else{
        ll cnt = 0;
        for (i = 1; i <= 1000000;i++){
            if(fre[i]>1)
                cnt++;
        }
        if(cnt>=1){
            cout << "setwise coprime\n";
        }
        else
            cout << "pairwise coprime\n";
    }
    return 0;
}


Measured memory_bytes: 26984
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N = int(input())

    #output
    M = N % 10

    # %%
    if M == 2 or M == 4 or M == 5 or M == 7 or M == 9:
        print("hon")
    elif M == 0 or M == 1 or M == 6 or M == 8:
        print("pon")
    elif M == 3:
        print("bon")

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

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

int main() {
  long x;
  cin >> x;
  map<long,long> aaa;
  map<long,long> bbb;
  for(long i=0;i<=4000;i++){
    aaa[i]=pow(i,5);
    bbb[pow(i,5)]=i;
  }
  for(long a=0;true;a++) {
    if(x-aaa[a]<0) {
      if(bbb.count(aaa[a]-x)) {
        cout << a << " " << bbb[aaa[a]-x] << endl;
        break;
      }
    } else {
      if(bbb.count(x-aaa[a])) {
        cout << a << " -" << bbb[x-aaa[a]] << endl;
        break;
      }
    }
  }
}

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

using namespace std;

int nr, N, a[100009], b[100009], t[200009];
pair < int, int > c[100009], d[100009];
map < int, int > mp;

int code (int x)
{
    if (mp.count (x)) return mp[x];
    return mp[x] = ++nr;
}

void checkPossibility ()
{
    for (int i=1; i<=N + 1; i++)
        c[i] = {a[i], i}, d[i] = {b[i], i};
    sort (c + 1, c + N + 2), sort (d + 1, d + N + 2);
    for (int i=1; i<=N + 1; i++)
        if (c[i].first != d[i].first)
        {
            printf ("-1\n");
            exit (0);
        }
}

int tata (int x)
{
    if (t[x] == x) return x;
    return t[x] = tata (t[x]);
}

vector < pair < int, int > > edges;
void unite (int x, int y)
{
    edges.push_back ({x, y});
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]), a[N + 1] ^= a[i];
for (int i=1; i<=N; i++)
    scanf ("%d", &b[i]), b[N + 1] ^= b[i];
checkPossibility ();
for (int i=1; i<=N + 1; i++)
    if (a[i] != b[i] || i == N + 1)
        unite (code (a[i]), code (b[i]));
for (int i=1; i<=nr; i++)
    t[i] = i;
int ans = 0, comps = nr;
for (int i=1; i<=N; i++)
    ans += (a[i] != b[i]);
for (auto it : edges)
    if (tata (it.first) != tata (it.second))
        comps --, t[tata (it.first)] = tata (it.second);
printf ("%d\n", ans + comps - 1);
return 0;
}


Measured memory_bytes: 9972
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long

#define pb push_back


#define all(x) (x).begin(),(x).end()

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


#define endl '\n'


template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


typedef vector<int> vii;


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        int x, y, a, b, c;
        ll ans = 0;
        in >> x >> y >> a >> b >> c;
        vii p(a);
        vii q(b);
        vii r(c);
        in >> p;
        in >> q;
        in >> r;
        sort(all(p));
        sort(all(q));
        vii tot;
        a--, b--;
        rep(i, 0, x, 1) tot.pb(p[a-i]);
        rep(i, 0, y, 1) tot.pb(q[b-i]);
        rep(i, 0, c, 1) tot.pb(r[i]);
        sort(all(tot));
        x += y;
        y = x + c - 1;
        while (x) {
            ans += tot[y];
            y--, x--;
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    bool isAC[n];
    int penalty[n];
    int totalpenalty = 0, numAC = 0;
    for (int i=0; i<n; i++) {
        isAC[i] = false;
        penalty[i] = 0;
    }
    for (int i=0; i<m; i++) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (!isAC[p]) {
            if (s == "AC") {
                isAC[p] = true;
                totalpenalty += penalty[p];
                numAC++;                
            } else if (s == "WA") {
                penalty[p]++;
            }
        }
    }
    cout << numAC << " " << totalpenalty << endl;
}

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

int main(){
  int n;
  cin >> n;
  auto s = [](int n){
    int sum = 0;
    while(n != 0){
      sum += n % 10;
      n /= 10;
    }
    return sum;
  };
  int sum = s(n);
  if (n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int x = 0;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] != T[i])
			x += 1;
	}
	cout << x << "\n";
}

Measured memory_bytes: 3928
#include<bits/stdc++.h>
#define N 100005
#define ll long long
#define rep(i,j,k) for(register int i = j; i <= k; i++)
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
} 

int n, a[N], b[N];
int main() {
	n = read();
	rep(i,1,n) a[i] = read();
	rep(i,1,n) b[i] = read();
	ll n1 = 0, n2 = 0;
	rep(i,1,n) {
		if( b[i] > a[i] ) n2+=(b[i]-a[i])/2;
		else n1+=(a[i]-b[i]);
	}
	if( n1 <= n2 ) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
a.sort()
def sub(x):
    v = a[x]
    for i,num in enumerate(a):
        if i==x:
            continue
        if v*2>=num:
            v += num
        else:
            ans = False
            break
    else:
        ans = True
    return ans
if sub(0):
    ans = n
elif not sub(n-1):
    ans = 0
else:
    l = 0
    r = n
    while l<r-1:
        m = (l+r)//2
        if sub(m):
            r = m
        else:
            l = m
    ans = n-r
print(ans)

Measured memory_bytes: 85928
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 256 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), m = sc.nextInt();
        int p[] = new int[n + 1];
        Map<Integer, List<Integer>> neighbors = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            p[i] = sc.nextInt();
            neighbors.put(p[i], new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            neighbors.get(a).add(b);
            neighbors.get(b).add(a);
        }

        Map<Integer, Integer> labels = BFS.labelLinking(neighbors);
        int count = 0;
        for (int i = 1; i < n + 1; i++) {
            if (labels.containsKey(i) && labels.get(i).equals(labels.get(p[i]))) {
                count++;
            }
        }
        System.out.println(count);
    }
}

class BFS {

    static Map<Integer, Integer> labelLinking(Map<Integer, List<Integer>> graph) {
        Map<Integer, Integer> labels = new HashMap<>();
        int linkId = 1;
        for (Map.Entry<Integer, List<Integer>> vertex : graph.entrySet()) {
            if (!labels.containsKey(vertex.getKey())) {
                _labelLinking(graph, labels, linkId, vertex.getKey());
                linkId++;
            }
        }
        return labels;
    }

    private static void _labelLinking(Map<Integer, List<Integer>> graph,
                                      Map<Integer, Integer> labels, int linkId, int root) {
        Deque<Integer> queue = new ArrayDeque<>();
        queue.add(root);
        labels.put(root, linkId);
        while (!queue.isEmpty()) {
            int parent = queue.poll();
            for (Integer child : graph.get(parent)) {
                if (!labels.containsKey(child)) {
                    labels.put(child, linkId);
                    queue.add(child);
                }
            }
        }
    }
}


Measured memory_bytes: 115408