akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split())

from fractions import gcd
g = gcd(a, b)

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

gg = prime_factorize(g)
print(len(list(set(gg))) + 1)


Measured memory_bytes: 5688
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N,M; cin >> N >> M;
    long long ans = 1;
    for(long long i = 1;(i <= sqrt(M))&&(i <= M/N );i++){
        long long ans1,ans2;
        if( M %i == 0) ans1 = i,ans2 = M/i;
        if(ans2 <= M/N){
            if(ans2 > ans) ans = ans2;
            continue;
        }else{
            if(ans1 > ans) ans = ans1;
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner scanner = new Scanner(System.in);
		int modulo = (int) 1e9 + 7;
		int n = scanner.nextInt();
		int want = scanner.nextInt();
		int pos = 0;
		int neg = 0;
		int[] nega = new int[n];
		int[] posi = new int[n];
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		for(int i = 0; i < n; i++) {
			int temp = scanner.nextInt();
			if(temp < 0) {
				nega[neg] = temp;
				neg++;
			}
			else {
				posi[pos] = temp;
				pos++;
			}
		}
		Arrays.sort(nega);
		Arrays.sort(posi);
		long result = 1l;
		if(n == want) {
			for(int i = 0; i < neg; i++)
				result = (modulo(nega[i], modulo) * result) % modulo;
			for(int i = n - 1; i >= n - pos; i--) {
				result = (posi[i] % modulo * result) % modulo;
			}
		}
		else if(pos != 0) {
			neg = neg / 2 * 2;
			int temp2 = 0;
			int temp = n - 1;
			if(want % 2 == 1) {
				result = result * posi[temp];
				temp--;
				want--;
			}
			while(want > 0 && temp2 < neg && temp > n - pos) {
				if(1l * nega[temp2] * nega[temp2 + 1] >= 1l * posi[temp] * posi[temp - 1]) {
					result *= (1l * nega[temp2] * nega[temp2 + 1]) % modulo; 
					result %= modulo;
					temp2 += 2;
					want -= 2;
				}
				else {
					result *= (1l * posi[temp] * posi[temp - 1]) % modulo; 
					result %= modulo;
					temp -= 2;
					want -= 2;
				}
			}
			
			if(want > 0) {
				while(temp2 < neg && want > 0) {
					result *= (1l * nega[temp2] * nega[temp2 + 1]) % modulo; 
					result %= modulo;
					temp2 += 2;
					want -= 2;
				}
				while(temp > n - pos && want > 0) {
					result *= (1l * posi[temp] * posi[temp - 1]) % modulo; 
					result %= modulo;
					temp -= 2;
					want -= 2;
				}
			}
		}
		else {
			if(want % 2 == 0)
				for(int i = 0; i < want; i++)
					result = (modulo(nega[i], modulo) * result) % modulo;
			else
				for(int i = n - 1; i >= n - want; i--)
					result = (modulo(nega[i], modulo) * result) % modulo;
		}

		log.write("" + result);
		log.flush();
	}

	private static int modulo(int i, int modulo) {
		if(i < 0)
			i *= -1;
		i %= modulo;
		if(i == 0)
			return 0;
		return modulo - i;
	}
}


Measured memory_bytes: 52412
n = int(input())
a = list(map(int, input().split()))
num_sum = 0
num_min = abs(a[0])
num_minus = 0

for i in range(n):
    if (a[i] <= 0):
        num_minus += 1
    num_min = min(num_min, abs(a[i]))
    num_sum += abs(a[i])

if (num_minus % 2 == 0):
    print (num_sum)
else:
    print(num_sum-num_min*2)


