akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] captoi = new int[26];
    for (int i = 0; i < 26; i++) captoi[i] = -1;
    int id = 0;
    for (char c : new char[] {'M', 'A', 'R', 'C', 'H'}) captoi[c - 'A'] = id++;
    long[] capCount = new long[5];
    for (int i = 0; i < N; i++) {
      int c = scanner.next().charAt(0) - 'A';
      if (captoi[c] >= 0) capCount[captoi[c]]++;
    }

    long count = 0;
    for (int i = 0; i < 3; i++) {
      for (int j = i + 1; j < 4; j++) {
        for (int k = j + 1; k < 5; k++) {
          count += capCount[i] * capCount[j] * capCount[k];
        }
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 46316
N,H=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
B=[]
C=[]
for a,b in A:
  B.append(a)
  C.append(b)
D=sorted(B)[::-1]
b=D[0]
F=[]
for i in C:
  if b<i:
    F.append(i)
G=sorted(F)[::-1]
cnt=0
for i in G:
  H-=i
  cnt+=1
  if H<=0:
    print(cnt)
    exit()
print(cnt-((-H)//b))

Measured memory_bytes: 31940
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int arr[n-1];
	for(int x=0;x<n-1;x++)
	{
		cin>>arr[x];
	}
	int sum=arr[0];
	for(int x=0;x<n-2;x++)
	{
		sum += min(arr[x],arr[x+1]);
	}
	sum+=arr[n-2];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
N,K=list(map(int,input().strip().split(' ')))

prob=0
for i in range(1,N+1):
    if i>=K:
        prob+=(N-K+1)/N
        break
    power=0
    for j in range(20):
        if i*(2**j)>=K:
            power=j
            break
    prob+=(1/N)*(1/2)**power

print(prob)







Measured memory_bytes: 3060
n = input()
n = int(n)

if n < 10:
    k = n

if 10 <= n < 100:
    k = 9

if 100 <= n < 1000:
    k = n -90

if 1000 <= n < 10000:
    k = 909

if 10000 <= n < 100000:
    k = n - 9090

if n == 100000:
    k = n - 9091

print(k)


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

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

int main() {
    int n,m; cin >> n >> m;
    cout << ( ((n - m) * 100) + (1900 * m) ) * pow(2,m);
}

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

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			ans = -1;
			flag = 0;
			t = sc.nextInt();
			int num = sc.nextInt();
			if(t == 0 && num == 0)break;
			else calc(t, Integer.toString(num));
			
		}
	}
	
	int t = 0;
	ArrayList<Integer> anslist;
	int ans = -1;
	int flag = 0;
	public void calc(int t, String num){
		for(int i = 0; i < num.length(); i++){
			calc2(num, i, 0, new ArrayList<Integer>());
		}
		if(ans == -1) System.out.println("error");
		else if(flag == 1) System.out.println("rejected");
		else {
			System.out.print(ans);
			int k = 0;
			for(int i = 0; i < anslist.size(); i++){
				System.out.print(" " + num.substring(k, k + anslist.get(i)));
				k = k + anslist.get(i);
			}
			System.out.println();
		}
	}
	
	public void calc2(String num, int i, int sum, ArrayList<Integer> list){
		if(i == 0){
			sum += Integer.parseInt(num);
			list.add(num.length());
			if(sum <= t && sum > ans) {
				ans = sum;
				anslist = list;
				flag = 0;
			}
			else if(sum == ans) flag = 1;
		}
		else{
			for(int k = 1; k < num.length() - i + 1; k++){
				ArrayList<Integer> l = new ArrayList<Integer>();
				for(int t = 0; t < list.size(); t++){
					l.add(t, list.get(t));
				}
				l.add(k);
				String next = num.substring(k);
				
				calc2(num.substring(k), i - 1, sum + Integer.parseInt(num.substring(0, k)), l);
				
			}
		}
	}

	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21056
sa=list(input())
sb=list(input())
sc=list(input())
sa.reverse()
sb.reverse()
sc.reverse()
fst='a'
while True:
  if fst=='a':
    if len(sa)==0:
      print('A')
      break
    else:
      fst=sa.pop()
  if fst=='b':
    if len(sb)==0:
      print('B')
      break
    else:
      fst=sb.pop()
  if fst=='c':
    if len(sc)==0:
      print('C')
      break
    else:
      fst=sc.pop()


Measured memory_bytes: 3064
n = int(input())
s = input()

def getChar(char, num):
    if num > 25:
        num %= 26

    if num + ord(char) > 90:
        num -= 26

    return chr(ord(char) + num)

result =""
for i in s:
    result += getChar(i, n)

print(result)

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

int n, k;
int h[100005];
int dp[100005];


int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 1; i < n; i++) {
		dp[i] = 1e9;
		for (int j = 1; j <= k; j++) {
			if (i - j < 0)
				break;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n - 1] << '\n';
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double ld;
typedef pair<int,int> pii;
#define ui(n) ((unsigned int)(n))
#define ll(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define ld(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)
const int INF=1e9+7;
const ll LINF=1e18;
#define PI 3.1415926535897932384626433832795028841971
#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define mod 1000000007
#define sz(a) ((int)(a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,n,step) for(int i=a;i<n;i+=step)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define sqr(x) ((x)*(x))
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define file(filename,name) fstream name(filename,ios::in|ios::out)
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define PC(x) putchar(x)
#define GC(x) x=getchar()
#define Endl PC('\n')

inline int READ()
{
    int X=0,w=0;char ch=0;while(!isdigit(ch)){w|=ch=='-';ch=getchar();}while(isdigit(ch))X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w?-X:X;
}
inline void WRITE(int x){if(x<0)putchar('-'),x=-x;if(x>9)WRITE(x/10);putchar(x%10+'0');}
inline void WRITEend(int x){WRITE(x);exit(0);}

inline ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll gcdll(ll a,ll b){return b?gcdll(b,a%b):a;}
inline string itoa(ll a){string res="";while(a>0)res+=(a%10+'0'),a/=10;reverse(All(res));return res==""?"0":res;}
inline ll atoi(string s){ll res=0;repV(i,s)res=res*10+i-'0';return res;}
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={1,0,-1,0,-1,-1,1,1};

/*************************************************************Begin****************************************************************/
int n,m,p[100005],cnt,vis[100005],ans;
vector<int> g[100005];
void dfs(int x)
{
	vis[x]=cnt;
	rep(i,g[x].size())
		if(!vis[g[x][i]])
			dfs(g[x][i]);
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,n)
    {
    	cin>>p[i];
    	p[i]--;
	}
	rep(i,m)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i,n)
		if(!vis[i])
		{
			cnt++;
			dfs(i);
		}
	rep(i,n)
	{
		if(vis[i]==vis[p[i]])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}
/**************************************************************End*****************************************************************/

Measured memory_bytes: 8576
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = 0
    for i in range(5):
        isAdd = i % 2 == 0
        if n < 10 ** (i+1):
            if isAdd:
                ans += n - 10 ** i + 1
            break
        elif isAdd:
            ans += 10 ** (i+1) - 10 ** i
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll cnt[1001]={0};

// 素因数分解する
void div_prime(ll n){
    // 割る数の初期値
    ll a = 2;

    // √n>=aの間ループ
    while(n >= a * a){
        if(n % a == 0){
            cnt[a]++;
            n /= a;
        }
        else{
            a++;
        }
    }

    // 最後に残ったnは素因数
    cnt[n]++;
}

int main(void)
{
    ll N, i, ans=1;

    cin >> N;

    if(N==1) cout << 1 << endl;

    else{
        for(i=2; i<=N; i++){
            div_prime(i);
        }

        for(i=1; i<=N; i++){
            ans *= (cnt[i]+1);
            ans %= div1;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N; cin >> N;
	vector<long> prime;

	vector<bool> isprime(100, true);
	isprime[1] = false;
	for (int i = 2; i < 100; i++) {
		if (isprime[i]) for (int j = 2; i * j < 100; j++) isprime[i * j] = false;
	}

	for (int i = 2; i < 100; i++) if (isprime[i]) prime.push_back(i);

	//N!に含まれる素因数のべき数
	vector<long> Npow(100, 0);

	for (int i = 1; i <= N; i++) {
		long p = i;
		for (long e : prime) while (p % e == 0) { Npow[e]++; p /= e; }
	}

	long res = 0;

	for (auto p1 : prime) if (Npow[p1] >= 74) res++;

	for (auto p1 : prime) {
		for (auto p2 : prime) {
			if (p1 != p2) {
				if (Npow[p1] >= 2 && Npow[p2] >= 24) res++;
			}
		}
	}

	for (auto p1 : prime) {
		for (auto p2 : prime) {
			if (p1 != p2) {
				if (Npow[p1] >= 4 && Npow[p2] >= 14) res++;
			}
		}
	}

	for (auto p1 : prime) {
		for (auto p2 : prime) {
			for (auto p3 : prime) {
				if (p1 != p2 && p2 != p3 && p3 != p1) {
					if (Npow[p1] >= 2 && Npow[p2] >= 4 && Npow[p3] >= 4 && p2 > p3) res++;
				}
			}
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define _ ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
using namespace std;

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

Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int k;
vector<long long int> a;
long long int mi, ma;

void solve(){
	if(a[0] != 2){
		printf("%d\n", -1);
		return;
	}
	mi = 2;
	ma = 3;
	for(int i=1; i<k; ++i){
		if(ma / a[i] == 0){
			printf("%d\n", -1);
			return;
		}
		mi = a[i] * ((mi - 1) / a[i] + 1);
		ma = a[i] * (ma / a[i] + 1) - 1;
//		printf("%d %d %d\n", i, mi, ma);
	}
	if(mi > ma){
		printf("%d\n", -1);
		return;
	}
	printf("%lld %lld\n", mi, ma);
	return;
}

int main(){
	scanf("%d", &k);
	for(int i=0; i<k; ++i){
		long long int t;
		scanf("%lld", &t);
		a.push_back(t);
	}
	reverse(a.begin(), a.end());
	solve();
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc079/tasks/abc079_c

string abcd;
string ops;

bool dfs(int sum, string current) {
    if (current.length() == 3) {
        ops = current;
        return sum == 7;
    }

    if (dfs(sum + (abcd[current.length() + 1] - '0'), current+"+")) return true;

    if (dfs(sum - (abcd[current.length() + 1] - '0'), current+"-")) return true;

    return false;
}

int main() {
    cin >> abcd;

    if (dfs(abcd[0] - '0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", abcd[0], ops[0], abcd[1], ops[1], abcd[2], ops[2], abcd[3]);
    } else {
        cout << "NO" << "\n";
    }


    return 0;
}


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

int main(){
  int N;
  int t[110000],x[110000],y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for(int i = 0;i < N;i++){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  bool can = true;
  for(int i = 0;i < N;i++){
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1] -y[i]);
    if(dt < dist) can = false;
    if(dist %2 != dt %2) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 4752
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))

a = K + A[0]
A = A + [a]

#print(A)

B = []
for i in range(N):
    B.append(A[i+1] - A[i])
B = sorted(B,reverse = False)

print(sum(B) - max(B))

Measured memory_bytes: 26444
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

string S;

vector<char> C;
vector<int> V;

int main () {
  cin >> S;
  int cnt = 0;
  C.push_back('X');
  for (auto i = 0; i < (int)S.size(); ++i) {
    if (S[i] == 'x') {
      cnt++;
    } else {
      V.push_back(cnt);
      cnt = 0;
      C.push_back(S[i]);
    }
  }
  C.push_back('X');
  if ((int)C.size() - 1 > (int) V.size()) {
    V.push_back(cnt);
  }
  for (auto x : V) {
    cerr << x << " ";
  }
  cerr << endl;
  for (auto x : C) {
    cerr << x << " ";
  }
  cerr << endl;
  int left = 0;
  int right = C.size() - 1;
  int ans = 0;
  while (left < right) {
    if (C[left] == C[right]) {
      ans += abs(V[left] - V[right-1]);
      left++;
      right--;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)

const int N = 103, W = 1e5 + 5;
long long n, k, a[N][2], dp[N][W];
bool solved[N][W];

long long calc(int i, int w)
{
    if (solved[i][w])
    {
        return dp[i][w];
    }

    if (i == n)
    {
        return 0;
    }

    dp[i][w] = 0;
    if (w + a[i][0] <= k)
        dp[i][w] = max(dp[i][w], a[i][1] + calc(i + 1, w + a[i][0]));
    dp[i][w] = max(dp[i][w], calc(i + 1, w));

    solved[i][w] = 1;
    return dp[i][w];
}

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

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

    cout << calc(0, 0);
}


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

int main()
{
    bool a =false;
    bool b = false;
    bool c = false;
    bool d = false;
    
    for(int i=0; i<4; i++){
        int x;
        cin >> x;
        if(x == 1) a = true;
        if(x == 9) b = true;
        if(x == 7) c = true;
        if(x == 4) d = true;
    }
        if(a && b && c && d)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[])
{
    string s, t;

    cin >> s;
    cin >> t;

    int counter = 0;

    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i])
            counter ++;
    }
    std::cout << counter;

    return 0;
}

Measured memory_bytes: 3828
from collections import defaultdict


def main():

    def is_in(a, b):
        return (a, b) in nums_points

    flag = 0
    mat = [
        list(map(int, input().split())),
        list(map(int, input().split())),
        list(map(int, input().split()))
    ]

    n = int(input())
    nums = [int(input()) for i in range(n)]

    combs = defaultdict(int)
    for i in range(3):
        for j in range(3):
            combs[mat[i][j]] = (i, j)

    nums_points = []
    for n in nums:
        nums_points.append(combs[n])

    if is_in(0, 0) and is_in(0, 1) and is_in(0, 2):
        flag += 1
    if is_in(1, 0) and is_in(1, 1) and is_in(1, 2):
        flag += 1
    if is_in(2, 0) and is_in(2, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 0) and is_in(2, 0):
        flag += 1
    if is_in(0, 1) and is_in(1, 1) and is_in(2, 1):
        flag += 1
    if is_in(0, 2) and is_in(1, 2) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 2) and is_in(1, 1) and is_in(2, 0):
        flag += 1

    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3436
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

x = NextInt()
ans = 0
now = 100
while(now < x):
    ans+= 1
    now = int(now*1.01)
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, k;
ll br[100001];
ll odg, todg;
int main() {
	cin >> n >> k;
	vector<ll> zbr(n);
	vector<ll> zbrp(n);
	cin >> br[0];
	if(br[0] >= 0) {
		zbrp[0] = br[0];
	}
	zbr[0] = br[0];
	for(int i = 1; i < n; i++) {
		cin >> br[i];
		zbr[i] = zbr[i - 1] + br[i];
		if(br[i] >= 0) {
			zbrp[i] = zbrp[i - 1] + br[i];
		} else {
			zbrp[i] = zbrp[i - 1];
		}
	}
	odg = zbrp[zbrp.size() - 1] - zbrp[k - 1];
	odg += zbr[k - 1];
	for(int i = 1; i < n - k + 1; i++) {
		todg = 0;
		todg = zbrp[zbrp.size() - 1] - zbrp[k - 1 + i];
		todg += zbrp[i - 1];
		if(zbr[k + i - 1] - zbr[i - 1] >= 0) {
			todg += zbr[k + i - 1] - zbr[i - 1];
		}
		//cout << todg << " ";
		odg = max(odg, todg);
	}
	if(odg < 0) {
		odg = 0;
	}
	cout << odg;
}


Measured memory_bytes: 2560
str =input()
q = int(input())

for i in range(q):
    order = input().split()
    if order[0] == "print":
        print(str[int(order[1]):int(order[2])+1])
    elif order[0] == "reverse":
        str = list(str)
        str[int(order[1]):int(order[2])+1] = reversed(str[int(order[1]):int(order[2])+1])
        str = "".join(str)
    elif order[0] == "replace":
        str = list(str)
        str[int(order[1]):int(order[2])+1] = list(order[3])
        str = "".join(str)


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define Ll long long
using namespace std;
const int N=2e5+5;
int a[N];
int n,m,ans,x,y;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i;i--)
		if(a[i]==m){
			if(x){cout<<(Ll)((Ll)x*(Ll)m);exit(0);}
			x=m;m=0;
		}else m=a[i];
	cout<<0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <list>
#include <iomanip>
#include <numeric>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ll;

static const ll mod = 1'000'000'007;

// const char m[4] = { 'T', 'A', 'G', 'C' };


int main(int, char**)
{
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	a = min(a, b);
	a = min(a, c);
	a = min(a, d);
	a = min(a, e);

	ll x = n / a;
	if (n % a > 0) x++;
	x += 4;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b, c) for (int i = (a); i <= (b); i += (c))
#define FORD(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define FORl(i, a, b, c) for (ll i = (a); i <= (b); i += (c))
#define FORDl(i, a, b, c) for (ll i = (a); i >= (b); i -= (c))
using namespace std;
int main () {
	ios::sync_with_stdio(false); cin.tie(0);
	string S;
	cin >> S;
	int n = S.length();
	if (S[0] == '0' || S[n - 1] == '1') {
		printf("-1\n");
		return 0;
	}
	S = '?' + S;
	FOR(i, 1, n - 1, 1) {
		if ((S[i] - '0') ^ (S[n - i] - '0')) {
			printf("-1\n");
			return 0;
		}
	}
	int f = 0;
	FOR(i, 1, n, 1) {
		if (S[i] == '0') break;
		f++;
	}
	int it = 1;
	int now = 1;
	vector<pii> elist;
	FOR(i, 1, f, 1) {
		elist.pb({now, ++it});
		now = it;
	}
	int last = f;
	FOR(i, f + 1, n, 1) {
		if (S[i] == '0') continue;
		int dif = i - last - 1;
		while (dif) {
			int u = now;
			FOR(j, 1, min(f, dif), 1) {
				int v = ++it;
				elist.pb({u, v});
				u = v;
			}
			dif = max(dif - f, 0);
		}
		elist.pb({now, ++it});
		now = it;
		last = i;
	}
	for (auto e : elist) {
		printf("%d %d\n", e.fi, e.se);
	}
	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(void){
	
	int N,A[100],i;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
	scanf("%d",&A[i]);
	}
	int max=A[0],min=A[0];
	
	
	for(i=0;i<N;i++){
		
		if(max<A[i]){
			max=A[i];
		}
		
		if(min>A[i]){
			min=A[i];
		}
	}
	
	printf("\n%d\n\n",max-min);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int N, M;
int P[100005], Y[100005];
vector<int> yd[100005];
int main()
{
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }
  for (int i = 0; i < N; i++)
    sort(yd[i + 1].begin(), yd[i + 1].end());
  for (int i = 0; i < M; i++)
  {
    printf("%06d", P[i]);
    printf("%06d\n", lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
  }

  return 0;
}


Measured memory_bytes: 7808
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	long long  x, y, ans = 1ll << 60;
	cin >> x >> y;
	if (x <= y)
		ans = min(ans, y - x);
	if ((-1) * x <= y)
		ans = min(ans, y + x + 1);
	if (x <= (-1) * y)
		ans = min(ans, (-1) * y - x + 1);
	if (x >= y)
		ans = min(ans, (-1) * y + x + 2);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     string s,t;
     cin >> s >> t;
     bool ans = false;
     int x = stoi(s + t);
     for(int i = 1; i < 1000; i++){
          if(i*i == x) ans = true;
     }
     if(ans) cout << "Yes" << endl;
     else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll n,m;
  cin >> n >> m;
  if(n == 1 || m == 1){
    if(n == m){
      cout << 1 << endl;
      return 0;
    }
    cout << n * m - 2 << endl;
    return 0;
  }
  n -= 2; m -= 2;
  cout << n * m << endl;
}

Measured memory_bytes: 384
using System;

namespace ALDS1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = new int[n];

            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < n-1; i++)
            {
                A[i] = int.Parse(input[i]);
                Console.Write(A[i] + " ");
            }
            A[n - 1] = int.Parse(input[n - 1]);
            Console.WriteLine(A[n-1]);

            for (int i = 1; i < n; i++)
            {
                int v = A[i];
                int j = i - 1;
                while(j >= 0 && A[j] > v)
                {
                    A[j + 1] = A[j];
                    j--;
                    A[j + 1] = v;
                }
                
                for (int p = 0; p < n-1; p++)
                {
                    Console.Write(A[p] + " ");
                }
                Console.WriteLine(A[n - 1]);
            }
        }
    }
}

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

