akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.BigDecimal;

public class Main{

    int n,m,p,a,b;
    int[] t;
    int[][] time;
    int INF = 100000;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            p = sc.nextInt();
            a = sc.nextInt();
            b = sc.nextInt();
            if(n==0 && m==0 && p==0 && a==0 && b==0) break;

            a--; b--;

            t = new int[n];
            for(int i=0; i<n; i++) t[i] = sc.nextInt();

            time = new int[m][m];
            for(int i=0; i<m; i++) Arrays.fill(time[i],INF);
            for(int i=0; i<p; i++){
                int x = sc.nextInt()-1;
                int y = sc.nextInt()-1;
                int z = sc.nextInt();
                time[x][y] = z;
                time[y][x] = z;
            }

            double[][] dp = new double[1<<n][m];
            for(int i=0; i<1<<n; i++) Arrays.fill(dp[i],INF);

            dp[0][a] = 0;
            for(int i=0; i<m; i++){
                for(int bit=0; bit<1<<n; bit++){
                    if(dp[bit][i]==INF) continue;
                    for(int j=0; j<m; j++){
                        if(time[i][j]==INF) continue;
                        for(int k=0; k<n; k++){
                            if((bit&1<<k)>0) continue;
                            int newbit = bit^(1<<k);
                            dp[newbit][j] = Math.min(dp[newbit][j],dp[bit][i]+(double)time[i][j]/t[k]);
                        }
                    }
                }
            }

            double ans = INF;
            for(int i=0; i<1<<n; i++) ans = Math.min(ans, dp[i][b]);
            BigDecimal bi = new BigDecimal(String.valueOf(ans));
            ans = bi.setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue();

            if(ans==INF) System.out.println("Impossible");
            else System.out.printf("%.3f\n",ans);
        }
    }

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

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

using namespace std;

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

	set<int> N;
	N.insert(a);
	N.insert(b);
	N.insert(c);

	cout << N.size() << endl;
	
	
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;

    if (st.size() % 2) {
        if (st[st.size()/2] != st[st.size()/2+1] ||
                st[st.size()/2] != st[st.size()/2-1]) {
            cout << st.size()/2 + st.size()%2 << endl;
            return 0;
        }
        int ans = INF;
        int mid = st.size()/2;
        for (int i = 1; i + mid < st.size(); i++) {
            if (st[mid] != st[mid+i]) {
                ans = mid+i;
                //cout << "i:" << i << endl;
                break;
            }
        }
        //cout << ans << endl;
        for (int i = 1; mid - i >= 0; i++) {
            if (st[mid] != st[mid-i]) {
                ans = min(ans, mid+i);
                //cout << "i:" << i << endl;
                break;
            }
        }
        cout << ((ans != INF) ? ans : st.size()) << endl;
    } else {
        if (st[st.size()/2] != st[st.size()/2-1]) {
            cout << st.size()/2 << endl;
            return 0;
        }
        int ans = INF;
        int mid = st.size()/2;
        for (int i = 1; i + mid < st.size(); i++) {
            if (st[mid] != st[mid+i]) {
                ans = mid+i;
                break;
            }
        }
        mid--;
        for (int i = 1; mid - i >= 0; i++) {
            if (st[mid] != st[mid-i]) {
                ans = min(ans, mid+i+1);
                break;
            }
        }
        cout << ((ans != INF) ? ans : st.size()) << endl;
    }


    return 0;
}




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

int main(){
  int N,K,L;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if (x <= K/2){
      L += x*2;
    }else{
      L += (K-x)*2;
    }
  }
  cout << L << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int d, l;
	cin >> d >> l;
	cout << (d % l) + (d / l) << endl;
}


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

const int maxn=100003;
const int mo=1000000007;

int n,cnt[31],res=1;
char s[maxn];

