akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll ALPHA = 30;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, m, ind = -1, ans;
string s, t;
vector<ll> vec[ALPHA];

int main() {
    fast_io;

    cin >> s >> t;
    n = s.size(), m = t.size();

    for (ll i = 0; i < n; i++) {
        vec[s[i] - 97].push_back(i);
        vec[s[i] - 97].push_back(i + n);
    }
    for (ll i = 0; i < ALPHA; i++) Sort(vec[i]);

    for (ll i = 0; i < m; i++) {
        ll x = upper_bound(all(vec[t[i] - 97]), ind) - vec[t[i] - 97].begin();
        if (x == vec[t[i] - 97].size()) return cout << -1 << endl, 0;
        ans += vec[t[i] - 97][x] - ind;
        ind = vec[t[i] - 97][x] % n;
    }
    cout << ans << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

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

Measured memory_bytes: 384
fn main() {
    let n: i32 = read();
    let mut a: Vec<i32> = Vec::new();
    for i in 0..n {
        a.push(read());
    }
    a.sort();

    let mut Al = 0;
    let mut Bo = 0;
    for i in 0..n {
        if i % 2 == 0 {
            Al += a.pop().unwrap();
        } else {
            Bo += a.pop().unwrap();
        }
    } 
    let ans = Al - Bo;
    println!("{}", ans);
}

// 以下関数


use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    vector<int> a(3);
    rep(i,3) cin >> a.at(i);
    sort(a.begin(),a.end());
    cout << a.at(0)+a.at(1) << endl;
}
   