int main()
{
    long long int n,m,j,k,l,i;
    while(scanf("%lld%lld",&n,&m)==2)
    {
        k=0;
        j=n+m;
        for(i=j;i>=1;i/=10)
            k++;
            printf("%lld\n",k);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

ll func(){
  ll k = in();
  ll n = in();
  vector<ll> line(n);
  foreach(i,line)i=in();
  ll ans = 0;
  rep(i,n-1){
    chmax(ans,line[i+1]-line[i]);
  }
  chmax(ans,line[0]+k-line.back());
  return k-ans;
}

int main(){
  cout <<func() << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    int n;
    long long mod = 1000000007;
    cin >> n;
    long long a = 1, b = 1, c = 1;
    for (int i = 0; i < n; i++)
    {
        a = a*10%mod;
        b = b*9%mod;
        c = c*8%mod;
    }
    cout << (a-2*b+c+2*mod)%mod << endl;
}

Measured memory_bytes: 3576
a, b, c = map(int, input().split())

if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= b <= a:
    print(c, b, a)
elif c <= a <= b:
    print(c, a, b)


Measured memory_bytes: 5592
import bisect

n = int(input())
a,b,c = [list(sorted(map(int, input().split())))  for _ in range(3)]

ans = 0
for i in b:
    x = bisect.bisect_left(a, i)
    y = len(c) - bisect.bisect_right(c, i)
    ans += x*y

print(ans)

Measured memory_bytes: 23244
//03/05/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;


int main(){
    _fastio
    ll n;
    cin>>n;
    ll a[n+10];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        ump[i+a[i]]++;
    }

    ll ans=0;
    for(ll i=n;i>=1;i--){
        ump[i+a[i]]--;
        ans+=ump[i-a[i]];
    }
    cout<<ans<<en;




    return 0;
}


Measured memory_bytes: 20040
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b)     for(ll i=a;i<b;i++)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
#define mod            1000000007
#define N              1e5+1

