akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {
	public static void main(String[] args) {

		// Queueはインターフェースなので、実装クラスのArrayDequeで実装
		Queue<Process> queue = new ArrayDeque<>();

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
			String[] str = br.readLine().split(" ");
			int n = Integer.parseInt(str[0]);// プロセス数
			int q = Integer.parseInt(str[1]);// クオンタム

			for (int i = 0; i < n; i++) {
				String[] tmp = br.readLine().split(" ");
				String name = tmp[0];// プロセス名
				int time = Integer.parseInt(tmp[1]);// 処理時間
				// キューに追加
				queue.add(new Process(name, time));
			}

			int total = 0;// 終了時刻
			// peek()メソッドは要素がなくても例外はスローせずnullを返す
			while (queue.peek() != null) {
				// キューから取り出し
				Process curPrcs = queue.remove();
				int curTime = Math.min(q, curPrcs.time);
				total += curTime;
				curPrcs.time -= curTime;
				if (curPrcs.time > 0) {
					// キューに追加
					queue.add(curPrcs);
				} else {
					System.out.println(curPrcs.name + " " + total);
				}

			}


		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

// プロセスの情報
class Process {
	String name;// プロセス名
	int time;// 処理時間

	public Process(String name, int time) {
		this.time = time;
		this.name = name;

	}

}



Measured memory_bytes: 60520
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A, B;
  	cin >> A >> B;
  
  	int counter=0;
  
  	for (int i=A; i<=B; ++i){
      	int A_ = i;
      
    	int num_1, num_2, num_3, num_4, num_5;	
     	num_5 = A_/10000;
      	A_ = A_ - 10000*num_5;
      
      	num_4 = A_/1000;
      	A_ = A_ - 1000*num_4;
      
      	num_3 = A_/100;
      	A_ = A_ - 100*num_3;
      
      	num_2 = A_/10;
      	A_ = A_ - 10*num_2;
      
      	num_1 = A_;
      
      	int i_inv = 10000*num_1 + 1000*num_2 + 100*num_3 + 10*num_4 + 1*num_5;
      
      
      	if (i==i_inv) {
        	counter += 1;
        }
    }  
  
  	cout << counter << endl;
}

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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;

    if (K<=A) {
        A -= K;
        // cout << "A" << endl;
    }
    else if (A<K and K<=A+B) {
        B -= K-A;
        A = 0;
        // cout << "B" << endl;
    }
    else {
        A = 0;
        B = 0;
        // cout << "C" << endl;
    }
    cout << A  << " " << B << endl;
}

Measured memory_bytes: 3596
# Problem D - Div Game

# input
N = int(input())

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# check
if N==1:
    print(0)
else:
    count = 0
    fact_list = factorization(N)
    for f in fact_list:
        tmp = f[1]
        i = 1
        while tmp-i>=0:
            count += 1
            tmp -= i
            i += 1
    print(count)


Measured memory_bytes: 9440
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(calcPersentage(a))
}

func calcPersentage(a int) float64 {
	if a%2 == 0 {
		return 0.5
	}
	return (float64(a/2) + 1) / float64(a)
}


Measured memory_bytes: 512
from math import factorial, sqrt
N,M=map(int,input().split())
prms={}
tmp=M
for i in range(2, int(sqrt(M))+2):
    while not tmp%i:
        if not i in prms:
            prms[i]=1
        else:
            prms[i]+=1
        tmp //= i
if tmp != 1:
    prms[tmp] = 1

# print(prms)

res=1
def cmb(a,b):
    res=1
    if a - b < b:
        b = a-b
    for i in range(b):
        res *= (a-i)
        res //= (i+1)
    return res

for p, cnt in prms.items():
    res *= cmb(cnt+N-1, cnt)
    res %= 1000000007

print(res % 1000000007)


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

using namespace std;

void func(int n)
{
    int Acard, Bcard;
    int Ascore = 0, Bscore = 0;
    for (int i = 0; i < n; ++i) {
        cin >> Acard >> Bcard;
        if (Acard > Bcard) {
            Ascore += Acard + Bcard;
        } else if (Acard < Bcard) {
            Bscore += Acard + Bcard;
        } else if (Acard == Bcard) {
            Ascore += Acard;
            Bscore += Bcard;
        }
    }
    cout << Ascore << " " << Bscore << '\n';
    return;
}

