akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, k; cin >> n >> k;
  vector<int>h(n);
  for(int i=0; i<n; i++) cin >> h[i];

  sort(h.begin(), h.end());
  int a = 1e9;
  for(int i=0; i<n-k+1; i++){
    a = min(h[i+k-1]-h[i], a);
  }
  cout << a << endl;

  return 0;
}



///


Measured memory_bytes: 640
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string t;
    cin>>t;
    int n = t.length();
    for(int i=0;i<n;i++){
        if(t[i]=='?')   t[i] = 'D';  
    }
    cout<<t<<endl;
    return 0;
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int n, k; cin >> n >> k;
    cout << max(0, n - 2 * k) << endl;
    

    

    return 0;
}

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

int main()
{
	int N, j = 0;

	cin >> N;

	for(int i = 1;i < 10; i++)
	{
		if (((N / i) < 10)&&(N % i == 0))j++;
	}

	if (j > 0)cout << "Yes";
	else cout << "No";

	cout << endl;
}

Measured memory_bytes: 256
//Created Time:2020年03月19日 星期四 08时40分24秒
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int k;

int main(){
	cin >> k; int n = ((k + 3) / 4) * 2;
	if(k == 1) return printf("1\n1\n"), 0;
	printf("%d\n", n);
	for(int i = 1; i <= n; ++i, puts(""))
		for(int j = 1; j <= n; ++j){
			int tmp = (i + j - 2) % n + 1 + n * !(i & 1);
			if(tmp > k) tmp -= n;
			printf("%d ", tmp);
		}
	return 0;
}

Measured memory_bytes: 1152
from collections import *
N = int(input())
A = Counter(list(map(int, input().split())))

x = [0,0]
for key, value in A.items():
    if A[key] > 1:
        x.append(key)
    if A[key] > 3:
        x.append(key)
x = sorted(x)

print(x[-1]*x[-2])


