akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int A,N;
  cin >> N;
  A = N % 10;
  if(A == 3){
  	cout << "bon" << endl;
  }else if(A == 0||A == 1||A == 6||A == 8){
    cout << "pon" << endl;
  }else{
  	cout << "hon" << endl;
  }
}

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

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vin(v,n) copy_n(istream_iterator<int>(cin),n,back_inserter(v));
#define all(v) v.begin(),v.end()
#define INF 2000000000
#define MOD 1000000007
#define ll long long 
#define vi vector<int>
#define ii pair<int,int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define f1(i,a,b) for(int i = a;i<b;i++)
#define f2(i,a,b) for(int i = a;i<=b;i++)

using namespace std;

int32_t main() 
{
	IOS;
	int n, w;
	cin >> n >> w;
	vi val(n+1,0);
	vi wt(n+1,0);
	f2(i,1,n)
		cin >> wt[i] >> val[i];

	vector<vi> dp(n+1, vi(w+1, 0));

	f2(i,1,n)
	{
		f2(j,1,w)
		{
			dp[i][j] = dp[i-1][j];
			if(wt[i]<=j)
				dp[i][j] = max(dp[i-1][j-wt[i]]+val[i], dp[i-1][j]);
			
		}
	}
	cout << dp[n][w];	
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
struct Kruskal{
  
  struct edge{
    Int from,to;
    T cost;
    Int used;
    edge(){}
    edge(Int from,Int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  Int n;
  vector<Int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(Int n):n(n){}

  void init(Int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(Int x,Int y){
    return find(x)==find(y);
  }

  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(Int u,Int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Kruskal<Int> ks(n);
  using P = pair<Int, Int>;
  auto add_edge=
    [&](Int x,Int y){
      if(x<0||y<0) return;
      Int c=abs(x-y)*d+a[x]+a[y];
      ks.add_edge(x,y,c);
    };

  const Int INF = 1e18;
  vector<P> dp(n);
  function<void(Int, Int)> dfs=
    [&](Int l,Int r)->void{
      if(l+1==r){
        dp[l]=P(a[l],l);
        return;
      }
      Int m=(l+r)>>1;      
      dfs(l,m);
      dfs(m,r);
      P x(INF,-1),y(INF,-1);
      for(Int i=l,j=m;i<m||j<r;){
        if(i==m){
          add_edge(x.second,dp[j++].second);
          continue;
        }
        if(j==r){
          add_edge(dp[i++].second,y.second);
          continue;
        }
        if(dp[i].first<=dp[j].first){
          Int k=dp[i++].second;
          add_edge(k,y.second);
          chmin(x,P(a[k]-k*d,k));
        }else{
          Int k=dp[j++].second;
          add_edge(x.second,k);
          chmin(y,P(a[k]+k*d,k));
        }
      }
      
      inplace_merge(dp.begin()+l,dp.begin()+m,dp.begin()+r);
    };  
  dfs(0,n);

  cout<<ks.build()<<endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

const int max_n = 100005;
int a[max_n];

int main(){
    int n;
    cin >> n;
    for(int i=2;i<n+1;i++){
        if(a[i]==0){
            int tmp = max_n/i;
            for(int j=2; j<=tmp ;j++){
                a[j*i] = 1;
            }
        }
    }
    for(int i=n;i<max_n;i++){
        if(a[i]==0) {
            cout << i <<endl;
            return 0;    
        }
    }
    return 0;
}

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


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

    if( (a == 'H' && b == 'H' ) || (a == 'D' && b == 'D') ) cout << "H" << endl;
    else cout << "D" << endl;
}


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

int main() {
    string a;
    string b;

    cin >> a >> b;

    int al = a.length();
    int bl = b.length();

    int dif = al - bl + 1;
    int res = bl;
    for(int i = 0; i < dif; i ++) {
        int cnt = 0;
        for(int j = 0; j < bl; j++) {
            if(b[j] != a[j+i]) {
                cnt++;
            }
        }
        if(cnt < res) {
            res = cnt;
        }
    }

    cout << res << endl;

}

Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
 
int N, M, S;
 
int dp[2][2001][3001];
 
int main()
{
    while (true)
    {
        scanf("%d", &N);
        scanf("%d", &M);
        scanf("%d", &S);
 
        if (N == 0 && M == 0 && S == 0) { break; }
 
        for (int i = 0; i < M; i++)
        {
            for (int j = 0; j < S; j++)
            {
                if (i == j && i != 0 && j != 0)
                {
                    dp[1][i][j] = 1;
                }
                else
                {
                    dp[1][i][j] = 0;
                }
            }
        }
 
        int A = N * N;
 
        for (int n = 2; n <= A; n++)
        {
            for (int i = 1; i <= M; i++)
            {
                for (int j = 1; j <= S; j++)
                {
                    if (j >= i)
                    {
                        dp[n % 2][i][j] = (dp[n % 2][i - 1][j - 1] + dp[(n + 1) % 2][i - 1][j - i]) % 100000;
                    }
                }
            }
        }
 
        int sum = 0;
 
        for (int i = 1; i <= M; i++)
        {
            sum += dp[A % 2][i][S];
 
            sum %= 100000;
        }
 
        printf("%d\n", sum);
    }
 
    return 0;
}

Measured memory_bytes: 47764
import Control.Monad

convertStrToInt :: String -> [Int]
convertStrToInt xs = head $ forM ['a'..'z'] $ \i -> return $ length $ filter (== i) xs

convertIntToStr :: [Int] -> String -> String
convertIntToStr [] _ = []
convertIntToStr _ [] = []
convertIntToStr (x:xs) (y:ys) = replicate x y ++ (convertIntToStr xs ys)

minNums' :: [Int] -> [Int] -> [Int]
minNums' [] _ = []
minNums' _ [] = []
minNums' (x:xs) (y:ys) = min x y : minNums' xs ys

minNums :: [[Int]] -> [Int]
minNums [x] = x
minNums (x:y:zs) = minNums ((minNums' x y) : zs)

main = do
  num <- fmap read getLine :: IO Int
  strs <- replicateM num $ do
            tempStr <- getLine
            return tempStr
  putStrLn $ convertIntToStr (minNums $ map convertStrToInt strs) ['a'..'z']


Measured memory_bytes: 1020
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque 


def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

# bingo = [[0] * 3 for i in range(3)]
# bingo[0][0] = 1
# print(bingo)

bingo = []
for i in range(3):
    ls = inpl()
    bingo.append(ls)
N = inp()
for i in range(N):
    a = inp()
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == a:
                bingo[i][j] = -1

bl = False
for i in range(3):
    if bingo[i][0] == -1 and bingo[i][1] == -1 and bingo[i][2] == -1:
        bl = True
    if bingo[0][i] == -1 and bingo[1][i] == -1 and bingo[2][i] == -1:
        bl = True
         
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
        bl = True

if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
        bl = True
 
print('Yes' if bl else 'No')


# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)



Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
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;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    COMinit();
    ll N,K;
    cin >>N>>K;
    vector<ll> A(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(all(A));
    ll ans = 0;
    rep(i,N){
        ans = (ans +A[i]*COM(N-1-i,K-1))%MOD;
        //cout << ans << endl;
        ans = (ans -A[i]*COM(i,K-1))%MOD;
    }
    cout << -ans << endl;


    return 0;
    

}

Measured memory_bytes: 15904
from sys import stdin


def get_result(data):
    N, M = data[0]
    H = data[1]
    adj_list = [set() for _ in range(N)]
    for val in data[2:]:
        adj_list[val[0]-1].add(val[1]-1)
        adj_list[val[1]-1].add(val[0]-1)

    ans = 0
    for i in range(N):
        base_h = H[i]
        flag = True
        edges = adj_list[i]
        for edge in edges:
            h = H[edge]
            if h >= base_h:
                flag = False
                break
        if flag:
            ans += 1
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 72772
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int32_t length = static_cast<int32_t>(S.length());
  int32_t count_c = 0;
  bool is_okay = true;
  for (int32_t i = 0; i < length; ++i) {
    const char ch = S.c_str()[i];
    if (i == 0) {
      if (ch != 'A') {
        is_okay = false;
        break;
      }
    } else if (i >= 2 && i <= length - 2 && ch == 'C') {
      ++count_c;
      if (count_c > 1) {
        is_okay = false;
        break;
      }
    } else {
      if (ch < 'a' || ch > 'z') {
        is_okay = false;
        break;
      }
    }
  }
  if (count_c != 1) {
    is_okay = false;
  }
  if (is_okay) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = a + b, y = c + d;
  if (x > y)
    cout << "Left" << endl;
  if (x == y)
    cout << "Balanced" << endl;
  if (x < y)
    cout << "Right" << endl;
}

Measured memory_bytes: 3608
#include <iostream>

int compare(int x, int y){
    if(x < y){
        return x;
    }
    else{
        return y;
    }
}

int main(int argc, const char * argv[]) {
    // insert code here...
    int A, B, C, D;
    int ans;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    
    ans = compare(A, B) + compare(C, D);
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define f(i,n)          for(int i=0;i<n;i++)
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
bool cmp(int a, int b)
{
	return a > b;
}
int32_t main()
{
	g_b();

	int l, r, d; cin >> l >> r >> d;
	int c = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)c++;
	}
	cout << c;

	return 0;

}



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

typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a+b-1>n||a*b<n){
        cout<<"-1";
    }
    else{
        ll s=n-(a+b-1);
        for(int i=0;i<a;i++){
            cout<<n-a+1+i<<" ";
        }
        b--;
        ll ost=n-a+1;
        for(int i=0;i<b;i++){
            if(s>a-1){
                s-=a-1;
                for(int j=0;j<a;j++){
                    cout<<ost-a+j<<" ";
                }
                ost-=a;
            }
            else{
                    //cout<<endl<<s<<" "<<<<endl;
                for(int j=0;j<s+1;j++){
                    cout<<ost-(s+1)+j<<" ";
                }
                ost-=s+1;
                s=0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  char c;
  R c;
  if(isupper(c)) pr("A");
  else pr("a");
}

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


Measured memory_bytes: 3688
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, K = map(int, input().split())
    num = 0
    for i in range(1, N + 1, 2):
        num += 1
    if num >= K:
        print(YES)
    else:
        print(NO)


if __name__ == '__main__':
    main()


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

#define LL long long
int n, m, x;
int c[] = {1000000000, 2, 5, 5, 4, 5, 6, 3, 7, 6}, d[10];
string ans = "";

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n, m; cin >> n >> m;
    for(int i = 0; i < m; i++) cin >> d[i];

    sort(d, d + m);
    reverse(d, d + m);

    vector<int> dp(n + 1, -1);
    dp[0] = 0;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j <= n; j++) {
            int x = c[d[i]];
            if(j + x <= n) dp[j + x] = max(dp[j + x], dp[j] + 1);
        }
    }

    int mx = dp[n];
    for(int i = 0; i < mx; i++) {
        for(int j = 0; j < m; j++) {
            int x = c[d[j]];
            if(n - x >= 0 && dp[n-x] == dp[n] - 1) {
                ans += d[j] + '0';
                n -= x;
                break;
            }
        }
    }

    cout << ans;
}

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

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	
		ll n;
		cin>>n;

		vector<pair<ll,ll>> v;
		for(ll i=0;i<n;i++){
			ll a,b;
			cin>>a>>b;

			v.pb({a,b});
		}

		ll flag=0;
		for(ll i=0;i<=n-3;i++){
			ll f=1;
			for(ll j=i;j<i+3;j++){
				if(v[j].first != v[j].second){
					f=0;
					break;
				}
			}

			if(f==1){
				flag=1;
				break;
			}
		}

		if(flag==1){
			cout<<"Yes"<<nl;
		}else{
			cout<<"No"<<nl;
		}


	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	cin >> n;
	vector<int> B(n);
	for(int i=0;i<n-1;++i){
		cin >> B[i];
	}
	ll res = 0;
	for(int i=1;i<n-1;++i){
		res += min(B[i],B[i-1]);
	}
	res += B[0];
	res += B[n-2];
	
	cout <<res <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int num[100001];
bool flag;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>num[i];
		if(num[i]<num[i-1])
		{
			flag=true;
			break;
		}
		else if(num[i]>num[i-1])
			num[i]--;
	}
	if(flag)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
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; }
//ここから始めよう
signed main(){
    int a[3];
    rep(i,0,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[0]*a[1]/2<<endl;return 0;
}

Measured memory_bytes: 256
/**
 * author: moririn_cocoa       
**/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

int main(void) {
  
  int r;
  int g;
  int b;
  
  cin >> r;
  cin >> g;
  cin >> b;
  
  if ( ( 100 * r + 10 * g + b ) % 4 == 0 ) {
    
    cout << "YES" << endl;
  }
  
  else {
    
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL x, y;
    cin >> x >> y;
    LL ans;
    if (x == 0) {
        if (y > 0) ans = y;
        else ans = -y + 1;
    } else if (y == 0) {
        if (x > 0) ans = 1 + x;
        else ans = -x;
    } else if (x > 0 && y > 0) {
        if (x < y) ans = y - x;
        else ans = 1 + (x - y) + 1;
    } else if (x > 0 && y < 0) {
        ans = 1 + abs(y + x);
    } else if (x < 0 && y > 0) {
        ans = 1 + abs(y + x);
    } else {
        if (x < y) ans = y - x;
        else ans = 1 + (x - y) + 1;
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  suira
//
//  Created by h3038178 on 2018/12/13.
//
//

#include <iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    
    int n,a=0,b=0,c=0,d=0,e=0,f=0;
    double h;
    string x,y,z,w,m,k;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>h;
        if(h<165){a=a+1;}
        else if(165<=h&&h<170){b=b+1;}
        else if(170<=h&&h<175){c=c+1;}
        else if(175<=h&&h<180){d=d+1;}
        else if(180<=h&&h<185){e=e+1;}
        else if(185<=h){f=f+1;}
    }
    for(int i=0;i<a;i++){x=x+"*";}
    for(int i=0;i<b;i++){y=y+"*";}
    for(int i=0;i<c;i++){z=z+"*";}
    for(int i=0;i<d;i++){w=w+"*";}
    for(int i=0;i<e;i++){m=m+"*";}
    for(int i=0;i<f;i++){k=k+"*";}
    cout<<"1:"<<x<<endl;
    cout<<"2:"<<y<<endl;
    cout<<"3:"<<z<<endl;
    cout<<"4:"<<w<<endl;
    cout<<"5:"<<m<<endl;
    cout<<"6:"<<k<<endl;
    
    
    return 0;
}


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

using namespace std;

#define pb push_back
#define pp pop_back
#define ft first
#define sd second


typedef long long ll;
typedef long double ld;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}             
int main () {
	INeedIt();
	int n, k=0;
	cin>>n;
	for (int i=1;i<=n;i++) {
		k+=i;
	}
	cout<<k;
	return 0;
}
 

Measured memory_bytes: 256
function main(input: string[]): void {
    const n = shi(input);
    let res = false;
    for (let i = 1; i < 10; i++) {
        if (n % i == 0 && n / i < 10) {
            res = true;
            break;
        }
    }
    puts(res ? 'Yes' : 'No');

}

// === BEGIN MODULE ===
function shi(array: string[]): number {
    return parseInt(array.shift());
}
function shf(array: string[]): number {
    return parseFloat(array.shift());
}
function puts(...message: any[]): void {
    process.stdout.write(message.join(' ') + '\n');
}
// === END   MODULE ===

import { readFileSync } from 'fs';
if (process.argv[1] == __filename) {
    const path = process.argv[2] || '/dev/stdin';
    const input = readFileSync(path, 'utf-8');
    main(input.split(/\s+/));
}

Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n,m;
int b[100000];

int main() {
    cin >> n >> m;
    int cnt = 0;
    for(int i=1;i*i<=m;++i){
        if(m%i==0){
            b[cnt++] = i;
            b[cnt++] = m/i;
        }
    }
    int res = 1;
    REP(i,cnt){
        if((ll)b[i]*n<=m){
            res = max(res,b[i]);
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005],ara[100005];
ll ans(ll n)
{
    if(n==1)
    {
        dp[1]=0;
    }
    if(n==2)
    {
        dp[2]=abs(ara[2]-ara[1]);
        return dp[2];
    }
    if(dp[n]!=-1)
        return dp[n];
    dp[n]=min((ans(n-1)+abs(ara[n]-ara[n-1])),ans(n-2)+abs(ara[n]-ara[n-2]));
    return dp[n];
}
int main()
{
    ll n;
    int i;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        cin>>ara[i];
    }
    cout<<ans(n)<<endl;
    return 0;
}



Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
	int n, x, a, i, j, k;
	while(1){
		x = 0;
		scanf("%d %d", &n, &a);
		if(n == 0 && a == 0)break;
		for(i = 1; i <= n; i++){
			for(j = 1; j <= i; j++){
				for(k = 1; k <= i+j; k++){
					if(i+j+k == a && i > j && j > k){
						x++;
					}
				}
			}
		}
		printf("%d\n", x);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

int main() {
    int X;
    cin >> X;
    if (X < 600) cout << 8 << endl;
    else if (X < 800) cout << 7 << endl;
    else if (X < 1000) cout << 6 << endl;
    else if (X < 1200) cout << 5 << endl;
    else if (X < 1400) cout << 4 << endl;
    else if (X < 1600) cout << 3 << endl;
    else if (X < 1800) cout << 2 << endl;
    else if (X < 2000) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3596
object Main extends App {
  val n = scala.io.StdIn.readLine()
  println(
    (1 to n.length).map { i =>
      if ( i % 2 == 0){
        0
      } else {
        var count = 0
        if(i == n.length) {
          count = n.toInt - Math.pow(10, n.length - 1).toInt
          count = count + 1
        } else {
          count = Math.pow(10, i).toInt - Math.pow(10, i - 1).toInt
        }
        count
      }
    }.sum
  )
}

Measured memory_bytes: 27336
#include<iostream>
using namespace std;
int H,W,dp[105][105];
int main(){
    char s[105][105];
    cin >> H >> W;
    for(int i=0;i<H;++i){
        for (int j=0;j<W;++j){
            cin >> s[i][j];
        }
    }
    //s[i][j]が良い状態であることに必要な仕事
    if(s[0][0] =='.') dp[0][0]=0;
    else dp[0][0]=1;

    //先に列を埋める
    for(int i = 1;i<H;++i){
        if(s[i][0]=='#' && s[i-1][0]=='.') dp[i][0]=dp[i-1][0]+1;
        else dp[i][0]=dp[i-1][0];
    }

    for(int j = 1;j<W;++j){
        if(s[0][j]=='#' && s[0][j-1]=='.') dp[0][j]=dp[0][j-1]+1;
        else dp[0][j]=dp[0][j-1];
    }

    for(int i = 1;i<H;++i){
        for(int j = 1;j<W;++j){
            if(s[i][j]=='#' && s[i-1][j]=='.' && s[i][j-1]=='.') dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]+1);
            if(s[i][j]=='#' && s[i-1][j]=='.' && s[i][j-1]=='#') dp[i][j] = min(dp[i-1][j]+1,dp[i][j-1]);
            if(s[i][j]=='#' && s[i-1][j]=='#' && s[i][j-1]=='.') dp[i][j] = min(dp[i-1][j],dp[i][j-1]+1);
            if(s[i][j]=='#' && s[i-1][j]=='#' && s[i][j-1]=='#') dp[i][j] = min(dp[i-1][j],dp[i][j-1]);
            if(s[i][j]=='.') dp[i][j]= min(dp[i-1][j],dp[i][j-1]);
        }
    }
    cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cctype>

#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)
#define ll long long

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void Main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;

    S[K-1] = tolower(S[K-1]);
    cout << S << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 256
N, x = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

a.sort()

cnt = 0
for i, child in enumerate(a):
    if x == 0:
        break
    if child == x:
        cnt += 1
        break
    if child < x:
        # 最後の要素か判定
        if i == len(a) - 1:
            break
        x -= child
        cnt += 1

print(cnt)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        String ans = "";

        int[] abm = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] an = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] bn = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int cheapestAn = 999999;
        for(int i=0; i<an.length; i++) {
            if (an[i] < cheapestAn) cheapestAn = an[i];
        }
        int cheapestBn = 999999;
        for(int i=0; i<bn.length; i++) {
            if (bn[i] < cheapestBn) cheapestBn = bn[i];
        }
        int mostCheap = cheapestAn + cheapestBn;

        for (int i = 0; i < abm[2]; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
            int usedCoupon = an[x - 1] + bn[y - 1] - c;
            if (usedCoupon < mostCheap) {
                mostCheap = usedCoupon;
            }
        }
        System.out.println(mostCheap);
    }
}


