akhauriyash/Code-Regression huggingface dataset:
while line = gets
   num = line.split(' ').map(&:to_f)
   a,b,c,d,e,f = num
   x = ((b*f-c*e)/(b*d-a*e))
   y = ((c*d-a*f)/(b*d-a*e))
   x3 = sprintf("%.3f", x)
   y3 = sprintf("%.3f", y)
   if x3 == "-0.000"
	  x3 = "0.000"
   end
   if y3 == "-0.000"
	  y3 = "0.000"
   end
   print x3+" "+y3+"\n"
end

Measured memory_bytes: 6140
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<double,double>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////

void solve(){
  ini(N);
  out(1.0 * ( (N + 1) / 2)  / N);

}

Measured memory_bytes: 256
while (line = gets)
  xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 =
    line.chomp.split(" ").map{|s| s.to_f}

  puts (xa2 < xb1 || xb2 < xa1 || ya2 < yb1 || yb2 < ya1) ? "NO" : "YES"
end

Measured memory_bytes: 6112
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NMC = Console.ReadLine().Split(' ').Select(Q => int.Parse(Q)).ToArray();
            int NA = NMC[0];
            int MA = NMC[1];
            int CA = NMC[2];
            int[] BA = Console.ReadLine().Split(' ').Select(X => int.Parse(X)).ToArray();
            int tmp = 0;
            int ans = 0;
            for(int i = 0; i < NA; i++)
            {
                int[] aaa = Console.ReadLine().Split(' ').Select(Z => int.Parse(Z)).ToArray();
                for(int j = 0; j < MA; j++)
                {
                    tmp += aaa[j] * BA[j];
                }
                if(tmp + CA > 0)
                {
                    ans++;
                }
                tmp = 0;
            }
            Console.WriteLine(ans);
        }
    }
}




//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 13268
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = 0

A.sort()

for i in range(N):
    if X > A[i]:
        if i == N - 1:
            break
        else:
            ans += 1
            X -= A[i]
    elif X == A[i]:
        ans += 1
        X -= A[i]
        break
    else:
        break

print(ans)


Measured memory_bytes: 3060
typedef long long ll;

#include <iostream>
#include <map>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

template<typename Data, typename Func>
class SegmentTree{
  int n;
  std::vector<Data> data;
  Func f;
  Data d;

  Data query(int a, int b, int k, int l, int r) const{
    if(r <= a || b <= l) return d;
    if(a <= l && r <= b) return data[k];
    else{
      const Data v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
      const Data v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return f(v1, v2);
    }
  }

public:
  SegmentTree(int nn, Func f, Data d) : f(f), d(d){
    n = 1;
    while(n < nn) n *= 2;
    data = std::vector<Data>(2 * n, d);
  }

  void update(int k, const Data &a){
    k += n - 1;
    data[k] = a;
    while(k > 0){
      k = (k - 1) / 2;
      data[k] = f(data[k * 2 + 1], data[k * 2 + 2]);
    }
  }

  // [a, b)
  Data query(int a, int b) const{
    return query(a, b, 0, 0, n);
  }
};

template<typename Data, typename Func> SegmentTree<Data, Func>
segtree(int numberOfElements, Data defaultValue, Func mergeFunc){
  return SegmentTree<Data, Func>(numberOfElements, mergeFunc, defaultValue);
}

const ll mod = 998244353;