ld dis(ll x1,ll x2,ll y1,ll y2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

ll get(ll n)
{
	ll tt=1;
	
	while(n>0)
	{
		tt=tt*n;
		n--;
	}
	
	return tt;
}
 
void solve()
{
	ll n;
	
	cin>>n;
	
	vector<pll> tt(n+1);
	
	for(int i=1;i<=n;i++)
	{
		cin>>tt[i].f>>tt[i].s;
	}
	
	ld a[n+1][n+1] {};
	
	ld ans=0;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			a[i][j]=dis(tt[i].f,tt[j].f,tt[i].s,tt[j].s);
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans+=2*get((n-1))*a[i][j];
		}
	}
	
	ll pp=get(n);

	cout<<fixed<<setprecision(10)<<(ans/(ld)pp);
}
 
signed main(){
 
    fast;
 
    ll t=1;
 
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
ll n,m,k,ans;
string s,t;
const ll powll = 1LL<<1;

bool cmp(P a, P b){
  if(a.first != b.first) return a.first < b.first;
  else return a.second > b.second;
}

int main(){
  string s; cin >> s;
  int q; cin >> q;
  string ini = "",end = "";
  int chan = 0;
  rep(i,q){
    int x; cin >> x;
    if(x == 1){
      if(chan) chan = 0;
      else chan = 1;
      
    }else{
      int f; cin >> f;
      char c; cin >> c;
      if(f == 1){
        if(chan) end += c;
        else ini = c + ini;
      }else{
        if(chan) ini = c + ini;
        else end += c;
      }
    }
  }
  s = ini + s + end;
  if(chan){
    rep(i,s.size()) cout << s[s.size()-1-i];
    cout << "\n";
  }else cout << s << "\n";
}

Measured memory_bytes: 1360
h, w = map(int, input().split())
f = [list(input()) for i in range(h)]

dp = [[0] * w for i in range(h)]
# 下の2つのfor で初期化をしている。ここで # が出たらそれ以降はいけないことに注意。(break)
for i in range(h):
    if f[i][0] != "#":
        dp[i][0] = 1
    else:
        break

for i in range(w):
    if f[0][i] != "#":
        dp[0][i] = 1
    else:
        break

for x in range(1, h):
    for y in range(1, w):
        if f[x][y] == ".":
            dp[x][y] = dp[x-1][y]+dp[x][y-1]

print(dp[h-1][w-1] % (10**9+7))

Measured memory_bytes: 165332
mod = 10**9+7 
n, a, b = map(int, input().split())
whole = pow(2, n, mod)-1 # 2^n-1(mod p)を計算。
# nCaの計算
comb1=1
for i in range(n-a+1,n+1): # n*(n-1)*(n-2)*...*(n-a+1)(mod p)を計算
  comb1 *= i
  comb1 %= mod
for i in range(1,a+1): # 1/a!(mod p)を計算 フェルマーの小定理:1/a = a^p-2(mod p)を利用
  comb1 *= pow(i,mod-2,mod)
  comb1 %= mod
comb2=1
for i in range(n-b+1,n+1): # n*(n-1)*(n-2)*...*(n-b+1)(mod p)を計算
  comb2 *= i
  comb2 %= mod
for i in range(1,b+1):
  comb2 *= pow(i,mod-2,mod)
  comb2 %= mod
whole -= (comb1+comb2)
whole %= mod
print(whole)

Measured memory_bytes: 41516
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const N = input[0]
  const d = input[1].split(' ').map(n => Number(n)).sort((a, b) => a - b)
  const tmp = d.length / 2

  if (d[tmp] == d[tmp - 1]) {
    console.log(0)
  } else {
    console.log(d[tmp] - d[tmp - 1])
  }
}

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


