akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
const MOD: u64 = 1000000007;


fn main() {
    input! {
        s: chars
    }
    let mut ans = false;
    let mut left = 0;
    let mut right = 0;

    for i in 0..s.len()-2 {
        if s[i] == s[i+1]{
            ans = true;
            left = i + 1;
            right = i + 2;
            break;
        } else if s[i] == s[i+2] {
            ans = true;
            left = i + 1;
            right = i + 3;
            break;
        }
    }
    if s[s.len()-2] == s[s.len()-1] {
        ans = true;
        left = s.len() - 1;
        right = s.len();
    }

    if ans {
        println!("{} {}", left, right);
    } else {
        println!("-1 -1");
    }
}

Measured memory_bytes: 4352
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

ll getMod(ll value,ll mod){
    if(value == 0) return 0;
    if(mod==0) return -1;
    value %= mod;
    if(value<0) value += mod;
    return value;
}
ll getPower(ll value,ll shisu,ll mod){
    ll ans = 1;
    ll cnt = shisu;
    while(cnt>0){
        if(cnt%2==1){
            ans = ans * value % mod;
        }
        value = value * value % mod;
        cnt = cnt/2;
    }
    return ans;
}

vll total111;
vll total100;
vll hosei;

ll getAns(string maxL){
    if(maxL=="0"){
        return 1;
    }
    ll leng = maxL.size();
    ll totaltmp= 1;
    total111.push_back(totaltmp);
    total100.push_back(1);
    hosei.push_back(1);
    ll keta = 0;

    while(keta<leng){
        totaltmp = totaltmp * 2 + totaltmp;
        totaltmp = getMod(totaltmp,MOD);
        total111.push_back(totaltmp);
        total100.push_back( 2 + total111[keta] );

        //cout << keta << " : "<< total100[keta] << endl;
        keta++;
    }

    keta = leng;
    ll ans = 2 + total111[keta-1];
    ll base = 2;
    for( ll li = 1 ; li <leng ; li++ ){
        string key = maxL.substr(li,1);
        if(key=="1"){
            keta = leng - li;
            ll dans = total100[keta] - 1;
            dans = dans*base;
            dans = getMod(dans,MOD);
            //cout << "dans " << dans << endl;
            ans  += dans;
            ans = getMod(ans,MOD);

            base *= 2;
            base = getMod(base,MOD);

        }
    }    
    return ans;

}


int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string maxL;
    cin >> maxL;

    ll ans = getAns(maxL);

    cout << ans << endl;




}

Measured memory_bytes: 5276
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,0,n){
	string t;
	cin >> t;
	s.it(t);
    }
    P(sz(s));
    return  0;
}


Measured memory_bytes: 19236
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
string s;
int dp[200010],st[200010];
unordered_map<int,int> ma;