int main(){
  scanf("%d",&n);
  scanf("%s",s+1);
  for(int i=1;i<=n;++i)
    ++cnt[s[i]-'a'];
  for(int i=0;i<26;++i)if(cnt[i]){
    res=(1ll*res*(cnt[i]+1))%mo;
  }
  printf("%d\n",(res+mo-1)%mo);
  return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;

    for(int i=0;i<n;++i){
        int h;
        cin >> h;
        if(h >= k) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
 
// ------------------------------------------------------------------------------------------------

ll n, k;

int main() {
    fast_io; cout_precision;
    cin >> n >> k;
    cout << (n + k - 3) / (k - 1) << endl;
}

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

int main() {
  
  long long x,y,a;
  cin >> x >> y;
  
  a = x;
  
  int cnt = 1;
  
  while(a <= y){
    a *= 2;
    //cout << a << endl;
    if ( a <= y ){
      cnt++;
    }
    //cout << cnt << endl;
  }
  
  cout << cnt << endl;   
 
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    if (n == 1) cout << "Hello World\n";
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

using ll = long long;
using ld = long double;
struct line{
    ll m, c;
    line(ll slope, ll inter) : m(slope), c(inter){}
    ll val(ll x) { return m*x + c;}
    ld inter(ll m1, ll c1){
        ld m2 = (ld)m;
        ld c2 = (ld) c;
        return (c2-c1)/(m1-m2);
    }
};

ll square (ll a){
    return a*a;
}

int main(){
    #ifndef ONLINE_JUDGE
        //freopen("C:\\Users\\ACER\\Desktop\\Codes\\input.txt", "r", stdin);
    #endif
    deque<line> s;
    int N;
    ll C;
    cin>>N>>C;
    vector<ll> h(N); for(auto &v : h) cin>>v;
    vector<ll> dp(N);
    dp[0] = 0;
    s.push_back({-2*h[0], square(h[0])});
    for(int i = 1; i<N; i++){
        //remove redundant
        while(s.size()>=2 && (s[0].val(h[i])>=s[1].val(h[i])))
            {
                s.pop_front();
            }
        dp[i] = square(h[i]) + C + s[0].val(h[i]);
        //insert if worth
        while(s.size()>=2){
            int nn = s.size();
            ld a = s[nn-1].inter(-2*h[i], dp[i] + square(h[i]));
            ld b = s[nn-2].inter(s[nn-1].m, s[nn-1].c);
            if(a<b) s.pop_back();
            else break;
        }
        s.push_back({-2*h[i], dp[i] + square(h[i])});
    }
    cout<<dp[N-1] << endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll cnt_prime(ll a){
    ll cnt = 0;
    for(ll i = 2; i * i <= a; i++){
        if (a % i == 0){
            cnt++;
            while(a % i == 0){
                a /= i;
            }
        }
    }
    if (a != 1) cnt++;
    return cnt;
}

int main(void){
    ll A, B; cin >> A >> B;
    ll G = __gcd(A, B);
    
    cout << cnt_prime(G) + 1 << endl;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    abc058b()
}

fun abc058b() {
    val (o, e) = (1..2).map { ArrayDeque(readLine()!!.toMutableList()) }

    val answer = StringBuilder()
    while (o.isNotEmpty() || e.isNotEmpty()) {
        o.pollFirst()?.let { answer.append(it) }
        e.pollFirst()?.let { answer.append(it) }
    }

    println(answer)
}


Measured memory_bytes: 33824
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem2020b(n, a))
}

fun problem2020b(n: Int, a: List<Int>): Int {
    var count = 0
    for (i in 0 until n) {
        val ai = a[i]
        if ((i + 1) % 2 != 0 && ai % 2 != 0) count++
    }
    return count
}

Measured memory_bytes: 37920
#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>;

// 約数を列挙
vector<ll> enumerateDivisors(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      // 対応する約数も追加(自分自身でなければ)
      if (n / i != i) {
        res.push_back(n / i);
      }
    }
  }
  // 昇順にソート
  sort(res.begin(), res.end());
  return res;
}

// 素数か判定する
bool isPrime(ll n) {
  if (n <= 1) {
    return false;
  }
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  vector<ll> aa = enumerateDivisors(a);
  vector<ll> bb = enumerateDivisors(b);
  vector<ll> common;
  for (ll aaa : aa) {
    if (find(bb.begin(), bb.end(), aaa) != bb.end()) {
      common.push_back(aaa);
    }
  }

  ll res = 1; // 1の分
  for (ll x : common) {
    if (isPrime(x)) {
      res++;
    }
  }
  cout << res << endl;

  return 0;
}


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

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

    int i,b,c,n,a[1000];
    int count = 0, sum = 0;

    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            count++;

            if(a[i]%3==0 || a[i]%5==0)
            {
                sum++;
            }
        }
    }



    if(count==sum)
    {
        cout<<"APPROVED";
    }

    else

        cout<<"DENIED";

    }





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