Measured memory_bytes: 14284
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
//int mod(int a,int b,int d);

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  ll s=0,e=1e9;
  int x;
  int ai;
  ll k1;
  while(e-s!=1){
    x = (e+s)/2;
    k1=0;
    rep(i,n){
      ai = (a[i]-1)/x;
      k1+=ai;
    }
    if(k1<=k) e=x;
    else s=x;
  }
  cout<<e<<endl;
  
      



}

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Split().Select(i => long.Parse(i)).OrderBy(i => i).ToArray();
            var s = string.Join("", n.Select(i => i.ToString()));

            if(s.Equals("557")){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
using namespace std;

int main() {
	int r, D, x; cin >> r >> D >> x;
	for (int i = 0; i < 10; i++) {
		cout << r * x - D << endl;
		x = r * x - D;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

def cumsum(xs):
  result = [xs[0]]
  for x in xs[1:]:
    result.append(result[-1] + x)
  return result
C = A

C.sort()
C = C[-M:]

B = cumsum(A)

if C[0]>=(1/(4*M))*(B[len(A)-1]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
n = gets.to_i
v = gets.split.map(&:to_i)
a = Hash.new(0)
b = Hash.new(0)

for i in 0..n/2-1
  a[v[i*2]] += 1
  b[v[i*2+1]] += 1
end
ans = n
a = a.sort_by{|k,v|v}
b = b.sort_by{|k,v|v}
if a[-1][0] != b[-1][0]
  ans -= a[-1][1]+b[-1][1]
elsif a.size == 1 && b.size == 1
  ans -= n/2
else
  ans -= a[-1][1]+b[-2][1] > a[-2][1]+b[-1][1] ? a[-1][1]+b[-2][1] : a[-2][1]+b[-1][1]
end
puts ans

Measured memory_bytes: 20340
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL A[MAX_N];
void solve() {
  int res=0;
  REP(i,N) {
    while(A[i]%2==0) {
      ++res,A[i]/=2;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 1016
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    read!(usize);
    let A = read![[i64]];

    let mut x = 0.0;
    for &a in &A {
        x += 1.0 / a as f64;
    }

    println!("{}", 1.0 / x)
}


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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<int> A;
    rep(i,N) {
        int a;
        cin >> a;
        A.push(a);
    }

    rep(i,M) {
        int a = A.top();
        A.pop();
        a /= 2;
        A.push(a);
    }

    ll ans = 0;

    rep(i,N) {
        ll a = A.top();
        A.pop();
        ans += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3876
/*  union_find_tree_rank.cpp
    素集合系を union-find tree で管理するライブラリ
    併合時の工夫：union by rank

    verified: AOJ DSL_1_A
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
*/

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

/* UnionFind：素集合系管理の構造体(union by rank)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
*/
struct UnionFind {  // The range of node number is from 0 to n-1
    //'rank[x]' is a rank of the union find tree the root of which is x.
    //'parents[x]' is the parent of x
    vector<int> rank, parents;
    // constructor
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        rank.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    // make a union find tree
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        rank[x] = 0;
    }

    // check whether the root of x is the same as that of y
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }

    // unite two tree
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (rank[x] > rank[y]) {
            parents[y] = x;
        } else {
            parents[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
        return true;
    }

    // travel the parents of tree recursivily to find root
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);  // change the x's parent to the root of tree.
        }
        return parents[x];
    }
};

int main() {
    int N;             // the number of nodes
    int Q;             // the number of query
    vector<int> P;     // p is a "same" or "unite" command.
    vector<int> A, B;  // a and b are nodes.

    cin >> N >> Q;
    UnionFind uft(N);  // make trees

    for (int i = 0; i < Q; i++) {
        int p, a, b;
        cin >> p >> a >> b;
        P.push_back(p);
        A.push_back(a);
        B.push_back(b);
    }

    for (int i = 0; i < Q; i++) {
        if (P[i] == 0)
            uft.unite(A[i], B[i]);
        else if (P[i] == 1) {
            if (uft.isSame(A[i], B[i]))
                cout << "1\n";
            else
                cout << "0\n";
        }
    }
    return 0;
}



Measured memory_bytes: 4264
/*ITP1_2_C.c*/
int main(void){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(a<=b && b<=c){
      printf("%d %d %d\n",a,b,c);
      return 0;
   }
   if(a<=c && c<=b){
      printf("%d %d %d\n",a,c,b);
      return 0;
   }
   if(b<=a && a<=c){
      printf("%d %d %d\n",b,a,c);
      return 0;
   }
   if(b<=c && c<=a){
      printf("%d %d %d\n",b,c,a);
      return 0;
   }
   if(c<=a && a<=b){
      printf("%d %d %d\n",c,a,b);
      return 0;
   }
   if(c<=b && b<=a){
      printf("%d %d %d\n",c,b,a);
      return 0;
   }
   return 0;
}

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

int main(){
  map<string, int> M;
  int q, query, x;
  string key, L, R;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    scanf("%d", &query);
    if(query == 0){
      cin >> key >> x;
      M[key] = x;
    }else if(query == 1){
      cin >> key;
      if(M.count(key) == 0){
        printf("%d\n", 0);
      }else{
        printf("%d\n", M[key]);
      }
    }else if(query == 2){
      cin >> key;
      M.erase(key);
    }else{
      cin >> L >> R;
      auto it = M.lower_bound(L);
      auto ub = M.upper_bound(R);
      for(auto i = it; i !=  ub; i++){
        printf("%s %d\n", i->first.c_str(), i->second);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 27964
#include <iostream>

using namespace std;
typedef long long ll;
const int MAX = 200010;
ll inv[MAX],fact[MAX],fi[MAX],mod = 1000000007;
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}
int main(){
	ll n,m,k;
	cin >> n >> m >> k;
	inverse();
	cout << (n + m)*inv[3]%mod*comb(k,2)%mod*comb(n*m,k)%mod << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, x, y, maxX = -101, minY = 101;
    cin >> n >> m >> x >> y;
    rep(i, n){
        ll tmp; cin >> tmp;
        chmax(maxX, tmp);
    }
    rep(i, m){
        ll tmp; cin >> tmp;
        chmin(minY, tmp);
    }
    cout << ((maxX < minY && minY > x && maxX < y) ? "No War" : "War") << endl;
}

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

int main() {
    ll x;
    cin >> x;

    for (ll i = -5000; i <= 5000; ++i) {
        for (ll j = -5000; j <= 5000; ++j) {
            if (i * i * i * i * i - j * j * j * j * j == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3632
def primes(n):
    if n == 2:
        return [2]
    nums = list(range(2, n + 1))
    primes = list()
    while len(nums) > 0:
        primes.append(nums[0])
        tmp = list()
        for n in nums[1:]:
            if n % nums[0] > 0:
                tmp.append(n)
        nums = tmp
    return primes


def main():
    N = int(input())
    ps = primes(10000)
    ans = list()
    for p in ps:
        if p % 5 != 1:
            continue
        ans.append(p)
        if len(ans) >= N:
            break
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C,D=0,E,F=INF;
  cin >> A;
  vector<lli>P(A);
  rep(i,A)cin >> P[i];
  rep(i,A-1){
    if(P[i]==P[i+1]){
      B++;
      if(P[i+1]==P[i+2])i++;
  }
  }
  Out(B);
}
 

Measured memory_bytes: 256
x = int(input())

if x >= 400 and x <= 599:
    print('8')
elif x >= 600 and x <= 799:
    print('7')
elif x >= 800 and x <= 999:
    print('6')
elif x >= 1000 and x <= 1199:
    print('5')
elif x >= 1200 and x <= 1399:
    print('4')
elif x >= 1400 and x <= 1599:
    print('3')
elif x >= 1600 and x <= 1799:
    print('2')
elif x >= 1800 and x <= 1999:
    print('1')

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int N, D;
    cin >> N >> D;
    V<> X(N), Y(N);
    REP(i, N) {
        cin >> X[i] >> Y[i];
    }
    two_sat ts(N);
    // X を選択 := true
    // Y を選択 := false
    REP(i, N) {
        for(int j = i + 1; j < N; ++j) {
            //if(i == j) { continue; }
            if(abs(X[i] - X[j]) < D) {
                // この 2 つは共存できない(両方 X はダメ)
                // -> どちらか 1 つは必ず Y を選ばなければならない
                ts.add_clause(i, false, j, false);
            }
            if(abs(X[i] - Y[j]) < D) {
                ts.add_clause(i, false, j, true);
            }
            if(abs(Y[i] - X[j]) < D) {
                ts.add_clause(i, true, j, false);
            }
            if(abs(Y[i] - Y[j]) < D) {
                ts.add_clause(i, true, j, true);
            }
        }
    }
    if(ts.satisfiable()) {
        Yes(true);
        auto ans = ts.answer();
        REP(i, N) {
            if(ans[i]) {
                print(X[i]);
            }
            else {
                print(Y[i]);
            }
        }
    }
    else {
        Yes(false);
    }


    return 0;
}


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

int main(void){
    // Your code here!
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < N; i++){
        cout << S[i] << T[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>

int gcd(int a, int b){
  if(a > b){
    int temp = a;
    a = b;
    b = temp;
  }
  int r = b % a;
  while(r != 0){
    b = a;
    a = r;
    r = b % a;
  }
  return a;
}

int main(){
  int A, B, C;
  std::cin >> A >> B >> C;
  int gcdAB = gcd(A, B);
  if(C % gcdAB == 0) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
}

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

int main(){
	string s, t;
	cin >> s >> t;
	
	int cnt = 0;
	for ( int i = 0; (int)i < s.size(); i++){
		if ( s[i] != t[i] )
			cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}

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

ll f(ll a){
    ll x=0;
    while(a>=pow(2,x)){
        x++;
    }
    x--;
    return x;
}

ll F(ll b){
    ll ans=0;
    while(b>=0){
        ans+=pow(2,b);
        b--;
    }
    return ans;
}

int main(){
    ll h; cin >> h;
    cout << F(f(h)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
void solve()
{
    string s;
    int q;
    ios::sync_with_stdio(false);
    cin>>s>>q;
    string ex[2];
    int d=0;
    for(int u=0;u<q;u++){
        int t;
        cin>>t;
        if(t==1){
            d^=1;
        }
        else {
            int f;
            char c;
            cin>>f>>c;
            if(f==1){
                ex[d]+=c;
            }
            else {
                ex[d^1]+=c;
            }
        }
    }
    if(d==1){
        reverse(s.begin(),s.end());
        reverse(ex[1].begin(),ex[1].end());
    }
    else reverse(ex[0].begin(),ex[0].end());
    cout<<ex[d]<<s<<ex[d^1];
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 1040
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


map<ll, vll> m;

ll func(ll s) {
	ll ret = 0;
	rep(i, 0, m[s].size()) {
		ret = max(ret, func(m[s][i]));
	}
	return ret + 1;
}

int main() {
	ll A, B, C, K, a, b, c;
	std::cin >> A >> B >> C >> K;


	if (abs(A-B) > 10e18) {
		std::cout << "Unfair" << endl;
		return 0;
	}
	else if (K % 2 == 0) {
		std::cout << A - B << endl;
	}
	else {
		std::cout << B - A << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
vector<pll> LR;
vector<ll> minleft;
vector<ll> minright;

string S;
int main() {
	cin >> S;
	ll N = S.size();
	vector<ll> charge;
	if (S[0] == '>')charge.push_back(0);
	ll counter = 1;
	for (ll n = 1; n < N; n++) {
		if (S[n] == S[n - 1])counter++;
		else {
			charge.push_back(counter);
			counter = 1;
		}
	}
	charge.push_back(counter);
	charge.push_back(0);
	ll sum = 0;
	for (ll n = 0; n < charge.size(); n++) {
		ll e = charge[n];
		sum += e * (e - 1) / 2;
	}
	for (ll n = 0; n + 1 < charge.size(); n+=2) {
		sum += max(charge[n], charge[n + 1]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3068
#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 n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  ll tot = 0;
  rep(i,m) tot += b[i];
  int j = m;
  int ans = 0;
  rep(i,n+1) {
    while (j > 0 && tot > k) {
      j--;
      tot -= b[j];
    }
    if (tot > k) break;
    ans = max(ans, i+j);
    if (i == n) break;
    tot += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4772
#include <stdio.h>

int main(void) {
  int N;
  int M;
  scanf("%d", &N);
  scanf("%d", &M);
  int A[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
  }
  double d = sum / (4.0 * M);
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= d) {
      cnt++;
    }
  }
  if (cnt >= M) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1620
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        var c = int.Parse(line[3]);
        Console.WriteLine(n - a - b + c);
    }
}



Measured memory_bytes: 17940
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 28;
int a[maxn], ans;
vector <int> v;
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)	
		cin >> a[i];
	sort(a, a + m);
	for(int i = 0; i < m - 1; i++)
		v.push_back(a[i + 1] - a[i]);
	sort(v.begin(), v.end());
	for(int i = 0; i < (int)v.size() - n + 1; i++)
		ans += v[i];
	cout << ans;
}

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

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



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    if (S[0] == S[1] && S[0] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<map>

using namespace std;

struct cube{
	int a,b,c,d;
	cube():a(0),b(0),c(0),d(0){}
	cube(int m,int n,int p,int q):a(m),b(n),c(p),d(q){}
	friend bool operator<(const cube &cb1,const cube &cb2){if(cb1.a!=cb2.a)return cb1.a<cb2.a;if(cb1.b!=cb2.b)return cb1.b<cb2.b;if(cb1.c!=cb2.c)return cb1.c<cb2.c;return cb1.d<cb2.d;}
	void rotate(){int t=a;a=b,b=c,c=d,d=t;}
};

class FastFileReader{char buffer[10000001];char *h;int len;inline char gchar(){return *h++;}inline bool validdigit(char c){return c>='0' && c<='9';}public:inline void init(){len=fread(buffer,1,10000000,stdin);h=buffer;}inline int nextint(){register int i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline int nextsigned(){register int i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline long long nextlonglong(){register long long i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline long long nextsignedlonglong(){register long long i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline char nextchar(){register char c;do c=gchar();while(c<=' ');return c;}};

FastFileReader fs;
map<cube,int> m;
int n;
long long ans;
cube c[401];

void insert(cube c,int x){for(int i=1;i<=4;++i)m[c]+=x,c.rotate();}

int main(){
	fs.init();n=fs.nextint();for(int i=1;i<=n;++i)c[i].a=fs.nextint(),c[i].b=fs.nextint(),c[i].c=fs.nextint(),c[i].d=fs.nextint(),insert(c[i],1);
	for(int i=1;i<=n;++i){
		insert(c[i],-1);
		for(int j=i+1;j<=n;++j){
			insert(c[j],-1);
			for(int k=0;k<4;++k){
				c[j].rotate();
				cube c1(c[i].b,c[i].a,c[j].a,c[j].d),c2(c[i].c,c[i].b,c[j].d,c[j].c),c3(c[i].d,c[i].c,c[j].c,c[j].b),c4(c[i].a,c[i].d,c[j].b,c[j].a);
				if(m.count(c1)&&m.count(c2)&&m.count(c3)&&m.count(c4)){long long sum=1ll;sum*=m[c1],insert(c1,-1),sum*=m[c2],insert(c2,-1),sum*=m[c3],insert(c3,-1),ans+=sum*m[c4],insert(c1,1),insert(c2,1),insert(c3,1);}
			}
			insert(c[j],1);
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long ;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> v1(a+2, -INF<ll>/100), v2(b+2, -INF<ll>/100);
    for (int i = 0; i < a; ++i) {
        scanf("%lli", &v1[i+1]);
    }
    for (int i = 0; i < b; ++i) {
        scanf("%lli", &v2[i+1]);
    }
    v1[a+1] = INF<ll>/100; v2[b+1] = INF<ll>/100;
    for (int i = 0; i < q; ++i) {
        ll p;
        scanf("%lli", &p);
        int x = static_cast<int>(distance(v1.begin(), lower_bound(v1.begin(), v1.end(), p)));
        int y = static_cast<int>(distance(v2.begin(), lower_bound(v2.begin(), v2.end(), p)));
        ll ans = INF<ll>;
        for (int X = max(x-10, 0); X < min(a+2, x+10); ++X) {
            for (int Y = max(y-10, 0); Y < min(b+2, y+10); ++Y) {
                ll dis1 = p-v1[X], dis2 = p-v2[Y];
                if(((dis1 >= 0) && (dis2 >= 0)) || ((dis1 <= 0 && dis2 <= 0))){
                    chmin(ans, max(llabs(dis1), llabs(dis2)));
                }else {
                    chmin(ans, llabs(dis1)+llabs(dis2)+min(llabs(dis1), llabs(dis2)));
                }
            }
        }
        cout << ans << "\n";
    };
    return 0;
}


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


int main() {

  string N;
  cin >> N;

  string ans = "No";

  for(int i=0; i<N.size(); i++){
    if(N.at(i)=='7'){
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 3600
#むずい
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
 
if n == 0:
    print(0)
else:
    s = ""
    while n != 0:
        #  print('n', n)
        if n % 2 != 0:
            n -= 1
            s = "1" + s
        else:
            s = "0" + s
        n //= -2
    print(s)


Measured memory_bytes: 38384
from operator import mul
n = int(input())
cof = [1 << x for x in range(10)]

fs = [sum(map(mul, map(int, input().split()), cof)) for _ in range(n)]
ps = [list(map(int,input().split())) for _ in range(n)]
ans = float("-inf")
for g in range(1,1024):
    ans = max(ans, sum(p[bin(f&g).count("1")] for f, p in zip(fs, ps)))
    
print(ans)

Measured memory_bytes: 3064
//Bismillahir rahmanir rahim
//Tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int prime_n[200005];
void prime(int n)
{
    for(int i=0;i<=n;i++) prime_n[i]=1;
    for (int i=2;i<=n;i++)
    {
      for (int j=i*i;j<=n;j+=i)
      {
         prime_n[j]=0;
      }
    }
}
int main()
{
    int t,a=0,b=0,c=0,d=0;
    string x;
    cin>>t;
    while(t--)
    {
       cin>>x;
       if(x=="AC")  ++a;
       else if(x=="WA")  ++b;
       else if(x=="TLE") ++c;
       else  ++d;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K <= A)
    cout << K << endl;
  else if(K <= A + B)
    cout << A << endl;
  else
    cout << A - (K - A - B) << endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
A = list(map(int,input().split()))

A.insert(0,-1)
root = [1]

for _ in range(N-1):
    root.append(A[root[-1]])

if K > N:
    start = root.index(root[-1])
    index = (K - start) % (len(root) - start - 1) + start
    ans = root[index]
else:
    ans = root[K]

print(ans)


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}

int digitSum(int x, int d){
  int res = 0;
  while (true) {
    res += x%d;
    x /= d;
    if (x==0) { break; }
  }
  return res;
}

int solve(){
  int n,s;cin>>n>>s;
  if (s>n){
    cout << -1 << endl;
    return 0;
  }

  rep(b, 2, 1000000){
    if (digitSum(n, b)==s){
      cout << b << endl;
      return 0;
    }
  }

  int res = INF;
  if (n==s) res = s+1;
  rep(i, 1, 100001){
    if (i>s) continue;
    int b = (n-(s-i))/i;
    if ((n-(s-i))%i==0 and (s-i)<b){
      chmin(res, b);
    }
  }
  if (res==INF) res=-1;
  cout << res << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    n = min(n,b-1);
    cout<<a*n/b-a*(n/b)<<endl;
    return 0;
}

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

int main(void){
    ll n, k;
    cin >> n >> k;

    pair<ll, ll> a[n];
    rep(i, n){
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);

    ll count = 0;
    ll out;
    rep(i, n){
        out = a[i].first;
        count += a[i].second;
        if(count >= k) break;
    }

    cout << out << endl;
    return 0;
}


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

/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

//const ll md = 1e9 + 7;//998244353;
const int xn = 1e5 + 10;
const int xm = -20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int Md = 998244353;
const int TM = 3;
const int Base = 257;


ll n, dist[xn];
set <pll> st;
vector <int> adj[xn];
bool mark[xn];


int main(){
    InTheNameOfGod;
    
    cin >> n;
    for (int i = 0; i < n; ++ i) dist[i] = INF;
    dist[100000 % n] = 1;
    for (int i = 0; i < n; ++ i) st.insert({dist[i], i});
    for (int v = 0; v < n; ++ v) for (int u = 0; u < 10; ++ u) adj[v].push_back(u);
    while (st.size()){
    	int v = st.begin() -> B;
    	st.erase(st.begin());
    	mark[v] = true;
    	for (int w : adj[v]){
    		int u = (10 * v + w) % n;
    		if (mark[u]) continue;
    		st.erase({dist[u], u});
    		dist[u] = min(dist[u], dist[v] + w);
    		st.insert({dist[u], u});
		}
	}
	cout << dist[0] << endl;
    
	
    return 0;
}


Measured memory_bytes: 17536
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: u32
    }
    let sum: u32 =
        n
        .to_string()
        .chars()
        .into_iter()
        .map(|ch| ch.to_digit(10).unwrap())
        .sum();
    println!("{}", if n % sum == 0 { "Yes" } else { "No" });
}


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

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

vector<int> par;
// par[i] is the 'parent' of item i
// i -> par[i]
vector<int> sz;
// sz[i] stores the number of items in group i

// this function initializes the UFDS
void ufds_init(int n) {
	par.resize(n);
	sz.resize(n);
	for (int i = 0; i < n; i++) {
		par[i] = i;
		sz[i] = 1;
	}
}

//  this function returns the representative of the group that item x is in
int ufds_find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		// path compression: link x -> representative of the group directly
		// recursively follow the arrows up to the representative
		par[x] = ufds_find(par[x]);
		return par[x];
	}
}

// this function combines the groups items x and y are in
void ufds_merge(int x, int y) {
	// find the representatives of the two groups
	x = ufds_find(x);
	y = ufds_find(y);
	if (x == y) {
		return;
	}
	par[x] = y; // x -> y
	sz[y] += sz[x]; // number of items in group y has increased by the number of items in group x
	return;
}

// this function returns the size of the group item x is in
int ufds_get_size(int x) {
	return sz[ufds_find(x)];
}

// this function returns true if items x and y are in the same set
bool ufds_is_same_set(int x, int y) {
	return ufds_find(x) == ufds_find(y);
}

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

	int n, m;
	cin >> n >> m;
	ufds_init(n+m);

	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			ufds_merge(i+m, x);
		}
	}
	int common_parent = ufds_find(m);
	for (int i = m+1; i < n+m; i++) {
		if (ufds_find(i) != common_parent) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;

  if(c-(a+b)<=0){
    cout << "No" << endl;
    return 0;
  }

  long long tmp=(c-(a+b))*(c-(a+b));
  if(4*a*b<tmp) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


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

bool primeJudje(int k){
    int r=sqrt(k);
    r++;
    if(k<2){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}

    for(int i=1;(2*i+1)<=r;i++){
        if(k%(2*i+1)==0){
            return false;
        }
    }
    return true;
}

int main(){
    int Q;
    cin>>Q;
    int k[100001]={};
    long long count=0;
    for(int i=1;i<100001;i++){
        if(primeJudje(i)&&primeJudje((i+1)/2)){
            k[i]=k[i-1]+1;
        }else{
            k[i]=k[i-1];
        }
    }

    for(int i=0;i<Q;i++){
        int l,r;
        cin >>l>>r;
        cout <</*  "\n"<<*/k[r]-k[l-1]<<"\n";
    }


    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {

  int w, h, x, y, r;

  scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

  if(x + r > w || y + r > h || x -r < 0 || y - r < 0)
    printf("No\n");
  else
    printf("Yes\n");

  return 0;

}

Measured memory_bytes: 584