akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = [int(m) for m in input().split()]
ans = 0
k = 1
tmp = -1
stmp = 0
numtmp = float("INF")
p = 0
while True:
    if k == 1:
        ans += min(h)
        t = min(h)
        for i in range(n):
            h[i] = h[i] - t
    else:
        for i in range(tmp + 1, n):
            p = 0
            if h[i] != 0:
                numtmp = min(numtmp, h[i])
                if numtmp == h[i]:
                    tmp = i
            else:
                tmp = i
                if numtmp != float("INF"):
                    ans += numtmp
                for j in range(stmp, tmp):
                    h[j] = h[j] - numtmp
                stmp = tmp + 1
                numtmp = float("INF")
                p = 1
            if i == n - 1 and p != 1:
                tmp = i + 1
                if numtmp != float("INF"):
                    ans += numtmp
                for j in range(stmp, tmp):
                    h[j] = h[j] - numtmp
                stmp = tmp + 1
                numtmp = float("INF")
                p = 1
    p = 0
    k += 1
    tmp = -1
    stmp = 0
    numtmp = float("INF")
    for i in range(n):
        if h[i] != 0:
            break
        if h[i] == 0:
            if i == n - 1:
                print(ans)
                exit()

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

int D[100010];

int main(){
    int n,q,t,c=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>D[i];
    cin>>q;
    for(int i=0;i<q;i++){
        int left=0,right=n;
        cin>>t;
        while(left<right){
            int mid=(left+right)/2;
            if(D[mid]==t){
                c++;
                break;
            }
            else if(t<D[mid]) right=mid;
            else left=mid+1;
        }
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3448
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
const LL inf=1LL<<60;
LL n,k,a[100010];
int main()
{
	scanf("%lld %lld",&n,&k);
	for(LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	LL ans=inf;
	for(LL i=1;i+k-1<=n;i++)
	{
		LL l=i,r=i+k-1;
		if(a[l]*a[r]>=0) ans=min(ans,max(abs(a[l]),abs(a[r])));
		LL k1=abs(a[l]),k2=abs(a[r]);
		if(k1>k2) swap(k1,k2);
		ans=min(ans,2*k1+k2);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s; cin>>s;
	if(s=="ABC") cout<<"ARC"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

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

    map<int, int> mp;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }

    int ans = 0;
    rep(i, N) {
        vector<ll> div = divisor(A[i]);
        bool flag = true;
        rep(j, div.size()) {
            // cout << A[i] << " " << div[j] << endl;
            if (mp.count(div[j]) >= 1) {
                if (div[j] == A[i] && mp[div[j]] == 1) continue;
                flag = false;
            }
        }
        if (flag) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13552
import java.util.Scanner;

public class Main {

    private static int A;
    private static int B;
    private static int C;
    private static long K;

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

        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        K = sc.nextLong();
        System.out.println(solve());
    }

    private static String solve() {
        if( K % 2 == 0 ) {
            return String.valueOf(A - B);

        } else {
            return String.valueOf(B - A);
        }
    }
}


Measured memory_bytes: 23636
#include<stdio.h>
#include<math.h>
int main()
{
    int i,n,x[1001],y=0;
    double a=0,alpha,m;

    for(i=0;; i++)
    {
    scanf("%d",&n);
        if(n!=0)
        {
            a=0;y=0;
            for(i=0; i<n; i++)
            {
                scanf("%d",&x[i]);
                y=y+x[i];
            }
            m=(double)y/n;
    //printf("%.8lf\n",m);
    for(i=0;i<n;i++)
        a=a+((x[i]-m)*(x[i]-m));
    alpha=sqrt(a/n);
    printf("%.8lf\n",alpha);
    continue;
        }
        else if(n==0)
            break;
    }
    return 0;

}




Measured memory_bytes: 2104
using System;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int[] vs = new int[2];
            string nd = Console.ReadLine();
            string[] vnd = nd.Split(' ');
            foreach(string a in vnd)
            {
                vs[i] = int.Parse(a);
                i++;
            }
            int[] x = new int[vs[0]];
            int[] y = new int[vs[0]];
            for (int k = 0; k < vs[0]; k++)
            {
                string inp = Console.ReadLine();
                string[] vinp = inp.Split(' ');
                x[k] = int.Parse(vinp[0]);
                y[k] = int.Parse(vinp[1]);
            }
            double[] d = new double[vs[0]];
            for(int k = 0; k < vs[0]; k++)
            {
                d[k] = Math.Sqrt(Math.Pow(x[k], 2) + Math.Pow(y[k], 2));
            }
            int j = 0;
            foreach(double dis in d)
            {
                if(dis <= vs[1])
                {
                    j++;
                }
            }
            Console.WriteLine(j);
        }
    }
}


Measured memory_bytes: 43888
def judge(s):
	a = s[0:len(s)/2]
	b = s[len(s)/2:len(s)]
	if a == b: return False
	else: return True

S = raw_input()
S = S[0:len(S)-2]
while judge(S):
	S = S[0:len(S)-2]

print len(S)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  ll n;
  ll k = 1000000000 + 7;
  cin >> n;
  ll b = 0;
  vector<ll> vec(n+1);
  for (int i = 1; i <= n; i++)
  {
    cin >> vec[i];
  }
  vector<ll> A(n, 0);
  for (int i = 2; i <= n; i++)
  {
    A[1] += vec[i];
  }
  for (int i = 2; i < n; i++)
  {
    A[i] = A[i - 1] - vec[i];
  }
  for (int i = 1; i < n;i++){
    A[i] = A[i] % k;
  }
  for (int i = 1; i < n;i++){
    b += vec[i] * A[i];
    if(b>=k){
      b = b % k;
    }
  }
  cout << b << endl;
}

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