int main() {
    int N;
    cin>>N;
    long A[N];
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    bool check = true;
    if(A[0]!=0)check = false;
    for(int i=1;i<N;++i){
        if(A[i]-A[i-1]>1)check = false;
    }
    long ans = A[N-1];
    if(check){
        for(int i=N-1;i>=1;--i){
            if(A[i]-A[i-1]!=1)ans += A[i-1];
        }
    }
    else ans = -1;
    cout<<ans<<endl;
}


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


#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;


int lev(int a, int b) {
	int ans = 1; int buf = a ^ b;
	while ((buf & 1) == 0) {
		ans++;
		buf >>= 1;
	}
	return ans;
}


void solve() {
	int n; cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			cout << lev(i, j);
			if (j != n - 1) cout << " ";
		}
		cout << endl;
	}
}

int main() {

	solve();

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, k;
string x;
vector<vector<Int> > cnt[1 << 21];

Int dp[1 << 21];
Int log_2[1 << 21];
Int ans[21];

Int rev(Int l, Int x){
    Int res = 0;
    for(int i = 0;i < l;i++){
        res *= 2;
        res += x % 2;
        x /= 2;
    }
    return res;
}

void prepare(vector<vector<Int>> &vec, int n){
    for(int i = 0;i < n;i++){
        vec.push_back(vector<Int>(1 << i, 0));
    }
}

void dfs(Int x = 1, int dep = 0){
    if(dep > n)return;
    if(dep < n){
        prepare(cnt[x*2], n-dep);
        prepare(cnt[x*2+1], n-dep);
    }
    for(int i = 0;i <= n-dep;i++){
        for(int j = 0;j < (1<<i);j++){
            dp[x] += cnt[x][i][j];
            if(j+1 != (1<<i)){
                int neg = ~j;
                int first_zero = neg & -neg;
                int length = log_2[first_zero] + 1;
                cnt[x * 2][i-length][j >> length] += cnt[x][i][j];             
            }
            if(j != 0){
                int first_one = j & -j;
                int length = log_2[first_one] + 1;
                cnt[x * 2 + 1][i-length][j >> length] += cnt[x][i][j];             
            }
        }
    }
//    cout << x << " "  << dp[x] << endl;
    if(dp[x] >= k){
        if(ans[dep] == -1)ans[dep] = INF;
        ans[dep] = min(ans[dep], rev(dep, x));
        dfs(x * 2, dep + 1);
        dfs(x * 2 + 1, dep + 1);
    }
}

int main(){
    for(int i = 0;i < 21;i++){
        log_2[1 << i] = i;
        ans[i] = -1;
    }
    cin >> n >> k;
    prepare(cnt[1], n+1);
    for(int i = 0;i <= n;i++){
        cin >> x;
        for(int j = 0;j < (1<<i);j++){
            cnt[1][i][j] = x[j] - '0';
        }
    }

    dfs(1);

    for(int i = n;i >= 0;i--){
        if(ans[i] != -1){
            for(int j = i-1;j >= 0;j--){
                cout << (ans[i] >> j)%2;
            }cout << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 615880
#include<stdio.h>
#include<algorithm>
#define maxn 100000
using namespace std;

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

int main(){
    long n;
    long a[maxn];
    scanf("%ld", &n);
    for(int i=0; i<n; i++){
        scanf("%ld", &a[i]);
    }
    long g= gcd(a[0], a[1]);
    for(int i=0; i<n; i++){
        g=gcd(g, a[i]);
    }
    printf("%ld\n", g);
    return 0;
}


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

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


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

int main(void) {
    int n, y, a = -1, b = -1, c = -1;
    cin >> n >> y;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; i + j <= n; j++) {
            if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                a = i; b = j; c = n - i - j;
                break;
            }
        }
    }
    cout << a << ' ' << b << ' '<< c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "stdc++.h"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int		GCD(int a, int b) {
	if (b == 0) return a;
	return GCD(b, a % b);
}

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

	ll a, b;
	cin >> a >> b;
	cout << a / GCD(a, b) * b << endl;
}


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

int main(){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    long long sum = 0,sum1 = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        sum += a[i] - b[i];
        if(a[i] < b[i]){
            sum1 += b[i] - a[i];
            cnt++;
        }
    }

    int c[n];
    for(int i = 0; i < n; i++){
        c[i] = a[i] - b[i];
    }
    sort(c,c+n);
    reverse(c,c+n);
    for(int i = 0; i < n; i++){
        if(c[i] > 0 && sum1 > 0){
            sum1 -= c[i];
            cnt++;
        }
    }
    if(sum < 0 || sum1 > 0){
        cout << -1 << endl;
    }else{
        cout << cnt << endl;
    }
    return 0;
}



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

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

    auto friends = vector<int>(N);
    for (auto& x : friends)
    {
        cin >> x;
        x--;
    }

    auto result = 0;
    for (auto i = 0; i < N; i++)
    {
        const auto j = friends[i];
        if (friends[j] == i && i <= j)
            result++;
    }

    cout << result << endl;
}