Measured memory_bytes: 22316
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut q2: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut r2: HashSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    let mut cnt = 1;
    while !rems.is_empty() {
        if let Some(s_idx) = q2.pop_front() {
            cnt += s_idx;
        }
        while let Some(s_idx) = q.pop_front() {
            r2.remove(&s_idx);
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            if let Some(destv) = dests.remove(&s_num) {
                for dest in destv {
                    q.push_back(dest);
                }
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
        if let Some(&r) = r2.iter().next() {
            q2.push_back(r);
        }
    }
    if cnt > 1e18 as usize{
        println!("{}", "hoge");
    }
    println!("{}", ans);
}


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

string c;
string f(string a, string b)
{
  c="";
  int p1=0,p2=0;
  while(1){
    if(p1==a.size())return c;
    if(p2==b.size())return c;
    if(a[p1]==b[p2]){
      c.push_back(a[p1]);
      p1++;p2++;
    } else if(a[p1]>b[p2]) {
      p2++;
    } else {
      p1++;
    }
  }
}
  




int main(void)
{
  string s[55];
  string buf;
  int n;cin >>n;
  for(int i=0;i<n;i++){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
    if(i>0){
      buf=f(s[i],s[i-1]);
      s[i]=buf;
    }
  }
  if(n==1)buf=s[0];
  cout << buf << endl;
}










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

const int maxn = 200005;

int n, a, b, l, u_n;
vector < int > g[maxn];

void dfs_mx (int u, int p, int lvl) {
	if (lvl >= l)
		l = lvl, u_n = u;
	for (int v: g[u]) {
		if (v != p) 
			dfs_mx(v, u, lvl + 1);
	}
}

signed main () {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs_mx(1, -1, 0);
	dfs_mx(u_n, -1, 0);
	if (l % 3 == 1)
		printf("Second\n");
	else
		printf("First\n");
}


Measured memory_bytes: 23928
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    bool flag=false;
    for(int i=1;i<1009;i++){
        int k=floor(i*0.1);
        int d=floor(i*0.08);
        if(k==b&&d==a){
            flag=true;
            cout<<i<<endl;
            break;
        }
    }
    if(!flag) cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov
//export PATH=PATH:~/.local/bin

int main(){
    ll n;
    cin >> n;
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9){
        cout << "hon" << endl;
    }else if(n==3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 5e5+1;

int main() {
	fastio();

	LL n;
	cin >> n;

	cout << ((n+999)/1000)*1000-n << "\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, M;
    cin >> N;
    vector<vector<P>> graph(N);
    for(int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        --a, --b;
        graph[a].emplace_back(b, i);
        graph[b].emplace_back(a, i);
    }
    cin >> M;
    vector<ll> edge_mask(M);
    for(int i = 0; i < M; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        auto dfs = [&](auto&& self, int from, int goal, int par = -1) -> bool {
            if(from == goal)    return true;
            for(auto& e : graph[from]){
                int to = e.first, idx = e.second;
                if(to == par)   continue;
                if(self(self, to, goal, from)){
                    edge_mask[i] |= 1LL << idx;
                    return true;
                }
            }
            return false;
        };
        dfs(dfs, u, v);
    }
    ll ans = 0;
    for(int mask = 0; mask < 1 << M; ++mask){
        ll total_mask = 0;
        int cnt = 0;
        for(int i = 0; i < M; ++i){
            if(mask >> i & 1){
                ++cnt;
                total_mask |= edge_mask[i];
            }
        }
        int edge_cnt = N - 1 - __builtin_popcountll(total_mask);
        if(cnt & 1) ans -= 1LL << edge_cnt;
        else    ans += 1LL << edge_cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import math
from functools import reduce
from collections import deque
from itertools import combinations
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

def subsets(items):
    _subsets_=[]
    for i in range(len(items) + 1):
        for c in combinations(items, i):
            _subsets_.append(c)
    return _subsets_

INF = 999999999999999999999999

n,m = get_nums_l()

# ある扉の組み合わせを鍵1本で開けられる最小コストのリスト
keys = [INF] * (2 ** (n+2))

for _ in range(m):
    cost, b = get_nums_l()
    ccc = get_nums_l()

    # print(cost,b)


    for s in subsets(ccc):
        keyn = 0
        # print(s)
        for c in s:
            keyn += 2 ** c
        
        #print("keyn", keyn)
        if keys[keyn] > cost:
            keys[keyn] = cost

# print(keys)

# そもそも開けられない扉があったら無理
for i in range(1,n+1):
    if keys[2**i] == INF:
        print(-1)
        exit()

memo=[None] * (2 ** (n+2))

def solve(targets):

    lent = len(targets)
    
    # print(targets)

    if lent == 0:
        return 0

    if lent == 1:
        memo[2*list(targets)[0]] = keys[2*list(targets)[0]]
        # print(targets, keys[2**list(targets)[0]])
        return keys[2**list(targets)[0]]

    # all_s = set(targets)

    keyn=0
    for c in targets:
        keyn += 2 ** c
    
    if memo[keyn]:
        return memo[keyn]

    _min = keys[keyn]

    for s in subsets(targets):
        if len(s) in (0, lent):
            continue
        rev = targets.difference(s)
        cost = solve(s) + solve(rev)
        if _min > cost:
            _min = cost
    memo[keyn] = _min
    # print(targets, memo[keyn])
    return _min


ans = solve(set(range(1, n+1)))
# print(memo)
print(ans if ans < INF else -1)

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

int main(){
    string s;
    cin >> s;
    int n = s.length();
    int cnt = n/2;
    for(int i = 0; i < n/2; i++){
        if((s[i]==s[n-1-i]&&(s[i]=='i'||s[i]=='w')) || (s[i]=='('&&s[n-1-i]==')') || (s[i]==')'&&s[n-1-i]=='(')) cnt--;
    }
    if(n%2 == 1 && (s[n/2]=='(' || s[n/2]==')'))    cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3212
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
constexpr ll mod = 1000000007;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

    ll sum = 0;
    rep(i,n.size()){
        sum+=n[i]-'0';
    }

    cout<<((sum%9==0) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3748
#include <stdio.h>

main(){
  char data[4];
  int i,temp;

  while(1){
    if(scanf("%c", &data[0])==EOF){
      break;
    }

    if(data[0]=='@'){
      scanf("%c%c", &data[1], &data[2]);
      temp=data[1]-'0';
      for(i=0;i<temp;i++){
	printf("%c", data[2]);
      }
    }

    else printf("%c", data[0]);
  }
  return 0;
}

Measured memory_bytes: 0
n, m, x = map(int, input().split())
lst = []
for i in range(n):
    tmp = list(map(int, input().split()))
    lst.append(tmp)

flag = False
ans = 10**10
for i in range(2 ** n):
    ans_lst = [0] * (m + 1)
    for j in range(n):
        if (i >> j) & 1:
            tmp = lst[j]
            for k in range(m + 1):
                ans_lst[k] += tmp[k]
        if all(score >= x for score in ans_lst[1:]):
            ans = min(ans, ans_lst[0])
            break

if ans == 10 ** 10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <stdbool.h>
using namespace std;

int main(){
  string s;
  bool isA = false, isB = false;
	cin>>s;
  for(int i=0; i<3; i++){
	if(s[i] == 'A') isA = true;
    else isB = true;
  }
  if(isA && isB) cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 1e5 + 10;
using namespace std;

int n, m, T, kase = 1;

ll f(ll x) {
	ll ans = 0;
	while(x) { ans += x % 10; x /= 10; }
	return ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	ll ans = 1, p = 1, num = 1;
	while(num <= n) {
		cout << ans << endl;
		ll a1 = ans + p;
		ll a2 = ans + p * 10;
		if(a1 * f(a2) <= a2 * f(a1)) ans = a1;
		else { ans = a2; p *= 10; }
		num++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define ARRAY_MAX 100005
#define MOD 1000000007


/*nまでの素数を列挙して配列に保持*/
vector<ll> Eratosthenes(ll n,vector<ll>& arr){
    
    for(ll i = 0; i < n;i++){
        arr[i] = 1;
    }
    arr[0] = arr[1] = 0;
    for(ll i = 2; i < sqrt(n); i++){
        if(arr[i]){
            for(ll j = 0; i * (j + 2) < n; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    return arr;
}


int main(){

    ll q;
    cin >> q;
    vector<ll> a(ARRAY_MAX,0),b(ARRAY_MAX,0);
    a = Eratosthenes(ARRAY_MAX,a);
   
    for(int i = 0;i <= 100000;i++){
        if(a[i] && a[(i+1)/2]){
            b[i] = 1;
        }
    }
      
    for(int i = 0;i <= 100000;i++){
        b[i+1]+=b[i];
    }

    ll l,r;
    REP(i,q){
        cin >> l >> r;
        cout << b[r] - b[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;

int main()
{
	int n;
	cin>>n;
	cout<<(n+1)/2<<"\n";	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;

void solve(){
    int n , k ;
    cin>>n>>k;
    vector<int> v(n);
    for(int i = 0 ; i < n ; i++){
        cin>>v[i];
    }
    ll sum = 0;
    sort(v.rbegin(), v.rend());
    for(int i = k ; i < n; i++){
        sum += v[i];
    }
    cout<<sum<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1024
while true
  a, b, c = gets.chomp.split(" ").map{|s| s.to_f}
  break if a == 0 && b == 0 && c == 0

  ha2 = a * a / 4
  hb2 = b * b / 4
  hc2 = c * c / 4

  rab2 = ha2 + hb2
  rbc2 = hb2 + hc2
  rca2 = hc2 + ha2

  min_r2 = [rab2, rbc2, rca2].min

  n = gets.chomp.to_i

  n.times do
    r = gets.chomp.to_f

    puts (r * r > min_r2) ? "OK" : "NA"
  end
end

Measured memory_bytes: 6124
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        Arrays.sort(a, Collections.reverseOrder());
        int alice = 0;
        int bob = 0;
        for (int i = 0; i < a.length; i++) {
            if (i % 2 == 0) {
                alice += a[i];
            } else {
                bob += a[i];
            }
        }
        int result = alice - bob;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
void output(int ct,int jud){
    ct--;
	if(jud == 1){
		if(ct%5 == 0)
			printf(".");
		else if(ct%5 == 1)
			printf(",");
		else if(ct%5 == 2)
			printf("!");
		else if(ct%5 == 3)
			printf("?");
		else
			printf(" ");
	}else if(jud == 2)
		printf("%c",'a'+(ct%3));
	else if(jud == 3)
		printf("%c",'d'+(ct%3));
	else if(jud == 4)
		printf("%c",'g'+(ct%3));
	else if(jud == 5)
		printf("%c",'j'+(ct%3));
	else if(jud == 6)
		printf("%c",'m'+(ct%3));
	else if(jud == 7)
		printf("%c",'p'+(ct%4));
	else if(jud == 8)
		printf("%c",'t'+(ct%3));
	else if(jud ==9)
		printf("%c",'w'+(ct%4));
}
int main(void){
    int i;
	int n,x;
	int ct = 0,jud = 0;
	scanf("%d",&n);
    x=getchar();
    for(i=0;i<n;i++){
        while ((x = getchar()) != EOF) {
			x -= '0';
            if (x == '\n'-'0'){
                break;
            }else if(x==0){
                output(ct,jud);
                ct=0;jud=0;
            }else{
                ct++;
                jud=x;
            }
        }puts("");ct=0;jud=0;
    }
	return 0;
}


Measured memory_bytes: 2108
#include<cstdio>
#include<map>
using namespace std;
int main(){
	map<int,int> people;
	int numbers;
	scanf("%d",&numbers);
	int no;
	int count=0;
	for(int i=0;i<numbers;i++){
		scanf("%d",&no);
		if(people.find(no)==people.end()){
			people[no]=1;
		}else{
			people[no]+=1;
			people[no]%=2;
		}
		if(people[no]==1){
			count++;
		}else{
			count--;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector <ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <vector<ll>> vv;
typedef vector <string> vs;
typedef vector <char> vc;
 
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
 
/*--------------------template--------------------*/
 
ll v[10][10];
 
map<ll, ll> mp;
 
int main() {
    cin >> n >> m;
    REP(i, 10) {
        REP(j, 10) {
            cin >> v[i][j];
        }
    }
    REP(i, 10) {
        mp[i] = 0;
    }
    REP(i, n*m) {
        cin >> k;
        if (k != -1) {
            mp[k]++;
        }
    }
 
    REP(i, 10) {
        REP(j, 10) {
            REP(k, 10) {
                v[j][k] = min(v[j][k], v[j][i] + v[i][k]);
            }
        }
    }
    FOR(i, 0, 10) {
        ans += (v[i][1] * mp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,w,r;
string str;
signed main()
{
cin>>n;
cin>>str;
for (int i=0;i<n;i++) if (str[i]=='R') w++;
for (int i=0;i<w;i++) if (str[i]=='W') r++;
cout<<r<<endl;
return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int N=16;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vi dp(1<<N,-1);
		dp[0]=0;
		for(int i=0;i<n;i++){
			int m,x;
			cin>>m>>x;
			int mx=0,k=0;
			for(int j=0;j<m;j++){
				int l,r;
				cin>>l>>r;
				l-=6,r-=6;
				while(l<r){
					k|=1<<l;
					l++;
				}
			}
			for(int j=(1<<N)-1;j>=0;j--) if(dp[j]>=0&&(j&k)==0){
				int I=j|k;
				dp[I]=max(dp[I],dp[j]+x);
			}
		}
		int res=0;
		for(auto i:dp) res=max(res,i);
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3376
#include<bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main(){
	ll a,b,n,x;
	cin>>a>>b>>n;
	if(n<b)cout<<a*n/b-a*(n/b);
	else x=n/b*b-1,cout<<a*x/b-a*(x/b);
	return 0;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size() <=n){
        cout<<s<<endl;
    }else{
        string temp = s.substr(0,n);
        temp+= "...";
        cout<<temp<<endl;
    }
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + 1 == c) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
use std::cmp::max;

fn read() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

fn main() {
    let vec = read();
    println!("{}", max(vec[0] * vec[1], vec[2] * vec[3]))
}


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

int main(){
  string sa,sb,sc;
  cin>>sa>>sb>>sc;
  reverse(sa.begin(),sa.end());
  reverse(sb.begin(),sb.end());
  reverse(sc.begin(),sc.end());
  queue<char> card;
  card.push(sa[sa.size()-1]);
  sa.pop_back();
  char ans;
  while(true){
    char now=card.front();
    card.pop();
    if(now=='a'){
      if(sa.empty()) {ans='A'; break;}
      card.push(sa[sa.size()-1]);
      sa.pop_back();
    }
    if(now=='b'){
      if(sb.empty()) {ans='B'; break;}
      card.push(sb[sb.size()-1]);
      sb.pop_back();
    }
    if(now=='c'){
      if(sc.empty()) {ans='C'; break;}
      card.push(sc[sc.size()-1]);
      sc.pop_back();
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string bef,s;
	cin>>n>>bef;
	set<string> st{bef};
	while(cin>>s){
		if(st.find(s)!=st.end()||bef.back()!=s[0]){
			cout<<"No"<<endl;
			return 0;
		}
		st.insert(s);
		bef=s;
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
using System;

class main
{
    static void Main(string[] args)
    {
        string s;
        while ((s = Console.ReadLine()) != null)
        {
            int m, sa = 0;
            int d = int.Parse(s);
            for (int i = 0; i < 600 / d; ++i)
            {
                m = (i * d) * (i * d) * d;
                sa += m;
            }
            Console.WriteLine(sa);
        }
    }
}

Measured memory_bytes: 5596
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        int n = sc.nextInt();
        double[] v = new double[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);

        for (int i = 1; i < n; i++) {
            v[i] = (v[i] + v[i - 1]) / 2;
            v[i - 1] = 0;
        }
        System.out.println(v[n-1]);
    }
}



Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][n];
		boolean enable = true;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();
		
		int[][] wf = new int[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				wf[i][j] = a[i][j];
			}
		}
		
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(wf[i][j] > wf[i][k]+wf[k][j]){
						enable = false;
					}
				}
			}
		}
		boolean[][] remove = new boolean[n][n];
		
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				remove[i][j] = false;
			}
		}
		
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(wf[i][j] != 0 && wf[i][j] >= wf[i][k]+wf[k][j] && k!=i && k!=j){
						remove[i][j] = true;
					}
				}
			}
		}
		
		long sum = 0;
		
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(!remove[i][j]){
					sum += wf[i][j];
				}
			}
		}
		
		if(!enable){
			System.out.println("-1");
		}else{
			System.out.println("" + sum/2);
		}
		
	}
}


Measured memory_bytes: 52256
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las


main = do
    money <- readInt
    let fh = money `div` 500
    let f = (money - 500 * fh) `div` 5
    print $ 1000 * fh + f * 5




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

using namespace std;
using ll = long long;

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

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  rep(i, m) cin >> b[i];

  int ans = 0;
  rep(i, n) {
    int a[m];
    rep(j, m) cin >> a[j];
    int sum = 0;
    rep(j, m) sum += a[j] * b[j];
    if (sum + c > 0) ++ans;
  }

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


Measured memory_bytes: 3596
from collections import deque

class RollingHash():
    def __init__(self, s, base1=1007, base2=2009, mod1=10**9+7, mod2=10**9+9):
        self.mod1 = mod1
        self.mod2 = mod2
        self.s = s
        n = len(s)
        self.hash1 = [0]*(n+1)
        self.pow1 = [1]*(n+1)
        self.hash2 = [0]*(n+1)
        self.pow2 = [1]*(n+1)
        for i in range(n):
            self.hash1[i+1] = (self.hash1[i]*base1 + ord(s[i])) % self.mod1
            self.pow1[i+1] = (self.pow1[i]*base1) % self.mod1
            self.hash2[i+1] = (self.hash2[i]*base2 + ord(s[i])) % self.mod2
            self.pow2[i+1] = (self.pow2[i]*base2) % self.mod2

    def get(self, l, r):
        h1 = (self.hash1[r] - self.hash1[l] * self.pow1[r-l]) % self.mod1
        h2 = (self.hash2[r] - self.hash2[l] * self.pow2[r-l]) % self.mod2
        return (h1,h2)


n = int(input())
s = input()
rh = RollingHash(s, base1=1007, base2=2009, mod1=10**9+7, mod2=10**9+7)

for len_ in range(n//2,0,-1):
    ql = [(-1,-1)]*(len_-1)
    wait_q = deque(ql)
    hset = set()
    # print(len_)
    for i in range(n-len_+1):
        # print(s[i:i+len_])
        hs = rh.get(i,i+len_)
        if hs in hset:
            print(len_)
            exit()
        else:
            wait_q.append(hs)
            hset.add(wait_q.popleft())
        # print(wait_q)
        # print(hset)

else:
    print(0)

Measured memory_bytes: 95788
N = int(input())
S = list(input())
S_number = []
# 変換
for i in range(N):
    if S[i] == '(':
        S_number.append(1)
    else:
        S_number.append(-1)

# print(S, S_number)
for i in range(N):
    if S_number[i] == 1:
        for j in range(i, N):
            if S_number[j] == -1:
                S_number[i] = 0
                S_number[j] = 0
                break
            if j == N-1:
                S_number[i] = 0
                S.append(')')
    # print(S, S_number)

insert_times = abs(sum(S_number))
for _ in range(insert_times):
    S.insert(0, '(')

answer = ''.join(S)
print(answer)


            
                

    


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b <<endl;;
    return 0;
}

Measured memory_bytes: 3564
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000



int main(){
    
    int a,b;
    cin>>a>>b;
    if(a>=b){
        rep(i,0,a)cout<<b;
    }
    else{
        rep(i,0,b)cout<<a;
    }
    cout<<endl;
    
}




Measured memory_bytes: 256
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]

def ldec(A, d=1): return map(lambda x: x - d, A)

def solve(N, A, S):
    dp = [0]

    for i in range(N-1, -1, -1):
        #print(i, dp)
        ai = A[i]
        if S[i] == "0":
            # Pattern 1 -> TLE
            #dp += [x^A[i] for x in dp if x^A[i] not in dp]
            
            # Pattern 2 -> TLE
            #for x in dp:
            #    a = x ^ A[i]
            #    if bisect_left(dp, a) == bisect_right(dp, a):
            #        insort(dp, a)

            for d in dp:
                if ai > ai^d: ai ^= d
            if ai: dp.append(ai)

        if S[i] == "1":
            #if A[i] not in dp:
            #    print("1")
            #    return

            for b in dp:
                if ai > ai^b: ai ^= b

            if ai != 0:
                print("1")
                return

    print("0")

T = n1()
for _ in range(T):
    N = n1()
    A = nn()
    S = s1()
    solve(N, A, S)


Measured memory_bytes: 78924
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String str = sc.next();
		int k  =sc.nextInt()-1;
		sc.close();
		char ch = str.charAt(k);
		for (int i=0;i<n;i++) {
			System.out.print((str.charAt(i)!=ch)?"*":str.charAt(i));
		}
		System.out.print("\n");
	}
}


Measured memory_bytes: 22996
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

int main()
{
    ll n,m;
    cin >> n >> m;
    if(n%2==0 && n-2==2*m){
        bool ok=false;
        for(ll l=1,r=n;l<r;l++,r--){
            if(r-l<=n/2 && ok==false){
                r++;
                ok=true;
                continue;
            }
            cout << l << " " << r << endl;
        }
    }
    else{
        for(ll i=1;i<=m;i++){
            cout << i << " " << n+1-i << endl;
        }
    }
    return 0;
} 

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll a[N];
  ll b[N];
  for(int i=0;i<N;i++){
    cin >> a[i] >> b[i];
  }
  ll ans=0;
  for(int i=N-1;i>-1;i--){
    if((a[i]+ans)%b[i]!=0){
      ans+=b[i]-(a[i]+ans)%b[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
main();

sub main {
    my $n = <STDIN>;
    my @nums = split ' ', <STDIN>;
    foreach my $i (@nums) {
        if ($i % 2 == 0 and $i % 3 != 0 and $i % 5 != 0) {
            print "DENIED\n";
            return;
        }
    }
    print "APPROVED\n";
}

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


int gcd(int l, int m){
    int we = max(l, m);
    int wu = min(l, m);
    int tmp;

    while(we%wu!=0){
        tmp = we;
        we = wu;
        if(wu!=0)wu = tmp%wu;
        else break;
    }
    return wu;
}

int main(){
    int k,l,m,n;
    long long int c=0;
    cin>>k;
    for(l=1;l<k+1;l++){
        for(m=1;m<k+1;m++){
            for(n=1;n<k+1;n++){
                c += gcd(gcd(l, m), n);

            }
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3636
use std::fs::File;
use std::io::{stdout, BufWriter, Read, Write};
use std::thread;

fn main() {
    thread::Builder::new()
        .stack_size(32 * 1024 * 1024) // 32MB
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

/// ローカル環境なら _in.txt から入力を受ける
fn read_input() -> String {
    let stdin = std::io::stdin();
    let mut s = String::new();
    match option_env!("LOCAL") {
        Some(_) => File::open("src/_in.txt")
            .expect("File not found")
            .read_to_string(&mut s)
            .unwrap(),
        None => stdin.lock().read_to_string(&mut s).unwrap(),
    };
    s
}

fn run() {
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    let input = read_input();
    let mut input = input.split_whitespace();

    let in_n: usize = input.next().unwrap().parse().unwrap();
    let mut in_a: Vec<i64> = input.map(|s| s.parse().unwrap()).collect();

    // 貪欲に作る
    let mut ans: i64 = 0;
    for i in 0..in_n {
        if in_a[i] >= 2 {
            ans += in_a[i] / 2;
            in_a[i] %= 2;
        }
        if i + 1 < in_n && in_a[i] >= 1 && in_a[i + 1] >= 1 {
            ans += 1;
            in_a[i + 1] -= 1;
        }
    }
    writeln!(out, "{}", ans).ok();
}


Measured memory_bytes: 12540
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <locale>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus > 201703L
#include <bit>
#endif

using i32 = int32_t;
using i64 = uint64_t;
using u32 = uint32_t;
using u64 = uint64_t;

template <typename T>
T input_value() {
  T result;
  std::cin >> result;
  return result;
}

template <typename T1, typename T2>
void input_multival_to_array(const T1& n, T2& array) {
  for (T1 i = T1(0); i < n; ++i) {
    array.emplace_back(input_value<typename T2::value_type>());
  }
}

template <typename T>
std::set<T> factorize(const T& n) {
  const T sqrtn = T(sqrt(double(n)));
  std::set<T> result = {T(1), T{n}};
  for (T i = T(2); i <= sqrtn; ++i) {
    if (n % i == T(0)) {
      result.insert(i);
      result.insert(n / i);
    }
  }
}

int main() {
  using namespace std;
  locale::global(locale(""));
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const auto n = input_value<u32>();
  vector<bool> mul_modulos;
  mul_modulos.reserve(n);
  input_multival_to_array(n, mul_modulos);
  u32 kakutei_min = n / 2 + 1;
  for (u32 i = kakutei_min - 1; i != 0; --i) {
    for (u32 j = 2; i * j <= n; ++j) {
      mul_modulos[i - 1] = mul_modulos[i - 1] != mul_modulos[i * j - 1];
    }
  }
  set<u32> result;
  for (u32 i = 1; i <= n; ++i) {
    if (mul_modulos[i - 1]) result.insert(i);
  }
  cout << result.size() << '\n';
  for (auto it = result.begin(); it != result.end(); ++it) {
    if (it != result.begin()) cout << ' ';
    cout << *it;
  }
  if (!result.empty()) cout << '\n';
  return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){
    FIO;
    ll x, y;    cin >> x >> y;
    ll tmp = __gcd(x, y);
    ll cnt = 1;
    for(ll i = 2 ; i * i <= tmp ; i++){
        if(tmp%i == 0){
            while(tmp%i == 0){
                tmp /= i;
            }
            cnt++;
        }
    }
    cnt += (tmp > 1) ? 1 : 0;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
vector<int> G[100010];
ll a[100010],b[100010],l[100010],u[100010],inf = 10000000000000000,ans = inf;
string s;
ll dfs(int v, int p){
	ll mx = -1,mn = inf;
	b[v] = a[v];
	if(G[v].size()==1 && p!=-1){
		l[v] = 0; u[v] = 0;
		return l[v]/2;
	}
	for(int x:G[v]){
		if(x==p) continue;
		dfs(x,v);
		l[v] += l[x] + b[x];
		b[v] += b[x];
		if(mx<l[x] + b[x]){
			if(mx==l[x] + b[x]){
				mn = min(u[x] + b[x],mn);
			}else{
				mn = u[x] + b[x];
			}
			mx = l[x] + b[x];
		}
	}
	ll sum = l[v] - mx;
	if(l[v]&1){
		if(mn>sum) mn--;
		else sum--;
		u[v] = max(1LL,mn - sum + 1);
	}else{
		u[v] = max(0LL,mn - sum);
	}
	return l[v]/2;
}

int main(){
	int i,j,n;
	cin >> n >> s;
	for(i=0;i<n;i++){
		a[i] = s[i] - '0';
	}
	for(i=0;i<n-1;i++){
		int u,v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v); G[v].push_back(u);
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			b[j] = 0; l[j] = 0; u[j] = 0;
		}
		ll num = dfs(i,-1);
		//cout << i << endl;
		/*for(j=0;j<n;j++){
			cout << l[j] << " " << u[j] << endl;
		}*/
		if(u[i]==0){
			ans = min(ans,num);
		}
	}
	if(ans!=inf){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 3968
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int main(){
	long long A,B,C;
	long long count = 0;

	scanf("%lld %lld %lld",&A,&B,&C);

	if(A%2==0&&A==B&&B==C){
		printf("-1\n");
		return 0;
	}

	while((A%2==0)&&(B%2==0)&&(C%2==0)){
		long long A2 = (B+C)/2;
		long long B2 = (A+C)/2;
		long long C2 = (A+B)/2;
		A = A2;
		B = B2;
		C = C2;
		count++;
	}

	printf("%lld\n",count);

	return 0;
}


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

N = int(input())
S = [input()[:-1] for _ in range(N)]
ans = 0

end_A = 0
start_B = 0
A_B = 0
for s in S:
    if s[0] == "B"and s[-1] == "A":
        A_B += 1
    elif s[0] == "B":
        start_B += 1
    elif s[-1] == "A":
        end_A += 1
    for a, b in zip(s, s[1:]):
        if a == "A" and b == "B":
            ans += 1

add = 0
if A_B == 0:
    add = min(end_A, start_B)
else:
    if max(end_A, start_B) > 0:
        add = A_B+min(end_A, start_B)
    else:
        add = A_B-1

print(ans+add)


Measured memory_bytes: 3700
//*in the name of GOD*\\

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main(){
  int n;
  cin >> n;
  int i;
  for(i = 1; i <= n; i *= 2){}
  cout << i / 2;
}


Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1e7;

int n,a,b;

int prec[]={1,682498929,491101308,76479948,723816384,67347853,27368307,625544428,199888908,888050723,927880474,281863274,661224977,623534362,970055531,261384175,195888993,66404266,547665832,109838563,933245637,724691727,368925948,268838846,136026497,112390913,135498044,217544623,419363534,500780548,668123525,128487469,30977140,522049725,309058615,386027524,189239124,148528617,940567523,917084264,429277690,996164327,358655417,568392357,780072518,462639908,275105629,909210595,99199382,703397904,733333339,97830135,608823837,256141983,141827977,696628828,637939935,811575797,848924691,131772368,724464507,272814771,326159309,456152084,903466878,92255682,769795511,373745190,606241871,825871994,957939114,435887178,852304035,663307737,375297772,217598709,624148346,671734977,624500515,748510389,203191898,423951674,629786193,672850561,814362881,823845496,116667533,256473217,627655552,245795606,586445753,172114298,193781724,778983779,83868974,315103615,965785236,492741665,377329025,847549272,
698611116};

int pw(int x,int n)
{
    int res=1;

    x%=M;
    for(;n;n/=2)
    {
        if(n%2)
            res=(res*x)%M;

        x=(x*x)%M;
    }

    return res;
}

int get_fact(int n) {
  int f = prec[n / N];
  while (n % N != 0) {
    f =(f*n)%M;
    n--;
  }
  return f;
}

int ncr(int n,int r)
{
    int num=get_fact(n);
    int den=(get_fact(r)*(get_fact(n-r)%M))%M;

    int res=(num*(pw(den,M-2)%M))%M;

    return res;
}

void solve()
{
    cin>>n>>a>>b;

    int ans=pw(2,n);

    int tmp=(ncr(n,a)+(ncr(n,b)%M))%M;
    ans=(ans-tmp+M)%M;
    ans=(ans-1ll+M)%M;

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
def main():
    h, w = map(int, input().split())
    cost = [list(map(int, input().split())) for _ in range(10)]
    a = [list(map(int, input().split())) for _ in range(h)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    answer = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == -1:
                continue
            answer += cost[a[i][j]][1]
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
  
int main() {
  char str[20];
  int i;
  
  scanf("%s", str);
  for (i = strlen(str); i > 0 && i <= 20; i--) {
    printf("%c", str[i - 1]);
  };
  printf("\n");  

  return 0;
}

Measured memory_bytes: 524