Measured memory_bytes: 28360
s = list(input())
#sが回文であるかを判定する
front =[]
rear =[]
mid = int(len(s)/2)
ans = 0
#sの文字列の長さが偶数だった場合
if(len(s)%2 == 0):
    for i in range(len(s)//2):
        a = s.pop(0)
        front.append(a)
    rear = s
    for i in range(len(front)):
        if(front[i] != rear[len(rear)-1-i]):
            ans += 1
#sの文字列の長さが奇数の場合
else:
    dead = s.pop(mid)
    for i in range(len(s)//2):
        a = s.pop(0)
        front.append(a)
    rear = s
    for i in range(len(front)):
        if(front[i] != rear[len(rear)-1-i]):
            ans += 1
print(ans)
 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    vector<string> v;
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        v.pb(s);
    }
    ll r=pow(2,h)-1;
    ll c=pow(2,w)-1;
    ll ans=0;
    for(int ir=0;ir<=r;ir++){
        for(int ic=0;ic<=c;ic++){
            ll lc=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((1<<i)&(ir))continue;
                    if((1<<j)&ic)continue;
                    else if(v[i][j]=='#')lc++;
                }
            }
            if(lc==k)ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std;
using i64 = uint_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    i64 N, ans = 1;
    cin >> N;
    const i64 M = 1e18;

    bool z = false;
    rep(i, N) {
        i64 a;
        cin >> a;
        ans *= a;
        if(a == 0) z = true;
        if(ans > M) ans = 0;
    }

    if(z) cout << 0 << endl;
    else if(ans == 0) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    cin >> n;
    vector<ll>l(n+1);
    l[0] =2; l[1] =1;
    
    for(int i=2; i<=n; i++){
        l[i] = l[i-2] + l[i-1];
    }
    cout << l[n] << endl;
}

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