Measured memory_bytes: 640
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
/*__int128 read()
{
	__int128 ans = 0;
	int sgn = 1;
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-')
			sgn *= -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - '0';
		c = getchar();
	}
	return ans * sgn;
}
void print(__int128 x)
{
	if (x > 9)
		print(x / 10);
	putchar(x % 10 + '0');
}*/
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, q = 0, ch = 0, p = 0, l = 0, r = 0; lli x = 0ll;
	cin >> n >> q;
	fenwick_tree<lli> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> x; v.add(i, x);
	}
	for (int i = 0; i < q; ++i)
	{
		cin >> ch;
		if (ch == 0)
		{
			cin >> p >> x; v.add(p, x);
		}
		else
		{
			cin >> l >> r; cout << v.sum(l, r) << "\n";
		}
	}
}

Measured memory_bytes: 8252
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	int n;
	cin>>n>>s;
	int k=s.size();
	if(k<=n)
	cout<<s;
	else
	{
		for(int i=0;i<n;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int hoge[4] = {10,50,100,500};

int main() {
  int s;
  int nnnn = 0; 
  while(cin >> s, s) {
    if (nnnn) cout << endl;
    else nnnn++;
    int num[4];
    REP(i,4) {
      cin >> num[i];
    }
    vector<int> ans(4);
    int mi = INF;
    REP(i,num[0]+1) {
      REP(j,num[1]+1) {
        REP(k, num[2]+1) {
          REP(l, num[3]+1) {
            if (i*10+j*50+k*100+l*500 < s ) continue;
            int x = i*10+j*50+k*100+l*500 - s;
            int tmp = -i-j-k-l;

            bool f = 0;
            for (int m=3; m>=0; --m) {
              while(x-hoge[m] >= 0) {
                x -= hoge[m];
                tmp++;
                if (m==0&&i>0) f = 1;
                else if (m==1&&j>0) f = 1;
                else if (m==2&&k>0) f = 1;
                else if (m==3&&l>0) f = 1;
              }
            }
            if (f) continue;
            
            if (tmp < mi) {
              mi = tmp;
              ans[0] = i;
              ans[1] = j;
              ans[2] = k;
              ans[3] = l;
            }
          }
        }
      }
    }
    REP(i,4) {
      if (ans[i] > 0)
        cout << hoge[i] << " " << ans[i] << endl;
    }
  }
}

Measured memory_bytes: 904
// Contest: AtCoder Beginner Contest 156 (https://atcoder.jp/contests/abc156)
// Problem: B: Digits (https://atcoder.jp/contests/abc156/tasks/abc156_b)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, k; cin >> n >> k;
    int c = 0;
    while (n)
        ++c, n /= k;

    cout << c << '\n';
    return 0;
}

Measured memory_bytes: 256
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 31 17:36:23 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct train_t {
  uint32_t time;
  uint32_t start;
  uint32_t interval;
};

int32_t main()
{
  uint32_t N;
  cin >> N;

  vector<train_t> trains;
  for (uint32_t i = 0; i < N; i++) {
    uint32_t C, S, F;
    cin >> C >> S >> F;
    trains.push_back(train_t({C, S, F}));
  }

  for (uint32_t i = 0; i < trains.size(); i++) {
    uint32_t clock = 0;
    for (uint32_t j = i; j < trains.size() - 1; j++) {
      uint32_t t = trains[j].time;
      uint32_t s = trains[j].start;
      uint32_t i = trains[j].interval;
      uint32_t n = 0;
      while (s + n * i < clock) {
        n++;
      }
      clock = (s + n * i) + t;
    }
    cout << clock << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    std::string x;
    int sum;
    for ( ; getline(std::cin, x) && !(x == "0"); ) {
        sum = 0;
        for (size_t i = 0; i < x.length(); i++) {
            sum += x[i] - '0';
        }
        std::cout << sum << std::endl;
    }
    return 0;
}

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

using namespace std;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
typedef long long ll;
const int mn = 1e6 + 5;
typedef pair<ll, int> pii;
int n;
ll k, ans;
int a[mn], f[mn];

bool c(ll x) {
    ll tk = k;
    for (int i = 1; i <= n; i++) {
        if (1ll * a[i] * f[i] <= x) continue;
        int needa = x / f[i];
        tk -= (a[i] - needa);
    }
    return tk >= 0;
}

int main() {
    //cin.sync_with_stdio(0);
#ifdef trote
    freopen("../1.txt", "r", stdin);
#endif
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &f[i]);
    }
    sort(f + 1, f + n + 1, [](int a, int b) { return a > b; });
    ll L = 0, R = n * 1000000000000ll, ans = 0;
    while (L <= R) {
        ll mid = L + R >> 1;
        if (c(mid)) R = mid - 1, ans = mid;
        else L = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5120
// BISMILLAHIR RAHMANIR RAHEEM
// ALLAH IS WATCHING ME
// ALLAH save us from COVID-19.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll     long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses    "\n"
#define all(x) (x).begin(), (x).end()
#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;
const ll MOD = 1000000007;

template <class T> inline T bigmod(T p,T e,T M){if(e==0)return 1;if(e%2==0){ll t=bigmod(p,e/2,M);return (T)((t*t)%M);}return (T)((ll)bigmod(p,e-1,M)*(ll)p)%M;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // when M is prime;

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge{int u, vv;bool operator<(Edge const& other){return vv > other.vv;}}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better


//***********************************************  The END **********************************************************************************************************************************


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



////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
    ios
    ll n,k=2;
    cin>>n;
    ll arr[n+1];
    for(ll i=1;i<=n;i++)cin >> arr[i];

    ll dp[n];
    for(ll i=0;i<=n;i++)dp[i]=0;
    for(ll i=2;i<=n;i++){
           dp[i]=INF;
           for(ll j=i-1;j>=max(1LL,i-k);j--){
               dp[i]=min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
           }
    //cout<<dp[i]<<" ";
    }
    cout<<dp[n]<<ses;
}
/*

*/



Measured memory_bytes: 1792
L,R = map(int, input().split())
rec = 2019
for i in range (2020):
    for j in range(2020):
        if i >= j or (L+j) > R:
            continue
        elif (((L+i)*(L+j)) % 2019) < rec:
            rec = ((L+i)*(L+j)) % 2019
print(rec)

Measured memory_bytes: 3060
# Dice for AOJ
class Dice
  def initialize(input)
    @t, @s, @e, @w, @n, @b = input
  end

  def roll_e
    tmp = @e
    @e = @t
    @t = @w
    @w = @b
    @b = tmp
  end

  def roll_n
    tmp = @n
    @n = @t
    @t = @s
    @s = @b
    @b = tmp
  end

  def roll_w
    tmp = @w
    @w = @t
    @t = @e
    @e = @b
    @b = tmp
  end

  def roll_s
    tmp = @s
    @s = @t
    @t = @n
    @n = @b
    @b = tmp
  end

  def spin_r
    tmp = @s
    @s = @e
    @e = @n
    @n = @w
    @w = tmp
  end

  attr_reader :t
  attr_reader :s
  attr_reader :e
  attr_reader :w
  attr_reader :n
  attr_reader :b
end

d = gets.split.map(&:to_i)
dice = Dice.new(d)
q = gets.to_i

q.times do
  qt, qs = gets.split.map(&:to_i)

  case qt
  when dice.s
    dice.roll_n
  when dice.e
    dice.roll_w
  when dice.w
    dice.roll_e
  when dice.n
    dice.roll_s
  when dice.b
    dice.roll_n
    dice.roll_n
  end

  4.times do
    dice.spin_r
    break if qs == dice.s
  end

  puts dice.e
end



Measured memory_bytes: 6876
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define ll long long





int main() {



	ll n;
	cin >> n;

	ll a[n];
	ll dp[n];

	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	dp[0] = 0;
	dp[1] = dp[0] + abs(a[1] - a[0]);

	for (ll i = 2; i < n; i++) {
		dp[i] = min((dp[i - 1] + abs(a[i] - a[i - 1])), (dp[i - 2] + abs(a[i] - a[i - 2])));
	}

	cout << dp[n - 1];


}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <set>
 
#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;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<ll> d(n);
  REP(i,n){
    cin >> d[i];
  }
  set<ll> s(ALL(d));
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals
#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>
#include <map>

int main() {
  size_t n;
  intmax_t d, a;
  scanf("%zu %jd %jd", &n, &d, &a);

  std::map<intmax_t, size_t> enc;
  std::vector<std::pair<intmax_t, intmax_t>> xh(n);
  for (auto& p: xh) {
    intmax_t x, h;
    scanf("%jd %jd", &x, &h);
    enc[x];
    p = std::make_pair(x, h);
  }
  intmax_t inf = 1e10;
  enc[inf];

  std::sort(xh.begin(), xh.end());
  {
    size_t i = 0;
    for (auto& p: enc) p.second = i++;
  }

  std::vector<intmax_t> h(n);
  for (size_t i = 0; i < n; ++i) {
    h[enc.at(xh[i].first)] = xh[i].second;
  }

  intmax_t res = 0;
  std::vector<intmax_t> dp(n+2);

  for (size_t i = 0; i < n; ++i) {
    h[i] += dp[i];
    intmax_t hi = h[i];
    if (hi > 0) {
      intmax_t cur = (hi+a-1) / a;
      intmax_t dh = cur * a;
      size_t j = enc.upper_bound(xh[i].first+d+d)->second;
      res += cur;
      dp[i] -= dh;
      dp[j] += dh;
    }

    dp[i+1] += dp[i];
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 18944
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);


// ===

fn main() {
    let s: String = read();
    let t: String = read();

    let mut ok = false;
    let n = s.len();
    for i in 0..n {
        let mut rotated = "".to_string();
        rotated.push_str(&s[i..n]);
        rotated.push_str(&s[0..i]);
        ok |= rotated == t;
    }

    if (ok) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstdlib>
#define _A_ true
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 10
#define INF 1<<30
using namespace std;
typedef pair<int,int> P;
int h,w,c;
int p[MAX][MAX];
int Ans;

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

void Display(){
  rep(i,h){
    rep(j,w){
      printf("%d ",p[i][j]);
    }
    printf("\n");
  }
  printf("\n");
}


void ColorCount(){
  queue<P> CQ;
  CQ.push(P(0,0));
  bool used[h][w];
  rep(i,h)rep(j,w)used[i][j] = false;
  used[0][0] = true;
  int count = 1;
  //Display();

  while(CQ.size()){
    P pi = CQ.front(); CQ.pop();

    rep(i,4){
      int nx = pi.first + dx[i], ny = pi.second + dy[i];
      if(0<= nx && nx < w && 0<= ny && ny < h && !used[ny][nx] && p[ny][nx] == c){
      count++;	
      CQ.push(P(nx,ny));
      used[ny][nx] = true;    
      }
      
    }
    
  }
  //cout << "Color = " << count << endl;
  Ans = max(Ans,count);

}



void FiveRec(){
  //cout << "In" << endl;
  queue<P> que;
  bool used[h][w];
  rep(i,h)rep(j,w)used[i][j] = false;
  //bool pre
  que.push(P(0,0));
  used[0][0] = true;
  int ThisColor = p[0][0];
  p[0][0] = c;

  while(que.size()){
    P pi = que.front(); que.pop();
    //cout << "pi.first = " << pi.first << ", pi.second = " << pi.second << endl;
    rep(i,4){
      int nx = pi.first + dx[i],ny = pi.second + dy[i];   
      if(0<= nx && nx < w && 0<= ny && ny < h && !used[ny][nx] &&  p[ny][nx] == ThisColor){       
	//cout << "In " << endl; 
	que.push(P(nx,ny));
	//cout << "w = " << w << ", h = " << h << endl;
	p[ny][nx] = c;
	used[ny][nx] = true;
      }
    }
  }
  //cout << "Five Fin " << endl;
}


void rec(int color,int count){
  //cout << "count = " << count << endl;
  if(count == 5){
    //printf("Five Count --------------\n");
    FiveRec();
    //Display();
    ColorCount();
    //printf("Fin Five Count ---------- %d\n",Ans);
    return;
  }

  //cout << "normal disp --------" << endl;
  //Display();
  //cout << "FF----------------FF" << endl;
  queue<P> que;
  bool used[h][w];
  rep(i,h)rep(j,w)used[i][j] = false;
 
  int ThisColor = p[0][0];
  int pb[h][w];
  rep(i,h)rep(j,w)pb[i][j] = p[i][j];
  que.push(P(0,0));
  used[0][0] = true;
  p[0][0] = color;


  while(que.size()){
    P pi = que.front(); que.pop();

    rep(i,4){
      int nx = pi.first + dx[i],ny = pi.second + dy[i];   
      if(0<= nx && nx < w && 0<= ny && ny < h && !used[ny][nx] &&  p[ny][nx] == ThisColor){ 
	que.push(P(nx,ny));
	p[ny][nx] = color;
	used[ny][nx] = true;
      }
    }
  }


  //koko ra hennde syuukei siteha douda roka
  REP(i,1,7){
    //if(i != color)
    rec(i,count+1);
  }
  //printf("-----------------------\n");
  rep(i,h)rep(j,w)p[i][j] = pb[i][j];
  
}



int main(){
  while(_A_){
    scanf("%d %d %d",&h,&w,&c);
    if(!(h|w|c))break;
    Ans = -1;
    rep(i,h)rep(j,w)scanf("%d",&p[i][j]);
    REP(i,1,7){
      //if(i != p[0][0])
	rec(i,1);
    }
    printf("%d\n",Ans);
  }
  return 0;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	vector<int> v[n+1];
	for(int i=0;i<m;i++)
	{
		int a, b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int nc=0;
	bool vs[n+1];
	fill(vs, vs+n+1, false);
	for(int i=1;i<n+1;i++)
	{
		if(!vs[i])
		{
			nc++;
			vs[i]=true;
			queue<int> q;
			q.push(i);
			while(!q.empty())
			{
				auto ii=q.front();
				q.pop();
				for(auto it:v[ii])
				{
					if(!vs[it])
					{
						vs[it]=true;
						q.push(it);
					}
				}
			}
		}
	}
	cout<<nc-1;
}

Measured memory_bytes: 8920
def main():
    L, R = map(int, input().split())
    if R // 2019 > L // 2019:
        print(0)
        return
    retval = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            retval = min(retval, (i % 2019 * j % 2019) % 2019)
    print(retval)
    return
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

int N, L;

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

	int ans = 10000;

	for (int i = 0; i < N; i++) {
		int T = L + i;
		if (abs(ans) > abs(T)) ans = T;
	}
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		ANS += L + i;
	}

	cout << ANS - ans;
}

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

int main() {
int n,m;
cin >> n >> m;
int a[n];
for(int i=0;i<n;i++){
    cin >> a[i];
}
long long sum=0;
for(int i=0;i<n;i++){
    sum+=a[i];
}
int cnt=0;
long double border=double(sum)/(4*m);
for(int i=0;i<n;i++){
    if(a[i]>=border)cnt++;
}
if(cnt>=m)cout << "Yes";
else cout << "No";
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

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

void hawawa()
{
	unsigned long long a, b;
	unsigned long long c, d;
	cin >> a >> b >> c >> d;
	unsigned long long ans = b - a + 1;
	ans -= (b / c) - (a / c) + !(a % c);
	ans -= (b / d) - (a / d) + !(a % d);
	ans += (b / ((d * c) / gcd(d, c))) - (a / ((d * c) / gcd(d, c))) + !(a % ((d * c) / gcd(d, c)));
	cout << ans << "\n";
}


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


Measured memory_bytes: 256
char a[500][501];m[500][500];main(i,j,k,x,y,r,M){
for(;scanf("%d%d",&y,&x),x;printf("%d\n",r)){
	for(j=0;j<y;j++)scanf("%s",a[j]);
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++)if(a[j][i]=='.')r++;else r=0;
	for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=99999,k=j;k<y;k++){
		if(M>m[k][i])M=m[k][i];
		if(r<M*(k-j+1))r=M*(k-j+1);
	}
}exit(0);}

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

int main() {
    
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    int cur = 0;
    int m = cur;
    for (auto c:s) {
        if (c == 'I') cur++; else cur --;
        m = max(m,cur);
    }
    
    cout << m;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll x,cur;
  double dx,rate;
  cin >> x;
  cur = 100;
  rate = 1.01;
  int cnt=0;
  while(cur<x){
    cur = cur*rate;
    //cout << cur << endl;
    cnt++;
  }

  cout << (cnt) << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
    #include <string>
    #include <cmath>
    #include <cstdint>
     
    using namespace std;
     
    int main(void)
    {
      uint64_t a, b, x;
      cin >> a >> b >> x;
      uint64_t il = a % x ? a / x + 1 : a / x;
      uint64_t ir = b / x;
     
      cout << ir - il + 1 << endl;
     
      return 0;
    }

Measured memory_bytes: 888
n = int(input())
arr = [tuple(map(int,input().split())) for _ in range(n)]

routesum = 0
for i in range(n-1):
    for j in range(i+1,n):
        routesum += ((arr[i][0]-arr[j][0])**2 + (arr[i][1]-arr[j][1])**2)**0.5
        
for i in range(1,n):
    routesum *= i
for i in range(1,n+1):
    routesum /= i

print(routesum*2)

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

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var numMax = 0;
            var ans = 1;

            for (int m = 1; m <= n; m++)
            {
                var k = m;
                var num = 0;

                while (k % 2 == 0)
                {
                    k = k / 2;
                    num++;
                }

                if(num > numMax)
                {
                    numMax = num;
                    ans = m;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27452
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=2e5+10;

ll int n,m,k;

ll int a[maxn];

ll int b[maxn];

int main()
{
	
	scanf("%lld%lld%lld",&n,&m,&k);
	
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	
	for(int i=0;i<m;i++)
	{
		scanf("%lld",&b[i]);
	}
	
	int maxx=-1;
	
	int cnt=0;
	
	ll int now=0;
	
	int mark=-1;
	
	for(int i=0;i<n;i++)
	{
		if(now+a[i]<=k)
		{
			now+=a[i];
			cnt++;
			mark=i;
		}
		else
		{
			break;
		}
	}
	
	maxx=max(maxx,cnt);
	
	for(int i=0;i<m;i++)
	{
		if(now+b[i]<=k)
		{
			now+=b[i];
			cnt++;
			
			maxx=max(maxx,cnt);
		}
		else
		{
			while(now+b[i]>k && mark!=-1)
			{
				
				now-=a[mark];
				
				mark--;
				
				cnt--;
			}
			
			if(now+b[i]<=k)
			{
				now+=b[i];
				cnt++;
				maxx=max(maxx,cnt);
				continue; 
				
			}
			else
			{
				break;
			}
			
		}
	}
	
	
	printf("%d\n",maxx);
	
	return 0;
}


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

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

  vector<int> v(n);
  vector<int> cv(n);
  for(int i=0; i < n; i++){
    cin >> v[i];
    cv[i] = i+1;
  }

  vector<int> sw(0);

  if(v == cv){
    cout << "YES" <<endl;
  }
  else{
    for(int i=0; i < n; i++){
      if(v[i] != cv[i]){
        sw.push_back(i);
      }
    }
    swap(v[sw[0]],v[sw[1]]);

    if(v == cv){
      cout << "YES" <<endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    int num = 1;
    int now = 0;
    for (int i = 0; i < N; i++) {
        now += L[i];
        if (now > X) break;
        num++;
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int n;
  cin>>n;
  int a[3];
  a[0]=n/3600;
  n%=3600;
  a[1]=n/60;
  n%=60;
  a[2]=n;
  rep(i,3){
    if(i) cout<<":";
    cout<<a[i];
  }
  cout<<endl;
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1160
# 2019-11-20 21:35:12(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
from scipy.misc import comb # (default: exact=False)
import numpy as np 


def main():
    n, p = [int(x) for x in sys.stdin.readline().split()]
    a = np.array(sys.stdin.readline().split(), np.int64)
    a %= 2
    a.sort()
    count0 = np.searchsorted(a, 1)
    count1 = n - count0

    ans = 0
    if p == 1:
        for i in range(count0+1):
            for j in range(1, count1+1, 2):
                ans += comb(count0, i, exact=True) * comb(count1, j, exact=True)
    else:
        for i in range(count0+1):
            for j in range(0, count1+1, 2):
                ans += comb(count0, i, exact=True) * comb(count1, j, exact=True)
    
    print(ans)





if __name__ == "__main__":
    main()


Measured memory_bytes: 13196