void solve(){
    cin >> s;
    n=s.length();
    rep(i,n){
        int k=(1 << (s[i]-'a'));
        st[i+1]=st[i]^k;
    }
    if (st[n]==0) {
        cout << 1 << endl;
        return;
    }
    ma[0]=0;
    rep(i,n){
        //cout << bitset<26>(st[i+1]) << endl;
        int res=mod;
        if (ma.count(st[i+1])){
            res=ma[st[i+1]];
        }
        else ma[st[i+1]]=mod;
        rep(k,26){
            int m=(1 << k);
            if (ma.count(st[i+1]^m)){
                res=min(res,ma[st[i+1]^m]);
            }
        }
        dp[i+1]=res+1;
        ma[st[i+1]]=min(ma[st[i+1]],dp[i+1]);
        //cout << dp[i+1] << endl;
    }
    cout << dp[n] << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 10332
#include<stdio.h>
#include<math.h>
int main()
{
    int a[100000],n,i,j,c=0,count=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        c=0;
        scanf("%d",&a[i]);
        int rt=sqrt(a[i]);
        for(j=2;j<=rt;j++)
        {
            if(a[i]%j==0)
                c++;

        }
        if(c==0)
            count++;

    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2036
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
k = int(input())
for i in range(len(a)):
	for j in range(i+1 , len(a) - i):
		if(a[j] - a[i] > k):
			print(':(')
			exit()
		else:
			continue
	if(i == 4):
		print('Yay!')

Measured memory_bytes: 3064
// ARC085
// C - HSI

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int T_1 = 1900;
const int T_2 = 100;

int N, M;

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

    int t = T_1 * M + T_2 * (N - M);

    cout << t * pow(2, M) << endl;

    return 0;
}


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

int main() {
    int n;

    cin >> n;

    int cards[4][13] = {};

    char x;
    int y;

    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(x ==  'S') {
            cards[0][y] = 1;
        } else if ( x == 'H') {
            cards[1][y] = 1;
        } else if ( x == 'C') {
            cards[2][y] = 1;
        } else if ( x == 'D') {
            cards[3][y] = 1;
        }
    }

    for(int i = 0; i < 4; i++) {
      for(int j = 1; j< 14; j++) {
            if(cards[i][j] != 1) {
                if(i ==  0) {
                    cout << "S " << j << endl;
                } else if ( i == 1) {
                    cout << "H " << j << endl;
                } else if ( i == 2) {
                    cout << "C " << j << endl;
                } else if ( i == 3) {
                    cout << "D " << j << endl;
                }

            }
      }
    }

}



Measured memory_bytes: 3072
// 公式PDFと https://pitsbuffersolution.com/compro/atcoder/arc089d.php
// を見て回答
//
// まず白点, 黒点をmod 2Kで考えられるところまではわかる。
// 白点をちょうどK下にずらすとそこはかならずマス目の色が入れ替わるので、
// この位置に黒点があるのと等価にできる。
//
// 累積和は、盤面を広げて作成しておくと計算が簡単

#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

vector<vector<int>> make_2d_sum(vector<vector<int>>& cells) {
    int size = SIZE(cells);
    vector<vector<int>> ret(size, vector<int>(size));
    REP(j, size) {
        REP(i, size) {
            ret[j][i] += cells[j][i];
            if (i != 0) ret[j][i] += ret[j][i - 1];
        }
    }
    FOR(j, 1, size) {
        REP(i, size) {
            ret[j][i] += ret[j - 1][i];
        }
    }

    return ret;
}