int main()
{
    for (;;) {
        int n;
        cin >> n;
        if (n == 0) break;
        func(n);
    }
    return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
int main()

{
    string p;
    int count=0, max=0;
    cin>>p;
    for(int i=0;i<3;i++)
    {
        if(p[i]== 'R')
        {
            count++;
            if(count>max && count!=0)
            {
                max= count;
            }
        }
        else
        {
            count=0;
        }
    }
    cout<<max;
}


Measured memory_bytes: 3568
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    let h_start: usize = read!();
    let m_start: usize = read!();
    let h_end: usize = read!();
    let m_end: usize = read!();
    let k: usize = read!();

    let start = h_start * 60 + m_start;
    let end = h_end * 60 + m_end;

    let time = end - start;
    let ans: usize = time - k;
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;
using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi c;
		vi x;
		c.assign(n+1, -1);

		c[0]=0;
		x.push_back(1);
		for(int i=6;i<=100000;i*=6) x.push_back(i);
		for(int i=9;i<=100000;i*=9) x.push_back(i);
		sort(x.rbegin(), x.rend());

		for(int i=0;i<x.size();i++)
		{
			for(int j=0;j+x[i]<=n;j++)
			{
				if(c[j]<0) continue;
				if(c[j+x[i]]>c[j]+1 || c[j+x[i]]<0)
				{
					c[j+x[i]]=c[j]+1;
				}
			}
		}
		printf("%d\n", c[n]);
	}

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();

		/*if(n/10==9||n%10==9) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}*/
		System.out.println(n*n-m);
	}
}




Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss>b.ss;
    return (a.ff < b.ff); 
} 
void solve(){

    ll n;
    cin>>n;
    vec a;
    inpvec(a,n);
    map<ll,ll> m;
    ll sum=0;
    loop(i,0, n){
        sum+= a[i];
        m[a[i]]++;
    }

    ll q; cin>>q;
    while(q--)
    {
        ll x,y;
        cin>>x>>y;
        sum-= x*m[x];
        m[y]+=m[x];
        sum+= y*m[x];
        m[x]=0;
        cout<<sum<<endl;
    }


    return;    
} 
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 9976
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


int main() {
	int n;
	cin >> n;
	vector<int> a(1000005);
	rep(ni, n) {
		int x;
		cin >> x;
		for (int i = 2; i * i <= x; i++) {
			if (x % i == 0) {
				a[i]++;
				while (x % i == 0) {
					x /= i;
				}
			}
		}
		if (x != 1) a[x]++;
	}
	bool p = true, s = true;
	rep(i, 1000005) {
		if (a[i] != 1 && a[i] != 0) p = false;
		if (a[i] == n) s = false;
	}
	if (p) {
		cout << "pairwise coprime" << endl;
	}
	else if (s) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
}