Measured memory_bytes: 106052
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  int s[10], c[10];
  rep(i, m) cin >> s[i] >> c[i];
  int p = 1;
  rep(i, n - 1) p *= 10;
  for (int t = (p == 1 ? 0 : p); t < p * 10; t++)
  {
    string st = to_string(t);
    bool can = true;
    rep(i, m)
    {
      if (st[s[i] - 1] - '0' != c[i])
      {
        can = false;
        break;
      }
    }
    if (can)
    {
      cout << t << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

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


//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;


//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

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

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

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



int main()
{
	LL r;
	cin >> r;
	cout << 3 * r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, X;
    cin >> N >> X;
    vector<int> x(N + 1, 0);
    REP(i, N) cin >> x[i + 1];
    reverse(x.begin(), x.end());

    vector<int> sum(N + 1);
    REP(i, N) {
        sum[i + 1] = x[i] + sum[i];
    }

    int ans = INF;
    FOR(k, 1, N) {
        int res = (N + k) * X;
        FOR(i, 1, (N - 1) / k + 1) {
            int r = min(N, i * k);
            int l = k * (i - 1);
            if (i == 1) {
                res += 5 * (sum[r] - sum[l]);
            } else {
                res += (2 * i + 1) * (sum[r] - sum[l]);
            }
            if (res < 0) break;
        }
        if (res > 0) ans = min(res, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
'use strict';
const fs = require('fs');

let N = 0;
let X = [];
let Y = [];

function distance(i, j) {
    return Math.sqrt(Math.pow(X[i] - X[j], 2) + Math.pow(Y[i] - Y[j], 2));
}

function calcTotalRouteDistance() {
    let result = 0;
    for(let i = 0; i < N-1; ++i) {
        for(let j = i+1; j < N; ++j) {
            result += distance(i, j);
        }
    }
    return result;
}

function calcAverageDistance() {
    return 2 * calcTotalRouteDistance() / N;
}

function main(arg) {
    const lines = arg.split('\n');
    N = parseInt(lines[0], 10);
    for(let i = 0; i < N; ++i) {
        let line = lines[i + 1].split(/\s/);
        X[i] = parseInt(line[0], 10);
        Y[i] = parseInt(line[1], 10);
    }
    console.log(calcAverageDistance());
}

main(fs.readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int N;
struct  edge{int to, cost;};
vector<vector<edge> > G;
vector<int> color;

void dfs(int now, int ago, int depth){
  if(depth % 2 == 0) color[now] = 1;
  else color[now] = 0;
  for(int i = 0; i < G[now].size(); i++){
    edge e = G[now][i];
    if(e.to == ago) continue;
    dfs(e.to, now, depth + e.cost);
  }
}

signed main(){
  cin >> N;
  G.resize(N);
  color.resize(N);
  for(int i = 1; i < N; i++){
	 int u, v, w; scanf("%d%d%d", &u, &v, &w);
	 edge e = {v - 1, w}, e1 = {u - 1, w};
	 G[u - 1].push_back(e); G[v - 1].push_back(e1);
  }
  dfs(0, -1, 0);
  for(int i = 0; i < N; i++) cout << color[i] << '\n';
}


Measured memory_bytes: 8192
# -*- coding: utf-8 -*-

from decimal import Decimal

def main():
     a, b, c = map(int, input().split())

     a_sqrt = Decimal(a).sqrt()
     b_sqrt = Decimal(b).sqrt()
     c_sqrt = Decimal(c).sqrt()

     if a_sqrt + b_sqrt < c_sqrt:
          print('Yes')
     else:
          print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 5076
// https://atcoder.jp/contests/abc049/tasks/abc049_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];
    REP(i, H) {
        REP(j, W) { cout << S[i][j]; }
        cout << "\n";
        REP(j, W) { cout << S[i][j]; }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int l, r, i, j, ans;

    scanf("%d%d", &l, &r);

    if (r - l >= 2019 || l % 2019 > r % 2019)
    {
        printf("0\n");
        return (0);
    }
    ans = 2019;
    i = l % 2019;
    while (i < r % 2019)
    {
        j = i + 1;
        while (j <= r % 2019)
        {
            if (ans > i * j % 2019)
                ans = i * j % 2019;
            j++;
        }
        i++;
    }

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

    return 0;
}

Measured memory_bytes: 3848
//#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=998244353;
const int maxn=1e6+100;
const int N=2e5+100;
const int M=2e6+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}


int main()
{
#ifdef local
      freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;cout.tie(0);
    string s,t;cin>>s>>t;
    int n=sz(s);
    int cnt=0;
    rep(i,n) if(s[i]!=t[i]) cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3756
def main():
    h, w = map(int, input().split())
    matrix = [list(input()) for _ in range(h)]

    stack = [(0, 0)]
    diffs = ((0, 1), (1, 0), (0, -1), (-1, 0))
    distance = [[float('inf')] * w for _ in range(h)]
    distance[0][0] = 1
    while stack:
        x, y = stack.pop()
        for dx, dy in diffs:
            nx, ny = x + dx, y + dy
            if 0 <= nx < h and 0 <= ny < w \
                           and matrix[nx][ny] == '.' \
                           and distance[x][y] + 1 < distance[nx][ny]:
                distance[nx][ny] = distance[x][y] + 1
                stack.append((nx, ny))

    if distance[h - 1][w - 1] == float('inf'):
        return -1
    else:
        white = sum(row.count('.') for row in matrix)
        return white - distance[h - 1][w - 1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3188
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
use std::cmp::min;

use std::collections::HashMap;
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    let mut iter = buf.split_whitespace();
 
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    
    let h: Vec<u64> = (0..n).map(|_| {iter.next().unwrap().parse().unwrap()}).collect();
    let mut counts = vec![0u64; n];
    
    for _ in 0..m {
        let a: usize = iter.next().unwrap().parse().unwrap();
        let b: usize = iter.next().unwrap().parse().unwrap();
        let a = a - 1;
        let b = b - 1;
        if h[a] > h[b] {
            counts[b] += 1;
        } else if h[a] < h[b] {
            counts[a] += 1;
        } else {
            // h[a] == h[b]
            counts[a] += 1;
            counts[b] += 1;
        }
    }
    
    
    let ans : isize = counts.iter().map(|k| {
        if k == &0 {1} else {0}
        }).sum();
    
    println!("{}",ans);
    
}

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

int n, m, a[100];

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

	cout << (a[n - m] * 4 * m >= sum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
MAX = 10**8+1
N, M = map(int, input().split())

X = [MAX]*(2**N)
X[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    k = sum(1<<(c-1) for c in map(int, input().split()))

    for j, x in enumerate(X):
        if X[j|k] > x + a:
            X[j|k] = x + a

print(X[-1] if X[-1] < MAX else -1)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

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

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int a[n+1];
    REP(i,1,n+1) cin >> a[i];
    int tmp=1;
    n -= k;
    tmp += (n+k-2)/(k-1);
    cout << tmp << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int N, _W;
int W[101], V[101];
ll dp[100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    ini(dp, 0);
    for1(i, N) 
        for(int w = _W; w >= W[i]; w--)
            dp[w] = max(dp[w], dp[w - W[i]] + V[i]);

    cout << dp[_W] << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


Measured memory_bytes: 1024