int count(vector<vector<int>>& blacks, int y, int x, int y2, int x2) {
    return blacks[y2][x2] + blacks[y - 1][x - 1]
        - blacks[y - 1][x2] - blacks[y2][x - 1];
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N, K;
    cin >> N;
    cin >> K;

    // 計算を簡単にするため広めにとっておく
    vector<vector<int>> blacks(4 * K, vector<int>(4 * K));
    REP(n, N) {
        int x, y; char c;
        cin >> x >> y >> c;
        if (c == 'W') y += K;
        x %= (K * 2); y %= (K * 2);
        ++blacks[y][x];
        ++blacks[y][x + 2 * K];
        ++blacks[y + 2 * K][x];
        ++blacks[y + 2 * K][x + 2 * K];
    }
    // 2次元累積和
    auto black_sums = make_2d_sum(blacks);

    // auto s = SIZE(black_sums);
    // REP(j, s) {
    //     REP(i, s) {
    //         cout << blacks[j][i] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // REP(j, s) {
    //     REP(i, s) {
    //         cout << black_sums[j][i] << " ";
    //         // cout << blacks[j][i] << " ";
    //     }
    //     cout << endl;
    // }

    int ans = 0;
    FOR(y, 1, 2 * K + 1) {
        FOR(x, 1, 2 * K + 1) {
            int score = 0;
            score += count(black_sums, y, x, y + K - 1, x + K - 1);
            score += count(black_sums, y + K, x + K, y + 2 * K - 1, x + 2 * K - 1);
            ans = max(ans, score);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 125568
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
char s[n],t[n];
cin >> s >> t;
string ans;
REP(i,n) {
  ans += s[i];
  ans += t[i];
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
x=int(input())
flag=True
k=-1
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return True

    return False
  
while flag:
  k+=1
  flag=is_prime(x+k)
print(x+k)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int A[2009];

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

	int N, Z, W;
	cin >> N >> Z >> W;
	for (int i = 0; i < N; i++) cin >> A[i];

	if (N == 1) {
		cout << abs(A[0] - W) << endl;
	}
	else if (N >= 2) {
		cout << max(abs(A[N - 1] - W), abs(A[N - 1] - A[N - 2])) << endl;
	}

	return 0;
}

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

int mod = 1'000'000'007;

long long modpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2 == 0) return modpow(x, y/2) * modpow(x, y/2) % mod;
    return x * modpow(x, y-1) % mod;
}

int main(){
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    long long p = a * modpow(a + b, mod - 2) % mod;
    long long q = b * modpow(a + b, mod - 2) % mod;
    long long r = 100 * modpow(a + b, mod - 2) % mod;

    long long ans = 0;
    long long x = modpow(p, n);
    long long y = modpow(q, n);

    vector<long long> comb(n);
    comb[0] = 1;
    long long pro = 1;
    long long div = 1;
    for (int i = 1; i < n; i++){
        pro *= n + i - 1;
        pro %= mod;
        div *= i;
        div %= mod;
        comb[i] = pro * modpow(div, mod - 2) % mod;
    }
    for (int i = 0; i < n; i++){
        ans += ((n + i) * (x * modpow(q, i) % mod) % mod) * comb[i] % mod;
        ans %= mod;
        ans += ((n + i) * (modpow(p, i) * y % mod) % mod) * comb[i] % mod;
        ans %= mod;
    }
    cout << ans * r % mod << endl;
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!

s = input()
t = input()

cslist = []
slist = []

ctlist = []
tlist = []
for x in t:
    if x in ctlist:
        pass
    else:
        tlist.append(t.count(x))
        ctlist.append(x)

for y in s:
    if y in cslist:
        pass
    else:
        slist.append(s.count(y))
        cslist.append(y)


if sorted(slist) == sorted(tlist):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
// ooooo      ooo                     
// `888b.     `8'                     
//  8 `88b.    8   .ooooo.   .oooo.   
//  8   `88b.  8  d88' `88b `P  )88b  
//  8     `88b.8  888   888  .oP"888  
//  8       `888  888   888 d8(  888  
// o8o        `8  `Y8bod8P' `Y888""8o 
// C++ Conpetitive Programming Template 
// Ver 2.0 (codename: Noa)
// Last Modified : 2019-06-07
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    ll x, a;
    cin >> x >> a;
    if(x < a) {
        out(0);
    }else {
        out(10);
    }
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 256
=begin
N
A1 A2 ... An
=end

n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i)

h = {}
f = false

as.each do |a|
  if h[a]
    puts "NO"
    f = true
    break
  end

  h[a] = true
end

if !f
  puts "YES"
end


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

using namespace std;
#define int long long

const int INF = 200000000007;


  vector<int> vl[100],vr[100];
signed main(){
    int n,k;
    cin>>n>>k;
    int v[n];
    for(int i=0;i<n;i++)cin>>v[i];
  vector<int>  mu,mu2;
    
    vl[0].push_back(v[0]);
    if(v[0]<0){
        mu.push_back(v[0]);
        sort(mu.begin(),mu.end());
    }
    for(int i=0;i<mu.size();i++){
        vl[0].push_back(vl[0][vl[0].size()-1]-mu[i]);
    }
    for(int i=1;i<n;i++){
       vl[i].push_back(vl[i-1][0]+v[i]);
       if(v[i]<0){
           mu.push_back(v[i]);
             sort(mu.begin(),mu.end());
       }
        for(int j=0;j<mu.size();j++){
        vl[i].push_back(vl[i][vl[i].size()-1]-mu[j]);
    }
    
    }

   vr[n-1].push_back(v[n-1]);

   if(v[n-1]<0){
       mu2.push_back(v[n-1]);
        sort(mu2.begin(),mu2.end());
   }
    for(int i=0;i<mu2.size();i++){
        vr[n-1].push_back(vr[n-1][vr[n-1].size()-1]-mu2[i]);
    }
    for(int i=1;i<n;i++){
        vr[n-1-i].push_back(vr[n-i][0]+v[n-1-i]);
     
          if(v[n-1-i]<0){
              mu2.push_back(v[n-1-i]);
               sort(mu2.begin(),mu2.end());
          }
       for(int j=0;j<mu2.size();j++){
            vr[n-1-i].push_back(vr[n-1-i][vr[n-1-i].size()-1]-mu2[j]);
        }
        
    }
   int m1,m2,ans=0;
   
   for(int i=0;i<n;i++){
       for(int j=0;j<vl[i].size();j++){
           if(i+1+j<=k){
                       
                       ans=max(ans,vl[i][j]);
                      
                   }
           for(int p=0;p<n;p++){
               for(int q=0;q<vr[p].size();q++){
                 
                   if(i<p&&i+1+j+n-p+q<=k){
             
                       ans=max(ans,vl[i][j]+vr[p][q]);
                       

                   }
               }
           }
           
       }
   }
   for(int p=0;p<n;p++){
               for(int q=0;q<vr[p].size();q++){
                 
                   if(n-p+q<=k){
                     
                       ans=max(ans,vr[p][q]);
                        
                   }
               }
           }
   cout<<ans;
for(int i=0;i<mu.size();i++)cerr<<mu[i]<<' ';
for(int i=0;i<mu2.size();i++)cerr<<mu2[i]<<' ';

    
    return 0;
}

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

using namespace std;

typedef long long ll;

ll counter[10001] = {0};

void setup()
{
	for(ll j = 1; j <= 100; j++)
	{
		for(ll k = 1; k <= 100; k++)
		{
			for(ll l = 1; l <= 100; l++)
			{
				if(j * j + k * k + l * l + j * k + k * l + l * j <= 10000)
				{
					counter[j * j + k * k + l * l + j * k + k * l + l * j]++;
				}
			}
		}
	}
}

int main()
{
	setup();

	//cout << "	ready" << endl;

	ll n;

	cin >> n;

	for(ll i = 1; i <= n; i++)
	{
		cout << counter[i] << endl;
	}

    return 0;
}



Measured memory_bytes: 3664
// include
#include <cstdint>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <array>

// ============================================
int main() {

    for (int i = 0; i < 5; ++i) {
       int x;
       std::cin >> x;
       if (x == 0) {
          std::cout << i + 1 << std::endl;
       }
    }

    return 0;
}


Measured memory_bytes: 3588
package main

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

func main() {
	input := ReadLine()
	chars := map[string]int{}

	for _, v := range strings.Split(input, "") {
		if _, exists := chars[v]; exists {
			fmt.Println("no")
			return
		}

		chars[v] = 1
	}
	fmt.Println("yes")
}

/////////////////////////////////////////

func fln(format string, elements ...interface{}) {

	fmt.Printf(format+"\n", elements...)
}

var BufReader = bufio.NewReaderSize(os.Stdin, 1e6)

func ReadLine() string {
	a, _, _ := BufReader.ReadLine()
	return string(a)
}

func ReadLineInt() (result []int) {
	in := strings.Split(ReadLine(), " ")
	result = make([]int, 0, 2)
	for _, v := range in {
		t, _ := strconv.Atoi(v)
		result = append(result, t)
	}
	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 400005;
using lint = long long;
using pi = pair<int, int>;

struct ret{
	pi c1;
	pi c2;
}rett[MAXN];

ret merge(ret a, ret b){
	vector<pi> v;
	v.push_back(a.c1);
	v.push_back(a.c2);
	v.push_back(b.c1);
	v.push_back(b.c2);
	sort(v.rbegin(), v.rend());
	ret r;
	r.c1 = v[0];
	for(int i=1; i<4; i++){
		if(v[i].second != v[0].second){
			r.c2 = v[i];
			return r;
		}
	}assert(0);
};

ret make(int v, int w){
	return (ret){pi(v, w), pi(-2e9, -1)};
}

int n, a[MAXN];
int dap[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=0;i<(1<<n); i++) scanf("%d",&a[i]);
	for(int i=0; i<(1<<n); i++){
		rett[i] = make(a[i], i);
		for(int j=0; j<n; j++){
			if((i >> j) & 1) rett[i] = merge(rett[i], rett[i ^ (1<<j)]);
		}
		dap[i] = rett[i].c1.first + rett[i].c2.first;
	}
	for(int i=1; i<(1<<n); i++){
		dap[i] = max(dap[i], dap[i-1]);
		printf("%d\n", dap[i]);
	}

}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

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

int main(void)
{
    int n, k;
    cin >> n >> k;
    
    v_int a(n);
    irep(i, n) {
        int x;
        cin >> a[i];
    }
    int g = a[0];
    int mx = -1;
    irep(i, n) {
        g = gcd(g, a[i]);
        chmax(mx, a[i]);
    }
    if(k % g || k >mx) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }
    return 0;
}
/*atcoder*/


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

