akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var T = (double)sc.nextInt();
        var X = (double)sc.nextInt();
        WriteLine(T / X);
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 11220
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;



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


  int N;
  int p[100010] = {};
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  int sp = 0;
  for (int i = 0; i < N; i++) {
    if (p[i] - 1 == i) {
      sp++;
      p[i + 1] = p[i];
    }
  }

  cout << sp << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<string, string> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n, f; cin>>n>>f;
    map<P, int> cnt;
    for(int i=0; i<n; i++){
        int m; cin>>m;
        vector<string> s(m);
        for(int j=0; j<m; j++){
            cin>>s[j];
        }

        for(int j=0; j<m; j++){
            for(int k=j+1; k<m; k++){
                string h = s[j];
                string t = s[k];

                if(h > t){
                    cnt[P(t, h)]++;
                }
                else{
                    cnt[P(h, t)]++;
                }
            }
        }
    }

    vector<P> ans;
    for(auto i : cnt){
        if(f <= i.second){
            ans.eb(i.first);
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << endl;
    for(auto i : ans){
        cout << i.first << " " << i.second << endl;
    }
}


Measured memory_bytes: 3532
import heapq
from math import ceil

n, m = [int(x) for x in input().split()]

a_list = [-int(x) for x in input().split()]
heapq.heapify(a_list)

for _ in range(m):
    temp = ceil(heapq.heappop(a_list) / 2)
    heapq.heappush(a_list, temp)
print(-sum(a_list))

Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct ll t;cin>>t;while(t--)
#define bi begin()
#define ei end()
#define fi first 
#define se second  
#define foe(i,a,b) for(ll i=a;i<b;i++)
#define rfoe(i,a,b) for(ll i=a;i>=0;i--)
#define sz(s) s.size() 
#define mem(a,s) memset(a,s,sizeof(a)) 
#define all(v) v.bi,v.ei
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL  
// ll MOD; 
ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
ll fact[1000007]={0};
ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
y=y>>1;x=(1ll*x*x)%MOD;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
int const N=2e5+9;
ll const INF = 2e9+5;
ll n;
    
void solve()
{ 
   ll n;
   cin>>n;
   string s;
   cin>>s;
   if(n%2==1)
   {
    
            cout<<"No\n";
            return;
   }
   foe(i,0,n/2)
   {
        if(s[i]!=s[i+n/2])
        {
            cout<<"No\n";
            return;
        }
   }
   cout<<"Yes\n";

}
int main()
{
    fast
    // ct
        // freopen("input.txt", "r", stdin);
            // freopen("output.txt", "w", stdout);
    { 
        solve();
    }
}

Measured memory_bytes: 3636
#from https://atcoder.jp/contests/abc087/submissions/4389032

class WeightedUnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
    @weight = Array.new(size, 0)
  end
 
  def get_parent(id_x)
    if @parent[id_x] == id_x
      id_x
    else
      root = get_parent(@parent[id_x])
      @weight[id_x] += @weight[@parent[id_x]]
      @parent[id_x] = root
    end
  end

  def unite(id_x, id_y, w)
    cw = w + weight(id_x) - weight(id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] < @rank[y_parent]
      @weight[x_parent] = -cw
      @parent[x_parent] = y_parent
    else
      @weight[y_parent] = cw
      @parent[y_parent] = x_parent

      @rank[x_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def weight(idx)
    get_parent(idx)
    @weight[idx]
  end

  def weight_diff(x, y)
    weight(y)-weight(x)
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

n, m = gets.strip.split.map(&:to_i)
lrd = readlines.map {|line| line.split.map(&:to_i) }

wuf = WeightedUnionFind.new(n+1)

lrd.each do |l, r, d|
  if wuf.same_parent?(l, r)
    if wuf.weight_diff(l, r) != d
      puts 'No'
      exit
    end
  else
    wuf.unite(l, r, d)
  end
end

puts'Yes'


Measured memory_bytes: 33788
w,h,n=map(int,input().split())
ans=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        ans[0]=max(ans[0],x)
    if a==2:
        ans[1]=min(ans[1],x)
    if a==3:
        ans[2]=max(ans[2],y)
    if a==4:
        ans[3]=min(ans[3],y)
if ans[1]-ans[0]<=0 or ans[3]-ans[2]<=0:
    print(0)
else:
    print((ans[1]-ans[0])*(ans[3]-ans[2]))

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, p[100001];

int main() {
	cin >> n;
	inc(i, n) { cin >> p[i]; p[i]--; }
	
	p[n] = -1;
	n++;
	int ans = 0, c = 0;
	inc(i, n) {
		if(p[i] == i) { c++; } else { ans += (c + 1) / 2; c = 0; }
	}
	
	cout << ans << endl;
	
	return 0;
}


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

template<typename T>
T get() { return 0; }
template<>
int get() { int x; scanf("%d", &x); return x; }
template<>
long get() { long x; scanf("%ld", &x); return x; }
template<>
std::string get() { std::string str; std::cin >> str; return str; }

template<typename T>
void put(T x) {}
template<>
void put(int x) { printf("%d\n", x); }
template<>
void put(long x) { printf("%ld\n", x); }
template<>
void put(std::string str) { printf("%s\n", str.c_str()); }
template<>
void put(const char* str) { printf("%s\n", str); }

int n, m;
int numball[112345];
bool hasred[112345];

void init() {
  for(int i = 1; i <= n; ++i) {
    numball[i] = 1;
  }
  hasred[1] = true;
  for(int i = 2; i <= n; ++i) {
    hasred[i] = false;
  }
}

int main() {
  n = get<int>();
  m = get<int>();
  init();

  for(int i = 0; i < m; ++i) {
    int x = get<int>();
    int y = get<int>();
    if( hasred[x] ) {
      if( numball[x] == 1 ) {
        numball[x] = 0; hasred[x] = false;
        numball[y] += 1;
        hasred[y] = true;
      }
      else {
        numball[x] -= 1;
        numball[y] += 1;
        hasred[y] = true;
      }
    }
    else {
      numball[x] -= 1;
      numball[y] += 1;
    }
  }

  int res = 0;
  for(int i = 1; i <= n; ++i) {
    if( hasred[i] ) res += 1;
  }

  put(res);
  
  return 0;
}



Measured memory_bytes: 768
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define N 1000000000ll
long long s,a,b;
int main()
{
	cin>>s;
	a=(s/N+(s%N!=0));
	b=a*N-s;
	printf("0 0 %d %d 1 %d",N,b,a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test ll T;cin>>T;while(T--) 
#define MAX 100004
#define __sort(v) sort(v.begin(),v.end())
#define rep(i,a,b) for(ll i=a;i<b;i++)
const ll inf=1e+9;
const ll mod=7 + 1e+9;
 
 
 
int32_t main(){
 
     fast;
     
     ll n,ans=0;
     cin>>n;
     
     for(ll i=1;i<=n;i++)
     {
		 if((i%3)!=0 && (i%5)!=0)
		   ans+=i;
	 }
     
         cout<<ans;
     
     
     return 0;
 }


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

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

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

	string s = to_string(n);

	int len = s.size();

	if(s[len-1] == '3') cout << "bon" << "\n";
	else if(s[len-1] == '0' || s[len-1] == '1' || s[len-1] == '6' || s[len-1] == '8') cout << "pon" << "\n";
	else cout << "hon" << "\n";

	return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 45
#define M 305
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
using namespace std;
ll dp[N][1<<18];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,x,y,z;
    while(cin>>n>>x>>y>>z)
    {
        MST(dp,0);
        dp[0][1] = 1;
        int ok = (1<<z);
        ok |= (1<<(y+z));
        ok |= (1<<(x+y+z));
        int mask = (1<<(x+y+z+1))-1;
        FOR(i,1,n)
        {
            FOR(j,1,mask)
            {
                FOR(k,1,10)
                {
                    int ns = ((j<<k)&mask)+1;
                    if((ns&ok) == ok)continue;
                    dp[i][ns] = (dp[i][ns]+dp[i-1][j])%MOD;
                }
            }
        }
        ll ans = 1;
        FOR(i,1,n)ans = (ans*10)%MOD;
        FOR(i,0,mask)
        {
            if((i&ok) == ok)continue;
            ans = (ans-dp[n][i])%MOD;
        }
        cout<<((ans+MOD)%MOD+MOD)%MOD<<endl;
    }
    return 0;
}


Measured memory_bytes: 92416
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int ans = 0;
    for(int l=0; l<=n; ++l) {
        for(int r=l-1; r<=n-1; ++r) {
            if (l + n-1-r > k) continue;
            priority_queue<int> pq;
            int tmp = 0;
            for(int i=0; i<l; ++i) {
                if (v[i]<0) pq.push(-v[i]);
                tmp += v[i];
            }
            for(int i=r+1; i<n; ++i) {
                if (v[i]<0) pq.push(-v[i]);
                tmp += v[i];
            }
            int cnt = k - l - (n-1-r);
            for(int i=0; i<cnt; ++i) if(pq.size()) { tmp += pq.top(); pq.pop(); }
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
N = int(input())
S = input()
flag = 0
if len(S)%2 != 0:
    flag = 1
ans1 = ''
ans2 = ''
for i in range(N):
    if i < N//2:
        ans1+=S[i]
    else:
        ans2+=S[i]
if ans1==ans2 and flag==0:
    print('Yes')
if ans1 != ans2 or flag ==1:
    print('No')
# print(ans1,ans2,flag)

Measured memory_bytes: 39860
program prob3
    implicit none
    integer::n, i, j, tmp, emax, omax, ei, oi
    integer, allocatable::v(:)
    integer::e(100000), o(100000)
    read(*,*) n
    allocate(v(n))
    read(*,*) v
    e = 0
    o = 0
    emax = 0
    omax = 0
    do i = 1, n
        tmp = v(i)
        if(mod(i,2) == 0) then
            e(tmp) = e(tmp) + 1
        else
            o(tmp) = o(tmp) + 1
        end if
    end do
    do i = 1, 100000
        if(e(i) > emax) then
            emax = e(i)
            ei = i
        end if
        if(o(i) > omax) then
            omax = o(i)
            oi = i
        end if
    end do
    if(ei /= oi) then
        write(*,*) n - emax - omax
    else
        call heapsort(100000,e)
        call heapsort(100000,o)
        write(*,*) n - max(e(99999)+o(100000), e(100000)+o(99999))
    end if
    stop
contains
    subroutine heapsort(n,array)
        implicit none
        integer,intent(in) :: n
        integer,intent(inout) :: array(1:n)
    
        integer ::i,k,j,l
        double precision :: t
    
        if(n.le.0)then
        write(6,*)"Error, at heapsort"; stop
        endif
        if(n.eq.1)return
    
        l=n/2+1
        k=n
        do while(k.ne.1)
        if(l.gt.1)then
            l=l-1
            t=array(L)
        else
            t=array(k)
            array(k)=array(1)
            k=k-1
            if(k.eq.1) then
                array(1)=t
                exit
            endif
        endif
        i=l
        j=l+l
        do while(j.le.k)
            if(j.lt.k)then
                if(array(j).lt.array(j+1))j=j+1
            endif
            if (t.lt.array(j))then
                array(i)=array(j)
                i=j
                j=j+j
            else
                j=k+1
            endif
        enddo
        array(i)=t
        enddo
    
        return
    end subroutine heapsort
end program

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> X(N);
    rep(i, N) cin >> X[i];

    ll fact = 1;
    for (int i = 1; i < N; ++i) {
        fact *= i;
        fact %= MOD;
    }

    vector<ll> inv(N);
    inv[1] = 1;
    for (int i = 2; i < N; ++i) {
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    }

    vector<ll> V(N - 1);
    V[0] = 1;
    for (int i = 1; i < N - 1; ++i) {
        V[i] = V[i - 1] + 1 * inv[i + 1];
        V[i] %= MOD;
    }

    ll res = 0;
    rep(i, N - 1) {
        res += (X[i + 1] - X[i]) * V[i];
        res %= MOD;
    }

    ll ans = res * fact;
    ans %= MOD;

    cout << ans << endl;
}

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

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

  string ans("No");

  for (int cake = 0; cake <= n; cake += 4) {
    for (int donuts = 0; cake + donuts <= n; donuts += 7) {
      if (cake + donuts == n) {
        ans = "Yes";
        goto endloop;
      }
    }
  }
 endloop:
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    vector<double> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    double isum=0;
    for(int i=0; i<K; i++){
        isum += vec.at(i);
    }
    double sum = isum;
    for(int i=0; i<N-K; i++){
        isum += vec.at(K+i) - vec.at(i);
        sum = max(isum, sum);
    }

    cout << fixed << setprecision(10) << (sum+K)/2 << endl;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n;
ll a[N], b[N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n)
        cin >> a[i] >> b[i];
    ll s = 0;
    for1(i, n, 1) {
        ll d = (b[i] - (a[i] + s) % b[i] + b[i]) % b[i];
        cerr << a[i] << " " << s << ": " << d << "\n";
        s += d;
    }
    cout << s << "\n";

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();

  int c[3] = {};
  REP(i, N) {
    int t = 0;
    int a = nextInt();
    while (a % 2 == 0) {
      t++;
      a /= 2;
    }
    c[ min(t, 2) ]++;
  }
  if (c[1] > 0) c[0]++;
  bool ans = false;
  if (c[0] <= 1 + c[2]) {
    ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 384
using System;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; ; i++)
            {
                var n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                Console.WriteLine("Case {0}: {1}", i, n);
            }
        }
    }
}



Measured memory_bytes: 9324
// Problem : A - Takoyaki
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n,a,t;
	rd(n,a,t);
	pp((int)(ceil(n/(a*1.0)))*t);	
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a+b) * h / 2 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    vector<ll> B;
    vector<ll> C;
    int n = 0;
    
    for (int i = 0; i < N/2+1; i++) {
        if(n==N-1 && abs(B.front()-A[N-1-i]) > abs(B.back()-A[N-1-i])){
            B.insert(B.begin(), A[N-1-i]);
            break;
        }else if(n==N-1){
            B.push_back(A[N-1-i]);
            break;
        }
        n++;
        B.push_back(A[N-1-i]);
        if(n==N-1 && abs(B.front()-A[i]) > abs(B.back()-A[i])){
            B.insert(B.begin(), A[i]);
            break;
        }else if(n==N-1){
            B.push_back(A[i]);
            break;
        }
        n++;
        B.push_back(A[i]);
    }
    
    n = 0;
    for (int i = 0; i < N/2+1; i++) {
           
        if(n==N-1 && abs(C.front()-A[i]) > abs(C.back()-A[i])){
            C.insert(C.begin(), A[i]);
            break;
        }else if(n==N-1){
            C.push_back(A[i]);
            break;
        }
        n++;
        C.push_back(A[i]);
        if(n==N-1 && abs(C.front()-A[N-1-i]) > abs(C.back()-A[N-1-i])){
            C.insert(C.begin(), A[N-1-i]);
            break;
        }else if(n==N-1){
            C.push_back(A[N-1-i]);
            break;
        }
        n++;
        C.push_back(A[N-1-i]);
        
    }
 
    
    ll ans = 0;
    ll an = 0;
    for (int i = 1; i < N; i++) {
        ans += abs(B[i]-B[i-1]);
        an += abs(C[i]-C[i-1]);
    }
    cout << max(ans, an) << endl;
    
    return 0;
}



Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(ll i=0; i<(n); i++)
#define REPj(n) for(ll j=0; j<(n); j++)
#define REPinit(i,a,n) for(ll i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(ll j=(a); j<(n); j++)