ll mpow(ll b, ll e){
  ll ret = 1;
  while(e){
    if(e & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    e /= 2;
  }
  return ret;
}


int main(){
  const int n = getInt();
  vector<pair<int, int> > xy(n);
  vector<int> ys(n);
  REP(i,n){
    xy[i].first = getInt();
    ys[i] = xy[i].second = getInt();
  }
  sort(xy.begin(), xy.end());
  sort(ys.begin(), ys.end());
  map<int, int> yid;
  REP(i,n) yid[ys[i]] = i;

  auto left = segtree(n, 0, [](int x, int y){ return x + y; });
  auto right = segtree(n, 0, [](int x, int y){ return x + y; });
  REP(i,n) right.update(i, 1);

  ll res = 0;

  REP(i,n){
    const int x = xy[i].first;
    const int y = xy[i].second;
    const int id = yid[y];
    right.update(id, 0);

    const int leftBottom = left.query(0, id);
    const int leftTop = left.query(id, n);
    const int rightBottom = right.query(0, id);
    const int rightTop = right.query(id, n);

    // printf("%d %d (%d):\n %d %d\n %d %d\n", x, y, id, leftTop, rightTop, leftBottom, rightBottom);

    res += mpow(2, n - 1); res %= mod;

    res += mpow(2, n - 1); res %= mod;
    res += mod - mpow(2, leftBottom + leftTop); res %= mod;
    res += mod - mpow(2, leftTop + rightTop); res %= mod;
    res += mod - mpow(2, rightTop + rightBottom); res %= mod;
    res += mod - mpow(2, rightBottom + leftBottom); res %= mod;
    res += mpow(2, leftBottom); res %= mod;
    res += mpow(2, leftTop); res %= mod;
    res += mpow(2, rightBottom); res %= mod;
    res += mpow(2, rightTop); res %= mod;
    res += mod - 1; res %= mod;

    left.update(id, 1);
  }

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

  return 0;
}

Measured memory_bytes: 17920
const solve = (input) => {
  const [n, hlist] = input.split("\n")
  const _hs = hlist.split(" ").map(Number)
  const hs = _hs.reduce((curr, next, i) => {
    if (_hs[i - 1] && _hs[i - 1] === _hs[i]) {
      return curr
    }
    return [...curr, next]
  }, [])
  let peaks = []
  hs.map((h, i, arr) => {
    const before = arr[i - 1] || 0
    const after = arr[i + 1] || 0
    // console.log(before, arr[i], after)
    if (arr[i] > before && arr[i] > after) {
      peaks.push(i)
    }
  })
  const pAndE = peaks.map((p) => {
    // let c = hs[p]
    for (i = p; i < hs.length; i++) {
      if (hs[i] < hs[i + 1]) {
        return {
          peak: p,
          peakValue: hs[p],
          edge: i,
          edgeValue: hs[i]
        }
      }
    }
    return {
      peak: p,
      peakValue: hs[p]
    }
  })
  let num = 0
  pAndE.map((p, j) => {
    num += p.peakValue
    if (j > 0) {
      const before = pAndE[j - 1]
      num -= before.edgeValue
    }
  })

  return num
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 11468
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    if a[0] != 0 {
        println!("{}", -1);
        return;
    }
    let mut ret = 0;
    for i in 0..n - 1 {
        if a[i] + 1 != a[i+1] {
            if a[i] + 1 < a[i+1] {
                println!("{}", -1);
                return;
            }
            ret += a[i];
        }
    }
    ret += a[n-1];
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 6396
import sys

use_clipboard=False
bbn=1000000007
	
#+++++

		
def main():
	n,k = map(int, input().split())
	hl=list(map(int, input().split()))
	hl.sort()
	#pa(hl)
	if k > 0:
		ret = sum(hl[:-k])
	else:
		ret=sum(hl)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 26024
# -*- coding: utf-8 -*-
from collections import deque


if __name__ == '__main__':

    n = int(input())
    M = [[0 for i in range(n)] for j in range(n)]
    for _ in range(n):
        l = list(map(int, input().split(" ")))
        u = l[0]
        k = l[1]
        if k != 0:
            for v in l[2:]:
                M[u - 1][v - 1] = 1

    color = [0] * n
    d = [-1] * n
    Q = deque()

    def bfs(s):  # breadth-first search
        color[s] = 1
        d[s] = 0
        Q.append(s)

        while len(Q) != 0:
            u = Q.popleft()
            for v in range(n):
                if M[u][v] == 1 and color[v] == 0:
                    color[v] = 1
                    d[v] = d[u] + 1
                    Q.append(v)
            color[u] = 2

    bfs(0)
    for i in range(n):
        print(i + 1, d[i])



Measured memory_bytes: 6116
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define ll          long long
#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
#define track(x)                cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define ed(i)       i.end()
#define mem(a)      memset(a, 0, sizeof(a))
#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int &b) {a = max(a, b); }
void self_min(int &a, int &b) {a = min(a, b); }
#define hell        1000000007
bool isPrime(long int n) 
{
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}


ll power(int x, unsigned int y, int p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    } 
    return res;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int n, k;

void solve(){
	
	ll n, r;
	cin >> n;
	string s = "";
	while(n) {
		r = n%26;
		if(!r)	r = 26;
		n -= r;
		n = n / 26;
		char ch = 'a' + r - 1;
		s += ch;
	}
	reverse(all(s));
	cout << s << endl;
}
int main() {
	// freopen("input.txt", "rt", stdin);
	// freopen("output.txt", "wt", stdout);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
}



// AGGC
// AGTC
// ATGC


Measured memory_bytes: 3628
import java.util.*;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    static int N;
    static int A;
    static long B;
    static long C;
    static int[] map = new int[1000000];
    static int min = 9994999;




    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

//        int N = scanner.nextInt();

        long A = scanner.nextInt();
        long B = scanner.nextInt();

        if(A == 0){
            if(B >= 100) {
                System.out.println(101);
            }else
            System.out.println(B);
        }else if(A == 1){
            int ans = 100;
            for (int i = 1; i < B; i++) {
                ans += 100;
                if((ans / 100) % 100 == 0)ans+=100;
            }
            System.out.println(ans);
        }else{
            int ans = 10000;
            for (int i = 1; i < B; i++) {
                ans += 10000;
                if((ans / 10000) % 100 == 0)ans+=10000;
            }
            System.out.println(ans);
        }

    }

}