int n, q, par[100000][17], dep[100009];

int LCA(int u, int v) {
    if(dep[u] > dep[v]) swap(u, v);

    rep(i, 17) if((dep[v] - dep[u] >> i) & 1) v = par[v][i];

    if(u == v) return u;

    for(int i = 16; i >= 0; i--)
        if(par[u][i] != par[v][i]) {
            u = par[u][i];
            v = par[v][i];
        }

    return par[u][0];
}

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

    cin >> n;
    par[0][0] = -1;
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            par[a][0] = i;
            dep[a] = dep[i] + 1;
        }
    }

    FOR(i, 1, 17) {
        rep(j, n) {
            if(par[j][i - 1] == -1)
                par[j][i] = -1;
            else
                par[j][i] = par[par[j][i - 1]][i - 1];
        }
    }

    cin >> q;

    while(q--) {
        int u, v;
        cin >> u >> v;
        cout << LCA(u, v) << endl;
    }

    return 0;
}


Measured memory_bytes: 10248
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
 
int main(){
     
    int n,i;
    double p1=0, p2=0, p3=0, pm=0;
    cin >> n ;
     
    int x[n], y[n], dif[n];
    for (i=0; i<n; i++){
        cin >> x[i] ;     
    }
    for (i=0; i<n; i++){
        cin >> y[i] ;     
    }   
    for (i=0; i<n; i++){
        dif[i]=fabs(x[i]-y[i]);
        p1+=dif[i];
        p2+=pow(dif[i], 2);
        p3+=pow(dif[i], 3);
        if (pm<dif[i]) pm=dif[i];
    }
    p2=sqrt(p2);
    p3=pow(p3, 1.0/3.0);
     
    printf("%.6f\n""%.6f\n""%.6f\n""%.6f\n", p1, p2, p3, pm);
     
    return 0;
}