Measured memory_bytes: 7140
#include <stdio.h>
int main(void)
{
    int i,n,num,min=1000001,max=-1000001;
    long sum=0;
    scanf("%d",&n);
      
    for(i=0;i<n;i++)
    {
        scanf("%d",&num);
        sum+=num;
              
        if(min>num){
            min=num;
        }
          
        if(max<num){
            max=num;
        }
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0 ;
}

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

int main(void){
   
   int N,K,X,Y,sum = 0;
   cin >> N >> K >> X >> Y;
   for(int i=1;i<=N;i++){
       if(i <= K){
           sum+=X;
       }
       else{
           sum+=Y;
       }
   }
cout << sum <<endl;
}

Measured memory_bytes: 3576
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import deque

h,w=nii()
ch,cw=nii()
dh,dw=nii()
s=[list(input()) for i in range(h)]

ch-=1
cw-=1
dh-=1
dw-=1

dist=[[-1]*w for i in range(h)]
dist[ch][cw]=0

que=deque()
que.append((ch,cw))

def BFS():
  while que:
    y,x=que.popleft()

    if y==dh and x==dw:
      print(dist[y][x])
      exit()

    for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#':
        que.appendleft((ny,nx))
        s[ny][nx]='#'
        dist[ny][nx]=dist[y][x]

    for i in range(-2,3):
      for j in range(-2,3):
        ny=y+i
        nx=x+j
        if 0<=ny<h and 0<=nx<w and s[ny][nx]!='#' and dist[ny][nx]==-1:
          que.append((ny,nx))
          dist[ny][nx]=dist[y][x]+1

BFS()

print(-1)

Measured memory_bytes: 135012
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>



int main(int argc, char* argv[])
{
  using std::cin;
  using std::cout;
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N, K;
  cin >> N >> K;
  cout << N - K + 1 << "\n";

  return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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


int main(){
	int a, b, c;
	bool flagA=true, flagB=true;

	cin >> a >> b;

	if(a%2 && b%2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())

wc = [0 for i in range(n)]
ac = [0 for i in range(n)]

n_wc = 0
n_ac = 0

for i in range(m):
    num,j = input().split()
    num = int(num)

    if j == 'AC' and ac[num-1] == 0:
        n_ac += 1
        ac[num-1] = 1
        n_wc += wc[num-1]
    else:
        wc[num-1] += 1

print(n_ac,n_wc)

Measured memory_bytes: 4656
#include <stdio.h>

using namespace std;

int main(){
	int n,m,tmp;
	scanf("%d %d",&n,&m);
	int** A = new int*[n];
	for(int i = 0; i < n; i++) A[i] = new int[m];
	int b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&tmp);
			A[i][j] = tmp;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d",&tmp);
		b[i] = tmp;
	}
	long long int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		printf("%lld\n",sum);
	}

	for(int i = 0; i < n; i++){
		delete[] A[i];
	}
	delete A;
}



Measured memory_bytes: 2756
# 初期入力
K,N = (int(x) for x in input().split(" "))
A = [0]
for i in input().split():
    if i !="0":
        A.append( int(i) )

# 1軒ずつ距離のリスト
x =[A[i+1] - A[i] for i,v in enumerate(A[:-1]) ]
if N == len(A):
    x.append(K -A[-1])
else:
    x.append(K - A[-1] +A[1])

#　求めるのは　K　－　max(隣と離れた家の距離)
kyori_min = K - max(x)
print(kyori_min)

Measured memory_bytes: 24600
object Main extends App {

  import scala.io.StdIn._
  val n = readLine.trim.toInt
  val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
  val points = readLine.trim.split(' ').map(_.toInt).toList
  println(calMax(points))
  def calMax(points: List[Int]): Int = {
    val canBeFirst = points.count(_ <= a)
    val canBeSecond = points.count(i ⇒ a < i && i <= b)
    val canBeThird = points.count(_ > b)
    List(canBeFirst, canBeSecond, canBeThird).min
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

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

ll lcm(ll x, ll y){
    return x / gcd(x, y) * y;
}

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

    ll res = t[0];
    for (int i = 0; i < n - 1; ++i) {
        res = lcm(res, t[i+1]);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
      cout<<"Yes";
    else 
      cout<<"No";
    
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = 998244353;
const ll INF = 1LL << 61;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N;
    mat dp(N+1, vec(N+1,INF)), numw(N*2+1, vec(N+1,0)), numb(N*2+1, vec(N+1,0));
    vec a(N*2,0), id(N*2,0);
    rep(i,N*2){
        char c;
        cin>>c>>A;
        --A;
        ll white = c == 'W';
        a[i] = white*N + A;
        id[white*N + A] = i;
    }
    //左k個中のw,bのi未満の数が書かれたボールの個数num[k][i]を前計算
    //便宜上1-indexedっぽい
    reps(k,1,N*2 + 1){
        rep(i,N+1){
            numw[k][i] = numw[k-1][i] + ((a[k-1]/N == 1) && (a[k-1]%N < i));
            numb[k][i] = numb[k-1][i] + ((a[k-1]/N == 0) && (a[k-1]%N < i));
        }
    }
    /*rep(k,N*2 + 1){
        cout<<k<<endl;
        rep(i,N) cout<<numw[k][i]<<' '<<numb[k][i]<<endl;
    }*/
    dp[0][0] = 0;
    reps(k,1,N*2 + 1){
        reps(j,max(0LL, k - N), min(k+1LL,N+1)){
            int i = k - j;
            //cout<<i<<' '<<j<<endl;
            //iはw,jはb
            if(i > 0) dp[i][j] = min(dp[i][j], dp[i-1][j] + id[N+i-1] - numw[id[N+i-1]][i-1] - numb[id[N+i-1]][j]);
            if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j-1] + id[j-1] - numw[id[j-1]][i] - numb[id[j-1]][j-1]);
        }
    }
    /*rep(i,N+1){
        rep(j,N+1) cout<<dp[i][j]<<' ';
        cout<<endl;
    }*/
    cout<<dp[N][N]<<endl;
}