int main(){
  int a, b;
  cin>> a >> b;
  if ((a+b)%2==0){
    cout << (a+b)/2 <<endl;
  }
  if ((a+b)%2==1){
    cout << (a+b)/2+1 <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	string s;
	string t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < s.length(); i++){
		if (s[i] != t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3836
H, W = map(int, input().split())
A = [input() for _ in range(H)]

h_check = [0] * H
w_check = [0] * W

for i in range(H):
  flag = 0
  for j in range(W):
    if A[i][j] != ".":
      flag = 1
      break
  h_check[i] = flag

for j in range(W):
  flag = 0
  for i in range(H):
    if A[i][j] != ".":
      flag = 1
      break
  w_check[j] = flag

for i in range(H):
  if h_check[i]:
    tmp = ""
    for j in range(W):
      if w_check[j]:
        tmp += A[i][j]
    print(tmp)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b; cin>>a>>b;
  int q; cin>>q;
  vector<ll> s, t;
  s.push_back(-1*INF); t.push_back(-1*INF);
  rep(i,a) {ll d; cin>>d; s.push_back(d);}
  rep(i,b) {ll d; cin>>d; t.push_back(d);}
  s.push_back(INF); t.push_back(INF);

  vector<ll> ans;
  rep(i,q) {
    ll x; cin>>x;
    ll sl = abs(s[lower_bound(s.begin(),s.end(),x)-s.begin()-1]-x);
    ll sr = abs(s[lower_bound(s.begin(),s.end(),x)-s.begin()]-x);
    ll tl = abs(t[lower_bound(t.begin(),t.end(),x)-t.begin()-1]-x);
    ll tr = abs(t[lower_bound(t.begin(),t.end(),x)-t.begin()]-x);
    ll tmp = min(max(sl,tl), max(sr,tr));
    tmp = min(tmp, 2*sl+tr);
    tmp = min(tmp, 2*sr+tl);
    tmp = min(tmp, 2*tl+sr);
    tmp = min(tmp, 2*tr+sl);
    ans.push_back(tmp);
  }
  rep(i,q) {
    cout << ans[i] << endl;
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3828
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll mod = 1e9 + 7;
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, e, prod = 1, neg = 1;
    cin >> n >> k;
    e = n - 1;
    ll a[n], i;
    for(i = 0; i < n; i++) {
    	cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);
    vector<ll> ans;
    i = 0;
    if(k & 1) {
    	if(a[0] < 0) {
    		ans.pb(a[0]);
    		i = 1;
    		neg = -1;
    	} else {
	    	ans.pb(a[0]);
	    	i = 1;
    	}
    }
    while(ans.size() < k) {
    	if(neg * a[i] * a[i + 1] < neg * a[e] * a[e - 1]) {
    		ans.pb(a[e]), ans.pb(a[e-1]);
    		e -= 2;
    	} else {
    		ans.pb(a[i]), ans.pb(a[i+1]);
    		i += 2;
    	}
    }
    for(i = 0; i < k; i++) {
    	prod = (prod * ans[i]) % mod;
    	if(prod < 0) {
    		prod += mod;
    	}
    }
    cout << prod << '\n';
}

Measured memory_bytes: 6856
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int H,W;
pint tozahyo(pint yx){
	int nowy=yx.first;
	int nowx=yx.second;
	if(nowy%2==0){
		if(nowx==W-1){
			return mp(nowy+1,nowx);
		}
		else{
			return mp(nowy,nowx+1);
		}
	}
	else{
		if(nowx==0){
			return mp(nowy+1,nowx);
		}
		else{
			return mp(nowy,nowx-1);
		}
	}
}
int main(){
	int a[501][501];
	int ruisekiwa[501][501]={0};
	int oddnum=0;
	vpint oddyx;
	scan(H);scan(W);
	rep(i,H){
		rep(j,W){
			scan(a[i][j]);
			if(a[i][j]%2==1){
				oddnum++;
				oddyx.push_back(mp(i,j));
			}
			a[i][j]%=2;
		}
	}
	int N;
	int pairnum=oddnum/2;
	bool combine[501][501]={0};
	vint fromx,fromy,tox,toy;
	pint onyx=mp(0,0);
	int nowpairnum=0;
	while(1){
		if(nowpairnum==pairnum) break;
		int nowy=onyx.first;
		int nowx=onyx.second;
		if(a[nowy][nowx]==0){
			onyx=tozahyo(onyx);
			continue;
		}
		pint toyx=tozahyo(onyx);
		fromy.push_back(nowy);
		fromx.push_back(nowx);
		toy.push_back(toyx.first);
		tox.push_back(toyx.second);
		//printf("%d %d %d %d\n",fromy.back(),fromx.back(),toy.back(),tox.back());
		if(a[toyx.first][toyx.second]==1){
			a[toyx.first][toyx.second]=0;
			nowpairnum++;
		}
		else{
			a[toyx.first][toyx.second]=1;
		}
		onyx=tozahyo(onyx);
	}
	prin(fromx.size());
	rep(i,fromx.size()){
		printf("%d %d %d %d\n",fromy[i]+1,fromx[i]+1,toy[i]+1,tox[i]+1);
	}
	return 0;
}


Measured memory_bytes: 8048
from itertools import accumulate
N, K = map(int, input().split())
*V, = map(int, input().split())

ans = 0
for a in range(N+1):
    for b in range(N+1):
        if a+b>N:continue
        t = []
        if a:
            t += V[:a]
        if b:
            t += V[-b:]
        t.sort()
        t = [0]+t
        
        v = sum(t)
        for c in range(a+b+1):
            v -= t[c]
            if a+b+c<=K:
                ans = max(ans, v)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n >>k;
  int l[n];
  for(int i=0;i<n;i++){
     cin >> l[i];
  }
  sort(l,l+n);
  int sum=0;
  for(int i=n-1;i>n-1-k;i--){
     sum+=l[i];
  }
  cout << sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
vector<ll> P;
vector<ll> le,ri;   //左から、右から連続何個の数
vector<ll> pos;   //何が何番目にあるか

int main() {
	cin >> N;
	P.resize(N);
	pos.resize(N+1);
	for (ll n = 0; n < N; n++) {
		cin >> P[n];
		pos[P[n]] = n;
	}
	le.resize(N+1, 0);
	le[1] = 1;
	for (ll num = 2; num <= N; num++) {
		if (pos[num - 1] < pos[num])le[num] = le[num - 1] + 1;
		else le[num] = 1;
	}
	ri.resize(N + 2, 0);
	ri[N] = 1;
	for (ll num = N - 1; num >= 1; num--) {
		if (pos[num + 1] > pos[num])ri[num] = ri[num + 1] + 1;
		else ri[num] = 1;
	}
	ll ans = LLONG_MAX;
	for (ll n = 0; n <= N; n++) {
		ll res = (n - le[n]) + (N - n - ri[n]+1);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

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

const double PI = acos(-1);

struct Point{
    double x, y;
    Point(){}
    Point(double x, double y):x(x), y(y){}
    void initialize(double xi, double yi){ x = xi; y = yi;}

    double det(Point other){
        return x*other.y - y*other.x;
    }

    Point operator-(Point other){
        return Point(x-other.x, y-other.y);
    }
    Point operator+(Point other){
        return Point(x+other.x, y+other.y);
    }
};

vector<Point> convex_hull(vector<Point> ps){
    int N = ps.size();
    sort(ps.begin(), ps.end(), [](auto a, auto b){ return make_pair(a.x, a.y) < make_pair(b.x, b.y);});
    int k = 0;
    vector<Point> qs(2*N);
    for(int i=0; i<N; i++){
        while(k>1 && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    for(int i=N-2, t=k; i>=0; i--){
        while(k>t && (qs[k-1] - qs[k-2]).det(ps[i] - qs[k-1]) <= 0) k--;
        qs[k++] = ps[i];
    }
    qs.resize(k-1);
    return qs;
}

int main(){
    int N;
    cin >> N;
    vector<double> X(N), Y(N);
    for(int i=0; i<N; i++) cin >> X[i] >> Y[i];
    vector<Point> ps;
    map<pair<double, double>, int> mp;
    for(int i=0; i<N; i++){
        ps.emplace_back(X[i], Y[i]);
        mp[{X[i], Y[i]}] = i;
    }

    auto hull = convex_hull(ps);
    int sz = hull.size();
    vector<double> angle(N), ans(N);
    for(int i=0; i<sz; i++){
        auto v = hull[(i+1)%sz] - hull[i];
        angle[i] = atan2(-v.x, v.y);
    }
    for(int i=0; i<sz; i++){
        double res = angle[i] - angle[(i-1+sz)%sz];
        if(res < 0) res += 2*PI;
        if(res > 2*PI) res -= 2*PI;
        ans[mp[{hull[i].x, hull[i].y}]] = res / 2 / PI;
    }
    for(int i=0; i<N; i++) cout << fixed << setprecision(10) << ans[i] << endl;
}

Measured memory_bytes: 256