Measured memory_bytes: 27220
K,S=map(int, input().split())
cnt=0
if K <= S:
  for i in range(K+1):
    for j in range(K+1):
      if S - (i+j) <= K and S >= i+j:
        cnt += 1
else:
  for i in range(S+1):
    for j in range(S+1):
      if S - (i+j) <= K and S >= i+j:
        cnt += 1
print(cnt)

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

typedef long long ll;
using namespace std;

int main() {
  ll N, M;
  cin >> N >> M;

  vector<vector<int>> Graph(N, vector<int>(N, 0));

  for (ll i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    Graph[a-1][b-1] = 1;
    Graph[b-1][a-1] = 1;
  }

  vector<ll> nodes(N, 0);
  for (ll i = 0; i < N; i++) {
    nodes[i] = i;
  }

  ll ans = 0;
  do {
    if (nodes[0] != 0) continue;

    bool ok = true;
    for (ll i = 0; i < N - 1; i++) {
      if (Graph[nodes[i]][nodes[i + 1]] == 0) {
        ok = false;
        break;
      }
    }

    if (ok) ans++;
  } while (next_permutation(nodes.begin(), nodes.end()));

  cout << ans << endl;
}

Measured memory_bytes: 256
let modulo = 1000000007
let (+@) a b = (a + b) mod modulo
let ( *@) a b = (a * b) mod modulo
let rec mod_pow a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a *@ mod_pow a (n-1)
  else let h = mod_pow a (n/2) in h *@ h
let () =
  Scanf.scanf "%d %d %d" @@ fun h w k ->
  let dp = Array.init (h+1) (fun _ -> Array.make w 0) in
  dp.(0).(0) <- 1;
  for i = 1 to h do
    for b = 1 to mod_pow 2 (w-1) do
      let exc = Array.init (w-1) (fun j -> b land (1 lsl j) > 0) in
      let valid = fst @@
        Array.fold_left (fun (a,p) b ->
          a && (not (p && b)), b) (true, false) exc
      in
      if valid then begin
        for j = 0 to w-1 do
          if (j = 0 || not exc.(j-1)) && (j = w-1 || not exc.(j)) then
            dp.(i).(j) <- dp.(i).(j) +@ dp.(i-1).(j);
        done;
        Array.iteri (fun j b ->
          if b then begin
            dp.(i).(j)   <- dp.(i).(j) +@ dp.(i-1).(j+1);
            dp.(i).(j+1) <- dp.(i).(j+1) +@ dp.(i-1).(j);
          end) exc
      end
    done;
  done;
  Printf.printf "%d\n" dp.(h).(k-1)

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define MOD                 1000000007LL
#define EPS                 1e-9
#define io                  ios_base::sync_with_stdio(false);cin.tie(NULL);

const int MAXN = 1e5+5;

int main(){
	io;
	string s;
	cin >> s;
	int minn = s.size();
	for(int i = 1;i < s.size(); i++){
		if(s[i] != s[i-1]){
			minn = min(minn, max(i, (int)s.size()-i));
		}
	}
	cout << minn << endl;
	return 0;
}

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

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

    string s; cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (i == 4) cout << " ";
        cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int, input().split())