Measured memory_bytes: 157056
n = int(input())
al = list(map(int,input().split()))

al_id = [(a, idx) for idx, a in enumerate(al)]
al_id = sorted(al_id, reverse=True)
dp = [[-float("inf") for i in range(n+1)] for j in range(n+1)]
dp[0][0] = 0
for count, (a, idx) in enumerate(al_id):
    for i in range(count+1):
        j = count - i
        dp[i+1][j] = max(dp[i][j] + abs(idx-i) * a, dp[i+1][j])
        dp[i][j+1] = max(dp[i][j] + abs(n-j-idx-1) * a, dp[i][j+1])


ans = 0
for i in range(n+1):
    j = n - i
    ans = max(dp[i][j], ans)

print(ans)

Measured memory_bytes: 193036
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  
  int y = atoi(a.substr(0,4).c_str());
  int m = atoi(a.substr(5,2).c_str());
  int d = atoi(a.substr(8,2).c_str());
  if(y < 2019){
    cout << "Heisei" << endl;
  }else if(y == 2019 && m <= 4){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}


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

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

  int count =0;
  for(int i=0; i<n; ++i)
    if(a[i] == count +1) ++count;
  
  if(count ==0)cout << -1<<endl;
  else
  cout << n-count<<endl;

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray(); char[] t = sc.next().toCharArray();
		int count = 0; int len = s.length;
		for (int i = 0; i<len; i++) {
			if (s[i] != t[i])
				count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 41868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll n;
	cin >> n;
	vl h(n);
	rep(i, n) cin >> h[i];
	vl dp(n, inf);
	dp[0] = 0;
	FOR(i, 1, n - 1) dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), (i >= 2) ? (dp[i-2] + abs(h[i-2] - h[i])) : (ll)inf);
	cout << dp[n-1] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


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

int main() {
    long long N;
    cin >> N;
    if ((N % 2) == 0) {
        long long sheets = N / 2;
        cout << sheets << endl;
    }
    else {
        long long sheets = ceil(N / 2.0);
        cout << sheets << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,dp[301000],a[301000],ans,vis[301000];
int main()
{
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++)
	dp[a[i]]=max(1,dp[a[i]-1]+1);
	for(i=1;i<=n;i++)
	ans=max(ans,dp[i]);
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,k,p[210000];
long long a;
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
        
    }
    for(int i=0;i<k;i++){
        a+=p[i];
        
    }
    double A=a;
    
    for(int i=k;i<n;i++){
        a=a-p[i-k]+p[i];
        if(A<a)A=a;
    }
    A=(A+k)/2;
    printf("%.12lf",A);
}


Measured memory_bytes: 1152
#include<stdio.h>
#define N 100