#define MAX_N 1000

using namespace std;

typedef long long lint;

lint sum[2];
lint v[MAX_N + 1];

int n, cate;

int stkLen;
int stk[MAX_N + 1];

int luat[MAX_N + 1];

void ops(int nr)
{
    int i;
    int cat = 0;
    for(i = 1; i <= nr; i ++)
        cat += 1 - luat[i];

    if(cat == 1 || cat == cate)
    {
        luat[nr] = 1;
        stk[++ stkLen] = cat;
        cate --;

       // cout << "OPS 1 " << cat << " " << cate << "\n";

        return;
    }

    int ant = nr - 1;
    int urm = nr + 1;
    while(luat[ant] == 1)
        ant --;

    while(luat[urm] == 1)
        urm ++;

    luat[ant] = 1;
    luat[urm] = 1;
    stk[++ stkLen] = cat;
    v[nr] = v[ant] + v[urm];
    cate -= 2;
      //  cout << "OPS 2 " << cat << " " << cate << "\n";
}

void doOps(int s2)
{
    int i;
    int cnt = 0;
    for(i = 1; i <= n; i ++)
    {
        if(luat[i] == 0)
            cnt ++;

        if(cnt == s2)
        {
            cnt = i;
            break;
        }
    }

    ops(cnt);
}

void spec(lint mx)
{
    int i;
    int poz = 0;
    int cate = n;
    for(i = 1; i <= n; i ++)
    {
        if(v[i] == mx)
            poz = i;
    }

    cout << mx << "\n";
    cout << n - 1 << "\n";

    while(poz > 1)
    {
        cout << 1 << "\n";
        poz --;
        cate --;
    }

    while(cate > 1)
    {
        cout << cate << "\n";
        cate --;
    }
}

int main()
{
    cin >> n;

    int i;
    lint mx = -2000000000;
    for(i = 1; i <= n; i ++)
    {
        cin >> v[i];

        mx = max(mx, v[i]);
    }

    if(mx <= 0)
    {
        spec(mx);

        return 0;
    }

    int cat = 1;
    while(v[cat] < 0)
        cat ++;

    cat --;

    for(i = 1; i <= cat; i ++)
        stk[++ stkLen] = 1;

    for(i = 1; i + cat <= n; i ++)
        v[i] = v[i + cat];

    n -= cat;

    for(i = 1; i <= n; i ++)
        sum[i & 1] += v[i] * (v[i] > 0);

    cate = n;
    int s2 = 0;
    int start = 0;
    if(sum[0] > sum[1])
        start = 2, s2 = 3;

    else
        start = 1, s2 = 2;

    for(i = start; i <= n; i += 2)
    {
        if(v[i] < 0)
            ops(i);
    }

    while(s2 + 1 <= cate)
    {
        doOps(s2);
    }

    for(i = 1; i < s2 - 1   ; i ++)
        doOps(1);

   // cout << cate << "\n";

    while(cate > 1)
    {
        doOps(cate);
        cate --;
    }

    cout << max(sum[0], sum[1]) << "\n";
    cout << stkLen << "\n";

    for(i = 1; i <= stkLen; i ++)
        cout << stk[i] << "\n";

    return 0;
}


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