//algorithm
#define SORT(c) sort((c).begin(),(c).end())
#define CONTAINER_ALL(a) a.begin(),a.end()

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


template <typename T>
void swapAlgorithm(T & a, T & b) {
    T tmp = a;
    a = b;
    b = tmp;
}

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

    int N, M, X, Y;
    int maxX, minY;
    int tmp;

    cin >> N >> M >> X >> Y;

    maxX = -99999;
    minY = 99999;
    REPinit(i, 0, N) {
        cin >> tmp;
        maxX = max(tmp, maxX);
    }

    REPinit(i, 0, M) {
        cin >> tmp;
        minY = min(tmp, minY);
    }

    REPinit(i, X + 1, Y + 1) {
        if (i > maxX && i <= minY) {
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;

    
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace  __gnu_pbds;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<
ii,
null_type,
less<ii>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

void init() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 5e3+5;
const int MOD = 1e9+7;

int main() {
	init();
	int num, sum = 0;
	lp(i, 3){
		cin >> num;
		sum += num;
	}
	cout << ((sum >= 22) ? "bust" : "win");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */
vector<ll> a(200006, 0);

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++)
    {
        a[i] -= (i + 1);
    }
    sort(a.begin(), a.begin() + n);
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        ans += abs(a[i] - a[n / 2]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2300
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        string[] input2 = ReadLine().Split(' ');
        int M1 = int.Parse(input[0]);
        int D1 = int.Parse(input[1]);
        int M2 = int.Parse(input2[0]);
        int D2 = int.Parse(input2[1]);
        if(D2 == 1)
        {
            WriteLine(1);
        }
        else
        {
            WriteLine(0);
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
using namespace std;

int h, w;
int get(int x, int y) { return x * x + y * y; }

int main() {
  while (1) {
    scanf("%d%d", &h, &w);
    if (h == 0) break;
    int ans = 10000000, ansh = 100000, answ = 10000, first = get(h, w);
    for (int i = 1; i <= 150; i++) {
      for (int j = i + 1; j <= 150; j++) {
        int g = get(i, j);
        if (g > first && ans > g) ans = g, ansh = i, answ = j;
        if (g == first) if (h < i) {
          if (ans != first) ans = g, ansh = i, answ = j;
          else if (ansh > i) ans = g, ansh = i, answ = j;
        }
      }
    }
    printf("%d %d\n",ansh, answ);
  }
}



Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <algorithm>

int const nmax = 200000;
int const lgmax = 20;
int v[5 + nmax];
std::vector<int> phases;
int st[1 + lgmax][5 + nmax], dr[1 + lgmax][5 + nmax];
int pref[(1 << lgmax)], suff[(1 << lgmax)];
int reach[5 + nmax];
int sol[5 + nmax];

int main() {
  int n, lim;
  std::cin >> n >> lim;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  while(0 < lim) {
    phases.push_back(lim);
    lim /= 2;
  }
  phases.push_back(0);

  std::reverse(phases.begin(), phases.end());
  for(int h = 0; h < phases.size(); h++){
    st[h][1] = 1;
    for(int i = 2;i <= n; i++) {
      if(v[i] - v[i - 1] <= phases[h])
        st[h][i] = st[h][i - 1];
      else
        st[h][i] = i;
    }
    dr[h][n] = n;
    for(int i = n - 1; 1 <= i; i--){
      if(v[i + 1] - v[i] <= phases[h])
        dr[h][i] = dr[h][i + 1];
      else
        dr[h][i] = i;
    }
  }
  int bits = phases.size() - 1;
  for(int mask = 0; mask < (1 << bits); mask++) {
    pref[mask] = 0;
    suff[mask] = n + 1;
  }

  for(int mask = 1; mask < (1 << bits); mask++)
    for(int i = 0; i < bits; i++)
      if(0 < (mask & (1 << i))) {
        int mask2 = (mask ^ (1 << i));
        if(pref[mask2] == n)
          pref[mask] = n;
        else
          pref[mask] = std::max(pref[mask], dr[i][pref[mask2] + 1]);
        if(suff[mask2] == 1)
          suff[mask] = 1;
        else
          suff[mask] = std::min(suff[mask], st[i][suff[mask2] - 1]);
      }
  for(int i = 0;i <= n; i++)
    reach[i] = n + 10;
  for(int mask = 0; mask < (1 << bits); mask++) {
    reach[pref[mask]] = std::min(reach[pref[mask]], suff[((1 << bits) - 1) ^ mask]);
  }

  for(int i = n - 1; 0 <= i; i--)
    reach[i] = std::min(reach[i + 1], reach[i]);
  for(int i = 1; i <= n; i++) {
    int x = st[bits][i], y = dr[bits][i];
   
    if(reach[x - 1] <= y + 1)
      std::cout << "Possible\n";
    else
      std::cout << "Impossible\n";
  }
  return 0;
}


Measured memory_bytes: 36812
#include<iostream>

using namespace std;

int main () {
  int N;
  cin >> N;
  bool OK =false;
  
  for (int a=1; a<10; a++) {
    for (int b=1; b<10; b++) {
      int total = a*b;
      if(total == N) OK = true;
    }
  }
  
  if (OK == false) cout << "No" << endl;
  else cout << "Yes" << endl;
}
      

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

vector<vector<P>> g;
vector<int> ans;

void dfs(int pre, int now, int col){
  ans[now] = col;
  for(P p: g[now]){
    if(p.first == pre) continue;
    if(p.second % 2) dfs(now, p.first, 1-col);
    else dfs(now, p.first, col);
  }
}

int main(){
  int n; cin >> n;
  g.resize(n);
  ans.resize(n, -1);
  for(int i = 0; i < n-1; i++){
    int a,b,c; cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(P(b,c));
    g[b].push_back(P(a,c));
  }
  dfs(-1, 0, 0);
  for(int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3003;
const int MOD = 1e9+7;

int dp[MAXN][MAXN][2];

void sum(int &a, int b)
{
    a = (a + b >= MOD ? a + b - MOD : a + b);
}

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

    for (int x = 1; x <= n; x++) dp[0][x][0] = 1;
    dp[0][0][1] = 1;

    for (int i = 0; i < m; i++) {
        for (int x = 0; x <= n; x++) {
            for (int k = 0; k < 2; k++) {
                ///RR operation
                if (x > 0) sum(dp[i+1][x-1][k||x==1], dp[i][x][k]);
                ///RB operation
                if (x > 0) sum(dp[i+1][x][k||x==1], dp[i][x][k]);
                ///BB operation
                if (x < n) sum(dp[i+1][x+1][k], dp[i][x][k]);
                ///BR operation
                if (x < n) sum(dp[i+1][x][k], dp[i][x][k]);
            }
        }
    }

    int ans = 0;
    for (int x = 0; x <= n; x++) sum(ans, dp[m][x][1]);

    cout << ans << endl;


    return 0;
}


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

int binary_search(vector<int> arr, int n, int key) {
  int left = -1;
  int right = n;

  while ( right - left > 1 ) {
    int mid = left + (right - left) / 2;
    if ( arr[mid] > key ) { right = mid; } else { left = mid; }
  }

  return right;
}

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

  vector<int> colors;
  colors.push_back(a[n-1]);
  for ( int i = n-2; i >= 0; i-- ) {
    int pos = binary_search(colors, colors.size(), a[i]);
    if ( pos < colors.size() ) {
      colors[pos] = a[i];
    } else {
      colors.push_back(a[i]);
    }
  }

  cout << colors.size() << endl;
  return 0;
}


Measured memory_bytes: 4540
#include <iostream>
#include <vector>

using namespace std;

#define MAX_V 15
#define INF 1000000

int V,E,D[MAX_V][MAX_V],all_d;
vector<int> G[MAX_V][MAX_V];

int solve() {
  for (int i=0;i<V;++i) {
    for (int j=0;j<V;++j) {
      for (int k=0;k<V;++k) {
        D[j][k] = min(D[j][k], D[j][i]+D[i][k]);
      }
    }
  }
  // for (int j=0;j<V;++j) {
  //   for (int k=0;k<V;++k) {
  //     cout<<"D"<<" "<<j<<" "<<k<<" "<<D[j][k]<<endl;
  //   }
  // }

  vector<int> odd_v;
  for (int i=0;i<V;++i) {
    int order = 0;
    for (int j=0;j<V;++j) {
      order += G[i][j].size();
    }
    if (order%2) {
      odd_v.push_back(i);
    }
  }
  // for (int i=0;i<odd_v.size();++i) {
  //   cout<<odd_v[i]<<endl;
  // }

  int odd_n = odd_v.size();
  int dp[1<<odd_n];
  for (int i=0;i<(1<<odd_n);++i) {
    dp[i] = INF;
  }
  dp[0] = 0;
  for (int s=0;s<(1<<odd_n);++s) {
    for (int i=0;i<odd_n&&!(s>>i&1);++i) {
      for (int j=0;j<odd_n;++j) {
        if (i!=j && ~s>>j&1) {
          dp[s|(1<<i)|(1<<j)] = min(dp[s|(1<<i)|(1<<j)],dp[s]+D[odd_v[i]][odd_v[j]]);
        }
      }
    }
    // cout<<dp[s]<<endl;
  }

  return all_d + dp[(1<<odd_n)-1];
}

int main() {
  for (int i=0;i<MAX_V;++i) {
    for (int j=0;j<MAX_V;++j) {
      D[i][j] = (i==j)?0:INF;
    }
  }
  cin>>V>>E;
  for (int i=0;i<E;++i) {
    int s,t,d;
    cin>>s>>t>>d;
    all_d += d;
    G[s][t].push_back(d);
    G[t][s].push_back(d);
    D[s][t] = min(D[s][t], d);
    D[t][s] = min(D[t][s], d);
  }
  cout<<solve()<<endl;
  return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<math.h>
using namespace std;
int check(int a[100][3],int N,int x,int y){
	int b[100],d[100],j=0;
	for(int i=0;i<N;i++){
		b[i]=a[i][2]+fabs(double(a[i][0]-x))+fabs(double(a[i][1]-y));
	}
	int q=0;
	for(int k=0;k<N;k++){
		if(a[k][2]>0){
			q=b[k];
		}
	}
	for(int p=0;p<N;p++){
		if(a[p][2]==0){
			if(b[p]<q)
				return 0;
		}
		else{
			if(b[p]!=q)
				return 0;
		}
	}
	return q;
}
int main(){
	int N;
	cin>>N;
	int a[100][3];
	for(int i=0;i<N;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	for(int x=0;x<=100;x++)
		for(int y=0;y<=100;y++){
			int f=check(a,N,x,y);
			if(f!=0){
				cout<<x<<" "<<y<<" "<<f<<endl;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
 
int main() {
  long N;
  
  cin >> N;
  
  vector<long> A(N);
  vector<long> C(N);
  
  for(long i = 0; i < N; i++) {
    cin >> A.at(i);
    C.at(A.at(i) - 1)++;
  }
  
  long sum = 0;
  
  for(long i = 0; i < N; i++) sum += C.at(i) * (C.at(i) - 1) / 2;
    
  for(long i = 0; i < N; i++) {
    if(C.at(A.at(i) - 1) >= 2) cout << sum - C.at(A.at(i) - 1) * (C.at(A.at(i) - 1) - 1) / 2 + (C.at(A.at(i) - 1) - 1) * (C.at(A.at(i) - 1) - 2) / 2 << endl; 
    else cout << sum << endl;
  }
}

Measured memory_bytes: 5760
#include <stdio.h>

int main(void)
{
	char w[101];
	int i, j, count_1 = 0;
	
	scanf("%s", w);
	
	for(i = 0; w[i] != '\0'; i++) {
		if(w[i] == ' ') {
			continue;
		}
		count_1++;
		for(j = i + 1; w[j] != '\0'; j++) {
			if(w[i] == w[j]) {
				count_1++;
				w[j] = ' ';
			}
		}
		if(count_1 % 2 != 0) {
			count_1++;
			printf("No");
			break;
		}
		count_1 = 0;
	}
	if(count_1 == 0) {
		printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 128
/*
 * hoge.cpp
 *
 *  Created on: 2014/09/30
 *      Author: eiichi
 */
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
using namespace std;

void draw(int H,int W){
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(i%2==0 && j%2==0 || i%2==1 && j%2==1)
				cout << "#";
			else
				cout << ".";
		}
		cout << endl;
	}
	cout << endl;
	return;
}

int main(){
	int H,W;
	for(int i=0;;i++){
		cin >> H >> W;
		if(H==0 && W==0)
			exit(0);
		draw(H,W);
	}
	return 0;
}

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

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    bool is = false;

    while(k>0){
        if(a>=b){
            b *= 2;
        }else if(b>=c){
            c *= 2;
        }else{
            break;
        }
        k--;
    }
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;
class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		ArrayList<Integer> input=new ArrayList<>();
		for(int i=0;i<n;++i){
			int t=s.nextInt();
			input.add(t);
		}
		int[] m=input.stream().mapToInt(i->i).sorted().skip(n-2).toArray();
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<n;++i)
			sb.append(input.get(i)==m[1]?m[0]:m[1]).append('\n');
		System.out.println(sb);
	}
}

Measured memory_bytes: 74652
def main():
    H, W = list(map(int, input().split()))
    c = [list(map(int, input().split())) for i in range(10)]
    A = [list(map(int, input().split())) for i in range(H)]

    flag = True
    while flag:
        flag = False
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    if c[i][k] + c[k][j] < c[i][j]:
                        c[i][j] = c[i][k] + c[k][j]
                        flag = True

    result = 0
    countNumber = []
    for i in range(10):
        if i != 1:
            a = sum([A[h].count(i) for h in range(H) if i in A[h]])
            countNumber.append(a)
            if countNumber[-1] != 0:
                result += c[i][1] * countNumber[-1]
    print(result)

if __name__ == '__main__':
    main()


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

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

const int N_ = int(1.1e5);

int N;
int A[N_];
pii B[N_], pref[N_];

long long ans[N_];

priority_queue<pll> pq;

int main() {
#ifdef IN_MY_COMPUTER
  freopen("e.in", "r", stdin);
#endif
  scanf("%d", &N);
  for(int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    B[i] = make_pair(A[i], i);
  }
  sort(B+1, B+N+1, greater<pii>());
  for(int i = 1; i <= N; i++) {
    pref[i] = max(pref[i-1], make_pair(A[i], -i));
  }
  for(int i = 1; i <= N; i++) {
    pref[i].second *= -1;
  }

  for(int i = N; i > 0; i--) {
    if(pref[i].second == i) {
      int cnt = 1;
      while(!pq.empty() && pq.top().first >= pref[i-1].first) {
        ans[i] += pq.top().second * (pq.top().first - pref[i-1].first);
        cnt += pq.top().second;
        pq.pop();
      }
      ans[i] += pref[i].first - pref[i-1].first;
      pq.emplace(pref[i-1].first, cnt);
    }else {
      pq.emplace(A[i], 1);
    }
  }
  
  for(int i = 1; i <= N; i++) {
    printf("%lld\n", ans[i]);
  }

  return 0;
}

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

int main()
{
	int n;
	int a[10000];

	cin >> n;

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

	long long total = 0;
	for (int i = 0; i < n; i++){
		total += a[i];
	}
	
	int mi = a[0], ma = a[0];

	for (int i = 1; i < n; i++){
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	cout << mi << " " << ma << " " << total << endl;

	return 0;
}

Measured memory_bytes: 1200
'''
参考
https://penyoo.hatenablog.com/entry/2019/12/02/045335
X を 「X//100=a…購入商品数」と「X%100=b…端数」の2つに分けて考える
※商品の価格が「100～105（100+0～100+5）」になっているため
a、bについて
    b//5!=0の場合
        b//5+1<=a
    b//5==0の場合
        b//5<=a
が成立すれば、買い物ができる

例1：X=617円の場合⇒買い物可能
a=X//100==6     b=X%100==17     b//5+1==4<=a
例2：X=489円の場合⇒買い物不可
a=X//100==4     b=X%100==89     b//5+1==18>a
'''
X = int(input())
purchase_count = X // 100
surplus = X % 100
tmp = surplus // 5

if surplus % 5 != 0:
    tmp += 1

if purchase_count >= tmp:
    print(1)
else:
    print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvii;
typedef pair<int, int> ii;
typedef vector<ii> vii;

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

void solve() {
	
}

const int INF = 1e9 + 1;

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

	int n;
	cin >> n;
	vector<int> dp(3);
	cin >> dp[0] >> dp[1] >> dp[2];
	for (int i = 1; i < n; ++i) {
		vector<int> cur(3), dplast(3, 0);
		cin >> cur[0] >> cur[1] >> cur[2];
		for (int j = 0; j < 3; ++j) {
			for (int z = 0; z < 3; ++z) {
				if (j != z) {
					dplast[j] = max(dplast[j], dp[z] + cur[j]);
				}
			}
		}
		dp = dplast;
	}
	cout << max({dp[0], dp[1], dp[2]}) << endl;
	return 0;
	// first solution o(n) mem
	/*
	int n;
	cin >> n;
	vector<vector<int>> a(3, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) cin >> a[0][i] >> a[1][i] >> a[2][i];
	vector<vector<int>> dp(n, vector<int>(3, 0));
	dp[0][0] = a[0][0];
	dp[0][1] = a[1][0];
	dp[0][2] = a[2][0];
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int z = 0; z < 3; ++z) {
				if (j == z) continue;
				dp[i][z] = max(dp[i][z], dp[i - 1][j] + a[z][i]);
			}
		}
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	return 0;
	*/
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		System.out.println(a[N - 1] - a[0]);
		
	}
}


Measured memory_bytes: 21204
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll h, a;
	cin >> h >> a;
	ll ans = h/a;
	if(h%a) ans++;
	co(ans);

	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, l;

int a[101010];

int main() {
	cin >> n >> l;
	REP(i, n)cin >> a[i];
	int maxl = 0;
	int maxpos = 0;
	REP(i, n) {
		if (i) {
			if (maxl < a[i] + a[i - 1]) {
				maxl = a[i] + a[i - 1];
				maxpos = i;
			}
		}
	}
	if (maxl < l) {
		cout << "Impossible" << endl;
		return 0;

	}
	cout << "Possible" << endl;
	for (int i = 1; i < maxpos; i++) {
		cout << i << endl;
	}
	for (int i = n - 1; i >= maxpos; i--) {
		cout << i << endl;
	}
}

Measured memory_bytes: 1152