int main(){
  int i,j;
  int count=0;
  int A[N];
  int num;
  int mask;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0;i<num-1;i++){
    for(j=num-1;i<j;j--){
      if(A[j]<A[j-1]){
	mask=A[j];
	A[j]=A[j-1];
	A[j-1]=mask;
	count++;
      }
    }
  }

  for(i=0;i<num;i++){
    if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");

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

  return 0;
  
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    vector<ll>v[4];
    ll N, W;
    cin >> N >> W;
    ll w0, v0;
    cin >> w0 >> v0;
    v[0].push_back(v0);
    for(ll i = 1; i < N; i++){
        ll wi, vi;
        cin >> wi >> vi;
        v[wi - w0].push_back(vi);
    }
    vector<ll>sum[4];
    for(ll i = 0; i < 4; i++){
        sum[i].push_back(0);
        sort(v[i].begin(), v[i].end(), greater<ll>());
        for(ll j = 0; j < v[i].size(); j++){
            sum[i].push_back(sum[i][j] + v[i][j]);
        }
    }
    ll ans = 0;
    for(ll a = 0; a < sum[0].size(); a++){
        for(ll b = 0; b < sum[1].size(); b++){
            for(ll c = 0; c < sum[2].size(); c++){
                for(ll d = 0; d < sum[3].size(); d++){
                    ll w = w0 * a + (w0 + 1) * b + (w0 + 2) * c + (w0 + 3) * d;
                    if(w > W)continue;
                    ans = max(ans, sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d]);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int time[4], total;
	int x, y;

	total = 0;
	for (int i = 0; i < 4; i++){
		cin >> time[i];

		total += time[i];
	}

	if (total >= 60){
		x = total / 60;
		total -= (x * 60);
		y = total;
	}
	else {
		x = 0;
		y = total;
	}

	cout << x << "\n" << y << endl;
}

Measured memory_bytes: 3084
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

const int maxn = 1e6 + 7;

bool Judge(int x) {
    for(int i = 2 ; i <= sqrt(x+0.5) ; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    while(cin >> x) {
        for(int i = x ; ; i++) {
            if(Judge(i)) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n, a[N];

int main(){
    //freopen("testgen.out", "r", stdin);
    //freopen("all.out", "w", stdout);

    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    vector <int> vec;

    vec.push_back(a[(n + 1) / 2]);
    int l = 1, r = n;

    while (l < (n + 1) / 2 && r > (n + 1) / 2) {
        vec.push_back(a[r--]);
        vec.push_back(a[l++]);
    }

    if (r > (n + 1) / 2) vec.push_back(a[r]);
    long long ans = 0;

    for (int i = 1; i < vec.size(); i++) ans += abs(vec[i] - vec[i - 1]);

    vec.clear();
    vec.push_back(a[n / 2 + 1]);
    l = 1, r = n;
    while (l < n / 2 + 1 && r > n / 2 + 1) {
        vec.push_back(a[l++]);
        vec.push_back(a[r--]);
    }

    if (l < n / 2 + 1) vec.push_back(a[l]);
    long long res = 0;
    for (int i = 1; i < vec.size(); i++) res += abs(vec[i] - vec[i - 1]);
    cout << max(ans, res);
    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N; cin >> N;
   ll A[100100];
   rep(i, N) cin >> A[i];
   sort(A, A + N);
   reverse(A, A + N);
   ll x[100100], y[100100];
   ll f = A[0], g = A[N - 1];
   rep(i, N - 2) {
       if(A[i + 1] < 0) {
       x[i] = f;
       y[i] = A[i + 1];
       f -= A[i + 1];
       }
       if(A[i + 1] >= 0) {
       x[i] = g;
       y[i] = A[i + 1];
       g -= A[i + 1];
       }
   }
   cout << f - g << endl;
   rep(i, N - 2) {
       cout << x[i] << " " << y[i] << "\n";
   }
   cout << f << " " << g << endl;
   return 0;
}

Measured memory_bytes: 4224
a = int(input())
b = list(map(int, input().split()))
p = min(b)
saveans = 0
ans = 0
for x in b:
    ans += (x - p) ** 2

while p <= max(b):
    saveans = 0
    for x in b:
        saveans += (x - p) ** 2
    if saveans < ans:
        ans = saveans
    p += 1

print(ans)


Measured memory_bytes: 38896
s = input()
t = input()
s = sorted(s)
t = sorted(t,reverse = True)
S = "".join(s)
T = "".join(t)
L = [S,T]
L = sorted(L)
if L[0] == S:
    if L[0] == L[1]:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
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 N;
    cin>>N;
    cout<<(N/2)*(N-N/2)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

/*-- template --*/

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> G(500);
    rep(i, M) {
        int l, r; cin >> l >> r;
        --l, --r;
        G[l].pb(r);
    }
    rep(i, N) {
        if(!G[i].empty())
            sort(G[i].begin(), G[i].end());
    }
    int p[Q], q[Q];
    rep(i, Q) {
        cin >> p[i] >> q[i];
        --p[i];
    }
    int answer[Q];
    rep(i, Q) {
        int ans = 0;
        for(int j = p[i]; j < q[i]; ++j) {
            if(!G[j].empty())
                ans += upper_bound(G[j].begin(), G[j].end(), q[i] - 1) - G[j].begin();
        }
        answer[i] = ans;
    }
    rep(i, Q)
        cout << answer[i] << endl;
}


Measured memory_bytes: 3328
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN];
int visited[MAXN];
ll k;
vector<int> b;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,n) {
        int x;
        cin >> x;
        a[i] = x;
    }
    FOR(i,1,n) visited[i] = -1;
    b.push_back(1);
    visited[1] = 0;
    int idx = -1;
    while (1) {
        int u = b.back();
        if (visited[a[u]] == -1) {
            b.push_back(a[u]);
            visited[a[u]] = SZ(b)-1;
        }
        else {
            idx = visited[a[u]];
            break;
        }
    }
    if (k < idx) cout << b[k];
    else {
        k -= idx;
        int len = SZ(b) - idx;
        k %= len;
        cout << b[idx + k];
    }
    return 0;
}


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

using namespace std;

struct edge {
    int to;
    long long cost;
};

vector<edge> s[100010];

bool visited[100010];
long long kyori[100010];

void dfs(int start, long long d) {
    kyori[start] = d;
    visited[start] = true;
    for (auto e : s[start]) {
        if (visited[e.to]) {
            continue;
        }
        dfs(e.to, d + e.cost);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        long long c;
        cin >> a >> b >> c;
        edge e = { b, c };
        edge e2 = { a, c };
        s[a].push_back(e);
        s[b].push_back(e2);
    }
    int q, k;
    cin >> q >> k;
    dfs(k, 0);

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << kyori[x] + kyori[y] << endl;
    }
}


Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	/**
	 * ?±±???????????????????????????????????´??°??§??¨?????? 10 ??????????????????????????????????????? 10 ????????????????????????????????§??????????????§????????????????????????????????????????????????????????°?????????????????????????????????
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int[] mountHill = new int[10];
		for(int i = 0;i < 10;i++) {
			mountHill[i] = sc.nextInt();
		}
		
		Arrays.sort(mountHill);
		System.out.println(mountHill[9]);
		System.out.println(mountHill[8]);
		System.out.println(mountHill[7]);
		
		
		
	}

}

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


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

   int n,m,c,ans=0; cin >> n >> m >> c;
   vector<int> b(m);
   rep(i,0,m) cin >> b[i];
   int  a[n][m];
   rep(i,0,n){
   	int sum=c;
	 rep(j,0,m){
	   cin >> a[i][j];
       sum+=a[i][j]*b[j];
	 }
	 if(sum>0) ans++;
   } 
    cout << ans << endl;
}



Measured memory_bytes: 256
import itertools,math,sys
def I(): return int(sys.stdin.readline().rstrip())
dp = [0]*31
dp[0],dp[1],dp[2] = 1,1,2
for i,j in itertools.product(range(3,31),[1,2,3]):
    dp[i] += dp[i-j]
while 1:
    n = I()
    if n==0:
        break
    print(math.ceil(dp[n]/10/365))



Measured memory_bytes: 5704
import sys
import math
import itertools
import collections
from collections import deque
import heapq 

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():

    N, M = NMI()
    A = NLI()
    
    A = list(map(lambda x: x*(-1), A))
    
    heapq.heapify(A)
    
    for m in range(M):
        highest = (heapq.heappop(A)*(-1))
        discounted = math.floor(highest/2) * -1
        heapq.heappush(A, discounted)

        
    print(sum(A)*-1)
#

if __name__ == '__main__':
    main()

Measured memory_bytes: 20584
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::map<int64_t, int64_t> A;
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t] = A[t] + 1;
    }

    auto xitr = std::find_if(A.rbegin(), A.rend(), [](auto e) { return e.second >= 2; });
    if (xitr == A.rend()) {
        std::cout << 0 << std::endl;
        return 0;
    }
    xitr->second -= 2;

    auto x = xitr->first;

    auto yitr = std::find_if(xitr, A.rend(), [](auto e) { return e.second >= 2; });
    if (yitr == A.rend()) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::cout << x * yitr->first << std::endl;

    return 0;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	int f = 0;
	REP(i,s.size()){
		if(s[i]=='C' && f == 0) f = 1;
		if(s[i]=='F' && f == 1) f = 2;
	}
	if(f==2)	 cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
    ll k,s; cin >> k >> s;
    ll ans = 0;
    REP(x,k+1){
        REP(y,k+1){
            if(0<= s-x-y && s-x-y <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=500005,P=998244353;
int n,m,ans,fac[N],ifac[N];
inline int C(int a,int b){return a<0||b<0||a<b?0:1ll*fac[a]*ifac[b]%P*ifac[a-b]%P;}
int main()
{
	scanf("%d%d",&n,&m);
	fac[0]=fac[1]=1;for(int i=2;i<=m;++i)fac[i]=1ll*fac[i-1]*i%P;
	ifac[0]=ifac[1]=1;for(int i=2;i<=m;++i)ifac[i]=P-1ll*P/i*ifac[P%i]%P;
	for(int i=2;i<=m;++i)ifac[i]=1ll*ifac[i-1]*ifac[i]%P;
	for(int i=n;i<=m;++i)ans=(ans+C(m,i))%P,ans=(ans+P-C(m,2*i-n+1))%P;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
string A,B;
int main(){
  cin >> A >> B;
  if(A==B) cout << "EQUAL" << endl;
  else if(A.size()<B.size()) cout << "LESS" << endl;
  else if(A.size()>B.size()) cout << "GREATER" << endl;
  else{
    for(int i=0;i<A.size();i++){
      if(A[i]<B[i]){
        cout << "LESS" << endl;
        return 0;
      }
      else if(A[i]>B[i]){
		cout << "GREATER" << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout << ((a%2&&b%2)?"Yes":"No")<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int k,l;
ll ans,po[4]={1,9,81,729},c[110][110];
char a[110];
int main()
{
    scanf("%s",a);
    int l=strlen(a);
    scanf("%d",&k);
    for(int i=0;i<=l;i++)
    {
        c[i][0]=c[i][i]=1;
    }
    for(int i=2;i<=l;i++)
    {
        for(int j=1;j<i;j++)
        {
            c[i][j]=c[i-1][j]+c[i-1][j-1];
        }
    }
    int cnt=0;
    for(int i=0;i<l&&cnt<k;i++)
    {
        if(a[i]!='0')
        {
            ans+=c[l-i-1][k-cnt]*po[k-cnt];
            if(cnt<k-1)
            {
                ans+=c[l-i-1][k-cnt-1]*(a[i]-'0'-1)*po[k-cnt-1];
            }
            else
            {
                ans+=c[l-i-1][k-cnt-1]*(a[i]-'0')*po[k-cnt-1];
            }
            cnt++;
        }
    }
    printf("%lld",ans);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string s, t;
  cin >> s >> t;

  if(s.size() > t.size()) cout << "GREATER" << endl;
  else if(s.size() < t.size()) cout << "LESS" << endl;
  else {
    bool equal = true;
    re(i, s.size()) {
      string a = s.substr(i, 1);
      string b = t.substr(i, 1);
      if(stoi(a) > stoi(b)) {
        equal = false;
        cout << "GREATER" << endl;
        break;
      } else if(stoi(a) < stoi(b)) {
        equal = false;
        cout << "LESS" << endl;
        break;
      } else continue;
    }
    if(equal) cout << "EQUAL" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int a, b;
  cin >> a >> b;

  double  ret=0;
  for(int i=1; i<=a; i++){
    double tmp = 1.0/a;
    int now=i;
    while(now<b){
      now*=2;
      tmp/=2;
    }
    ret+=tmp;
  }

  printf("%.12f\n", ret);

  return 0;
}

Measured memory_bytes: 256
function main(input) {
    var arr = input.replace(/\r?\n/g, "").split(" ");
    const A = arr[0], B = arr[1], C = arr[2];
    var flg = false;
    if (A == B && B != C) flg = true;
    if (B == C && C != A) flg = true;
    if (C == A && A != B) flg = true;
    console.log(flg ? "Yes" : "No")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 20936
n=int(input())
a=list(map(int,input().split()))
dp=[-1]*n
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,len(a)):
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]))
print(dp[-1])


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//------------------------------------------------------//


int main() {
  int x, y;
  cin >> x >> y;
  repc(i, 0, x){
    if(i * 2 + (x-i) * 4 == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
ll n,ans,cnt;
int main()
{
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>cnt;
        if((i%2)&&(cnt%2))
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

typedef struct {
	int g; int s;
}GS;

int h, w;
GS map[2001][2001];
char m[2001][2001];

int main()
{
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> m[i];
	}

	for (int i = 0; i < h; i++) {
		int g = 0;
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '#') {
				g = 0;
			}
			else {
				g++;
			}
			map[i][j].g = g;
		}
		int first = 1; int fixg; g = 0;
		for (int j = w - 1; j >= 0; j--) {
			g = map[i][j].g;
			if (g != 0) {
				if (first == 1) {
					fixg = g;
					first = 0;
				}
			}
			else {
				first = 1;
			}

			if (first == 0) {
				map[i][j].g = fixg;
			}
		}
	}

	for (int i = 0; i < w; i++) {
		int s = 0;
		for (int j = 0; j < h; j++) {
			if (m[j][i] == '#') {
				s = 0;
			}
			else {
				s++;
			}
			map[j][i].s = s;
		}
		int first = 1; int fixs; s = 0;
		for (int j = h - 1; j >= 0; j--) {
			s = map[j][i].s;
			if (s != 0) {
				if (first == 1) {
					fixs = s;
					first = 0;
				}
			}
			else {
				first = 1;
			}

			if (first == 0) {
				map[j][i].s = fixs;
			}
		}
	}
	int max=0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (max < map[i][j].s + map[i][j].g - 1) {
				max = map[i][j].s + map[i][j].g - 1;
			}
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

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



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

	
	priority_queue <string, vector<string>, greater<string> > pq;

	int n,l;
	string s;
	cin >> n >> l;

	REP(i,n) {
		cin >> s;
		pq.push(s);
		
	}

	REP(i,n) {
		cout << pq.top();
		pq.pop ();
	}
	cout << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>

using namespace std;

int H,W;
queue<pair<int,int>> q;
int m[1000][1000];
int d[5] = {0,1,0,-1,0};

int main(){
    char c;
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            m[i][j] = -1;
            cin >> c;
            if(c == '#'){
                q.push(make_pair(i,j));
                m[i][j] = 0;
            }
        }
    }
    int last = 0;
    while(!q.empty()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        int l = m[x][y];
        for(int i=0;i<4;i++){
            int xx = x+d[i];
            int yy = y+d[i+1];
            if(xx < 0 || yy < 0 || xx >= H || yy >= W) continue;
            if(m[xx][yy] != -1) continue;
            last = m[xx][yy] = l + 1;
            q.push(make_pair(xx,yy));
        }
    }
    cout << last << endl;
    return 0;
}

Measured memory_bytes: 12304
#include<iostream>
 
using namespace std;
 
int main(){
    int a,b,c;
    int i;
    cin >> a >> b >> c;
    i=0;
    while(i<60){
        if((c+60*i)%(a+b)<=a){
            cout << (i*60+c) << '\n';
            break;
        }
        i++;
    }
    if(i==60){
        cout <<-1<< '\n';
    }
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    vector<ll> a(N*3);
    REP(i,N*3) cin >> a[i];
    sort(RALL(a));
    ll ans = 0;
    for (int i = 1; i < 2 * N ; i += 2) ans += a[i];

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 2560