#define Rep(j,n) for(int j=0;j<(int)(n);++j)

#define int long long

using namespace std;

signed main()
{
  int x=0,y=0,z=0,i,j;
  std::cin >> x>>y>>z;
  if (x*y>=z) {
  std::cout << z<< '\n';
}else{
  std::cout << x*y << '\n';
}

//  std::vector<int> v(x);
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();
		int n = s.length;
		
		for (int i = 0; i < n; i++) {
			if (i % 2 == 1 && s[i] == 'R') {
				pr.println("No");
				return;
			} else if (i % 2 == 0 && s[i] == 'L') {
				pr.println("No");
				return;
			}
		}

		pr.println("Yes");
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    rep(i, 3) {
        if(s[i]!=s[2-i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import deque
N,M=map(int,input().split())
table=[[float("inf") for _ in range(N)] for _ in range(N)]
used=[[-float("inf") for _ in range(N)] for _ in range(N)]
tree=[[] for _ in range(N)]
for i in range(M):
    a,b,c=map(int,input().split())
    table[a-1][b-1]=c
    table[b-1][a-1]=c
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
    used[a-1][b-1]=0
    used[b-1][a-1]=0
for i in range(N):
    table[i][i]=0
#print(used)
for i in range(N):
    d=[float("inf") for _ in range(N)]
    d[i]=0
    q=[]
    prev=[-1]*N
    q.append([0,i])
    heapq.heapify(q)
    while len(q)>0:
        dist,u=heapq.heappop(q)
        if d[u]<dist: continue
        piv=prev[u]
        v=u
        while piv!=-1:
            #print(piv)
            used[piv][v] = 1
            used[v][piv] = 1
            v = piv
            piv=prev[piv]
        for i in tree[u]:
            alt=d[u]+table[u][i]
            if d[i]>alt:
                d[i]=alt
                heapq.heappush(q,[alt,i])
                prev[i]=u
        #print(q,d,prev)
        #input()
    #print(d)
#print(used)
ans=0
for i in range(N):
    for j in range(N):
        if used[i][j]==0:
            ans=ans+1
print(ans//2)


Measured memory_bytes: 53852
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 1E+05;

int N;
int scdl[MAX_N][3];

bool solve();

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

    cin >> N;

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

    if (solve()) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

bool solve()
{
    int t = 0;
    int x = 0;
    int y = 0;
    for (int i = 0; i < N; i++) {
        int dt = scdl[i][0] - t;
        t = scdl[i][0];
        int dx = abs(scdl[i][1] - x);
        x = scdl[i][1];
        int dy = abs(scdl[i][2] - y);
        y = scdl[i][2];

        bool cantra = false;
        for (; dt >= 0; dt -= 2) {
            if (dx + dy == dt) {
                cantra = true;
            }
        }
        if (!cantra)
            return false;
    }
    return true;
}

Measured memory_bytes: 4768
n , k = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n):
    for j in range(i,n):
        b.append(sum(a[i:j+1]))
ans = 0
for i in reversed(range(41)):
    cou = 0
    now = ans + 2**i
    for j in b:
        if j & now >= now:
            cou += 1
    if cou >= k:
        ans += 2**i
print(ans)

Measured memory_bytes: 110532
N = int(input())
a = [0]+list(map(int, input().split())) # 1-indexed

b = [0]*(N+1)
for i in range(N,0,-1):
    if N//i == 1:
        b[i] = a[i]
    else:
        tmp = a[i]
        loop = N//i
        index = i*loop
        for j in range(loop):
            if j == loop-1: # end
                b[i] = tmp
            else:
                tmp = (tmp+b[index])%2
                index -= i
print(sum(b))
for i in range(1,N+1):
    if b[i] == 1:
        print(i, end=" ")

Measured memory_bytes: 65884
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   String A = sc.next();
   int B = A.length();
 
   StringBuilder ans = new StringBuilder();
   for(int i= 0;i<B;i+=2)
   {
     ans.append(A.substring(i,i+1));
   }
 
   System.out.println(ans.toString());
 }
}

Measured memory_bytes: 27612
import Control.Applicative
input = (read :: String -> Int) <$> getLine
toInt = (read :: String -> Int)
solve c n
  | length n > 1 = solve (c+1) $ show $ maximum [(toInt $ take d n)*(toInt $ drop d n) | d <- [1..(length n)-1]]
  | otherwise    = c

aaaa n = if n > 0 then (getLine >>= \x -> putStrLn $ show $ solve 0 x) >> aaaa (n-1) else do return ()
main = input >>= aaaa

Measured memory_bytes: 4088
#include <stdio.h>

int parent(int i) {
	return (i - 1) /4;
}

int childTab[256];

void initChildTab() {
	childTab['A'] = 1;
	childTab['C'] = 2;
	childTab['G'] = 3;
	childTab['T'] = 4;
}

inline int child(int i, int c) {
	return i*4 + childTab[c];
}

unsigned char H[2100000];

inline int index(int i) {
	return i / 8;
}

inline int offset(int i) {
	return i % 8;
}

void Set(int i) {
	int j = index(i);
	int off = offset(i);
	H[j] = H[j] | (1 << off);
}

int Get(int i) {
	int j = index(i);
	int off = offset(i);
	return H[j] & (1 << off);
}

int main(int argc, char **argv)
{
	int n, i, j, nd;
	char s[32];
	initChildTab();
	scanf("%d", &n);
	for (j = 0; j < n; j++) {
		scanf("%s", s);
		if (s[0] == 'i') {
			scanf("%s", s);
			nd = 0;
			for (i = 0; s[i] != '\0'; i++) {
				nd = child(nd, s[i]);
			}
			Set(nd);
		} else {
			scanf("%s", s);
			nd = 0;
			for (i = 0; s[i] != '\0'; i++) {
				nd = child(nd, s[i]);
			}
			if (Get(nd)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}


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

int main ()
{
    int n,m;
    cin >> n >> m;
    vector< pair<int,int> > v;
    for (int i=0;n>i;i++)
    {
        for (int j=0;m>j;j++)
        {
            char c;
            cin >> c;
            if (c == '#') v.push_back(make_pair(i,j));
        }
    }
    for (pair<int,int> p:v)
    {
        for (pair<int,int> q:v)
        {
            if (p.first < q.first && p.second > q.second)
            {
                puts("Impossible");
                return 0;
            }
        }
    }
    puts("Possible");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=1e6+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    umll mp;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(a,a+n);
    if(mp[1]==1){
        cout << 1 <<"\n";
        return;
    }
    if(mp[1]>=2){
        cout << 0 <<"\n";
        return;
    }
    ll ans=n;
    for(ll i=0;i<n;i++){
        ll x=a[i];
        if(mp[x]>=2){
            ans--;
            continue;
        }
    
        
        
        for(ll j=2;j<=sqrt(x);j++){
            if(x%j==0){
                ll f1=j;
                ll f2=x/j;
                if(mp[f1]>=1 || mp[f2]>=1){
                    ans--;
                    break;
                }
            }
        }
        
    }
    cout <<ans<<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 33188
<?php

	fscanf(STDIN, "%d", $input_k);
	fscanf(STDIN, "%s", $input_s);
	
	if (strlen($input_s) > $input_k) {
		echo (substr($input_s, 0, $input_k) . '...');
	} else {
		echo $input_s;
	}

?>


Measured memory_bytes: 16088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var a, b int

func main() {
	a = nextInt()
	b = nextInt()
	var answer, char string
	var time int
	if a < b {
		char = strconv.Itoa(a)
		time = b
	} else {
		char = strconv.Itoa(b)
		time = a
	}
	for i := 0; i < time; i++ {
		answer += char
	}
	fmt.Println(answer)
}

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
#define endl '\n'

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

void sanjeev(int kkkk)
{
    int n;
    cin>>n;
    vector<double>A;
    for(int i=0;i<n;i++)
    {
        double t;
        cin>>t;
        A.push_back(t);
    }

    vector<vector<double>>dp(n+1,vector<double>(n+1,0));
    dp[0][0]=1;

    for(int i=1;i<n+1;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-A[i-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j]*(1-A[i-1])+dp[i-1][j-1]*A[i-1];
            }
        }
    }

    // for(int i=0;i<dp.size();i++)
    // {
    //     for(int j=0;j<dp[0].size();j++)cout<<dp[i][j]<<" ";
    //         cout<<endl;
    // }
    double ans=0;
    for(int i=n;i>n/2;i--)ans+=dp[n][i];
        cout<<ans;
}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 70784
#include<stdio.h>
#include<string.h>
int main(void)
{
    int n,i,j;
    char s[10000],x[100] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    scanf("%d %s",&n,s);
    int p = strlen(s);
    for(i = 0 ; i < p ; i++)
    {
        for( j = 0 ; j < 100 ; j++)
        {
            if(s[i] == x[j])
            {
                
                s[i] = x[j + n];
                break;
            }
        }
    }
    printf("%s\n",s);
    return 0;
}

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



int main() {
	int n;
	scanf("%d",&n);
	
	int S_value[n]; //今更ながら要素数はnでもいいのでは？

	for(int i = 0; i < n; i++){
		scanf("%d",&S_value[i]);
	}
	
	int q;
	scanf("%d",&q);
	int counter = 0;
	
	for(int i = 0; i < q; i++){
		int val;
		scanf("%d",&val);
		
		int left = 0;
		int right = n;
		int mid;
		for(;left < right;){
			mid = (left + right) / 2;
			if(S_value[mid] > val){
				right = mid;
			}else if(S_value[mid] < val){
				left = mid + 1;
			}else{
				counter++;
				break;
			}
		}
	}
	
	
	printf("%d\n",counter);
	return 0;
}






Measured memory_bytes: 2068
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<VecDeque<_>>()
        }
    )
}

fn max_v(s:u32, e:u32, v: u32, t: f32) -> f32 {
    let s = s as f32;
    let e = e as f32;
    let v = v as f32;

    if t < s {
        v + (s-t) 
    } else if e < t {
        v + (t - e)
    } else {
        v
    }
}

use std::collections::VecDeque;

fn solve(mut ts: VecDeque<u32>, mut vs: VecDeque<u32>) -> f32 {
    let a = 0;

    ts.push_front(0);
    ts.push_back(0);
    vs.push_front(0);
    vs.push_back(0);

    let total_t: u32 = ts.iter().cloned().sum();
    let mut dist = 0.0;
    let mut last_v = 0.0;

    for t in 1..(total_t*2+1) {
        let t = t as f32 / 2.0;

        let mut min_v = std::f32::MAX;
        let mut acc_t = 0;
        for i in 0..vs.len() {
            let v = vs[i];
            let rt = ts[i];

            let mv = max_v(acc_t, acc_t + rt, v, t);
            if mv < min_v {
                min_v = mv;
            }
            acc_t += rt;
        }
        dist += 0.25*(last_v + min_v);
        last_v = min_v;
    }

    dist
}

fn main() {
    read_line!();

    let ts = parse_vec!(u32);
    let vs = parse_vec!(u32);

    println!("{}", solve(ts ,vs));
}

#[test]
fn solve_test() {
    assert!((solve(vec![100].into_iter().collect::<VecDeque<u32>>(),
                   vec![30].into_iter().collect::<VecDeque<u32>>()) - 2100.0).abs() < 10e-3);

    assert!((solve(vec![60,50].into_iter().collect::<VecDeque<u32>>(),
                   vec![34,38].into_iter().collect::<VecDeque<u32>>()) - 2632.0).abs() < 10e-3);

    assert!((solve(vec![12,14,2].into_iter().collect::<VecDeque<u32>>(),
                   vec![6,2,7].into_iter().collect::<VecDeque<u32>>()) - 76.0).abs() < 10e-3);

}


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

#define ABS(x) (((x)<0)?(-(x)):(x))

int main(void){
  char str[2][100001]={"",""};
  int num[2][100001][2]={{{0}}};
  int i,j,k,q,a[2],b[2],t,l;
  int snum[2];

  for(i=0;i<2;i++){
    scanf("%s%*c",str[i]);
    num[i][0][0]=(str[i][0]=='A');
    num[i][0][1]=(str[i][0]=='B');
    l=strlen(str[i]);
    for(j=1;j<l;j++){
      for(k=0;k<2;k++)
	num[i][j][k]=num[i][j-1][k]+(str[i][j]==('A'+k));
    }
  }
  scanf("%d",&t);
  while(t--){
    scanf("%d%d%d%d",&a[0],&b[0],&a[1],&b[1]);
    for(i=0;i<2;i++){
      a[i]--;
      b[i]--;
      snum[i]=(num[i][b[i]][0]-num[i][a[i]][0]+(str[i][a[i]]=='A'))-(num[i][b[i]][1]-num[i][a[i]][1]+(str[i][a[i]]=='B'));
      //printf("snum=%d,a=%d,b=%d\n",snum[i],num[i][b[i]][0]-num[i][a[i]][0]+(str[0][a[i]]=='A'),num[i][b[i]][1]-num[i][a[i]][1]+(str[0][a[i]]=='B'));
      if(snum[i]>=0) snum[i]%=3;
      else{
	snum[i]+=(ABS(snum[i])+3)/3*3;
	snum[i]%=3;
      }
    }
    puts(snum[0]==snum[1]?"YES":"NO");
  }
  return 0;
}
    


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

int main(){
  int a[3], b[3];
  int c[3][3];
  int sum = 0;
  for ( int i = 0; i < 3; i++){
    for ( int j = 0; j < 3; j++){
      cin >> c[i][j];
      sum += c[i][j];
    }
  }



  if ( 3 *(c[0][0] + c[1][1] + c[2][2] ) != sum ){
    cout << "No" << endl;

  } else if (  c[0][0] + c[1][1] + c[2][2] != c[0][2] + c[1][1] + c[2][0]){
    cout << "No" << endl;

  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= k; ++i) {
        cout << c(n-k+1, i) * c(k-1, i-1) << endl;
    }
}


Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set
const ll MOD = 1e9+7;
const int MAX = 1001001;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}
signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    COMinit();
    int n,m; cin >> n >> m;
    ll ans=(COM(m,n)*fac[n])%MOD;
    ll res=0;
    for(int i=1;i<=n;i++){
        ll cnt=(COM(n,i)*COM(m-i,n-i))%MOD;
        cnt=(cnt*fac[n-i])%MOD;
        if(i%2==1)res+=cnt;
        else res-=cnt;
        res=(res+MOD)%MOD;
    }
    ll res2=(ans-res+MOD)%MOD;
    ans=(ans*res2)%MOD;
    cout<<ans<<endl;
}