def m(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list


list = m(a)+ m(b)
res = [e for e in set(list) if list.count(e) > 1]
res.sort(reverse=True)
print(res[c-1])

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

template<class TI, class TF>
TI bin_search(TI l, TI u, TF f) {
	while(u - l > 1) {
		TI c = (l + u) / 2;
		if (f(c)) u = c;
		//if (!f(c)) u = c;
		else l = c;
	}
	assert(l + 1 == u);
	return u;
	//return l;
}

template<class T>
bool is_prime(T n) {
	if (n < 2) return false;
	int u = bin_search((T)1, n, [n](T i) {return n / i / i == 0;});
	for(int i = 2; i < u; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}

struct primes_ {
	vector<int> v;
	primes_(int n): v{2, 3} {
		if (n < 3) {
			if (n == 2) v = vector<int>(1, 2);
			else v.clear();
			return;
		}
		bool f = false;
		int end = 1;
		for(int i = 5; i <= n; i += (f = !f) ? 2 : 4) {
			while(v[end] * v[end] <= i) end++;
			bool isprime = true;
			for(int k = 0; k < end; k++) {
				if (i % v[k] == 0) {
					isprime = false;
					break;
				}
			}
			if (isprime) v.push_back(i);
		}
	}
	auto begin() {return v.begin();}
	auto end() {return v.end();}
} primes(1000000);

template<class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}

int main() {
	long long a, b;
	cin >> a >> b;
	auto d = gcd<long long>(a, b);
	int ans = 1;
	for(auto p: primes) if (d % p == 0) {
		ans++;
		do d /= p; while(d % p == 0);
	}
	if (d > 1000000 && is_prime(d)) ans++;
	//if (d > 1000000 && ans == 1) ans++;
	cout << ans << endl;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);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 PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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



int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<int> d(n);
    REP(i,n)cin >> d[i];

    sort(ALL(d),greater<int>());

    cout << d[(n / 2) - 1] - d[n / 2] << endl;
    
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> S(n);
	REP(i, n) cin >> S[i];
	sort(S.begin(), S.end());
	int q;
	cin >> q;
	vector<ll> T(q);
	REP(i, q) cin >> T[i];
	int res = 0;
	REP(i, q) {
		if (binary_search(S.begin(), S.end(), T[i])) res++;
	}
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int a[25], b[25];
int main(){
	int n, m, k, ans = 0;
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1 ; i <= m ; ++i)
		scanf("%d", &a[i]);
	for(int i = 1 ; i <= n ; ++i){
		int sum = 0;
		for(int j = 1 ; j <= m ; ++j){
			scanf("%d", &b[j]);
			sum += a[j] * b[j];
		}
		sum += k;
		if(sum > 0) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

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

#define int long long
#define pii pair<int,int>
#define fi first
#define se second
#define all(v) v.begin(),v.end()
const int MOD =1e9+7;

void insert(vector<int>& basis,int mask){
    for(int i=0;i<basis.size();i++){
        if(!mask) return;
        if(!(mask&(1LL<<i))) continue;
        if(!basis[i]){
            basis[i]=mask;
            return;
        }
        mask^=basis[i];
    }
}

bool exist(vector<int>& basis,int mask){
    for(int i=0;i<basis.size();i++){
        if(!mask) return 1;
        if(!(mask&(1LL<<i))) continue;
        if(!basis[i]) return 0;
        mask^=basis[i];
    }
    return (!mask);
}

bool solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    string b;
    cin>>b;
    vector<int> basis(61);
    for(int i=n-1;i>=0;i--){
        if(b[i]=='0'){
            insert(basis,a[i]);
        }else if(!exist(basis,a[i])){
            return 1;
        }
    }
    return 0;
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie();
    //If you hack my code , You are gay;
    int T;
    cin>>T;
    while(T--){
        cout<<solve()<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <map>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
using namespace std;
#define ll long long int 
int main()
{
	ll n,Z,W;
	cin>>n>>Z>>W;
	ll a[n];
	for(int i=0;i<n;i++ )
	cin>>a[i];
	if(n==1)
	cout<<abs(a[0]-W);
	else
	cout<<max(abs(a[n-1]-W),abs(a[n-1]-a[n-2]));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stdlib.h>
#include <math.h>

#define timemax 24*60*60 + 1
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	
	//imos法を用いる
	
	while(1) {
		int n;
		scanf("%d",&n);
		if( n == 0 ) break;
		vector<int> time;
		
		for(int i = 0; i < timemax; i++)
			time.push_back(0);

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 2; j++){
				int h,m,s;
				scanf("%02d:%02d:%02d", &h, &m, &s);
				if(j == 0) time.at(h*3600 + m*60 + s) ++;
				else time.at(h*3600 + m*60 + s) --;
			}
		}

		//最大値を求める
		int max = 0;
		for(int i = 1; i < time.size(); i++)
			time.at(i) += time.at( i - 1 );

		for(int i = 0; i < time.size(); i++)
			if( time.at(i) > max ) max = time.at(i);

		cout << max << endl;

	}

	
	//while(1){}
	return 0;
}

Measured memory_bytes: 1872
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main(int argc, char *argv[])
{
  int n, i, j;
  int *R;
  int max = INT_MIN;
  int min;

  scanf("%d", &n);

  R = (int *)malloc(sizeof(int) * n);

  for (i = 0; i < n; i++) scanf("%d", &R[i]);

  min = R[0];
  for (i = 1; i < n; i++) {
    if (max < R[i] - min) max = R[i] - min;
    if (min > R[i]) min = R[i];
  }

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

  free(R);
  
  return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) (a>0?a:(-(a)))
#define maxn 200050
using namespace std;
int a[maxn];
char s[maxn];
bool cmp(int a,int b){
	return a>b;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	int ans=0,tot=0,now=0;
	for (int i=2;i<=n;i++)
	if (s[i]==s[i-1]) ans++;
	if (ans==n-1) return printf("%d\n",ans),0;
	for (int i=1;i<=n;i++){
		if (s[i]=='R') now++;else {
			if (now) {
				if (i-now==1) a[++tot]=1;else
					a[++tot]=2;
			}
			now=0;
		}
	}
	if (now&&tot) a[++tot]=1;
	sort(a+1,a+1+tot,cmp);
	for (int i=1;i<=min(k,tot);i++)
	ans+=a[i];
	int mx=ans;
	now=0,tot=0,ans=0;
	for (int i=2;i<=n;i++)
	if (s[i]==s[i-1]) ans++;
	for (int i=1;i<=n;i++){
		if (s[i]=='L') now++;else {
			if (now) {
				if (i-now==1) a[++tot]=1;else
					a[++tot]=2;
			}
			now=0;
		}
	}
	if (now&&tot) a[++tot]=1;
	sort(a+1,a+1+tot,cmp);
	for (int i=1;i<=min(k,tot);i++)
	ans+=a[i];
	if (ans>mx) mx=ans;
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll ans=INF2;
    vector<ll> x(N);
    rep(i,N){
        cin>>x[i];
    }
    reps(i,-100,101){
        ll buf=0;
        rep(j,N){
            buf+=(x[j]-i)*(x[j]-i);
        }
        mini(ans,buf);
    }
    cout<< ans <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
L = [int(i) for i in str(input())]
for i in range(2 ** 3):
    l = ['+'] * 3
    for j in range(3):
        if ((i >> j) & 1):
            l[j] = '-'
    s = L[0]
    for k in range(3):
        if l[k] == '+':
            s += L[k + 1]
        else:
            s -= L[k + 1]
    if s == 7:
        for m in range(3):
            print(str(L[m]) + str(l[m]), end='')
        print(str(L[3]) + '=7')
        exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int main(){
	int x,y;
	cin>>x>>y;
	if(x*2 <= y && y <= x*4 && y%2 == 0){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A;
    for (int i = 0; i < N; ++i) {
        int temp; 
        cin >> temp;
        A.push_back(temp);
    }

    int currMin = K;
    for (int i = 0; i < N; ++i) {
        int nextDistClock = i < N - 1 ? A[i + 1] - A[i] : K - A[N - 1] + A[0];
        int nextDistCounterclock = i > 0 ? A[i] - A[i - 1] : K - A[N - 1] + A[0];
        int clockwise = K - nextDistCounterclock;
        int counterclockwise = K - nextDistClock;
        int tempMin = min(clockwise, counterclockwise);
        if (tempMin < currMin) {
            currMin = tempMin;
        }
    }
    int res = currMin;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mp(a,b) make_pair(a,b)
#define vi vector<int>
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define vp vector<pair<int,int> >
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define dom 998244353
#define pi 3.14159265
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pii pair<int,int> 
#define mini 2000000000000000000
#define time_taken 1.0 * clock() / CLOCKS_PER_SEC
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
void shikhar7s(int cas)
{
    int n,i;
    cin>>n;
    int a,c[1000005]={0};
    vi v;
    fr(i,n)
    {
        cin>>a;
        if(!c[a])
            v.pb(a);
        c[a]++;
    }
    sort(all(v));
    int vis[1000005]={0},j,f,ans=0;
    fr(i,sz(v))
    {
        f=1;
        rep(j,1,sqrt(v[i])+1)
        {
            if(v[i]%j==0)
            {
                if(vis[j]||vis[v[i]/j])
                {
                    f=0;
                    break;
                }
            }
        }
        if(f)
        {
            if(c[v[i]]==1)
                ans++;
        }
        vis[v[i]]=1;
    }
    cout<<ans;
}
signed main()
{
    fast;
    int t=1;
    //cin>>t;
    int cas=1;
    while(cas<=t)
    {
    shikhar7s(cas);
    cas++;
    }
    return 0;
}

Measured memory_bytes: 20496
n = input()
_list = input().split(" ")
_list = [int(x) for x in _list]
even = [x for x in _list if x % 2==0]
answer = []
for x in even:
    if x % 3 == 0 or x % 5 == 0:
        answer.append(True)
if len(even) ==len(answer):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3188
c=3.times.map{gets.split.map(&:to_i)}
all=c.map{ |e| e.inject(:+) }.inject(:+)%3==0
al2=2.times.all?{ |i| c[i..i+1].map{ |e| e[i..i+1].inject(:+) }.inject(:+)%2==0}
puts all && al2 ? :Yes : :No


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

long long MOD = 1000000007;

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    int count = 0;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == t[i]) {
            count++;
        }
    }

    std::cout << count << std::endl;
    
    return 0;
}




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

int main()
{
  int max,min;
  cin>>min>>max;
  int sum=0;
  int a1,a2,a3,a4,a5;
  for(int i=min; i<=max; i++){
    
    a1=i%10;
    a2=(i/10)%10;
    a3=(i/100)%10;
    a4=(i/1000)%10;
    a5=(i/10000)%10;
    if(a1==a5 && a2==a4) sum++;


  }
  cout<<sum<<endl;

}


Measured memory_bytes: 256
#include <algorithm>
    #include <cstdio>
    #include <iostream>
    #include <cfloat>
    #include <climits>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <queue>
    #include <sstream>
    #include <stack>
    #include <time.h>
    #include <vector>
    #include <complex>
    #include <map>
    #include <set>
    #include <iomanip>
    #include <math.h>
    #include <stdlib.h>
    #include <list>
    #include <utility>
    #include <memory>
    #include <cstring>
    #include <fstream>
    #include <numeric>
    #include <assert.h>
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
    	int n;
    	cin>>n;
    	if (n==22) puts("Christmas Eve Eve Eve");
    	if (n==23) puts("Christmas Eve Eve");
    	if (n==24) puts("Christmas Eve");
    	if (n==25) puts("Christmas");
    	return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 


int main(){
    LL N,K;
    cin>>N>>K;
    vector<PLL>pi;
    REP(i,N){
        LL a,b;
        cin>>a>>b;
        pi.PB(MP(a,b));
    }
    SORT(pi);
    LL sum=0;
    REP(i,SZ(pi)){
        if(sum+pi[i].second>=K){
            cout<<pi[i].first<<endl;return 0;
        }
        sum+=pi[i].second;
    }

    return 0;
}


Measured memory_bytes: 2420
# from pprint import pprint
# import math
# import collections

n = input()
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

l = map(int, list(n))

if sum(l) % 9 == 0:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)


