akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int h, w, k;

bool check(int num)
{
    bool prevone = false;
    while (num != 0)
    {
        int cur = num % 2;
        if (cur == 1)
        {
            if (prevone == true)
                return false;
            prevone = true;
        }
        else
        {
            prevone = false;
        }
        num /= 2;
    }
    return true;
}

int main(int argc, char const *argv[])
{
    cin >> h >> w >> k;
    vector<vector<ll>> dp(h + 1, vector<ll>(w, 0));
    dp[0][0] = 1;
    rep(i, 1, h + 1)
    {
        rep(pattern, 1 << (w - 1))
        {
            if (check(pattern) == false)
                continue;
            vector<int> order(w);
            rep(j, w) order[j] = j;
            rep(j, w - 1)
            {
                if (((pattern >> j) & 1) == 1)
                {
                    swap(order[j], order[j + 1]);
                }
            }
            rep(j, w)
            {
                dp[i][j] += dp[i - 1][order[j]];
                dp[i][j] %= MOD;
            }
        }
    }
    /*
    rep(i, h + 1)
    {
        for (auto x : dp[i])
            cerr << x << " ";
        cerr << endl;
    }*/
    cout << dp[h][k - 1] << endl;
    return 0;
}


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

int main() {
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        rep(i, n) {
                cin >> a[i];
        }
        sort(a.begin(), a.end());
        int ans = 0;
        rep(i, k) {
                ans += a[i];
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 3616
import java.lang.Math

fun main(args: Array<String>) {
    val mod = 1000000007L
    val A_MAX = 1000000
    val N = readInputLine().toInt()
    val AArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    val inverse = LongArray(A_MAX + 1)
    inverse[0] = 1L
    inverse[1] = 1L
    for (i in 2..A_MAX) {
        inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)
    }

    val minFactor = LongArray(A_MAX + 1) { -1L }
    minFactor[0] = 0L
    minFactor[1] = 1L
    for (i in 2..A_MAX) {
        if (minFactor[i] == -1L) {
            minFactor[i] = i.toLong()
            for (j in i * 2..A_MAX step i) {
                if (minFactor[j] == -1L) {
                    minFactor[j] = i.toLong()
                }
            }
        }
    }

    val factorCount = mutableMapOf<Long, Long>()
    for (A in AArr) {
        var tmp = A
        val factorTmp = mutableMapOf<Long, Long>()
        while (tmp != 1L) {
            val factor = minFactor[tmp.toInt()]
            val cnt = factorTmp[factor] ?: 0L
            factorTmp[factor] = cnt + 1L
            tmp /= factor
        }
        factorTmp.forEach { e ->
            factorCount[e.key] = Math.max(factorCount[e.key] ?: 0, e.value)
        }
    }

    var lcm = 1L

    factorCount.forEach { e ->
        for (i in 1..e.value) {
            lcm *= e.key
            lcm %= mod
        }
    }

    var ans = 0L

    for (A in AArr) {
        ans += lcm * inverse[A.toInt()] % mod
        ans %= mod
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 68044
#include<stdio.h>

int main()
{
	long long n, k, tmp1{}, tmp2{};

	scanf("%lld%lld", &n, &k);
	tmp1 = n / k;
	n *= 2;
	if (!(k % 2))
		tmp2 = n / k - tmp1;

	printf("%lld\n", tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;
int main(void){
    string a, b, c;
    cin >> a;
    cin >> b; 
    cin >> c;
    cout << char((int)a[0]-32) << char((int)b[0]-32) << char((int)c[0]-32) << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int n;
int array[100010];

int main(void)
{
    int i;
    int result,flag;

    //freopen("x.in","r",stdin);

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

    result = 1;
    flag = 0;
    for(i = 1;i < n;++i)
    {
        if(array[i] == array[i - 1])
            continue;
        if(!flag){
            flag = array[i] > array[i - 1] ? 1 : -1;
            continue;
        }

        if((array[i] > array[i - 1] && flag < 0) || (array[i] < array[i - 1] && flag > 0)){
            ++result;
            flag = 0;
            continue;
        }
    }

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

    return 0;
}

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

namespace ConsoleApplication1
{
    static class Program
    {
        static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            Console.WriteLine(ToAlphabet(n).ToLower());
        }

        static string ToAlphabet(this long self)
        {
            if (self <= 0) return "";
            long n = self % 26;
            n = (n == 0) ? 26 : n;
            string s = ((char)(n + 64)).ToString();
            if (self == n) return s;
            return ((self - n) / 26).ToAlphabet() + s;
        }

    }
}

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

int main() {
	long long A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (i % 2 == 0) {
			if (A % 2 == 0) {
				B += A / 2;
				A /= 2;
			}
			else {
				A--;
				B += A / 2;
				A /= 2;
			}
		}
		else {
			if (B % 2 == 0) {
				A += B / 2;
				B /= 2;
			}
			else {
				B--;
				A += B / 2;
				B /= 2;
			}
		}
	}
	cout << A << " " << B << endl;
}

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

// ----- MP algorithm -----

template <typename Type = string>
class MP
{
  int N;
  Type S;
  vector<int> A;

public:
  MP() {}
  MP(Type const &S) : N(S.size()), S{S}, A(N + 1, -1)
  {
    int j{-1};
    for (auto i{0}; i < N; i++)
    {
      while (j != -1 && S[j] != S[i])
      {
        j = A[j];
      }
      ++j;
      A[i + 1] = j;
    }
  }

  int operator[](int i) const { return A[i]; }

  int period(int i) const { return i - A[i]; }

  vector<int> place(Type const &T) const
  {
    vector<int> res;
    int j{0};
    for (auto i{size_t{0}}; i < T.size(); i++)
    {
      while (j != -1 && S[j] != T[i])
      {
        j = A[j];
      }
      ++j;
      if (j == N)
      {
        res.push_back(i - j + 1);
        j = A[j];
      }
    }
    return res;
  }

  vector<bool> table(Type const &T) const
  {
    vector<bool> res(T.size(), false);
    for (auto e : place(T))
    {
      res[e] = true;
    }
    return res;
  }
};

int main()
{
  string t, p;
  cin >> t >> p;
  MP<string> mp{p};
  for (auto e : mp.place(t))
  {
    cout << e << endl;
  }
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 998244353
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll a,ll b,ll m=mod) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%m ;
        a = (a * a)%m ;
        b >>= 1;
    }
    return res;
}
main()
{   IO
    ll a,b;
    cin>>a>>b;
    if(b>=2*a && (b-2*a)%2==0 && a>=((b-2*a)/2))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 3648
M = 10 ** 6 + 5
N = int(input())
A = list(map(int, input().split()))

cnt = [0] * M
for i in A:
    if(cnt[i] >= 2):
        continue
    for j in range(i, M, i):
        cnt[j] += 1
ans = 0
for i in A:
    if(cnt[i] == 1):
        ans += 1
print(ans)

Measured memory_bytes: 32372
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    long long lcm = 1;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;
        long long gcd = __gcd(x, lcm);
        lcm = x / gcd * lcm;
    }
    cout << lcm << '\n';
    return 0;
}

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

int main() {
int a,b;
cin >> a >> b;
int ans =0;
int space = 1;
while(space < b){
   --space;
   space += a;
   ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int>d;
    int temp;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        d.push_back(temp);
    }
    sort(d.begin(), d.end());

    cout << d[n / 2] - d[n / 2 - 1];

    

    return 0;
}

Measured memory_bytes: 892
import math
line = list(map(int,input().split()))
a = line[0]
b = line[1]
num1 = math.floor(a/b)
num2 = a%b
num3 = float(a/b)

print(str(num1) + " "+str(num2),end= " ")
print("{:.8f}".format(num3))


Measured memory_bytes: 5672
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdio.h>

int main()
{   int a,b,n,k,i,j;
    scanf("%d",&k);
    if(k%2==0){a=k/2;
    a=a*a;
    
    printf("%d",a);}
    else{
        a=k/2;
    a=a*(a+1);
    printf("%d",a);
    }return 0;
}



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

A.sort(reverse=True)
sumofvote = sum(A)
res = 0

for a in A:
  if a < (sumofvote/(4*M)):
    break
  else:
    res+=1
    
if res >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n-k; i++){
		if(a[i] < a[k+i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define endl '\n';
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N),F(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> F[i];
  }
  sort(A.begin(),A.end());
  sort(F.begin(),F.end(),greater<ll>());
  ll ok=INF,ng=-1;
  while(ok-ng>1){
    ll mid = (ng+ok)/2;
    ll cnt = 0;
    for(int i=0; i<N; i++){
      if(A[i] > mid/F[i]) cnt += A[i] - mid/F[i];
    }
    if(cnt <= K){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


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


int main()
{
    int r, c, k; cin >> r >> c >> k;
    char ch;
    int row[r] = {}, col[c] = {}, table[r][c]={};
    int countn{0}, result{0};
    for(int i = 0; i < r*c; i++)
    {
        cin >> ch;
        if(ch == '#')
        {
            col[i%c] += 1;
            row[i/c] += 1;
            countn++;
            table[i/c][i%c] = 1;
        }
    }
    /*
    for(int i = 0; i < r; i++)
        cout << row[i] << " ";
    cout << endl;
    for(int j = 0; j < c; j++)
        cout << col[j] << " ";
    cout << endl;
    */
    // すべての選び方を試して、総和がkになるものがあるかを調べる
    for (int tmp = 0; tmp < (1 << r); tmp++) 
    {
        bitset<6> sr(tmp);  // 最大r個なのでrビットのビット列として扱う
    
        // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
        int sum = 0, temp;
        for (int i = 0; i < r; i++) {
            if (sr.test(i)) {
                sum += row[i];
            }
        }
        temp = sum;
        for (int tmpj = 0; tmpj < (1 << c); tmpj++) 
        {
            bitset<6> sc(tmpj);  // 最大r個なのでrビットのビット列として扱う
        
            // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
            sum = temp;
            for (int j = 0; j < c; j++) {
                if (sc.test(j)) {
                    sum += col[j];
                }
            }
            for(int ri = 0; ri < r; ri++)
                if(sr.test(ri))
                    for(int ci = 0; ci < c; ci++)
                        if(sc.test(ci))
                            sum -= table[ri][ci];
            if ((countn - sum) == k) {
                result++;
            }
            //cout << sum << " ";
        }
        
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3648
def LCS(s,t): # s,tの共通部分列の最長
    global dp,ns,nt
    ns=len(s)
    nt=len(t)
    dp=[[0 for _ in range(nt+1)] for _ in range(ns+1)]
    for i in range(1,ns+1):
        for j in range(1,nt+1):
            if s[i-1]==t[j-1]:
                dp[i][j]=dp[i-1][j-1]+1
            else:
                dp[i][j]=max( dp[i][j-1] , dp[i-1][j] )
    #print(dp[ns][nt])

def recovery(s,t): # LCSのDPを逆から追い復元
    LCS(s,t)
    x=ns
    y=nt
    ans=[]
    while x>0 and y>0:
        if dp[x][y]==dp[x][y-1]:
            y-=1
        elif dp[x][y]==dp[x-1][y]:
            x-=1
        else:
            x-=1
            y-=1
            ans.append(s[x])
    ans.reverse()
    print(''.join(ans))
    
def main():
    s=list(input())
    t=list(input())
    recovery(s,t)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 120156
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; i++){
        int j = n - i;
        if(i >= j) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s = it.next().unwrap();
    println!("{}", s.replace("?", "D"));
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
long long int pp[100005],p[100005],ar[100005],n,k,x,y,z,ans,tut,top,maks;
int main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		p[i]=p[i-1]+x;
		if(x>0)
			pp[i]=pp[i-1]+x;
		else
			pp[i]=pp[i-1];
	}
	for(int i=1;i<=n-k+1;i++)
	{
		if(p[i+k-1]-p[i-1]>0)
			ans+=p[i+k-1]-p[i-1];
		ans+=pp[i-1];
		ans+=pp[n]-pp[i+k-1];
		if(ans>maks)
			maks=ans;
		ans=0;
	}
	printf("%lld",maks);
}


Measured memory_bytes: 1792
// battle
#include <iostream>
#include <set>
#include <string>
using namespace std;

int main(void){
    
    set<string> s;
    int N;
    string st;

    cin >> N;

    for(int i=0; i<N; i++){
        cin >> st;
        s.insert(st);   
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 19256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b; cin >> a >> b;
    string A, B;
    for (int x = 0; x < b; x++) {
        A += to_string(a);
    }
    for (int x = 0; x < a; x++) {
        B += to_string(b);
    }
    cout << min(A, B) << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  set<string> mp;
  cin>>n;
  string bef;
  cin>>bef;
  mp.insert(bef);
  FOR(i,1,n){
    string nxt;
    cin>>nxt;
    if(mp.count(nxt)){
      puts("No");
      return 0;
    }
    mp.insert(nxt);
    if(bef.back() != nxt.front()){
      puts("No");
      return 0;
    }
    bef = nxt;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = 1e18
for i in range(1<<n):
    cost = 0
    udst = [0] * m
    for j in range(n):
        if((i>>j)&1):
            cost += ca[j][0]
            for k in range(m):
                udst[k] += ca[j][k+1]
    ok = True
    for j in range(m):
        if udst[j]<x: ok = False
    if ok: ans = min(ans, cost)

if ans>=1e18: print(-1)
else: print(ans)

Measured memory_bytes: 9092
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans=0;
    rep(i,n+1){
        if(i==0)continue;
        int j=i;
        int count=0;
        while(j%2==0){
            j/=2;
            count++;
        }
        chmax(ans,count);
    }
    cout<<pow(2,ans)<<"\n";
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

W = sys.stdin.readline().rstrip()

if any([w % 2 for w in Counter(list(W)).values()]):
    print('No')
else:
    print('Yes')


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(b - a == c - b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main()
{
  int64_t N, asum = 0, bsum = 0, lim, acnt = 0, bcnt = 0;
  cin >> N;
  vector<int64_t> A(N), B(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
    asum += A.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> B.at(i);
    bsum += B.at(i);
  }
  lim = bsum - asum;
  for (int i = 0; i < N; i++)
  {
    if (A.at(i) > B.at(i))
    {
      bcnt += A.at(i) - B.at(i);
    }
    else if ((B.at(i) - A.at(i)) % 2 == 0)
    {
      acnt += (B.at(i) - A.at(i)) / 2;
    }
    else
    {
      acnt += (B.at(i) - A.at(i)) / 2 + 1;
      bcnt += 1;
    }
  }
  cout << (acnt >= bcnt ? "Yes" : "No") << endl;
}

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


int main()
{
    int n;
    cin >> n;
    list<int>b;
    int temp;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        b.push_back(temp);
    }
    int ans[n];
    int ans_n = n-1;
    while(!b.empty())
    {
        jump:
        list<int>::iterator it;
        int i = b.size()-1;
        it = b.end();
        it--;
        for (it; i >= 0; it--, i--)
        {
            if(*it == i+1)
            {
                ans[ans_n--] = *it;
                b.erase(it);
                goto jump;
            }
        }
        break;
    }
    if(!b.empty())
    {
        cout << -1 << endl;
    }
    else 
    {
        for (int i = 0; i < n; i++)
        {
            cout << ans[i] << endl;
        }
        
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<ll,pair<int,int>> P;

void deb(vector<pair<int,int>> &da){
    int n=da.size();
    rip(i,n,0){
            cout << da[i].first << ' ' << da[i].second << endl;
    }
}

int main(){
    int n;
    cin >> n;
    ll ma=INT_MIN,mi=INT_MAX;
    map<ll,int> m;
    vector<ll> da(n);
    vector<pair<int,int>> ans(0);
    rip(i,n,0){
        cin >> da[i];
        m[da[i]]=i;
        ma=max(ma,da[i]);
        mi=min(mi,da[i]);
    }
    if(abs(ma)>abs(mi)){
        int id=m[ma];
        rip(i,n,0){
            if(da[i]<0){
                da[i]+=ma;
                ans.push_back(make_pair(id+1,i+1));
            }
        }
        rip(i,n,1){
            if(da[i-1]>da[i]){
                da[i]+=da[i-1];
                ans.push_back(make_pair(i,i+1));
            }
        }
    }
    else{
        int id=m[mi];
        rip(i,n,0){
            if(da[i]>0){
                ans.push_back(make_pair(id+1,i+1));
                da[i]+=mi;
            }
        }
        rip(i,n,1){
            if(da[n-i]<da[n-i-1]){
                da[n-i-1]+=da[n-i];
                ans.push_back(make_pair(n-i+1,n-i));
            }
        }
    }
    cout << ans.size() << endl;
    deb(ans);
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def getsize(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = map(int, readline().split())
yoko = [list(map(int, readline().split())) for _ in range(n)]
tate = [list(map(int, readline().split())) for _ in range(m)]

INF = 10**9+5
xcoord = [-INF,0,INF]
ycoord = [-INF,0,INF]

for a,b,c in yoko: # (a,c) to (b,c)
    xcoord.append(a)
    xcoord.append(b)
    ycoord.append(c)
for d,e,f in tate: # (d,e) to (d,f)
    ycoord.append(e)
    ycoord.append(f)
    xcoord.append(d)

xcoord = list(sorted(set(xcoord)))
ycoord = list(sorted(set(ycoord)))

zaatu_x = {a:i for i,a in enumerate(xcoord)}
zaatu_y = {a:i for i,a in enumerate(ycoord)}

P = len(xcoord)
Q = len(ycoord)
QQ=Q-1


# (i,j) から右 or 上 に行けるか？
ok_up = [[0]*P for _ in range(Q)]
ok_ri = [[0]*Q for _ in range(P)]

for a,b,c in yoko: # (a,c) to (b,c)
    xa = zaatu_x[a]
    xb = zaatu_x[b]
    yc = zaatu_y[c]
    ok_up[yc-1][xa] += 1
    ok_up[yc-1][xb] -= 1


for d,e,f in tate: # (d,e) to (d,f)
    ye = zaatu_y[e]
    yf = zaatu_y[f]
    xd = zaatu_x[d]
    ok_ri[xd-1][ye] += 1
    ok_ri[xd-1][yf] -= 1

#print(ok_up)
#print(ok_ri)
from itertools import accumulate
for i in range(Q):
    ok_up[i] = list(accumulate(ok_up[i]))
for j in range(P):
    ok_ri[j] = list(accumulate(ok_ri[j]))

#print(*[i for i in ok_ri],sep="\n")

UF = UnionFind((P-1)*QQ)
for i in range(P-1):
    for j in range(Q-2):
        v = i*QQ+j
        if ok_up[j][i]==0: UF.merge(v,v+1)
for i in range(P-2):
    for j in range(Q-1):
        v = i*QQ+j
        if ok_ri[i][j]==0: UF.merge(v,v+QQ)
        
x0 = zaatu_x[0]
y0 = zaatu_y[0]

#print([UF.root(i) for i in range((P-1)*(Q-1))])
r = UF.root(x0*QQ+y0) 
if UF.root(0) == r:
    print("INF")
else:
    ans = sum((xcoord[i+1]-xcoord[i])*(ycoord[j+1]-ycoord[j]) for i in range(P-1) for j in range(Q-1) if UF.root(i*QQ+j) == r)
    print(ans)

#print(xcoord)
#print(ycoord)




Measured memory_bytes: 443872
import std.stdio, std.conv, std.algorithm, std.string, std.container;

void main(){
    SList!int list;
    while(true){
        auto line = readln.chomp;
        if(line.length == 0){
            break;
        }
        auto input = line.to!int;
        if(input){
            list.insertFront(input);
        }else{
            list.front.writeln;
            list.removeFront;
        }
    }
}

Measured memory_bytes: 972
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

// returns gcd(a, b)
// x, y will contain the answer for ax + by = gcd(a, b) after the execution
// if answer for ax + by = c is needed,
// check if c % gcd(a, b) == 0
// get (c / gcd(a, b)) * (x, y)
// O(log (max(a, b)))

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a%b, y, x);
  y -= a/b * x;
  return d;
}


// O(N log (MAX_ELEMENT))
long long vector_gcd(const vector<long long> &Input, long long N) {
  long long r = Input[0];
  long long x, y;
  for (int i = 0; i < N; i++) {
    r = extGCD(r, Input[i], x, y);
  }
  return r;
}

int main() {
  int N, X; cin >> N >> X;
  vector<ll> T;
  rep(i, N) {
    ll a; cin >> a;
    T.push_back(abs(X - a));
  }
  ll ans = vector_gcd(T, N);
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std; 
int main() 
{ 
	char a[100000]; 
	int i=1; 
	bool x=0; 
	while(cin>>a[i])
	{ 
		if(a[i]=='C') 
		{
   			x=1; 
			
		}
		else
		{
			if(x==1) 
			{
				if(a[i]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		} 
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;

int main() 
{ 
    FIO
    ll t;
    t=1;

    while(t--)
    {
        long double r;
        cin >> r;

        long double ans = (2.0)*PI1*r;


        cout << setprecision(20) << ans << '\n';

    }
    return 0; 
} 


Measured memory_bytes: 3808
#include<stdio.h>
int main(void) {
    int i,j;
    int input;
    int sosu[300000];

    for(i=6 ; i < 300000; i++) {        
        if( (i % 7) == 1 || (i % 7) == 6) {
            sosu[i] = 1;
        } else {
            sosu[i] = 0;
        }
    }


    
    for(i=6; i < 300000; i++) {        
        if(sosu[i] == 1) {
            for(j = 2; i*j < 300000; j++) {
                sosu[i*j] = 0;
            }
        }
    }

  
    while(1) {
        scanf("%d", &input);
        if( input == 1) {
            break;
        }

        printf("%d:", input);
        
        for(i=0; i < 300000; i++) {
            if(sosu[i] == 1) {
                if( input % i == 0) {
                    printf(" %d", i);
                }
            }
        }

            

        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1772
#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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
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 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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n), ra(n + 1);
	rep(i, n) {
		cin >> a[i];
		ra[i + 1] = ra[i] + a[i];
	}
	vector<ll> b(m);
	rep(i, m) {
		cin >> b[i];
	}
	int ans = 0;
	ll s = 0;
	rep(i, m + 1) {
		if (s > k)break;
		int id = upper_bound(all(ra), k - s)- ra.begin();
		ans = max(ans, i + id-1);
		
		//cout << i << " " << id << "\n";
		if (i < m)s += b[i];

	}
	cout << ans << "\n";
}



signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)
	solve();
		return 0;
}


Measured memory_bytes: 24356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m;
	cin >> n >> m;
	int a[n], sum = 0, cnt = 0;
  	for (int i = 0; i < n; i++)
  	{
    	cin >> a[i];
  		sum += a[i];
  	}
  	sort(a, a + n);
  	double r = sum * (1 / (m * 4.0));
  	for (int i = n - 1; i >= 0; i--)
  	{
  		if (a[i] < r) break;
  		cnt++;
  	}
  	cout << (cnt >= m ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int last[26];
int c[26];
int s[365][26];
int a[365];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    for(int i=0;i<26;i++){
    	cin >> c[i];
    }
    for(int i=0;i<d;i++){
    	for(int j=0;j<26;j++){
    		cin >> s[i][j];
    	}
    }
    for(int i=0;i<d;i++){
    	cin >> a[i];
    }
    int res=0;
    for(int i=0;i<d;i++){
    	res+=s[i][a[i]-1];
    	last[a[i]-1]=i+1;
    	for(int j=0;j<26;j++){
    		res-=c[j]*(i+1-last[j]);
    	}
    	cout << res << endl;
    }
}

Measured memory_bytes: 3608
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String s = fs.next();
        if( s.equals("hi") ||s.equals("hihi") ||s.equals("hihihi") ||s.equals("hihihihi") ||s.equals("hihihihihi") ){
            System.out.println("Yes");
        }
        else {
            System.out.println("No");
        }

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 24532
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt() - 1;
		}
		System.out.println(sum);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MX = 400010;


string s;

int main() {
	//freopen("input.txt", "r", stdin);
	cin >> s;
	int mn = 1e9;
	for(char c = 'a';c <= 'z';c++){
		string cpy = s;
		string tmp = s;
		bool ok = true;
		for (int i = 0; i < s.size(); ++i){
			if(s[i] != c)
				ok = false;
		}
		if(ok)
			mn = min(mn,0);
		for(int it = 0 ; it < s.size() ; it++){
			bool can = true;
			for(int k = 0 ; k < s.size() - 1 - it ; k++){
				if(tmp[k] == c)
					continue;
				if(cpy[k+1] == c)
					tmp[k] = c;
				if(tmp[k] != c)
					can = false;
			}
			cpy = tmp;
			if(can)
				mn = min(mn,it+1);

		}
	}
	cout << mn << endl;
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct Edge
{
	int s, t, cost;
	Edge(int s, int t, int cost) :s(s), t(t), cost(cost) {}
	Edge() :Edge(-1, -1, -1) {}
};

const int MAXV = 100010;

vector<Edge> G[3 * MAXV];
int d[3 * MAXV];
int V, E, S, T;

void shortest_path(int s)
{
	rep(i, 0, 3*MAXV)d[i] = INF;
	d[s] = 0;

	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(mp(0, s));

	while (!pq.empty())
	{
		pii p = pq.top(); pq.pop();
		if (d[p.second] < p.first)
		{
			continue;
		}
		for (auto& e : G[p.second])
		{
			if (d[e.t] > d[e.s] + e.cost)
			{
				d[e.t] = d[e.s] + e.cost;
				pq.push(mp(d[e.t], e.t));
			}
		}
	}
}

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

	cin >> V >> E;
	int u, v;
	rep(i, 0, E)
	{
		cin >> u >> v;
		u--, v--;
		G[u].push_back(Edge(u, MAXV + v, 1));
		G[MAXV + u].push_back(Edge(MAXV + u, 2 * MAXV + v, 1));
		G[2 * MAXV + u].push_back(Edge(2 * MAXV + u, v, 1));
	}
	cin >> S >> T;
	S--, T--;

	shortest_path(S);

	if (d[T] == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << d[T] / 3 << endl;
	}

	return 0;
}

Measured memory_bytes: 20352
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 998244353;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    vector<int> cnt(n);
    for(int i=0; i<n; ++i){
        cin >> d[i];
        ++ cnt[d[i]];
    }
    if(d[0] != 0 || cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }

    long long ans = 1;
    for(int i=1; i<n; ++i){
        for(int j=0; j<cnt[i]; ++j){
            ans *= cnt[i-1];
            ans %= MOD;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int64_t mod = 1000000007;

int64_t mypow(int64_t x, int64_t y)
{
    if (y == 1)
        return x;
    else if (y % 2 == 1)
        return mypow(x, y - 1) * x % mod;
    else
    {
        int64_t tmp = mypow(x, y / 2);
        return tmp * tmp % mod;
    }
}

int64_t soujo(int64_t x, int64_t y)//x~y
{
    if (x == y)
        return y;
    else
        return x * soujo(x + 1, y) % mod;
}

int64_t combi(int64_t x, int64_t y)//y C x,y < x
{
    int64_t X = soujo(x - y + 1, x);
    int64_t Y = soujo(1, y);
    return X * mypow(Y, mod - 2) % mod;
}

int main()
{
    int64_t N, A, B;
    cin >> N >> A >> B;

    int64_t ans = mypow(2, N) - 1;
    ans -= combi(N, A);
    ans -= combi(N, B);
    cout << (ans + mod * 2) % mod;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n), v;
	rep(i,n) cin >> a[i];
	v.push_back(a[n-1]);
	for(int i = n-2; i >= 0; i--){
		auto it = upper_bound(v.begin(), v.end(), a[i]);
		while(*it == a[i] && it != v.end()){
			it++;
		}
		if(it == v.end()) v.push_back(a[i]);
		else *it = a[i];
	}
	cout << v.size() << endl;
	return 0;
}

Measured memory_bytes: 1276
from collections import deque
def main():
    n=int(input())
    d=sorted(map(int,input().split()))
    m=int(input())
    t=deque(sorted(map(int,input().split())))
    
    for i in d:
        if t[0] == i:
            t.popleft()
            if len(t) == 0:
                print("YES")
                break
        elif t[0] < i:
            print("NO")
            break
    else:
        print("NO")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 41696
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
long long ans;
int main()
{
    cin>>a>>b>>c>>d;
	ans=a*c;
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	cout<<ans<<endl;
	return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define LL  long long
typedef pair<LL, LL> P;

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}
int main(void)
{
    IOS
    int n,m;
    cin >> n >> m;
    vector<LL> a(n);
    vector<P> bc(m);

    for (int i = 0;i < n;i++) cin >> a[i];
    for (int i = 0;i < m;i++) {
        cin >> bc[i].first >> bc[i].second;
    }

    sort(a.begin(),a.end());
    sort(bc.begin(),bc.end(),pairCompare);
    
    int cnt = 0;
    for(int i = 0; i < m;i++){
        if (a[cnt] >= bc[i].second) break;
        for(int j = 0; j < bc[i].first;j++){
            if (a[cnt] < bc[i].second) {
                a[cnt] = bc[i].second;
                cnt++;
                if (cnt == n) break;
            } else continue;
        }
        if (cnt == n) break;
    }
    /*
    for(int i = 0; i < n; i++) {
        cerr << a[i] << endl;
    }
    */

    LL ans = accumulate(a.begin(),a.end(),0LL);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 2560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int platformNum = Integer.parseInt(sc.next());
		int roadNum = Integer.parseInt(sc.next());
		List<Platform> platFormList = new ArrayList<>();
		for (int i = 0; i < platformNum; i++) {
			long height = Long.parseLong(sc.next());
			platFormList.add(new Platform(height));
		}

		for (int i = 0; i < roadNum; i++) {
			int platformFrom = Integer.parseInt(sc.next());
			int platformTo = Integer.parseInt(sc.next());

			long platformFromheight = platFormList.get(platformFrom - 1).getHeight();
			long platformToheight = platFormList.get(platformTo - 1).getHeight();
			if (platformFromheight < platformToheight) {
				platFormList.get(platformFrom - 1).setGood(false);
			} else if (platformToheight < platformFromheight) {
				platFormList.get(platformTo - 1).setGood(false);
			} else {
				// 同値の場合、両方いい展望台ではない
				platFormList.get(platformFrom - 1).setGood(false);
				platFormList.get(platformTo - 1).setGood(false);
			}
		}

		int count = 0;
		for (Platform platform : platFormList) {
			if (platform.isGood()) {
				count++;
			}
		}
		System.out.println(count);

	}

}

class Platform {
	private long height;
	private boolean isGood = true;

	public Platform(long height) {
		setHeight(height);
	}

	public long getHeight() {
		return height;
	}

	public void setHeight(long height) {
		this.height = height;
	}

	public boolean isGood() {
		return isGood;
	}

	public void setGood(boolean isGood) {
		this.isGood = isGood;
	}

}


Measured memory_bytes: 63024