Measured memory_bytes: 27088
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int keisan(int n){
  int wa = 0;
  while(n>0){
    wa += n%10;
    n /=10;
  }
  return wa;
}

int main() {
  int n;
  cin >> n;
  int mi = 100000;
  for(int i=1;i<n;i++){
    int a = i;
    int b = n-a;
    int c = keisan(a);
    int d = keisan(b);
    mi = min(mi,c+d);
  }
  cout << mi << endl;
}

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

class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            } else {
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
    int n, q; cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++){
        int t, a, b; cin >> t >> a >> b;
        if(t == 0){
            ds.unite(a, b);
        } else {
            if(ds.same(a, b))cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}


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

using namespace std;

int n, m;
const int maxn = 1e5 + 100;
struct node
{
    int a, b;
    bool operator<(const node &S) const
    {
        if(a == S.a)
            return b < S.b;
        return a < S.a;
    }
} e[maxn];

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i ++)
        cin >> e[i].a >> e[i].b;
    sort(e, e + m);
    int st = e[0].a;
    int en = e[0].b;
    int ans = 0;
    for(int i = 1; i < m; i ++)
    {
        if (en <= e[i].a)
        {
            ans ++;
            st = e[i].a;
            en = e[i].b;
        }
        else
        {
            st = e[i].a;
            if(en > e[i].b)
                en = e[i].b;
        }

    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    vector<ll> num(k,0);
    for(int i=1;i<=n;i++) num[i%k]++;
    ll res=0;
    for(int a=0;a<k;a++){
        int b=(k-a)%k;
        int c=(k-a)%k;
        if((b+c)%k!=0) continue;
        res+=num[a]*num[b]*num[c];
    }

    cout<<res<<endl;

}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		String s = Integer.toString(in.readInt());
		if(s.contains("9"))System.out.println("Yes");
		else System.out.println("No");
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)