Measured memory_bytes: 3336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,T;
ll calc(ll k) {
  ll x=1;
  for(ll i=0; i<k; i++) {
    x*=n;
    if(x>1000000000) return x;
  }
  return x;
}

int main() {
  string s;
  cin >> n >> T >> s;
  s+="+";
  ll k=0,sum=0;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='^') k=0;
    if(isdigit(s[i])) {
      k*=10;
      k+=s[i]-'0';
    }
    if(s[i]=='+') sum+=calc(k);
    if(sum>1000000000||sum*T>1000000000) {
      cout << "TLE" << endl;
      return 0;
    }
  }
  cout << sum*T << endl;
  return 0;
}

Measured memory_bytes: 1204
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se1 second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

int main() {
    get(n);
    gets(s);
    if(n%2==0) {
        string t = s.substr(0,n/2);

        if(t+t==s) {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
    return 0;  
}

Measured memory_bytes: 256
/*
[agc039] C - Division by Two with Something
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MOD = 998244353;

class gf {
public:
    int n;
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf& operator-=(gf x) { return *this = (*this - x); }
    gf& operator*=(gf x) { return *this = (*this * x); }
};

int N;
string X;

gf calc(int l) {
    gf cnt = 0;
    for (int i = 0; i < l; i++) {
        cnt = cnt * 2 + (X[i] - '0');
    }
    string y = X;
    for (int i = l; i < N; i++) {
        y[i] = y[i - l] ^ 1;
    }
    if (y <= X) {
        cnt += 1;
    }

    return cnt;
}

ll solve() {
    vector<int> ls;
    for (int i = 1; i <= N; i++) {
        if (N % i == 0 && (N / i) % 2 == 1) {
            ls.push_back(i);
        }
    }

    vector<gf> coeffs(ls.size());
    for (int i = (int)ls.size() - 1; i >= 0; i--) {
        coeffs[i] = 2 * ls[i];
        for (int j = i + 1; j < (int)ls.size(); j++) {
            if (ls[j] % ls[i] == 0 && (ls[j] / ls[i]) % 2 == 1) {
                coeffs[i] -= coeffs[j];
            }
        }
    }

    gf ans = 0;
    for (int i = 0; i < (int)ls.size(); i++) {
        ans += calc(ls[i]) * coeffs[i];
    }

    return ans.n;
}

int main() {
    cin >> N;
    cin >> X;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 772
// 2011/03/14 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		bool rem[10000];
		for(int i=0; i<n; i++)
			rem[i] = false;

		for(int i=1; i<=n-1; i++)
			rem[i*i%n] = true;

		int cnt[5000];
		for(int i=1; i<=(n-1)/2; i++)
			cnt[i] = 0;

		for(int a=0; a<n; a++){
			if(!rem[a])
				continue;

			for(int b=a+1; b<n; b++){
				if(!rem[b])
					continue;

				int c = b-a;
				if(c>(n-1)/2)
					c = n-c;
				cnt[c]++;
			}
		}

		for(int i=1; i<=(n-1)/2; i++)
			cout << cnt[i]*2 << endl;
	}

	return 0;
}

Measured memory_bytes: 892
def comb(a, b, p=10 ** 9 + 7):
    if (b > a - b):
        return comb(a, a - b, p)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= p
        d %= p
    return c * modpow(d, p - 2, p) % p


def modpow(n, p, m=10 ** 9 + 7):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, p // 2, m) ** 2) % m
    return (modpow(n, p - 1, m) * n) % m


def resolve():
    n, a, b = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = modpow(2, n) - 1
    ans -= comb(n, a)
    ans -= comb(n, b)
    print(ans % mod)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
a,b=map(int,input().split())
c,d=map(int,input().split())
e,f=map(int,input().split())
li=[a,b,c,d,e,f]
x=[li.count(i) for i in range(1,5)]
if max(x)<3:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  
  string name;
  
  while(N!=0){
    int num = N%26;
    string S = "";
    if(num == 0){
      num=26;
    }
    S+= 'a'+num-1;
    name = S + name;
    N=(N-num+1)/26;
  }
  
  cout << name << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


/*
int main(){
  ll N,M;
  ll ans = 0;

  cin >> N >> M;
  vector<vector<ll>>cakes(N,vector<ll>(3));
  for(ll i=0;i<N;i++){
    cin >> cakes[i][0] >> cakes[i][1] >> cakes[i][2];
  }
  for(int bit=0;bit<(1<<N);bit++){
    ll cnt = 0;
    ll sx=0,sy=0,sz=0;
    for(ll i=0;i<N;i++){
      if(bit & (1<<i)){
        sx += cakes[i][0];
        sy += cakes[i][1];
        sz += cakes[i][2];
        cnt++;

      }
    }
    if(cnt==M)ans = max(ans,abs(sx)+abs(sy)+abs(sz));
  }
  cout<< ans <<endl;
}
*/

int N, M;

int main() {
    cin >> N >> M;
    vector<long long> a[3];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            long long num; cin >> num;
            a[j].push_back(num);
        }
    }
    long long res = 0;
    for (int bit = 0; bit < (1<<3); ++bit) {
        vector<long long> b;
        for (int i = 0; i < N; ++i) {
            long long tmp = 0;
            for (int j = 0; j < 3; ++j) {
                if (bit & (1<<j)) tmp += a[j][i];
                else tmp -= a[j][i];
            }
            b.push_back(tmp);
        }
        sort(b.begin(), b.end(), greater<long long>());
        long long sum = 0;
        for (int i = 0; i < M; ++i) {
            sum += b[i];
        }
        res = max(res, sum);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int64_t s[N+1]={};
  s[0]=2,s[1]=1;
  if(N>=2)  {
    for(int i=2;i<=N;i++) s[i]=s[i-1]+s[i-2];
  }
  cout<<s[N]<<endl;
}
  



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<(int)n;i++)
#define rev(i,n,init) for(int i=(int)n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }

