akhauriyash/Code-Regression huggingface dataset:
/* atcoder */
#include "bits/stdc++.h"
using namespace std;

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    int n;
    cin >> n;
    vd a, b;
    a.resize(n);
    for (int rv = 0; rv < n; rv++)
    {
        cin >> a[rv];
    }
    b.resize(n);
    for (int rv = 0; rv < n; rv++)
    {
        cin >> b[rv];
    }
    double sum = 0.0;
    for (int i = 0; i < n; i++)
    {
        sum += fabs(a[i] - b[i]);
    }
    cout << sum << endl;
    sum = 0.0;
    for (int i = 0; i < n; i++)
    {
        sum += pow(fabs(a[i] - b[i]), 2.0);
    }
    cout << sqrt(sum) << endl;
    sum = 0.0;
    for (int i = 0; i < n; i++)
    {
        sum += pow(fabs(a[i] - b[i]), 3.0);
    }
    cout << cbrt(sum) << endl;
    vd c;
    for (int i = 0; i < n; i++)
    {
        c.push_back(fabs(a[i] - b[i]));
    }
    cout << *max_element(all(c)) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

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

  vector <long long> vec(N);
  vector <long long> vec_min(N);
  
  for (long long i = 0;i < N;i++){
    cin >> vec.at(i) ;
  }
  
  long long res = 0;
  long long min;
  
  vec_min.at(0) = vec.at(0);
  for (long long i = 1;i < N;i++){
    if(vec.at(i) > vec_min.at(i-1)){
      vec_min.at(i) = vec_min.at(i-1);
      //    cout << "same:" << vec_min.at(i) << endl;
    }
    else{
      vec_min.at(i) = vec.at(i);
      //    cout << "diff:" << vec_min.at(i) << endl;
    }
  }  
 /* 
  for (long long i = 0;i < N;i++){
    cout << vec_min.at(i) << endl;
  }
  */
  
  for (long long i = 0;i < N;i++){
//    cout << "i:" << i << " vec:" << vec.at(i) << " min:" << vec_min.at(i) << endl;
    if(vec.at(i) <= vec_min.at(i)){
      res += 1;
    }
  }  
  
  cout << res << endl;
}





Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;

int main(void) {
	string s;
	cin >> s;
	
	for(int i = 0; i < s.size(); ++i) {
		cout << "x";
	}
	
	cout << endl;
	
	return 0;
}


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