typedef long long ll;
using namespace std;

int main() {
    
    int n, ans = 0;
    cin >> n;
    while (n) {
        if (n % 10 == 2) ans++;
        n /= 10;
    }
    cout << ans << endl;
    
}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}

	int res = 0;
	bool sat = false;
	while (!sat) {
		sat = true;
		int ind = 0;
		while (ind < N) {
			if (h[ind] > 0) {
				sat = false;
				int s = ind;
				int t = N;
				int water = h[ind];
				bool zero = false;
				for (int i = ind+1; !zero && i < N; ++i) {
					if (h[i] == 0) {
						t = i;
						zero = true;
					}
					else {
						water = min(water,h[i]);
						++ind;
					}
				}
				for (int i = s; i < t; ++i) {
					h[i] -= water;
				}
				res += water;
			}
			++ind;
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<string, pair<int, int>>PP;
typedef long long ll;

int main() {
	int n, C, d[31][31], c;
	int t[3][30];
	int ans = 1<<30;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 30; j++) {
			t[i][j] = 0;
		}
	}
	cin >> n >> C;
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> c;
			t[(i + j) % 3][c - 1]++;
		}
	}
	for (int i = 0; i < C; i++) {
		for (int j = 0; j < C; j++) {
			for (int k = 0; k < C; k++) {
				if ((i != j && j != k) && k != i) {
					int res = 0;
					for (int m = 0; m < C; m++) {
						res += t[0][m] * d[m][i] + t[1][m] * d[m][j] + t[2][m] * d[m][k];
					}
					ans = min(ans, res);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e9 + 5;
const long double PI = 3.141592653589793;

void solve(){
  string s, t;
  cin >> s >> t;
  int n = s.length(), ans = 0;
  for(int i = 0; i<n; i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	string s;
	
	int m = 0, d;
	
	cin>>s;
	
	m = (s[5]-'0')*10 + s[6]-'0';
	d = (s[8]-'0')*10 + s[9]-'0';
	
	if(m <= 4)cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  long long sum = 0;
  long long maxi = 0;
  for (int i = 0; i < n; ++i) {
    long long a;
    cin >> a;
    sum += maxi-a>0 ? maxi-a : 0;
    maxi = max(maxi,a);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
//#define ll long long
//#define INF LONG_MAX
//#define int long long
using namespace std;

int main() {

  int h, w;
  cin >> h >> w;
  char s[h][w];
  int ans[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }
  int num = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
	ans[i][j] = 10;
      } else {
	num = 0;
	for (int y = i-1; y <= i+1; y++) {
	  for (int x = j-1; x <= j+1; x++) {
	    if(x < 0 || y < 0 || x >= w || y >= h || (y == i && x == j)) {
	      continue;
	    }
	    if (s[y][x] == '#') num++;
	  }
	}
	ans[i][j] = num;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(ans[i][j] == 10) cout << "#";
      else cout << ans[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# agc040/agc040_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    sum_r = 0
    ls_max = 0
    i = 0
    while i < len(S):
        if S[i] == '<':
            next_lg = S.find('>', i + 1)
            if next_lg == -1:
                next_lg = len(S)
            ls_len = next_lg - i
            ls_max = ls_len - 1
            sum_r += ls_len * (ls_len - 1) / 2
            i = next_lg
        else:
            next_ls = S.find('<', i + 1)
            if next_ls == -1:
                next_ls = len(S)
            lg_len = next_ls - i
            lg_max = lg_len
            sum_r += lg_len * (lg_len + 1) / 2
            if ls_max >= lg_max:
                sum_r += ls_max + 1 - lg_max
            i = next_ls
    if S[-1] == '<':
        sum_r += ls_max + 1
    print(int(sum_r))
    return

main()


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  char a, ans;
  cin >> a;
  if(0<=a-'a' && a-'a'<=26) ans = 'a';
  else ans = 'A';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	
	int n;
	ll k;

	cin >> n >> k;

	vector<vector<int>> g(n + 1, vector<int>(62, -1));

	for(int i = 1; i <= n; i++)
		cin >> g[i][0];

	for(int k = 1; k < 62; k++)
		for(int i = 1; i <= n; i++)
			g[i][k] = g[g[i][k - 1]][k - 1];

	int u = 1;
	for(int i = 0; i < 62; i++)
		if(k & (1ll << i))
			u = g[u][i];
		

	cout << u << endl;

	return 0;	
}

Measured memory_bytes: 57780