Measured memory_bytes: 10500
#include <iostream>
#include <set>
using namespace std;
int main(){
    int n;
    long long m;
    cin >> n >> m;
    long long a[n+1]={0};
    for (int i=1; i<=n; i++){
        cin >> a[i];
        a[i]=(a[i]+a[i-1])%m;
    }
    multiset<long long> M;
    set<long long> S;
    for (int i=0; i<=n; i++){
        M.insert(a[i]);
        S.insert(a[i]);
    }
    long long ans=0;
    for (auto itr:S){
        long long x;
        x=M.count(itr);
        ans+=x*(x-1)/2;
    }
    cout << ans << endl;
}




Measured memory_bytes: 8704
from math import gcd
class SparseTable:
    def __init__(self,arr,N,op,e):
        self.A=arr
        self.N=N
        self.Unit=e
        self.Op=op
        self.K=N.bit_length()-1
        self.pow2=[1]
        for i in range(self.K):
            self.pow2.append(self.pow2[-1]*2)
        self.ST=[[self.Unit]*(self.K+1) for i in range(N)]
        for i in range(N):
            self.ST[i][0]=self.A[i]
        for i in reversed(range(N)):
            for k in range(1,self.K+1):
                if self.N<i+self.pow2[k]:
                    break
                self.ST[i][k]=self.Op(self.ST[i][k-1],self.ST[i+self.pow2[k-1]][k-1])
    def get(self,l,r):
        if l==r:
            return self.Unit
        x=r-l
        t=x.bit_length()-1
        return self.Op(self.ST[l][t],self.ST[r-self.pow2[t]][t])