using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int cost[3005][3005];
int dp[3001][3001][4];


int32_t main()
{ 
      getFaster;
      int tests=1; 
      //cin>>tests;
      rep(ii,0,tests)
      {
           int n,m,k;
           cin>>n>>m>>k;
           rep(i,1,k+1)
           {
                 int x,y,z;
                 cin>>x>>y>>z;
                 cost[x][y]=z;
           }

           int val=0;
           rep(i,1,n+1)
           {
                 rep(j,1,m+1)
                 {
                       int max_val=0;
                       rep(k,0,4)max_val=max(max_val,dp[i-1][j][k]);
                       rep(k,0,4)
                       {
                             int& ans=dp[i][j][k];
                             ans=0;
                             ans=max(ans,max_val);
                             
                             if(k==0)
                             {
                                ans=max({ans,dp[i][j-1][k]});
                                continue;
                             }
                             ans=max({ans,cost[i][j]+max_val,cost[i][j]+dp[i][j-1][k-1]});
                             ans=max({ans,max_val,dp[i][j-1][k]});
                             val=max(val,ans);
                       }
                 }
           }
           cout<<val<<endl;
      } 
      return 0;                         
}

Measured memory_bytes: 355240
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    Job[] jobs = new Job[N];
    for (int i = 0; i < N; i++) jobs[i] = new Job(scanner.nextInt(), scanner.nextInt());
    Arrays.sort(jobs, Comparator.comparingInt(j -> j.due));

    int ans = 0;
    int j = 0;
    PriorityQueue<Job> pq = new PriorityQueue<>();
    for (int i = 1; i <= M; i++) {
      while (j < N && jobs[j].due <= i) pq.add(jobs[j++]);
      if (!pq.isEmpty()) ans += pq.poll().reward;
    }
    System.out.println(ans);
  }

  private static class Job implements Comparable<Job> {
    private final int due;
    private final int reward;

    private Job(int due, int reward) {
      this.due = due;
      this.reward = reward;
    }

    @Override public int compareTo(Job job) {
      return job.reward - reward;
    }
  }
}