Measured memory_bytes: 3568
n, m = map(int, input().split())
if (m & 1):
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
else:
    if n & 1:
        left_1 = 1
        right_1 = n // 2
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1
    else:
        left_1 = 1
        right_1 = n // 2 - 1
        for _ in range(m // 2):
            print(left_1, right_1)
            left_1 += 1
            right_1 -= 1
        left_2 = (n // 2) + 1
        right_2 = n
        for _ in range(m // 2, m):
            print(left_2, right_2)
            left_2 += 1
            right_2 -= 1


Measured memory_bytes: 69976
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b;
        //?¨??????\??????????????????????????§????????????
    	Scanner scanner = new Scanner(System.in);
    	//??\????????????int??????????????????
    	a = scanner.nextInt();
    	b = scanner.nextInt();
    	//a ?????? b ???????????§???????????°
    	if(a<b){
    		System.out.println("a < b");
    	}
    	//a ?????? b ??????????°????????????°???
    	else if(a>b){
    		System.out.println("a > b");
    	}
    	//a ??¨ b ?????????????????°???
    	else{
    		System.out.println("a == b");
    	}
    }
}

Measured memory_bytes: 26120
#include <iostream>
#include <stdio.h>
 
using namespace std;
 
int main(void) {
    int n;
    cin >> n;
    string w[n];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> w[i];
        for(int j = 0; j < i; j++){
            if(w[i] == w[j]){
                ans++;
            }
        }
        if(i != 0){
            if(w[i][0] != w[i-1][w[i-1].size()-1]){
                ans++;
            }
        }
    }
    if(ans == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if (a < b){
 
        if (b < c){

        printf("Yes\n");

        } else {

        printf("No\n");
    
        }

    } else {

    printf("No\n");

}

return 0;
    
}


Measured memory_bytes: 1976
use List::Util 'sum';
use Math::BigInt;

while(<>){
	chomp;
	($h, $n) = split(/ /, $_) if($. == 1);
	@m = split(/ /, $_) if($. == 2);
}

if($h <= $n){
	print "0\n";
	exit;
}

@m = sort{$b <=> $a}(@m);
$r = Math::BigInt->new("0");
$r = sum(@m[$n .. $h - 1]);

print "$r\n";



Measured memory_bytes: 41216
s = input()

prod = 1
for i in range(len(s)):
  if s[i] == 'a':
    prod *= 2
  elif s[i] == 'b':
    prod *= 3
  elif s[i] == 'c':
    prod *= 5

if prod == 2 * 3 * 5:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
package main

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

var (
	s = bufio.NewScanner(os.Stdin)
	n = 0
	k = 0
	w = []int{}
)

func check(p int) int {
	i := 0
	for j := 0; j < k; j++ {
		s := 0
		for s+w[i] <= p {
			s += w[i]
			i++
			if i == n {
				return n
			}
		}
	}
	return i
}

func binarySearch() int {
	left, right := 0, 100000*100000
	for right-left > 1 {
		mid := (left + right) / 2
		v := check(mid)
		if v >= n {
			right = mid
			continue
		}
		left = mid
	}
	return right
}

func main() {
	s.Split(bufio.ScanWords)

	n = nextInt(s)
	k = nextInt(s)
	w = make([]int, n)

	for i := range w {
		w[i] = nextInt(s)
	}
	fmt.Println(binarySearch())
}

func nextInt(s *bufio.Scanner) int {
	s.Scan()
	n, err := strconv.Atoi(s.Text())
	if err != nil {
		panic(err)
	}
	return n
}



Measured memory_bytes: 2308
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(ALL(a));
  ll an = a[a.size()-1];

  auto itr = lower_bound(a.begin(), a.end(), an / 2);
  ll ar = *itr;

  if (itr != a.begin()) {
    itr--;
    if (abs(ar * 2 - an) >= abs(*itr * 2 - an)) {
      ar = *itr;
    }
  }

  cout << an << " " << ar << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
int a[22];
map<int,int> m;
void init(){
	int r=1<<20;
	for(int t=1;t<r;t++){
		int k=t;
		int s=0;
		for(int i=0;k;i++){
			if(k%2)s+=a[i];
			k/=2;
		}
		m[s]=1;
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	init();
	int T;cin>>T;
	while(T--){
		int tt;
		cin>>tt;
		if(m[tt])puts("yes");
		else puts("no");
	}
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#include <numeric> 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define int long long int
#define mod 1000000007
#define INT_BITS 16
#define INF 10000000
#define pi 3.141592
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n" 
#define pb push_back
//__builtin_popcount

#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    // fast;

   int x;
   cin>>x;
   if(x==0)
    cout<<1<<endl;
else
    cout<<0<<endl;

    
 return 0;

}


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

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

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

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

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

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    LL s;
    cin >> s;
    LL m = s % 1'000'000'000;
    LL y2 = (1'000'000'000 - m) % 1'000'000'000;
    LL x2 = (s + y2) / 1'000'000'000;
    cout << "0 0 " << 1 << " " << 1'000'000'000 << " " << x2 << " " << y2 << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

const long long M = 998244353;

class Combination {
  public:
	vector<long long> fact, rev;
	Combination(int n = 300005) : fact(n), rev(n) { // n = h + w
		fact[0] = fact[1] = 1;
		range(i, 2, n) { (fact[i] = fact[i - 1] * i) %= M; }
		rev[n - 1] = power(fact[n - 1], M - 2) % M;
		for (int i = n - 1; i > 0; i--) { rev[i - 1] = rev[i] * i % M; }
	}
	long long power(long long x, long long n) { //$B$Y$->h(B x^n mod M
		long long res = 1;
		if (n > 0) {
			res = power(x, n / 2);
			if (n % 2 == 0)
				res = (res * res) % M;
			else
				res = (((res * res) % M) * x) % M;
		}
		return res;
	}
	long long factorial(long long l, long long r) {
		return fact[r] * rev[l - 1] % M;
	}
	long long factorial(long long n) { return fact[n]; }
	long long combination(
		long long n,
		long long r) { // nCr (1,1)$B$+$i(B(w,h)$B$@$H!"0z?t$O(B(w - 1, h - 1, M)
		return factorial(n - r + 1, n) * rev[r] % M;
	}
};

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

	int ans = 0;
	Combination com;
	rep(i, n + 1) {
		int c = k;
		if (a * i > c) continue;
		c -= a * i;
		if (c % b != 0) continue;
		int j = c / b;
		if(j > n) continue;

		auto tmp = com.combination(n, i) * com.combination(n, j) % M;
		(ans += tmp) %= M;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    int n,k; string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
    if(s[k-1]=='C')s[k-1]='c';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
typedef long long ll;
using namespace __gnu_pbds;

typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double lld;

lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll dp[100005][4];
ll a[100005];
ll b[100005];
ll c[100005];
ll n,i,j;
ll solve(ll i,ll k)
{
    if(i==n)
        return 0;
    if(dp[i][k]!=-1)
        return dp[i][k];
    ll x;
    if(k==1)
    {
        x=max((b[i]+solve(i+1,2)),(c[i]+solve(i+1,3)));
    }
    else if(k==2)
    {
        x=max((a[i]+solve(i+1,1)),(c[i]+solve(i+1,3)));
    }
    else
    {
        x=max((b[i]+solve(i+1,2)),(a[i]+solve(i+1,1)));
    }
    dp[i][k]=x;
    return x;
}

int main()
{

    cin>>n;
    for(i=0;i<100005;i++)
        for(j=0;j<4;j++)
            {dp[i][j]=-1;
            }
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    cout<<max((a[0]+solve(1,1)),max((b[0]+solve(1,2)),(c[0]+solve(1,3))));
    return 0;
}






Measured memory_bytes: 10496
N,*A = $<.read.split.map &:to_i
c,M = 0, [nil]*A.sort![-1]
exit 0&p(A[1]==1 ? 0 : 1)  if A[0]==1
A.each_with_index {|a,i|
  next  if M[a]
  c+=1  if a!=A[i+1]
  a.step(M.size,a) {|m| M[m]=a}
}
p c

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

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

    if((b - a - 1) == 0) {
        cout << "Borys" << endl;
        return 0;
    }

    if((b - a - 1) % 2) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 256
class Dice
  V={N:0,E:1,S:2,W:3}
  def initialize(label)
    @label=label # Top down Rignt Left up Bottom
    @top=1
    @around=[5,3,2,4] # U R D L
    # 右に転がす場合
    # 対角値(レフト,idx3)が上面(top)になる
    # 右(idx1)にもともと上面だった値（top）が入る
    # その対角面(右,idx1)には対角値（合計7になる値）が入る
    # 1 => [5,3,2,4]
    # 4 => [5,1,2,6]
    # 下に転がす場合
    # 1 => [5,3,2,4]
    # 5 => [6,3,1,4]
  end
  def set_position(top_value,front_value)
    set_uniq_top(top_value)
    set_front(front_value)
  end
  def set_uniq_top(top_value)
    # 与えられた値（ラベル値）になるようにダイスを回転させる
    # 指定された値がラベルに存在しない場合を考慮せよ
    return nil if (top_num=@label.index(top_value)).nil?
    top_num+=1
    # 縦横の回転数を計算して実際に動かす
    #top_num=@label.index(top_value)+1
    # TOP面をあわせる
    if top_num==@top then
    elsif idx=@around.index(top_num)
      rn=self.reverse_vector(idx)
      v=V.key(rn)
      self.move(v)
    elsif
      2.times{self.move("S")}
    end
  end
  def set_front(front_value)
    # 与えられた値（ラベル値）になるようにダイスを回転させる
    # 指定された値がラベルに存在しない場合を考慮せよ
    return nil if (front_num=@label.index(front_value)).nil?
    front_num+=1
    # 縦横の回転数を計算して実際に動かす
    # FRONT面を合わせる
    if idx=@around.index(front_num)
      n=reverse_vector(idx)
      self.turn(n) unless n==0
    else
      # "i can not"
    end
  end

  def turn(n)
    # n回右に回転する（TOPは変わらず）
    # n = turn_right * n
    @around.push(@around.shift(n)).flatten!
  end
  def move(v)
    # v = U,R,D,L
    #     N,E,S,W
    #     0,1,2,3
    vn=V[v.to_sym] # 移動方向のインデックス数値
    rn=reverse_vector(vn) # 対角のインデックス数値（2を足す。4を超えていた場合は剰余）
    @top,@around[vn]=@around[rn],@top
    @around[rn]=7-@around[vn]
  end
  def state
    arr=[]
    arr<<@label[@top-1] #top
    @around.each do |n|
      arr<<@label[n-1] #around
    end
    arr<<@label-arr #bottom
    return arr
  end
  def reverse_vector(vn)
    return (vn+2)%4
  end
end
def uniq_value(label)
  label.each do |i|
    return i if label.count{|j|i==j} == 1
  end
  return label[0]
  #uts "uniq none"
end


def code_run4
  iN=$stdin.gets.to_i
  # 基準ダイス読み込み
  label1=$stdin.gets.split.map(&:to_i)
  d1=Dice.new(label1)
  # 基準値作成
  t=uniq_value(label1)
  d1.set_uniq_top(t)
  f=d1.state[3] #down(front)

  ans=nil
  (iN-1).times do
    labelx=$stdin.gets.split.map(&:to_i)
    dx=Dice.new(labelx)
    dx.set_position(t,f)
    (ans="No";break) if d1.state==dx.state
  end
  puts ans ? ans : "Yes"

end
  code_run4




Measured memory_bytes: 6896
N=int(input())
SP=[]
for i in range(N):
    SP.append(input().split())
for j in range(N):
    SP[j].append(j+1)
SP.sort(key=lambda x:int(x[1]),reverse=True)
SP.sort(key=lambda x:x[0])
for k in range(N):
    print(SP[k][2])

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for (int i = 0, j = 0; i < N; i = j) {
    j = i;
    while (j < N and A[i] == A[j]) { ++j; }
    ans += (j - i) % 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p[1110],b[110],num,cz[1999];
int cnt2,cnt4,cnt14,cnt24,ans;
int main(){
//	freopen(".in","r",stdin);
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int x=i;
		for(int j=2;j<=i;j++)
			if(x%j==0)
				while(x%j==0) x/=j,p[j]++;
	}
	for(int i=1;i<=110;i++)
		if(p[i])
			b[++num]=p[i];
	n=num;
	for(int i=1;i<=n;i++){
		if(b[i]>=2)
			cnt2++;
		if(b[i]>=4)
			cnt4++;
		if(b[i]>=14)
			cnt14++;
		if(b[i]>=24)
			cnt24++;
		if(b[i]>=74)
			ans++;
	}
	ans+=cnt14*(cnt4-1)+cnt24*(cnt2-1)+cnt4*(cnt4-1)/2*(cnt2-2);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
def calc(a, m)
  i = 1
  1.step do |co|
    i = a * i % m
    return co if i == 1
  end
end

until (a = $<.gets.split.map(&:to_i)) == [0] * 6
  cx, cy, cz = a.each_slice(2).map {|a, m| calc(a, m)}
  puts cx.lcm(cy).lcm(cz)
end


Measured memory_bytes: 6872
#include<stdio.h>

//int A[10001], B[10001];

unsigned int *A, *B;


void countingSort(int);


main(){
  int i, k;
  scanf("%d", &k);
  A = malloc(sizeof(int)*k+1);
  B = malloc(sizeof(int)*k+1);

  for(i = 0; k > i; i++){
    scanf("%d", &A[i]);
  }
  
  countingSort(k);
  
  for(i = 1; i <= k; i++){printf("%d", B[i]);
    if(i < k)printf(" ");
  }
  
  printf("\n");
  return 0;
}


void countingSort(int k){
  
  int i, C[2000001];
  
  for(i = 0; i < k; i++){
    C[i] = 0;
  }
  
  for(i = 0; i < k; i++ ){
    C[A[i]]++;
    
  }
  
  
  for(i = 0; i < 2000001; i++ ){
    
    C[i] = C[i] +C[i-1];
    
    if(C[i] == k)break;
    
    
  }
  
  for(i = k -1; i >= 0; i--){
    
    B[C[A[i]]] = A[i];
    
    C[A[i]]--;
  }
}

Measured memory_bytes: 24048
#include <cstring>
#include <cstdio>
#include <algorithm>
#define ll long long
const int MAXN = 2010;
const int MOD = 1000000007;
inline int mul(int x, int y) { return (ll)x * (ll)y % MOD; }
inline int add(int x, int y) { int r = x + y; if(r >= MOD) r -= MOD; return r; }
inline int fpm(int a, int p) {
	int ret = 1, x = a;
	while(p) {
		if(p & 1) ret = mul(ret, x);
		x = mul(x, x);
		p >>= 1;
	}
	return ret;
}
using namespace std;

int N, K, C[MAXN * MAXN], F[MAXN][MAXN], fact[MAXN];

int main() {
	int i, k;
	scanf("%d%d", &N, &K);
	if(K == 1) printf("1\n");
	else {
		fact[0] = 1; for(int i = 1; i <= N; i++) fact[i] = mul(fact[i - 1], i);

		C[K - 2] = 1;
		for(i = K - 2 + 1; i <= N * K; i++) C[i] = mul(mul(C[i - 1], i), fpm(i - (K - 2), MOD - 2));

		F[0][0] = 1;
		for(i = 1; i <= N; i++) {
			F[i][0] = mul(F[i - 1][0], C[i * (K - 1) - 1]);
			for(k = 1; k <= i; k++) F[i][k] = add(F[i][k - 1], mul(F[i - 1][k], C[i * (K - 1) + k - 1]));
		}

		printf("%d", mul(fact[N], F[N][N]));
	}
	return 0;
}

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

int main()
{
    int a, b, arr[3];

    cin>>a>>b;
    arr[0] = a+b;
    arr[1] = a-b;
    arr[2] = a*b;

    sort(arr, arr+3);

    cout<<arr[2];

}


Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
ans = []
for m in range(n-1,-1,-1):
    for i in range(m,-1,-1):
        if b[i] == i+1:
            ans.append(i+1)
            del b[i]
            break
if b:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Q003 {
   Int n, offset;
   T e;
   std::function<T(T,T)> f;
   std::vector<T> xs;
   Q003(Int n_, T e_, std::function<T(T,T)> f_)
      : n(vecSize(n_)), offset(n/2), e(e_), f(f_), xs(n, e) {}
   static Int vecSize(Int x) {
      Int t = 1;
      while( t < x ) t *= 2;
      return 2 * t;
   }
   void update(Int i, T x) {
      Int k = i + offset;
      xs[k] = x;
      update(k>>1);
   }
   void update(Int i, std::function<T(T)> g) {
      Int k = i + offset;
      xs[k] = g(xs[k]);
      update(k>>1);
   }
   void update(Int k) {
      if( k == 0 ) return;
      xs[k] = f(xs[k<<1], xs[(k<<1)+1]);
      update(k>>1);
   }
   T query(Int x, Int y) {
      return query2(1, x, y, 0, offset);
   }
   T query2(Int k, Int x, Int y, Int a, Int c) {
      if( y <= a or c <= x ) return e;
      if( offset <= k ) return xs[k];
      if( x <= a and c <= y ) return xs[k];
      Int b = (a + c) / 2;
      return f(query2(k<<1, x, y, a, b), query2((k<<1)+1, x, y, b, c));
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n, q; scan(n, q);
      Q003<Int> rmq(n, 0, [](Int x, Int y){ return x + y; });
      for(Int i = 0; i < q; ++i) {
         Int c, x, y; scan(c, x, y);
         if( c == 0 ) {
            x -= 1;
            rmq.update(x, [y](Int t){ return t + y; });
         }
         if( c == 1 ) {
            x -= 1;
            y -= 1;
            Int z = rmq.query(x, y + 1);
            printf("%ld\n", z);
         }
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n, k;
  std::cin >> n >> k;
  vi numSeq;
  REP(i, n) numSeq.PB(read());
  vector<pi> cnt(n);
  REP(i, n) {
    REP(j, n) {
      if (numSeq[i] > numSeq[j])
        if (i < j)
          cnt[i].first++;
        else
          cnt[i].second++;
    }
  }
  int ans = 0;
  REP(i, n) {
    ans += (cnt[i].first * k);
    ans += (cnt[i].first + cnt[i].second) * ((k * k - ((k + 1) * k / 2)) % mod);
    ans %= mod;
  }
  print(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main (void){
        int N;
        long long int A,min,max;
        scanf("%lld",&N);
        scanf("%lld",&A);
        min=A;
        max=A;
        for (int i = 0; i < N-1; i++) {
          scanf("%lld",&A);
          if (A<min) {
            min=A;
          }
          if (A>max) {
            max=A;
          }
        }
printf("%lld\n",max-min );
        return 0;
}


Measured memory_bytes: 128
# C - Tax Increase
from math import floor

def calc(a: int, b: int) -> int:
    for i in range(1, 10001):
        if floor(i * 0.08) == a and floor(i * 0.1) == b:
            return i
    return -1


def main():
    A, B = map(int, input().split())
    print(calc(A, B))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];

  int cnt_n = 0;
  rep(i, n) {
    if (a[i] < 0){
      cnt_n++;
      a[i] *= -1;
    }
  }

  ll ans = 0;
  rep(i, n) ans += a[i];

  sort(a.begin(), a.end());
  if (cnt_n % 2 == 1) ans -= 2*a[0];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<endl;cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

ll get(vector<ll>v){
  sort(all(v));
  return v[1];
}

ll func(vector<ll>a){
  if(a.size()==1)return a[0];
  vector<ll>ret;
  rep(i,(int)a.size()-2){
    ret.push_back(get(vector<ll>(a.begin()+i,a.begin()+i+3)));
  }
  return func(ret);
}

void add(ll &x,ll n){
  x++;
  if(x>2*n-1)x=1;
}

bool solve(){
  ll n,x;cin>>n>>x;
  ll X=x;
  if(x<=1 or x>=2*n-1){
    cout<<"No"<<endl;
    return false;
  }
  x-=n-1;
  if(x<=0)x+=2*n-1;
  vector<ll>ans(2*n-1);
  rep(i,2*n-1){
    ans[i]=x;
    add(x,n);
  }
  cout<<"Yes"<<endl;
  cout<<ans<<endl;
 
  //cout<<func(p)<<endl;
  // if(func(ans)!=X){
  //   cout<<"AAA"<<endl;
  //   return true;
  // }


  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  return solve();
}


Measured memory_bytes: 3072
//https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_A
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b; //あまりが0ならそれが、最大公約数
}


int main(){
    int x,y;
    cin >> x >> y;

    int res = gcd(x,y);

    cout << res << endl;


    return 0;    
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    int main() {
     while(true){
     	int a,b;
     	char op;
     	cin >> a >> op >> b;
     	if(op == '+')	cout << a + b << '\n';
     	else if(op == '-')	cout << a - b << '\n';
     	else if(op == '*')	cout << a * b << '\n';
     	else if(op == '/')	cout << a / b << '\n';
     	else 			  return 0;
     }
     
     return 0;
    }


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

int main()
{
  int n;
  cin >> n;
  vector<int> A(n);
  for(int i = 0;i<n;i++)cin >> A[i];
  int ans = 0;
  for(int i = 0;i<n;i++)
  {
    int k = i;
    int j = i;
    while(A[k]<=A[k+1])k++;
    while(A[j]>=A[j+1])j++;
    ans++;
    i = max(k,j);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
  cout << fixed << setprecision(15);
  int n; cin >> n;
  vi m(n); rep(i, n) cin >> m[i];

  ll ans = 0;
  rep(i, n) ans = gcd(ans, m[i]);

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

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 1e5 + 47;

string s;
int n;

string n9;

string add(string& x, string& y)
{
	int sz1 =  max(SZ(x), SZ(y));
	int sz2 = min(SZ(x), SZ(y));

	string z;
	int carry = 0;
	int dx = sz1 - SZ(x);
	int dy = sz1 - SZ(y);

	RFOR(i, sz1, max(dx, dy))
	{
		int now = 0;
		now += (x[i - dx] - '0');
		now += (y[i - dy] - '0');

		if (now + carry > 9)
		{
			z.push_back('0' + (now + carry) % 10);
			carry = 1;
		}
		else
		{
			z.push_back('0' + (now + carry) % 10);
			carry = 0;
		}
	}

	RFOR(i, max(dx, dy), 0)
	{
		int now = 0;
		if (SZ(x) > SZ(y))
			now += (x[i - dx] - '0');
		else
			now += (y[i - dy] - '0');

		if (now + carry > 9)
		{
			z.push_back('0' + (now + carry) % 10);
			carry = 1;
		}
		else
		{
			z.push_back('0' + (now + carry) % 10);
			carry = 0;
		}
	}

	if (carry)
		z.push_back('1');

	reverse(ALL(z));
	return z;
}

bool can(int k)
{
	k *= 9;
	string res;
	string K = to_string(k);
	res = add(n9, K);
	int ans = 0;
	FOR(i, 0, SZ(res))
		ans += (res[i] - '0');
	return ans <= k;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> s;
	n = SZ(s);
	n9 = s;
	string rr = n9;
	FOR(i, 0, 8)
		n9 = add(n9, s);

	//cout << n9 << endl;
	int L = 1, R = n, M;
	while (R - L > 1)
	{
		M = (L + R) >> 1;
		if (can(M))
			R = M;
		else
			L = M;
	}

	if (can(L))
		M = L;
	else
		M = R;

	cout << M << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 3288
N,K = map(int,input().split())
ans1 = 0
ans2 = 0
for i in range(1,N+1):
    if i%K == 0:
        ans1 += 1
if K%2 == 0:
    for i in range(1,N+1):
        if i%K == K//2:
            ans2 += 1
print(ans1**3 + ans2**3)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<algorithm>

int a[1005];
int b[1005];
int c[1005];
int dp[1<<12];

int main(){

  int n,m,C;

  scanf("%d%d",&n,&m);

  for(int i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
    for(int j=0;j<b[i];j++){
      scanf("%d",&C);
      C--;
      c[i]|=1<<C;
    }
  }

  memset(dp,0x7f,sizeof(dp));
  
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<(1<<n);j++){
      if(dp[j]>=0){
        dp[j|c[i]]=std::min(dp[j]+a[i],dp[j|c[i]]);
      }
    }
  }

  if(dp[(1<<n)-1]==2139062143) printf("-1");
  else printf("%d",dp[(1<<n)-1]);
   puts("");

  return 0;

}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


MOD = 10**9 + 7
L = _s()

ans = 3**(len(L) - 1) % MOD
# for i in range(1, len(L)):
#     ans = (ans + 2**(2*i-1)) % MOD

sumL = L.count('1')
ans = (ans + 2**(sumL) % MOD) % MOD

count = 0
for i in range(len(L)-1):
    if L[-1-i] == '1':
        count += 1
        ans = (ans + 2 * pow(2, sumL-count-1, MOD) * pow(3, i, MOD)) % MOD

print(int(ans))


Measured memory_bytes: 3188
import sys

def sol(a, n):
  for i in range(0, n):
    x = a[i]
    if x%2 == 0:
      if x%3 != 0 and x%5 != 0:
        return False
  return True

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

if sol(a, n) == True:
  print('APPROVED')
else:
  print('DENIED')



Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int max_x = 0;
    for(char s : S){
        if(s == 'I') x++;
        if(s == 'D') x--;
        max_x = max(max_x, x);
    }
    cout << max_x << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n,a,b; cin>>n>>a>>b;
        printf("%d %d\n",min(a,b),max(0,a+b-n));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
string s;
string g;
cin>>k;
cin>>s;
if(s.size()<=k)
    cout<<s;
else if(s.size()>k)
{
for(int i=0;i<k;i++)
    cout<<s[i];
    cout<<"...";
}
return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define cin_fit() cin.tie(nullptr);ios::sync_with_stdio(false)
#define rep(i, N) for(int i=0; i<(N); i++)
#define reps(i, N) for(int i=1; i<=(N); i++)
#define rrep(i, N) for(int i=(int)(N)-1; i>=0; i--)
#define rreps(i, N) for(int i=(int)(N); i>=1; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll W, H, x, y;

int main() {
    cin_fit();
    cin >> W >> H >> x >> y;
    cout << W / 2.0 * H << ' ';
    if (2*x == W && 2*y == H) cout << 1;
    else cout << 0;
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Bytes, Chars};

fn main() {
    input! {
        k: usize,
        a: usize,
        b: usize,
    }
    for i in a..=b {
        if i % k == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


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

int main(){
    int N;
    int A;
    cin >> N >> A;
    
    if ( N % 500 <= A) {
        cout << "Yes" << endl;
    }
    
    if ( N % 500 > A) {
        cout << "No" << endl;
    }
    // Your code here!
    
}

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

  string key="keyence";


  if(s.substr(0,7)=="keyence" || s.substr(s.size()-7,7)=="keyence"){std::cout << "YES" << '\n';return 0;}

  int f=0;
  rep(i,7){
    if(s[f]!=key[f])break;
    f++;
  }

  bool ok=true;

  for (int i = s.size()-7+f; i < s.size(); i++) {
    if(s[i]!=key[f])ok=false;
    f++;
  }

  if(ok)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int s[1002];
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int main()
{
    int n, i, is;
    double m, fs, a;
     
    while (n = in()) {
        is = 0; for (i = 0; i < n; i++) is += s[i] = in();
        m = (double)is/n;
        fs = 0; for (i = 0; i < n; i++) {
            a = s[i]-m;
            fs += a*a;
        }
        printf("%.8lf\n", sqrt(fs/n));
    }
    return 0;
}


Measured memory_bytes: 2088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, w;
	struct { int v, w; } item[101];
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
		cin >> item[i].v >> item[i].w;
	int dp[101][10001] = {};
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= w; j++)
			if (item[i].w <= j)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j - item[i].w] + item[i].v);
			else
				dp[i][j] = dp[i-1][j];
	cout << dp[n][w] << endl;
	return 0;
}

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

int main(){
	long long n,k;
	cin>>n>>k;
	if(k==0){
		cout<<n*n;
		return 0;
	}
	long long ret = 0;
	for(int i=k+1; i<=n; i++){
		int curr = 0;
		int b = i;
		int cycle = b-k;
		curr+=(n/b)*cycle;
		int left = n%b;
		if(left>=k && left) curr+=left-k+1;
		ret+=curr;
	}
	cout<<ret;
}

Measured memory_bytes: 3548
N,M = map(int,input().split())
AB= []
for i in range(N):
    AB.append(list(map(int,input().split())))

AB.sort()

res = 0
count = 0

for A,B in AB:
    if  B <= M - count:
        count += B
        res += A * B
    else:
        res += A * (M - count)
        count = M

    if count == M:
        break

print(res)


Measured memory_bytes: 27760
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

print('ABD' if ri() > 999 else 'ABC')
















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

using namespace std;

const int MAXN=3100;

struct elem{
	long long int first;
	long long int second;
};

elem dp[MAXN][MAXN];
long long int A[MAXN];
int N;
void calcDP(){
	for(int i=0;i<N;i++)
		dp[i][i].first=A[i];
	for(int offset=1;offset<N;offset++){
		for(int i=0;i+offset<N;i++){
			long long int firstX = A[i]+dp[i+1][i+offset].second;
			long long int firstY = dp[i+1][i+offset].first;
			long long int secondX = A[offset+i] + dp[i][i+offset-1].second;
			long long int secondY = dp[i][i+offset-1].first;
			if((firstX-firstY)>secondX-secondY){
				dp[i][i+offset].first=firstX;
				dp[i][i+offset].second=firstY;
			}
			else{
				dp[i][i+offset].first=secondX;
				dp[i][i+offset].second=secondY;
			}
		}
	}
}
int main(){
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>A[i];
	calcDP();
	cout<<dp[0][N-1].first-dp[0][N-1].second;
}

Measured memory_bytes: 145664
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, int> pr;

#define MAX 100000
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF -1

int n, c[MAX];
ll d[MAX];
vector<pair<int, ll>> adj[MAX];

void dijkstra_init(){
	for(int i=0; i<n; i++){
		d[i]=INF;
		c[i]=WHITE;
	}
	return;
}

void dijkstra(int s){
	d[s]=0;
	priority_queue<pr, vector<pr>, greater<pr>> pq;
	pq.push(make_pair(0,s));
	c[s]=GRAY;

	while(!pq.empty()){
		pair<ll, int> f=pq.top();
		pq.pop();
		int u=f.second;
		c[u]=BLACK;
		if(d[u]<f.first && d[u]!=INF) continue;

		for(int j=0; j<adj[u].size(); j++){
			ll v=adj[u][j].first;
			if(c[v]==BLACK) continue;
			if(d[v]==INF || d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				pq.push(make_pair(d[v], v));
				c[v]=GRAY;
			}
		}
	}
	return;
}

int main(){
	cin >> n;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		adj[a-1].push_back(make_pair(b-1, c));
		adj[b-1].push_back(make_pair(a-1, c));
	}

	int q, k;
	cin >> q >> k;
	dijkstra_init();
	dijkstra(k-1);
	for(int i=0; i<q; i++){
		int x, y;
		cin >> x >> y;
		cout << d[x-1]+d[y-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 11504