N=int(input())

A=list(map(int,input().split()))
ST=SparseTable(A,N,gcd,0)
ans=1
for i in range(N):
    l,r=ST.get(0,i),ST.get(i+1,N)
    ans=max(ans,gcd(l,r))
print(ans)

Measured memory_bytes: 107072
N, M, Q = map(int, input().split())
b = [list(map(int, input().split())) for _ in range(Q)]
ans = 0

import itertools
a = range(1, M+1)
for set_A in itertools.combinations_with_replacement(a, N):
    A = list(set_A)
    n = 0
    for i in range(Q):
        if A[b[i][1]-1] - A[b[i][0]-1] == b[i][2]:
            n += b[i][3]
    ans = max(ans, n)
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>n>>m>>k;
    cout<<min(ceil(1.0*k/n),ceil(1.0*k/m));
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
#define int long long int
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll MOD = 1e9+7;
const ll inf = 1e18;
const ll p = 998244353;
int fac[200005];
double powe(double x,int y) 
{ 
    if (y == 0) 
        return 1.00;
    double p = powe(x, y/2);
    p = (p * p); 
    return (y%2 == 0)? p : (x * p); 
} 
int power(int x,int y, int m) 
{ 
    if (y == 0) 
        return 1;
    int p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
int mod(int x)
 {
	if(x<0)return -x;
	else return x;
 }
 int inverse(int a, int p)
{
    return power(a, p-2, p);
}
int ncr(int n, int r, int p)
{
    if (r==0)
        return 1;
    return (fac[n]*inverse(fac[r], p) % p *
            inverse(fac[n-r], p) % p) % p;
}
 int leaves=0;
 vector<int> visited;
 vector<set<int> > adj;
 vector<int> color;
 void dfs(int s)
{    
     
     if(visited[s])return;
     visited[s]=1;
     for(set<int>::iterator i=adj[s].begin();i!=adj[s].end();i++)
     {
     	if(!visited[*i])
     	{
     	 dfs(*i);	
		}
	 }
 }
 //Don't forget to clear vectors>>;
 //i miss simpu;
 //work_hard();
signed main()
{
readb(n,wt);
int w[n+1],v[n+1];
FOR(i,1,n)
{
	cin>>w[i]>>v[i];
}
//cout<<"OKAY"<<endl;
int m=100000;
int dp[n+1][m+1];
//cout<<"OKAY"<<endl;
FOR(i,0,n)
{
	FOR(j,0,m)
	dp[i][j]=inf;
}
//cout<<"OKAY"<<endl;
FOR(i,0,n)
dp[i][0]=0;
FOR(i,1,n)
{
	FOR(j,1,m)
	{ 
	 dp[i][j]=dp[i-1][j];
	 if(j>=v[i])
	 dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
	}
}
//cout<<"OKAY"<<endl;
int ans=0;
FORD(j,m,1)
{
	if(dp[n][j]<=wt)
	{
		ans=j;break;
	}
}
//cout<<"OKAY"<<endl;
cout<<ans<<endl;
}

Measured memory_bytes: 82540
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
li = [i for i in range(1, n+1)]
j = 1
p_index = 1
q_index = 1
for v in itertools.permutations(li, n):
  if(list(v) == p):
    p_index = j
  if(list(v) == q):
    q_index = j
  j += 1
print(abs(p_index - q_index))

Measured memory_bytes: 3064
//????????????????????????0611
#include<stdio.h>
long long int z[1001][1001];
int main(void)
{
	int n,m,d[1001],c[1001],i,j;
	long long int min,s;
	s=9223372036854775806; 
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++) scanf("%d",&d[i]);
	for(i=0;i<m;i++) scanf("%d",&c[i]);
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++) z[i][j]=s;
	}
	z[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(z[i][j]!=s){
				if(z[i+1][j]>z[i][j]){
					z[i+1][j]=z[i][j];
				}
				if(z[i+1][j+1]>z[i][j]+d[j]*c[i]){
					z[i+1][j+1]=z[i][j]+d[j]*c[i];
				}	
			}	
		}
	}
	min=s;
	for(i=0;i<=m;i++){
		if(min>z[i][n]){
			min=z[i][n];
		}
	}
	printf("%lld\n",min);
}