Measured memory_bytes: 86872
#include<iostream>

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

using namespace std;

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i, k){
        if(b >= c || a >= c){
            c *= 2;
            continue;
        }
        if(b < c){
            if(a >= b){
                b *= 2;
                continue;
            }
            if(a < b){
                c *= 2;
                continue;
            }
        }
    }

    if(b > a && c > b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
N=int(input())
h_num=10000
L=[[] for x in range(h_num)]
def string_to_hash(S):
    S_num=0
    i=0
    for s in S:
        i+=1
        if s=='A':
            S_num+=1*i
        elif s=='C':
            S_num+=10*i
        elif s=='G':
            S_num+=100*i
        elif s=='T':
            S_num+=1000*i
    return(S_num%h_num)

for n in range(N):
    cmd , str_ = input().split()
    h=string_to_hash(str_)
    if cmd=='insert':
        L[h].append(str_)
    elif cmd== 'find':
        L_temp=L[h]
        if str_ in L_temp:
            print('yes')
        else:
            print('no')
    


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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
*/

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int k;
    cin >> n >> k;
    vector<vector<int>> a(n,vector<int>(n));
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin >> a[i][j];
    a=pow_mat(a,k);
    int dp=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            dp+=a[i][j];
            dp%=mod;
        }
    cout << dp;
	return 0;
}