int main(){
    long long N, M;
    cin >> N >> M;
    long long A[M+1];
    for(long long i=1; i<=M; i++){
        cin >> A[i];
    }
    long long ans = N;
    for(long long i = 1; i<= M; i++){
        ans -= A[i];
    }
    if(ans >= 0){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 3772
import numpy as np


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def submit():
    n = int(input())
    alist = list(map(int, input().split()))

    g = alist[0]
    for a in alist[1:]:
        g = gcd(g, a)

    print(g)
    

if __name__ == "__main__":
    submit()

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

int main()
{
    int S;
    cin >> S;
    int h = S / 3600;
    S = S - h * 3600;
    int m = S / 60;
    S = S - m*60;
    cout << h << ':' << m << ':' << S << endl;
    return 0;
}


Measured memory_bytes: 3108
def solve():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41068
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N,M = MI()
G = {}
for i in range(1,N+1):
    G[(i,0)] = []
    G[(i,1)] = []
    G[(i,2)] = []
for _ in range(M):
    u,v = MI()
    G[(u,0)].append((v,1))
    G[(u,1)].append((v,2))
    G[(u,2)].append((v,0))

S,T = MI()

flag = [[-1]*3 for i in range(N+1)]

from collections import deque

q = deque([(S,0,0)])  # 頂点、mod 3、Sからの最短距離
while q:
    n,m,r = q.pop()
    for d,e in G[(n,m)]:
        if flag[d][e] != -1:
            continue
        else:
            flag[d][e] = r+1
            q.appendleft((d,e,r+1))

print(flag[T][0]//3)


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

int main () {
  int A, B;
  cin >> A >> B;
  int N = B - A + 1;
  int sum = 0;
  
  for (int i = 0; i < N; i++){
    int x = A + i;
    int a, b, c, d;
    a = x/10000;
    b = x%10000/1000;
    c = x%10000%1000%100/10;
    d = x%10;
    
    if (a == d && b == c) {
    sum++;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int N,M,A,B,C,D,x1,x2,x3,x4;


int main() {

  scanf("%d%d", &N, &M);
  int K[24][24];
  for (int i=1; i<=N; i++){
    for(int j=1; j<=N; j++){
      K[i][j] = 1e6;
    }
  }

  while(M) {
    scanf("%d,%d,%d,%d", &A, &B, &C, &D);
    K[A][B] = C;
    K[B][A] = D;
    M--;
  }
  scanf("%d,%d,%d,%d", &x1, &x2, &x3, &x4);
  for (int k=1; k<=N; k++){
    for(int i=1; i<=N; i++){
      for(int j=1; j<=N; j++){
        if(K[i][j] > K[i][k] + K[k][j]){
          K[i][j] = K[i][k] + K[k][j];
        }
      }
    }
  }

  // int answer;
  // answer = x3 - x4 - K[x1][x2] - K[x2][x1];
  cout << (x3 - x4 - K[x1][x2] - K[x2][x1]) << endl;

  return 0;

}



Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

typedef long long ll;

using namespace std;

template<typename T> ll count(vector<T>& v, const T n) {
    return count(v.begin(), v.end(), n);
}
template<typename T> ll count(vector< vector<T> >& v, const T n) {
    return accumulate(v.begin(), v.end(), 0, [n](ll init, vector<T> i) { return init + count(i, n); });
}

int main() {
    int w, h, n, x, y, a;
    cin >> w >> h >> n;
    vector< vector<bool> > b(h, vector<bool>(w));
    for (int i = 0; i < n; ++i) {
        cin >> x >> y >> a;
        switch (a) {
            case 1: for (int i = 0; i < h; ++i) fill(b.at(i).begin(), b.at(i).begin() + x, 1); break;
            case 2: for (int i = 0; i < h; ++i) fill(b.at(i).begin() + x, b.at(i).end(), 1); break;
            case 3: for (int i = 0; i < y; ++i) fill(b.at(i).begin(), b.at(i).end(), 1); break;
            case 4: for (int i = y; i < h; ++i) fill(b.at(i).begin(), b.at(i).end(), 1); break;
        }
    }
    cout << count(b, false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  if (abs(x - a) < abs(x - b))
    cout << "A" << endl;
  else
    cout << "B" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  long a,b,c,k;
  long sum=0;
  int f=0;
  scanf("%ld",&a); scanf("%ld",&b); scanf("%ld",&c); scanf("%ld",&k);
  if(a<k){
    sum+=a;
    f=1;
    k=k-a;
  }
  else sum=k;
  if(f==1&&b<k){
    f=2;
    k=k-b;
  }
  if(f==2) sum=sum-k;
  printf("%ld",sum);
  return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n,ll d)
{
    KAKA
    ll cnt = 0;
    pragi(0,n)
    {
        ll x,y;
        cin>>x>>y;
        ll dist = (x * x) + (y * y);
        ll b = d * d;
        if(dist <= b) cnt++;
    }
    cout<<cnt<<"\n";
}
int main()
{
    KAKA
    ll n,d;
    cin>>n>>d;
    Compute(n,d);
}

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

#define MOD 1000000007

long long N, L;
long long x[6000], a[6000];
long long dp[6000][6000];

int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++) { cin >> x[i]; }
	for (int i = 0; i < N; i++) { cin >> a[i]; }
	int cnt = 0;
	for (int i = x[N - 1]; i < L; i += a[N - 1]) {
		cnt++;
		if (cnt >= 20000) { break; }
		dp[N - 1][i] = 1;
	}
	for (int i = L - 1; i >= 0; i--) {
		dp[N - 1][i] += dp[N - 1][i + 1];
	}
	for (int i = N - 2; i >= 0; i--) {
		cnt = 0;
		for (int j = x[i]; j < L; j += a[i]) {
			cnt++;
			if (cnt >= 20000) { break; }
			dp[i][j] = dp[i + 1][j + 1];
		}
		for (int j = L - 1; j >= 0; j--) {
			dp[i][j] += dp[i][j + 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[0][0] << endl;
	return 0;
}

Measured memory_bytes: 236592
N = int(input())
sum = 0
now = 1
for i in sorted(list(map(int,input().split()))):
    if(now == i):
        sum += 1
    else:
        print(sum)
        for j in range(i-now-1):
            print(0)
        now = i
        sum = 1
else:
    print(sum)
while(now < N):
    now += 1
    print(0)


Measured memory_bytes: 32188
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=200005;
#define ll long long
int l[N],r[N];
ll sl[N],sr[N];
inline int read(){
	int x=0;char e=getchar();
	for (;e<'0'||e>'9';e=getchar());
	for (;e>='0'&&e<='9';e=getchar()) x=(x<<1)+(x<<3)+(e^48);
	return x;
}
inline ll Max(ll a,ll b){return a>b?a:b;}
int main (){
	int len=read(),n=read();
	for (int i=1;i<=n;i++) l[i]=read();
	for (int i=1;i<=n;i++) r[i]=len-l[n+1-i];
	for (int i=1;i<=n;i++){
		sl[i]=sl[i-1]+l[i];
		sr[i]=sr[i-1]+r[i];
	}
	ll ans=0;
	for (int i=1;i<=n;i++){
		ll cur;
		int j=i+((n-i)>>1),k=(n-i+1)>>1;
		cur=(sl[j]-sl[i-1]+sr[k])<<1ll;
		if ((n-i)&1) cur-=r[k];else cur-=l[j]; 
		ans=Max(ans,cur);
		cur=(sr[j]-sr[i-1]+sl[k])<<1ll;
		if ((n-i)&1) cur-=l[k];else cur-=r[j]; 
		ans=Max(ans,cur);
	}
	printf ("%lld",ans);
	return 0;
} 

Measured memory_bytes: 4992
import std.stdio, std.string, std.conv, std.range, std.algorithm;
void main() {
	string[] n = [];
	foreach (string l; lines(stdin)) n ~= l.chomp;
	foreach (s; ["S", "H", "C", "D"])
		foreach (i; 1..14) {
			auto t = "%s %d".format(s, i);
			if (!n[1..$].canFind(t)) t.writeln;
		}
}

Measured memory_bytes: 2484
#Coding:Utf-8

N,M=map(int, input().split())
A=[]
B=[]
C=[]
count=0
index=0
remain=0
total=0
for i in range(N):
    a,b=map(int, input().split())
    A.append(a)
    B.append(b)


import numpy as np
A=np.array(A)
B=np.array(B)
C=A.argsort()

for j in range(len(C)):
    if count<=M:
        count=count+B[C[j]]
        index+=1
    else:
        break
remain= count- M

for k in range(index):
    total=total+A[C[k]]*B[C[k]]
else:
    print(total-remain*A[C[k]])


Measured memory_bytes: 20956
import sys
from math import sqrt

def solve():
    n = int(sys.stdin.readline())

    ans = sum(is_prime(int(sys.stdin.readline())) for i in range(n))

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and not(n & 1)):
        return False

    lim = int(sqrt(n)) + 1

    for p in range(3, lim, 2):
        if not(n % p):
            return False
            
    return True

if __name__ == '__main__':
    solve()

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

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

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;

    ll a[200005];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(i >= k) {
            if(a[i] > a[i - k]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5192
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

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

typedef long long ll;

int main()
{
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    
    ll x=(h2-h1-1)*60+m2+60-m1;
    if(x-k<0)
    cout<<0;
    else
    cout<<x-k;
    

    return 0;
}


Measured memory_bytes: 3624
H,W=gets.split.map(&:to_i)
S=[]
H.times{
    S<<gets.chomp
}
r="Yes"
H.times{|h|
    W.times{|w|
        next if S[h][w]=="."
        next if w>0&&S[h][w-1]=="#"
        next if w<W-1&&S[h][w+1]=="#"
        next if h>0&&S[h-1][w]=="#"
        next if h<H-1&&S[h+1][w]=="#"
        r="No"
    }
}
puts r


Measured memory_bytes: 14348
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define all(x) x.begin(),x.end()
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll INF=(ll)1e18+7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	while(b<=a){
		b*=2;
		ans++;
	}
	while(c<=b){
		c*=2;
		ans++;
	}
	ans<=k ? cout<<"Yes" : cout<<"No";
}

int main(){
    FAST_IO
    cout<<fixed<<setprecision(10);
    //init_fact();
    //TEST_CASE(solve)
    //TEST_CASE_2{}
    //TEST_CASE_3(solve)
    solve();
    return 0;
}

Measured memory_bytes: 3484
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll H,W,K; cin>>H>>W>>K;
  vector<string> S(H); rep(i,H) cin>>S[i];
  
  vector<pair<ll,ll>> sb(0);
  rep(y,H) rep(x,W) if(S[y][x]=='#') sb.push_back({x,y});
  
  vector<vector<ll>> vec(H,vector<ll>(W,-1));
  rep(i,K) {ll x,y; tie(x,y)=sb[i]; vec[y][x]=i;}
  
  rep(x,W){
    ll color=-1;
    rep(y,H){
      if(vec[y][x]>-1) color=vec[y][x];
      vec[y][x]=color;
    }
    for(int y=H-1;y>=0;y--){
      if(vec[y][x]>-1) color=vec[y][x];
      else vec[y][x]=color;
    }
  }
  
  rep(y,H){
    ll color=-1;
    rep(x,W){
      if(vec[y][x]>-1) color=vec[y][x];
      vec[y][x]=color;
    }
    for(int x=W-1;x>=0;x--){
      if(vec[y][x]>-1) color=vec[y][x];
      else vec[y][x]=color;
    }
  }
  
  for(auto gyo:vec){
    rep(x,W){
      if(x!=0) cout<<" ";
      cout<<gyo[x]+1;
    }
    cout<<endl;
  }
  
      
  return 0;
}

Measured memory_bytes: 5436
def main():
    from math import floor, ceil
    h, w = map(int, input().split(' '))
    result = []
    if h%3 == 0 or w%3 == 0:
        print(0)
    elif h<3 or w<3:
        if h<3 and w>=3:
            for i in range(1, w-1):
                x = i*h
                y = (w-i)*floor(h/2)
                z = (w-i)*ceil(h/2)
                result.append(max(x,y,z)-min(x,y,z))
                y = floor((w-i)/2)*h
                z = ceil((w-i)/2)*h
                result.append(max(x,y,z)-min(x,y,z))
            print(min(result))
        elif h>=3 and w<3:
            for i in range(1, h-1):
                x = i*w
                y = (h-i)*floor(w/2)
                z = (h-i)*ceil(w/2)
                result.append(max(x,y,z)-min(x,y,z))
                y = floor((h-i)/2)*w
                z = ceil((h-i)/2)*w
                result.append(max(x,y,z)-min(x,y,z))
            print(min(result))
        else:
            print(1)
    else:
        for i in range(1, h-1):
            x = i*w
            y = (h-i)*floor(w/2)
            z = (h-i)*ceil(w/2)
            result.append(max(x,y,z)-min(x,y,z))
            y = floor((h-i)/2)*w
            z = ceil((h-i)/2)*w
            result.append(max(x,y,z)-min(x,y,z))
        for i in range(1, w-1):
            x = i*h
            y = (w-i)*floor(h/2)
            z = (w-i)*ceil(h/2)
            result.append(max(x,y,z)-min(x,y,z))
            y = floor((w-i)/2)*h
            z = ceil((w-i)/2)*h
            result.append(max(x,y,z)-min(x,y,z))
        print(min(result))
main()

Measured memory_bytes: 18992
#include <stdio.h>
int main() {
	int i, j;
	int N;
	int d[50];
	int ans = 0;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi = 3.141592654;
void solve()
{
    ll a[3];
    cin>>a[0]>>a[1];
    sort(a,a+2);
    //cout<<a[0]<<" "<<a[1]<<endl;
    if(a[0]==a[1])
        cout<<a[0]+a[1]<<endl;
    else
        cout<<(2*a[1])-1<<endl;
}

int main()
{

    //freopen("Input.txt","r",stdin);
    ios_base :: sync_with_stdio(false);
    ll t;
   //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())

ans=[]

for i in range(A, A + K):
    if A <= i <= B:
        ans.append(i)
for i in range(B - K + 1, B + 1):
    if A <= i <= B:
            ans.append(i)
ans = list(set(ans))
ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 3064
from enum import IntEnum

class Face(IntEnum):
    One=1
    Two=2
    Three=3
    Four=4
    Five=5
    Six=6


class Dice:
    def __init__(self):
        self.top=Face.One
        self.bottom=Face.Six
        self.back=Face.Two
        self.front=Face.Five
        self.left=Face.Four
        self.right=Face.Three
    
    def roll(self,command):
        if command=="E":
            #back-frontを軸として右回転
            temp=self.top
            self.top=self.left
            self.left=self.bottom
            self.bottom=self.right
            self.right=temp
            
        elif command=="N":
            #right-leftを固定して前転
            temp=self.top
            self.top=self.back
            self.back=self.bottom
            self.bottom=self.front
            self.front=temp
            
        elif command=="S":
            #right-leftを固定して後転
            temp=self.top
            self.top=self.front
            self.front=self.bottom
            self.bottom=self.back
            self.back=temp
            
        elif command=="W":
            #back-frontを軸として左回転
            temp=self.top
            self.top=self.right
            self.right=self.bottom
            self.bottom=self.left
            self.left=temp
            



def run():
    dice_score_ls=list(map(int,input().split()))
    command_str=input()
    
    dice_score_dict={i+1:score for i,score in enumerate(dice_score_ls)}
    
    dice=Dice()
    for command in command_str:
        dice.roll(command)
        

    final_score=dice_score_dict[int(dice.top)]
    print(f"{final_score}")


run()


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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)




void solve(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int money = 1000;
    rep(i,N-1){
        
        if(A[i+1]>A[i]){
            int kabu = money / A[i];
            money += (A[i+1]-A[i])*kabu;
        }
    }
    cout << money << endl;
    
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
     int t,n;
     cin>>n>>t;
     if(n==t){
        for(int i=0;i<n;i++){
            cout<<n;
        }
     }
      else if(n>t){
        for(int i=0;i<n;i++){
            cout<<t;
        }
      }
         else{
        for(int i=0;i<t;i++){
            cout<<n;
        }
         }
}



Measured memory_bytes: 3560
#include <cstdio>
using namespace std;
void printSums(const int &N)
{
    int start = 1, end = 1, sum = 1, ans=0;
    while (start <= N/2)
    {
        if (sum < N) {
            end += 1;
            sum += end;
        }
        else if (sum > N) {
            sum -= start;
            start += 1;
        }
        else if (sum == N) {

            ans++;
            sum -= start;
            start += 1;
        }
    }
    printf("%d\n", ans);
}

int main() {
    int N;
    for (; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        printSums(N);
    }
    return 0;
}



Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int main() {
    cin>>n;
    int a;
    ll ans=0;
    cin>>a;
    int maxn=a,ch=0;
    for(int i=1;i<n;i++) {
        cin>>a;
        maxn=max(a,maxn);
        ch=maxn-a;
        maxn=max(maxn,a+ch);
        ans+=ch;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int n = scan.nextInt();
		int[] a = new int[n];
		char[] m = new char[n];
		int[] sq = new int[n];
		for (int i = 0; i < n; i++) {
			sq[i] = i;
			m[i] = scan.next().charAt(0);
			a[i] = scan.nextInt();
		}

		QuickSsort(a, m, sq, 0, n - 1);

		boolean stab = true;
		for (int i = 1; i < a.length; i++)
			if (a[i] == a[i - 1])
				if (sq[i] < sq[i - 1]) {
					stab = false;
					break;
				}
		if (stab)
			System.out.println("Stable");
		else
			System.out.println("Not stable");

		for (int i = 0; i < a.length; i++)
			System.out.println(m[i] + " " + a[i]);

		scan.close();
		System.exit(0);
	}

	private static void QuickSsort(int[] a, char[] m, int[] sq, int st, int ed) {
		if (st >= ed)
			return;
		int v = Q2sort(a, m, sq, st, ed);
		QuickSsort(a, m, sq, st, v - 1);
		QuickSsort(a, m, sq, v + 1, ed);
	}

	private static int Q2sort(int[] a, char[] m, int[] sq, int st, int ed) {
		int x = a[ed];
		int i = st - 1;
		for (int j = st; j < ed; j++)
			if (a[j] <= x) {
				i++;
				int tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
				char t = m[j];
				m[j] = m[i];
				m[i] = t;
				tmp = sq[j];
				sq[j] = sq[i];
				sq[i] = tmp;
			}
		int tmp = a[i + 1];
		a[i + 1] = a[ed];
		a[ed] = tmp;
		char t = m[i + 1];
		m[i + 1] = m[ed];
		m[ed] = t;
		tmp = sq[i + 1];
		sq[i + 1] = sq[ed];
		sq[ed] = tmp;

		return i + 1;
	}

}

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

int main()
{

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

        bool approved = false;
        bool denied = false;

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


                int temp = a[i];

                if (temp % 2 == 0) {

                        if ((temp % 3 == 0) || (temp % 5 == 0)) {

                        }
                        else {
                                denied = true;
                                break;
                        }
                }

        }
        if (denied) {
                cout << "DENIED" << endl;
        }
        else {
                cout << "APPROVED" << endl;
        }



}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
int a, b;
char  op;
while(true){

cin >> a >> op >> b;

    if(op == '?'){
   break;
    }
if(op == '+'){
    cout << (a+b) << endl;
}
if(op == '-'){
    cout << (a-b) << endl;
}
if(op == '*'){
    cout << (a*b) << endl;
}
if(op == '/' ){
    cout << (a/b) << endl;
}
}/* end of while */
}


Measured memory_bytes: 3096
#x, y = map(int,input().split())
#ls = list(map(int,input().split()))
n = int(input())
s = input()
#x, y = input().split()
ls = []
for i in range(n):
  ls.append([set(s[:i]),set(s[i:])])

n_ls = [len(i[0] & i[1]) for i in ls]
print(max(n_ls))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll c[3][3];
    ll sum = 0;
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> c[i][j];
            sum += c[i][j];
        }
    }
    sum /= 3;
    if (sum - c[0][0] - c[1][1] == c[2][2] && sum - c[0][1] - c[1][2] == c[2][0] && sum - c[0][2] - c[1][0] == c[2][1]) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

vector<int> adj[MAX];
int main() {
	int n, m, x, y, i;
	cin>>n>>m;
	
	for(i=0;i<m;i++) {
		inp(x);inp(y);
		adj[x].PB(y);
		adj[y].PB(x);
	}
	
	int p[n+1];
	MSV(p, -1);
	queue<int> q;
	q.push(1);
	p[1] = 1;
	
	while(!q.empty()) {
		int node = q.front();
		q.pop();
		
		for(i=0;i<adj[node].size();i++) {
			if(p[adj[node][i]] == -1) {
				q.push(adj[node][i]);
				p[adj[node][i]] = node;
			}
		}
	}
	bool f = true;
	for(i=2;i<=n;i++) {
		if(p[i] == -1) {f= false; break;}
	}
	
	if(f) {
		printf("Yes\n");
		for(i=2;i<=n;i++) printf("%d\n", p[i]);
	} else printf("No\n");
		
    return 0;
}



Measured memory_bytes: 10460
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll 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(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  int ans=1;
  int n;
  cin>>n;
  vi h(n);
  rep(i,n) cin>>h[i];
  int ja=h[0];
  for(int i=1;i<n;i++){
    if(h[i]>=ja){
      ans++;
      ja=h[i];
    }
  }
  cout<<ans<<endl;
}


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

class pred {
public:
    bool operator()(const int& left, const int& right) const {
        return left > right;
    }
};

int main()
{
    int N, card;
    int alice = 0, bob = 0;

    cin >> N;

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

    sort(cards.begin(), cards.end(), pred());

    for (int i = 0; i < N; i+=2) {
        alice += cards[i];
        bob += cards[i+1];
    }

    cout << (alice - bob) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int k;
	while(~getI(k)) printf("%d\n",a[k-1]);
}


Measured memory_bytes: 256
#include<stdio.h>

void compression(int height, int width, char matrix[height][width]){
	int row[height], col[width], i,j;
	for(i = 0; i < height; i++){
		row[i] = 0;
		for(j = 0; j < width; j++){
			if(matrix[i][j] == '#'){
				row[i] = 1;
				break;
			}
		}
	}
	
	for(j = 0; j < width; j++){
		col[j] = 0;
		for(i = 0; i < height; i++){
			if(matrix[i][j] == '#'){
				col[j] = 1;
				break;
			}
		}
	}
	
	for(i = 0; i < height; i++){
		for(j = 0; j < width; j++){
			if(row[i] == 1 && col[j] == 1){
				printf("%c", matrix[i][j]);
			}
		}
		printf("\n");
	}
}

int main(void){
	int height, width, i, j;
	scanf("%d %d", &height, &width);
	char matrix[height][width];
	for (i = 0; i < height; i++){
		for (j = 0; j < width; j++){
			scanf(" %c", &matrix[i][j]);
		}
	}
	
	compression(height, width, matrix);
	
	return 0;
}

Measured memory_bytes: 128
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<int> b(n - 1);
    cin >> b;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            sum += b[0];
        } else if (i == n - 1) {
            sum += b[i - 1];
        } else {
            sum += min(b[i - 1], b[i]);
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

#define chmin(a,b) a=min(a,b)
#define rep(i,x) for(ll i=0;i<(x);++i)

const ll linf = 3e18;

ll cost[100][100];
ll d[100];
bool used[100];

ll N, K;

void dijkstra(ll s)
{
    fill_n(d, N, linf);
    fill_n(used, N, false);
    d[s] = 0;

    while (true) {
        ll v = -1;

        rep(u, N) {
            if (!used[u] && (v == -1 || d[v] > d[u])) v = u;
        }

        if (v == -1) break;
        used[v] = true;

        rep(u, N) {
            chmin(d[u], d[v] + cost[v][u]);
        }
    }
}

signed main()
{
    while (scanf("%lld %lld", &N, &K), N || K) {
        fill(cost[0], cost[N], linf);

        rep(i, K) {
            ll t; scanf("%lld", &t);
            if (t == 1) {
                ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c); a--; b--;
                chmin(cost[a][b], c);
                chmin(cost[b][a], c);
            } else {
                ll a, b; scanf("%lld %lld", &a, &b); a--; b--;
                dijkstra(a);
                printf("%lld\n", d[b] == linf ? -1 : d[b]);
            }
        }
    }
}

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

int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A-B >= 0) cout << "delicious" << endl;
  else if(A-B >= -X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


int main(){
    string s,t; cin>>s>>t;
    int ans = 0;
    REP(i,s.size()){
        if(s[i]!=t[i]) ++ans;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3804
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, K = LI()
    ans = 0
    for i in range(1, N + 1):
        if i >= K:
            ans += 1
        else:
            times = -(-K // i)
            bits = (times - 1).bit_length()
            ans += 0.5 ** bits
    ans /= N
    return ans

print(main())


Measured memory_bytes: 3064
from itertools import chain, permutations, dropwhile
from heapq import merge
from functools import wraps

def listify(fn):
  @wraps(fn)
  def wraper(*args, **kwargs):
    return list(fn(*args, **kwargs))
  return wraper

def comp_wild(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

@listify
def includers(a,b):
  for i in range(len(a)-len(b)+1):
   if comp_wild(a[i:], b):
     yield i 

@listify
def connectors(a,b):
  for i in range(max(len(a)-len(b)+1, 1), len(a)+1):
    if comp_wild(a[i:], b):
      yield i

class c_int(int):
  def __new__(cls, *args, **kwargs):
    cond = kwargs.pop("cond", lambda:True)
    i = int.__new__(cls, *args, **kwargs)
    i.cond = cond
    return i

def iter_from(it, fm):
  return dropwhile(fm.__gt__, it)

def solve(a, b, c):
  keys = sorted((a,b,c), key=len, reverse=True)
  len_keys = list(map(len, keys))
  inc = { (i,j):includers(keys[i],keys[j]) for i,j in permutations(range(3), 2) }
  con = { (i,j):connectors(keys[i],keys[j]) for i,j in permutations(range(3), 2) }
  
  for i in inc[0,1]:
    for j in inc[0,2]:
      if (
        j+len_keys[2] <= i or i+len_keys[2] <= j or
        j-i in inc[1,2] or j-i in con[1,2] or i-j in con[2,1]
      ):
        return len_keys[0]
  
  def candicates(x,y,z):
    return chain(
      ( c_int(
          i+len_keys[z], 
          cond=lambda:(
            (inc[x,y] and inc[x,y][0]+len_keys[y] <= i) or 
            (inc[z,y] and len_keys[x] <= i+inc[z,y][-1]) or 
            any(
              (i-j in con[y,z] if i>j else j-i in inc[z,y])
               for j in iter_from(inc[x,y]+con[x,y], i-len_keys[y])
            )
          )
        ) for i in iter_from(con[x,z], len_keys[y]-len_keys[z]+1)
      ),
      ( c_int(
          min( i+next(iter_from(q, len_keys[x]-i+1))+len_keys[z] for i in p )
        ) for (p, q) in [sorted((con[x,y], con[y,z]), key=len)]
      ),
    )
  
  for c in merge(*( candicates(*xyz) for xyz in permutations(range(3), 3) )):
    if c.cond():
      return c
  
  return sum(len_keys)

print(solve(*(input() for _ in range(3))))


Measured memory_bytes: 3796
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://github.com/atcoder-live/library/blob/master/comb.cpp

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(1000004);

int main() {
    int x, y;
    cin >> x >> y;

    if((x+y)%3) cout << 0 << endl;
    else {
        int C = (x+y)/3;
        int rr = x-C;
        cout << c(C, rr) << endl;
    }
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
const long long infl = LLONG_MAX;

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase   
ll a[100000+4],dp[100000+4];

ll fun(ll i,ll n,ll k){
	if(i==n) return 0;
	if(i>n) return infl;
	if(dp[i]!=-1)	return dp[i];
	ll q=infl,j;
	rep(j,1,k+1,1){
		if(j+i<n)	  q=min(q,abs(a[i]-a[i+j])+fun(i+j,n,k));
		else	break;
	}
	
	if(i+1==n )q=0;
	if(q!=infl)	
		dp[i]=q;
	else return 0;
	
	return dp[i];
}

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t,i,x,j,y,z,k,n;
memset(dp,-1,sizeof(dp));
cin>>n>>k;
rep(i,0,n,1)cin>>a[i];
cout<<fun(0,n,k);
}


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

using namespace std;
int waa[100110];
bool acc[100110];
int main(){

    int n,m,WAcc=0,ACcc=0,x;
    string s;

    cin>>n>>m;

    while(m--){
        cin>>x>>s;

        if(acc[x]) continue;
        else{
            if(s == "WA") waa[x]++;
            else{
                acc[x] = true;
                ACcc++;
                WAcc+= waa[x];
            }
        }

    }
    cout<<ACcc << " "<<WAcc<<"\n";
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int y=sc.nextInt();
    int[] a={1,2,1,4,1,4,1,1,4,1,4,1};
    if(a[x-1]==a[y-1]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 25172
import itertools
import math

n = int(input())
A = [[0,0] for _ in range(n)]
for i in range(n):
    A[i] = [int(s) for s in input().split()]


B = [s for s in range(n)]
al_list = list(itertools.permutations(B))
#print(al_list)

mx = math.factorial(n)

sm = 0
for j in range(mx):
    res = 0
    for k in range(n-1):
       st = al_list[j][k] 
       en = al_list[j][k+1]
       x_1,y_1 = A[st]
       x_2,y_2 = A[en]
       dist = math.sqrt((x_1-x_2)**2 + (y_1-y_2)**2)
       res += dist
    
    sm += res

print(sm/mx)
#print(A)

Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		ll a, b;
		cin>>a>>b;
		cout<<a*b<<"\n";
	}
}

Measured memory_bytes: 3636