Measured memory_bytes: 10448
#include <bits/stdc++.h>
#define nmax 100005

using namespace std;

const int mod = 1e9+7;

int powmod(int b, int p){
	int ans=1;
	while(p){
		if(p&1){
			ans=(1ll*ans*b)%mod;
		}
		p>>=1;
		b=(1ll*b*b)%mod;
	}
	return ans;
}

int fact[nmax],ifact[nmax];

int ncr(int n, int r){
	if(n<r)
		return 0;
	int ans=(1ll*ifact[r]*ifact[n-r])%mod;
	return (1ll*ans*fact[n])%mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	fact[0]=1;ifact[0]=1;
	for(int i=1;i<nmax;i++){
		fact[i]=(1ll*fact[i-1]*i)%mod;
		ifact[i] = powmod(fact[i],mod-2);
	}
	
	int n; cin >> n;
	vector<int> a(n+1);
	
	long long sum=0;
	for(int i=0;i<=n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sum-=(1ll*n*(n+1))/2;
	
	int dup = sum;
	
	int fi=-1,la=-1;
	for(int i=0;i<=n;i++){
		if(a[i]==dup){
			if(fi==-1){
				fi=i;
			}
			else{
				la=i;
			}
		}
	}
	
	int ex = n-la+fi;
	for(int i=1;i<=n+1;i++){
		cout << (ncr(n+1,i)-ncr(ex,i-1)+mod)%mod << endl;
	}
	
	return 0;
}

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

int main(){
    int N;
    cin >>N;
    string S;
    cin >> S;
    int second = N/2;
    int div = N%2;
    if (div != 0){
        cout << "No" << endl;
    }else {
        int flag =0;
        for (int i=0;i< second;i++){
            if (S.at(i)!=S.at(second + i)) flag++;
        }
        if (flag == 0){
            cout << "Yes" << endl;
        }else {
            cout << "No" << endl;
        }
    }

}

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

maxA = max(A)
maxl = len(bin(maxA)[2:])
binary_c = [0 for _ in range(maxl)]
A_binary = [bin(a)[2:].zfill(maxl) for a in A]
for a in A_binary:
    for i, n in enumerate(a):
        if n == "1":
            binary_c[i] += 1
is_inv = []
for bc in binary_c:
    if bc % 2 == 0:
        is_inv.append(False)
    else:
        is_inv.append(True)

for a in A_binary:
    l = []
    for i, n in enumerate(a):
        if is_inv[i]:
            if n == "0":
                l.append("1")
            else:
                l.append("0")
        else:
            l.append(n)
    print(int("".join(l), 2))


Measured memory_bytes: 110440
#include <iostream>
#include <vector>
#include <cstdio>
#include <string.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
using namespace std;



int main(void)
{
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)return 0;
    vector<pair<int,int>>n_max(n);
    vector<pair<int,int>>n_min(n);
    vector<int>quiz(m);
    for(int i=0;i<n;i++){
      n_max[i].second=i;
      n_min[i].second=i;
    }
    int k;
    for(int i=0;i<m;i++){
      cin>>quiz[i];
      cin>>k;
      for(int j=0;j<k;j++){
        int tmp;
        cin>>tmp;
        tmp--;
        n_max[tmp].first+=quiz[i];
        if(k==1)n_min[tmp].first+=quiz[i];
      }
    }
    
    sort(n_max.begin(),n_max.end());
    sort(n_min.begin(),n_min.end());
    int ans=0;
    if(n_max[n-1].second==n_min[0].second){
      ans=max((n_max[n-2].first-n_min[0].first),(n_max[n-1].first-n_min[1].first));
    }else{
      ans=n_max[n-1].first-n_min[0].first;
    }
    cout<<ans+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3212
//解説版
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int n,T; cin>>n>>T;
    int c[n];
    int t[n];
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
    }
    int count=0;
    //T以下のものがない
    for(int i=0;i<n;i++){
        if(t[i]>T) count++;
    }
    /*for(int i=0;i<n;i++){
        if(t[i]>T) t[i]=1010;
    }
    int mint=t[0];*/
    int num=1010;
    for(int i=0;i<n;i++){
        if(t[i]<=T){
            if(c[i]<num) num=c[i];
        }
    }
    if(count==n) cout<<"TLE"<<endl;
    else cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
fn solve() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();

    let info: Vec<usize> = buf.trim().split_whitespace()
        .map(|a| a.parse().unwrap()).collect();

    let n = info[0];
    let x = info[1];
    let ans = f(n as isize, x as isize);
    println!("{}", ans);
}

fn f(n: isize, x: isize) -> isize {
    if n == 0 { return 1;}
    if n >= x { return 0;}
    if (burger_len(n) + 1) / 2 > x {
        f(n-1, x-1)
    } else {
        if burger_len(n) == x {
            return 2_isize.pow((n+1) as u32) -1
        }
        2_isize.pow((n+1) as u32) - 1
        - f(n, burger_len(n) - x)
    }
}

fn burger_len(n: isize) -> isize {
    2_isize.pow((n+2) as u32) - 3
}
fn main() {
    solve();
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	var ans int64
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		if i == 0 {
			continue
		}
		ans += max(aa[i-1]-aa[i], 0)
		aa[i] = max(aa[i], aa[i-1])
	}
	fmt.Fprintln(writer, ans)
}
func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 6348