Measured memory_bytes: 1664
MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


N, K = map(int, input().split())
A = list(map(int, input().split()))
modFacts, invs = prepare(N)


# mod2 = [0] * (N + 1)
# mod2[0] = 1
# for i in range(N):
#     mod2[i + 1] = mod2[i] * 2
#     mod2[i + 1] %= MOD

A.sort()
ans = 0

for i in range(K - 1, N):
    n = i
    r = K - 1
    num = (modFacts[n] * invs[n - r] * invs[r]) % MOD
    ans += A[i] * num
    ans %= MOD

for i in range(N - K + 1):
    n = N - (i + 1)
    r = K - 1
    num = (modFacts[n] * invs[n - r] * invs[r]) % MOD
    ans -= A[i] * num
    ans %= MOD


print(ans)


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

int main() {
  long long n,a,b;
  cin>>n>>a>>b;
  long long h=a+b;
  long long p=n/h;
  long long r=n-p*h;
  
  long long ans=0;
  
  ans=a*p;
  if(r>a) ans=ans+a;
  else ans=ans+r;
  
  cout << ans << endl;
}

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

int main()
{
    int n,m;
    int ki,x;
    int num[50]={0};
    cin >> n >> m;
    for(int i=0;i<n;i++)
    {
        cin >> ki;
        for(int j=0;j<ki;j++)
        {
            cin >> x;
            num[x]++;
        }
    }
    int cnt=0;
    for(int i=0;i<=m;i++)
        if(num[i]==n)
            cnt++;
        printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
S=list(input())
G=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
ans=10**10
AAA=10**10
for i in range(n):#根
  D=deque([i])
  A=[i]
  V=[0]*n
  V[i]=1
  C=[[] for i in range(n)]
  while len(D)>0:
    x=D[0]
    D.popleft()
    for j in range(len(G[x])):
      if V[G[x][j]]==0:
        V[G[x][j]]=1
        D.append(G[x][j])
        A.append(G[x][j])
        C[x].append(G[x][j])
  A=A[::-1]
  Ans=[[0]*3 for i in range(n)]
  for v in A:
    if len(C[v])==1:
      vc=C[v][0]
      Ans[v]=[Ans[vc][0],Ans[vc][1]+Ans[vc][2],Ans[vc][2]]
    elif len(C[v])!=0:
      L=[]
      LL=[]
      cc=0
      s=0
      M=0
      MM=0
      for vc in C[v]:
        m=Ans[vc][1]+Ans[vc][2]
        if m>M:
          M=m
          MM=Ans[vc][0]
        L.append(Ans[vc][1]+Ans[vc][2])
        LL.append(2*Ans[vc][0]+Ans[vc][1]+Ans[vc][2])
        cc=cc+Ans[vc][2]
        s=s+Ans[vc][0]
      if sum(LL)-M-2*MM>=M:
        ss=sum(L)//2
      else:
        ss=sum(LL)-M-2*MM-s+MM
      Ans[v]=[s+ss,sum(L)-2*ss,cc]
    if S[v]=="1":
      Ans[v][2]+=1
  if Ans[i][1]==0:
    if Ans[i][0]<ans:
      ans=Ans[i][0]
if ans==10**10:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 132868
/**********************************************

1.data_convert.cpp
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-07-10@17:49

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

#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;

int main(void){


        int n=0;

        while(1){

                int n=0;
                int k=0;
             
                cin >> n;
                if(n==0)break;
                vector <char> a(n);
                vector <char> b(n);

                for(int i=0; i< n; i++){

                        cin >> a[i] >> b[i];
                }
                
                cin >> k;
                vector <char> data(k);
                
                for(int i=0; i<k; i++){

                        cin >> data[i];
                        for(int j=0; j<n; j++){
                               
                                if(data[i] == a[j]){
                                        data[i] = b[j];
                                        break;
                                }
                        }
                }
                
                for(int i=0; i<k; i++){
                        cout << data[i];
                }

                cout <<endl;
                
        }
        
        
        return 0;
        
        
}

Measured memory_bytes: 1288