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

const int N = 2e5 + 5;

struct NODE {
  int val, who, id;
  friend bool operator < (NODE a, NODE b) {
    return a.val < b.val;
  }
}P[N];

int n, m, x, y, A[N][2], tot;

bool vis[N][2];

int main() {
  cin >> n;
  for(int i = 1; i <= n; ++ i) {
    scanf("%d%d", &A[i][0], &A[i][1]);
    P[++ tot] = (NODE){A[i][0], i, 0};
    P[++ tot] = (NODE){A[i][1], i, 1};
  }
  sort(P + 1, P + tot + 1);
  long long ans = 0;
  for(int i = 1; i <= n; ++ i) {
    vis[P[i].who][P[i].id] = 1;
    ans += P[i].val;
  }
  int l = 0, r = 0;
  for(int i = 1; i <= n; ++ i) {
    l += vis[i][0];
    r += vis[i][1];
    if(vis[i][0] == vis[i][1]) {
      printf("%lld\n", ans);
      return 0;
    }
  }
  if(l == n || r == n) {
    cout << ans << endl;
    return 0;
  }

  int res = 1e9;
  if(l == 1) {
    for(int i = 1; i <= n; ++ i) {
      if(vis[i][0]) res = min(res, A[i][1] - A[i][0]);
    }
  }
  if(r == 1) {
    for(int i = 1; i <= n; ++ i) {
      if(vis[i][1]) res = min(res, A[i][0] - A[i][1]);
    }
  }
  vis[P[n + 1].who][P[n + 1].id] = 1;
  for(int i = 1; i <= n; ++ i) {
    if(!vis[P[i].who][P[i].id ^ 1]) {
      res = min(res, P[n + 1].val - P[i].val);
    }
    else res = min(res, P[n + 2].val - P[i].val);
  }
  cout << ans + res << endl;
}


Measured memory_bytes: 3584
n = gets.to_i
arr = gets.split(' ').map(&:to_i)
total = 0
arr.each { |i| total = total + i }
even_total = 0
for i in 0...n do
  next if i % 2 == 0
  even_total += arr[i]
end
results = [total - (2 * even_total)]
stop1 = n - 1
1.upto(stop1) do |i|
  results.push(2 * arr[i - 1] - results[i - 1])
end
stop2 = n - 2
0.upto(stop2) do |i|
  print "#{results[i]} "
end
puts results[n - 1]

Measured memory_bytes: 13068
#include<iostream>
#include<string>
#include<vector>
using namespace std;

vector<string> vs1(50),vs2(50);

int check_ans(int i,int j,int m){
  for(int t=1;t<m;t++){
    if(vs2[t]!=vs1[i+t].substr(j,m))return 0;
  }
  return 1;
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++)
    cin>>vs1[i];
  for(int i=0;i<m;i++)
    cin>>vs2[i];
  int flag=0;
  for(int i=0;i<=n-m&&flag==0;i++){
    for(int j=0;j<=n-m&&flag==0;j++){
      if(vs2[0]==vs1[i].substr(j,m)){
	flag=check_ans(i,j,m);
      }
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int H, W; cin >> H >> W;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    int cnt = 0;
    rep(i, H){
        rep(j, W){
            if(s[i][j] == '#') cnt++;
        }
    }
    if(cnt == H+W-1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
function main(input){
  var input=input.split('\n');
  var N=parseInt(input[0],10);
  var K=parseInt(input[1],10);
  var X=parseInt(input[2],10);
  var Y=parseInt(input[3],10);
  var payment=0;
  var daysForX=Math.min(K,N);
  var daysForY=Math.max(0,N-K);
  payment = X*daysForX+Y*daysForY;
  console.log(payment);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 21192
input1 = input().split(" ")

N = int(input1[0])
K = int(input1[1])

list = input().split(" ")
num_list = []

for num in list:
    num_list.append(int(num))

num_list.sort(reverse=True)

length = 0
for k in range(K):
    length += num_list[k]
    
print(length)

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    string n;
    cin >> n;
    REP(i, n.length()){
        if(n[i] == '9')n[i]='1';
        else if(n[i] == '1')n[i]='9';
    }
    cout << n << endl;


}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, ans = 100000; cin >> n;
	for (int h = 1; h <= n / 2; h++) {
		int sum = 0;
		sum += h / 10000;
		sum += h % 10000 / 1000;
		sum += h % 1000 / 100;
		sum += h % 100 / 10;
		sum += h % 10;
		sum += (n - h) / 10000;
		sum += (n - h) % 10000 / 1000;
		sum += (n - h) % 1000 / 100;
		sum += (n - h) % 100 / 10;
		sum += (n - h) % 10;
		ans = min(ans, sum);
	}
	cout << ans << endl;
	cin >> n;
}

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

using namespace std;

#define INF 1e9

void wf(vector< vector<int> >& m) {
	int N = m.size();
	for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
		m[i][j] = min(m[i][j], m[i][k] + m[k][j]);
	}
}

int main() {
	int n, N;
	while (cin >> n >> N, n || N) {
		vector< vector<int> > cost(N, vector<int>(N, INF));
		vector< vector<int> > time(N, vector<int>(N, INF));
		for (int i = 0; i < N; ++i) cost[i][i] = time[i][i] = 0;
		for (int i = 0; i < n; ++i) {
			int a, b, c, t;
			cin >> a >> b >> c >> t; --a, --b;
			cost[a][b] = cost[b][a] = c;
			time[a][b] = time[b][a] = t;
		}

		wf(cost);
		wf(time);

		int k; cin >> k;
		for (int t = 0; t < k; ++t) {
			int p, q, r; cin >> p >> q >> r; --p, --q;
			vector< vector<int> >& m = r == 0 ? cost : time;
			cout << m[p][q] << endl;
		}
	}
}

Measured memory_bytes: 1304
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    S = input().rstrip()

    R = set([])
    G = set([])
    B = set([])

    for i in range(N):
        temp = S[i]
        if temp == 'R':
            R.add(i)
        elif temp == 'G':
            G.add(i)
        else:
            B.add(i)

    all = [R,G,B]

    M = [len(R),len(G),len(B)]
    res = M[0] * M[1] * M[2]
    index = M.index(max(M))

    most = all.pop(index)
    first = all[0]
    second = all[1]

    count = 0

    for f in first:
        for s in second:
            temp1 = s * 2 - f
            temp2 = f * 2 - s
            temp3 = (f + s) // 2
            if (True) & (temp1 in most):
                count += 1
            if (True) & (temp2 in most):
                count += 1
            if (s + f) % 2 == 0:
                if temp3 in most:
                    count += 1

    res -= count
    print(res)




main()


Measured memory_bytes: 9496
package main

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

func main() {
	AMax := 10000

	H := readInt()
	N := readInt()
	AB := make([]struct{ A, B int }, N)
	for i := 0; i < N; i++ {
		AB[i].A = readInt()
		AB[i].B = readInt()
	}

	dpLen := H + AMax + 1
	dp := make([]int, dpLen)
	for i := 0; i < dpLen; i++ {
		dp[i] = math.MaxInt64
	}

	dp[0] = 0
	for i := 0; i < H; i++ {
		if dp[i] == math.MaxInt64 {
			continue
		}
		for j := 0; j < N; j++ {
			a := AB[j].A
			b := AB[j].B
			if dp[i]+b < dp[i+a] {
				dp[i+a] = dp[i] + b
			}
		}
	}

	result := math.MaxInt64
	for i := H; i < dpLen; i++ {
		if dp[i] < result {
			result = dp[i]
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 896
#include <iostream>
#include <set>
#include <cstring>
using namespace std;
typedef pair<int,int> pos;
pos map[100][100];
int memo[100][100];
int search(int i,int j,int count)
{
  if(memo[i][j] != 0) return count;
  set<pos> list;
  list.insert(make_pair<int,int>(i,j));
  int number;
  for(;;){
    int ni,nj;
    ni = map[i][j].first;
    nj = map[i][j].second;
    if(memo[ni][nj] != 0){
      number = memo[ni][nj];
      break;
    }
    if(!list.insert(make_pair<int,int>(ni,nj)).second){
      number = ++count;
      break;
    }
    i = ni;
    j = nj;
  }
  for(set<pos>::iterator it = list.begin(); it != list.end(); it++){
    memo[(*it).first][(*it).second] = number;
  }
  return count;
}
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    memset(map,0,sizeof(map));
    memset(memo,0,sizeof(memo));
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        cin >> map[i][j].second >> map[i][j].first;
      }
    }
    int count = 0;
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        count = search(i,j,count);
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <iomanip>
#include <cmath>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int rows, cols, r, c;
    cin >> rows >> cols >> r >> c;
    int total = cols * r + c * (rows - r);
    cout << rows * cols - total << '\n';
    return 0;
}

Measured memory_bytes: 256
def main(k, a, b):
    if k < a:
        return k + 1
    
    t = a
    k -= a - 1
    if b - a >= 2:
        t += (b - a) * (k // 2)
        k -= (k // 2) * 2
    
    t += k
    return t


k, a, b = map(int, input().split())
print(main(k, a, b))

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem098a(a, b))
}

fun problem098a(a: Int, b: Int): Int {
    return listOf(a + b, a - b, a * b).max()!!
}

Measured memory_bytes: 33992
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#define ll long long
#define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B))
#define gcd(A,B) (__gcd(A,B))
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define usecppio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

typedef pair<int,int> pii;
ll a,b,c,d;
ll cdiv, ddiv;
ll udiv;
int main()
{
    cin >> a >> b >> c >> d;
    ll u = lcm(c,d);
    cdiv = (b/c)-((a-1)/c);
    ddiv = (b/d)-((a-1)/d);
    udiv = (b/u)-((a-1)/u);
    cout << ((b-a+1)-(cdiv+ddiv) + udiv) << '\n';
}

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

int main() {
  int a,b,t;
  cin>>a>>b>>t;
  cout<<b*(t/a)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main(){
	string s;cin>>s;
	int first, second;
	first = 10*(s[0]-'0') +  (s[1]-'0');
	second = 10*(s[2]-'0') +  (s[3]-'0');
	bool ismmf = (0 < first) && (first < 13);
	bool ismms = (0 < second) && (second < 13);

	if(ismmf && ismms){
		cout<<"AMBIGUOUS"<<endl;
	} else if (!ismmf && ismms){
		cout<<"YYMM"<<endl;
	} else if (ismmf && !ismms){
		cout<<"MMYY"<<endl;
	} else {
		cout<<"NA"<<endl;
	}

	return 0;

}


Measured memory_bytes: 256
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

mat = []
for i in range(3):
    mat.append(Is())
if mat[0][0] - mat[0][1] == mat[1][0] - mat[1][1] == mat[2][0] - mat[2][1]:
    if mat[0][1] - mat[0][2] == mat[1][1] - mat[1][2] == mat[2][1] - mat[2][2]:
        if mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2]:
            if mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2]:
                print("Yes")
                exit()
print("No")

Measured memory_bytes: 3444
#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--)
using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b))
        cout << "A" << endl;
    else
        cout << "B" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin>>n;
  rep(i,9){
    if(n%(i+1)==0&&n/(i+1)<10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main() {
  int n;
  cin >> n;
  int x = n;
  int sum = 0;
  for (int i = 0; i < 8; i++) {
    sum += n%10;
    n /= 10;
  }
  if (x%sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	long[] ary = new long[N];
    	int ans = 0;
    	for(int i = 0; i < N; i++){
    		ary[i] = sc.nextLong();
		}
    	sc.close();
    	for (int i = 0; i < N; i++)
        {
            while(ary[i] % 2 == 0)
            {
                ans++;
                ary[i] /= 2;
            }
        }
    	System.out.println(ans);
    }

}


Measured memory_bytes: 34196
# coding=utf-8
# Author: lee215

get = lambda: int(raw_input().strip())
gets = lambda: [int(i) for i in raw_input().strip().split()]
getss = lambda n: [gets() for _ in xrange(n)]


m = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}


def solve(S):
    res = cur = 0
    for c in S:
        if c in m:
            cur += 1
            res = max(res, cur)
        else:
            cur = 0
    print res

S = raw_input().strip()
solve(S)
# solve("HATAGAYA")


Measured memory_bytes: 2568
#include <stdio.h>

int main(void)
{
	
	int i;
	int n;
	int count = 1;
	int h[20];
	int max;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	
	max = h[0];
	
	for(i = 1; i < n; i++) {
		if(h[i] >= max) {
			count++;
			max = h[i];
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="SUN"){cout<<7<<endl;}
    if(s=="MON"){cout<<6<<endl;}
    if(s=="TUE"){cout<<5<<endl;}
    if(s=="WED"){cout<<4<<endl;}
    if(s=="THU"){cout<<3<<endl;}
    if(s=="FRI"){cout<<2<<endl;}
    if(s=="SAT"){cout<<1<<endl;}
}

Measured memory_bytes: 256
//====== begin of bisma c++ template===========

        #include <iostream>
        #include <string>
        #include <vector>
        #include <algorithm>
        #include <sstream>
        #include <queue>
        #include <deque>
        #include <bitset>
        #include <iterator>
        #include <list>
        #include <stack>
        #include <map>
        #include <set>
        #include <functional>
        #include <numeric>
        #include <utility>
        #include <limits>
        #include <time.h>
        #include <math.h>
        #include <stdio.h>
        #include <string.h>
        #include <stdlib.h>
        #include <assert.h>
        using namespace std;
        #define rep(a,b,c) for(int a=b;a<=c;a++)
        #define ll long long
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))


int main(){
    
    string a,b;
    getline(cin,a);
    getline(cin,b);
    
    while(a.size()>b.size())b='0'+b;
    while(a.size()<b.size())a='0'+a;
    
    rep(i,0,a.size()-1){
        if(a[i]>b[i]){
            cout<<"GREATER";
            return 0;
        }else if(b[i]>a[i]){
            cout<<"LESS";
            return 0;
        }
    }
    
    cout<<"EQUAL";
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		
		
		if (k >= n) {
			System.out.println(0);
		} else {
			Arrays.sort(a);
			long ans = 0;
			for (int i = 0; i < n - k; i++) {
				ans += a[i];
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 71340
/*input
7
14 14 2 13 56 2 37
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    ll ans = INF64;
    vector<ll> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    for(ll i = 1; i <= 100; i++)
    {
    	ll sum = 0;
    	for(int j = 0; j < n; j++) sum += (x[j] - i) * (x[j] - i);
    	ans = min(ans, sum);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  ll A,B,K;
  cin >> A >> B >> K;
  rep(i,K) {
    if(i&1) {
      B >>= 1;
      A += B;
    } else {
      A >>=1;
      B += A;
    }
  }
  cout << A << " " << B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n;
	map<string,int> mp;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	int ma = 0;
	for(auto p : mp){
		chmax(ma,p.second);
	}
	for(auto p : mp){
		if(p.second == ma) cout << p.first << endl;
	}
}

Measured memory_bytes: 25216
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_B&lang=jp

#include <iostream>
#include <algorithm>


using namespace std;

int main(){
  int n, times=0;
  cin >> n;
  int A[n];
  for(int i = 0; i<n; i++){
    cin >> A[i];
  }
  //???????????????
  int minj;

  for(int i = 0; i<n; i++){
    minj = i;
    for(int j = i+1; j<n; j++){
      if(A[j] < A[minj]){
        minj = j;
            }
    }
    if(i != minj){
    swap(A[i],A[minj]);
    times++;
    }
  }

  for(int i = 0; i<n-1; i++){
    cout << A[i] << " ";
  }
  cout << A[n-1] << endl;
  cout << times << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

vector<int> solve(int n, int l, int t, vector<int> a, vector<int> w) {
	// int shift = accumulate(all(w), 0);
	// if (shift < 0) {
	// 	shift += n;
	// }

	// rotate(a.begin(), a.begin() + (1ll * (t / l) * shift) % n, a.end());
	// t %= l;

	vector<int> new_pos(n);
	for (int i = 0; i < n; ++i) {
		new_pos[i] = a[i] + t * w[i];
		new_pos[i] %= l;
		if (new_pos[i] < 0) {
			new_pos[i] += l;
		}
	}
	sort(all(new_pos));

	if (n == 1) {
		return new_pos;
	}

	long long sum = 1ll * accumulate(all(w), 0) * t;
	long long cur = accumulate(all(new_pos), 0ll) - accumulate(all(a), 0ll);
	// cerr << new_pos << " " << shift << " " << sum << " " << cur << "\n";

	long long diff = (sum - cur) / l;
	diff %= n;
	if (diff < 0) {
		diff += n;
	}
	rotate(new_pos.begin(), new_pos.begin() + diff, new_pos.end());

	return new_pos;
}

vector<int> stupid(int n, int l, int t, vector<int> a, vector<int> w) {
	for (int& x : a) {
		x *= 2;
	}
	t *= 2;
	l *= 2;
	while (t--) {
		for (int i = 0; i < n; ++i) {
			a[i] += w[i];
			if (a[i] == l) {
				a[i] = 0;
			}
			if (a[i] == -1) {
				a[i] = l - 1;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (i == 1 && n == 2) {
				continue;
			}
			if (a[i] == a[(i + 1) % n]) {
				swap(w[i], w[(i + 1) % n]);
			}
		}
	}
	for (int& x : a) {
		x /= 2;
	}
	return a;
}

int main(){
	int n = nxt(), l = nxt(), t = nxt();
	vector<int> a(n);
	vector<int> w(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
		w[i] = 3 - 2 * nxt();
	}
	auto ans = solve(n, l, t, a, w);
	for (int x : ans) {
		printf("%d\n", x);
	}
	return 0;

	while (true) {
		int n = rand() % 5 + 1, l = rand() % 5 + 1, t = rand() % 10;
		if (l < n) {
			continue;
		}
		vector<int> a(l);
		for (int i = 0; i < l; ++i) {
			a[i] = i;
		}
		random_shuffle(all(a));
		a.resize(n);
		sort(all(a));
		vector<int> w(n);
		for (int i = 0; i < n; ++i) {
			w[i] = rand() % 2 * 2 - 1;
		}

		auto ans = stupid(n, l, t, a, w);
		auto res = solve(n, l, t, a, w);

		if (res != ans) {
			cerr << n << " " << l << " " << t << "\n";
			cerr << a << " " << w << "\n";
			cerr << ans << "\n";
			cerr << res << "\n";
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 2416
n,x=map(int,input().split())
A=[i for i in range(1,2*n)]
if x==1 or x==2*n-1:
    print('No')
else:
    print('Yes')
    if n==2:
        print(*A,sep='\n')
    else:
        if x==2:
            T=[3,2,1,4]
        else:
            T=[x-1,x,x+1,x-2]
        S=list(set(A)-set(T))
        ans=S[:n-2]+T+S[n-2:]
        print(*ans,sep='\n')

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

if K < len(A):
    ans = A[:K-1] + A[K-1].lower() + A[K:]
else:
    ans = A[:K-1] + A[K-1].lower()
# print(ans)
print(A[:K-1] + A[K-1].lower() + A[K:])

Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import defaultdict
from collections import Counter
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    
    dc = Counter(A)
    dd = defaultdict(int)

    A.sort()
    mx = A[-1]
    for i in A:
        j = i
        while j <= mx:
            dd[j] += 1
            j += i
    cnt = 0
    for e in A:
            cnt += (dd[e] == 1) 
    print(cnt)
if __name__ == '__main__':
    main()


Measured memory_bytes: 220392
package main

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

var sc = bufio.NewScanner(os.Stdin)

func out(x ...interface{}) {
	fmt.Println(x...)
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	H := getInt()
	N := getInt()
	A := make([]int, N)
	B := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = getInt()
		B[i] = getInt()
	}

	//out(H, N, A, B)
	dp := make([]int, 10001)
	max := 2147483647
	for i := 0; i < 10001; i++ {
		dp[i] = max
	}

	dp[0] = 0
	for i := 0; i < N; i++ {
		for j := 0; j <= H; j++ {
			pos := min(j+A[i], H)
			if dp[pos] > dp[j]+B[i] {
				dp[pos] = dp[j] + B[i]
			}
		}
	}

	fmt.Println(dp[H])
}


Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=100005;
int ap[nmax];
pair<long long,int> v[2*nmax];
long long suma,sumb,ans,act;
long long a[nmax],b[nmax];
int n,i;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        suma+=1LL*a[i];
        sumb+=1LL*b[i];
    }
    ans=min(suma,sumb);
    for(i=1;i<=n;i++)
    {
        v[i].first=a[i];
        v[i].second=i;
        v[n+i].first=b[i];
        v[n+i].second=i;
    }
    sort(v+1,v+2*n+1);
    for(i=1;i<=n;i++)
        act+=1LL*v[i].first,ap[v[i].second]++;
    for(i=1;i<=n;i++)
    {
        if(ap[i]==0)
        {
            ans=min(ans,act-v[n].first-v[n-1].first+a[i]+b[i]);
        }
        if(ap[i]==1)
        {
            if(v[n].second!=i)ans=min(ans,act-v[n].first+max(a[i],b[i]));
            else ans=min(ans,act-v[n-1].first+max(a[i],b[i]));
        }
        if(ap[i]==2)
        {
            ans=min(ans,act);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
int solve(int n,int x){
	int ans =0;
	while(n){
		ans++;
		n/=x;
	}
	return ans;
}
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n,x;
		cin>>n>>x;
		cout << solve(n,x);
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;


int main() {
	double n;
	cin >> n;
	double ans = 0;
	double cnt = 0;
	for (int i = 1; i <= n;++i) {
		if (i % 2 == 1) cnt++;
	}
	cout << cnt / n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num[1000];

int main(int argc, char const *argv[])
{
	int a,b,c,d;
	while(cin>>a>>b>>c>>d){
		int ans=0;
		memset(num,0,sizeof(num));
		for(int i=a+1;i<=b;i++){
			num[i]++;
		}
		for(int i=c+1;i<=d;i++){
			num[i]++;
		}
		for(int i=1;i<=100;i++){
			if(num[i]==2){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int sum(int n){
  int s=0;
  while(n!=0){
    s += n%10;
    n = n/10;
  }
  return s;
}
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int t=0;
  for(int i=1;i<=N;++i){
    int S=sum(i);
    if(S>=A && S<=B)
      t += i;
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 13 19:20:01 2020

@author: dantitussalajan
"""
'''
# get a integer
a = int(input())
# get two integers separated with half-width break
b, c = map(int, input().split())
# get a string
s = input()
# output
print(str(a+b+c) + " " + s)
'''

#first line
S,T=map(str,input().split())
#second line
A,B=map(int,input().split())
#third line
U=input()

if U==S:
    print(A-1,B)
else:
    if U==T:
        print(A,B-1)
    else:
        print(A,B)
    

    


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std; 
#define ll long long  
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define forn(i,n) for(int i = 0; i < int(n); ++i)
#define forni(i,a,b) for(int i=int(a) ; i<=int(b) ; ++i)
#define sz(z) (int)z.size()
#define lb lower_bound
#define ub upper_bound 
#define dbg cout << "yo" << endl  
#define N (ll)5e5+10
#define M (ll)2e6+10 

typedef pair<ll,ll> pll ;
typedef vector<pair<ll,ll>> vpll ;
typedef vector<ll> vll ;
typedef vector<char> vch ;
typedef vector<bool> vbl ;


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    
    
    string s ; cin >> s ;
    if(s.back()=='s')s+='e' ;
    s+='s' ;
   cout << s ;

    return 0 ;
    
}



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

const int RLEN=1<<18|1;
inline char nc() {
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
    char ch=nc(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
    return i*f;
}

const int N=2e5+50;
int n,a[N];
#define up(i,j) ((a[i]>=v) && (a[j]>=v))
#define dn(i,j) ((a[i]<v) && (a[j]<v))
inline bool check(int v) {
    if(up(n-1,n) || up(n,n+1)) return 1;
    if(dn(n-1,n) || dn(n,n+1)) return 0;
    for(int i=1;i<n-1;i++) {
        if(up(n+i,n+i+1) || up(n-i,n-i-1)) return 1;
        if(dn(n+i,n+i+1) || dn(n-i,n-i-1)) return 0;
    } return up(1,1);
}
int main() {
    n=rd(); for(int i=1;i<n*2;++i) a[i]=rd();
    int l=1, r=*max_element(a+1,a+2*n), ans=0;
    while(l<=r) {
        int mid=(l+r)>>1;
        if(check(mid)) ans=mid, l=mid+1;
        else r=mid-1;
    } cout<<ans<<'\n';
}

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

typedef long long LL;

const int maxn=1e5+5;

int n,a[2*maxn],p[2*maxn],q[2*maxn];

bool cmp(const int &x,const int &y) {return a[x]<a[y];}

int main()
{
	scanf("%d",&n);
	LL suma=0, sumb=0;
	fo(i,1,n)
	{
		scanf("%d %d",&a[2*i-1],&a[2*i]);
		suma+=a[2*i-1], sumb+=a[2*i];
		p[2*i-1]=2*i-1, p[2*i]=2*i;
	}
	
	LL ans=min(suma,sumb);
	
	sort(p+1,p+1+2*n,cmp);
	fo(i,1,2*n) q[p[i]]=i;
	LL sum=0;
	fo(i,1,n-2) sum+=a[p[i]];
	fo(i,1,n)
	{
		int x=q[2*i-1], y=q[2*i];
		if (x>y) swap(x,y);
		if (y<=n-1) ans=min(ans,sum+a[p[n-1]]+a[p[n]]);
			else if (x<=n-2) ans=min(ans,sum+a[p[n-1]]+a[p[y]]);
				else ans=min(ans,sum+a[p[x]]+a[p[y]]);
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
     int a ,b ,c ,dev;
     
     scanf("%d %d %d",&a ,&b ,&c);
     
     for(int i = a; i <= b; i ++)
     {
     	if(c%i == 0)
     	{
     		dev ++;
		 }
	 }
     
     
     printf("%d\n",dev);
     
     
return 0;

} 


Measured memory_bytes: 2728
while True:
	try:
		n,m = map(float,raw_input().split())
	except EOFError:
		break
	
	if n < 35.5 and m < 71.0:
		print "AAA"
	elif n < 37.5 and m < 77.0:
		print "AA"
	elif n < 40.0 and m < 83.0:
		print "A"
	elif n < 43.0 and m < 89.0:
		print "B"
	elif n < 50.0 and m < 105.0:
		print "C"
	elif n < 55.0 and m < 116.0:
		print "D"
	elif n < 70.0 and m < 148.0:
		print "E"
	else:
		print "NA"

Measured memory_bytes: 6308
s=input()
t=input()
s_l,t_l=[],[]
for i in s:
	s_l.append(i)
for i in t:
	t_l.append(i)
s_l.sort()
t_l.sort(reverse=True)
s="".join(s_l)
t="".join(t_l)
if s<t:
	print("Yes")
else:
	print("No")


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}
// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    string a, b;
    cin >> a >> b;
    
    ll res = 1e12;
    for (int i = 0; i < a.length() - b.length() + 1; i++) {
        ll tmp = 0;
        for (int j = 0; j < b.length(); j++) {
            if (a[j + i] != b[j]) {
                tmp++;
            }
        }
        res = min(res, tmp);
    }
    cout << res;
}

// Driver Function
int main()
{
    ll compte = 1;
   // test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3632
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;

static const LL MOD = 1000000007;
static const size_t MAX_N = 100001;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll combination(LL n, LL r) {
	static modll fact[MAX_N + 1], inv[MAX_N + 1];
	if (!fact[0]) {
		fact[0] = 1;
		for (int i = 1; i <= MAX_N; ++i) {
			fact[i] = fact[i - 1] * i;
		}
		inv[MAX_N] = modll::modinv(fact[MAX_N]);
		for (int i = MAX_N; i >= 1; --i) {
			inv[i - 1] = inv[i] * i;
		}
	}
	if (n >= r) {
		return (fact[n] * inv[r]) * inv[n - r];
	} else {
		return 0;
	}
}

int main(int argc, char *argv[]) {
	int n, d;
	cin >> n;
	vector<int> pos(n + 1, -1);
	for (int i = 0; i <= n; ++i) {
		int a;
		cin >> a;
		if (pos[a] >= 0) {
			d = i - pos[a];
		}
		pos[a] = i;
	}
	for (int i = 1; i <= n + 1; ++i) {
		modll ans = combination(n + 1, i) - combination(n - d, i - 1);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3200
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	string tmp;
	int n; cin >> n;
	map<string, int> m;
	REP(i, n){
		cin >> tmp;
		m[tmp]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout <<  "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  ll a, b; cin >> a >> b;
  ll odd_a = a + a%2, even_b = b - (b+1)%2;
  int center = (even_b + 1 - odd_a) / 2 % 2;
  bitset<40> ans(center);
  if (a%2) {
    bitset<40> tmp(a);
    ans = (ans ^ tmp);
  }
  if ((b-1)%2) {
    bitset<40> tmp(b);
    ans = (ans ^ tmp);
  }
  cout << ans.to_ullong() << endl;
  return 0;
}


Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defun main ()
  (let ((p (read)) (q (read)) (r (read)))
    (println
     (min (+ p q) (+ q r) (+ r p)))))

#-swank(main)


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

int l,r,a[3000],ans=0x3f3f3f3f;

int main()
{
	cin>>l>>r;
	if(r-l>=2019)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=l;i<=r;a[++a[0]]=i%2019,i++);
	for(int i=1;i<a[0];i++)
		for(int j=i+1;j<=a[0];ans=min(ans,(a[i]*a[j])%2019),j++);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    int n = scan.nextInt();

    int i = 1;
    int x = 0;

    while (true) {
      x = i;
      if (x % 3 == 0) {
        System.out.print(" " + i);
        if (++i <= n) {
          continue;
        } else {
          break;
        }
      }

      while (true) {
        if (x % 10 == 3) {
          System.out.print(" " + i);
          break;
        }
        x /= 10;
        if (x != 0) {
          continue;
        } else {
          break;
        }
      }

      if (++i <= n) {
        continue;
      } else {
        break;
      }
    }

    System.out.println();

  }
}


Measured memory_bytes: 28576
if __name__ == '__main__':

    n,m,a = map(int,input().split())

    A = []
    for i in range(n):
        cmd = list(map(int,input().split()))
        A.append(cmd)
    #bit全探索 買う・買わないを判断する
    INF = 10**19
    ans = INF
    for x in range(2**n):
        ALG = [0]*m
        gokei = 0
        for y in range(n):
            if (x>>y) & 1:
                #取得する配列が決まったら、アルゴリズム理解度を＋していく
                for j in range(m):
                    ALG[j] += A[y][j+1]
                gokei += A[y][0]
        #Alg配列の中身がすべて理解度xを超えているかのチェック
        algflg=True
        for k in ALG:
            if k < a:
                algflg=False
                break
        if algflg:
            ans = min(ans,gokei)
    if ans == INF:
        print("-1")
    else:
        print(ans)


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

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

using namespace std;

int ary[7][7] = {
  {18,17,15,14,13,10, 9},
  {17,16,14,13,12, 9, 8},
  {15,14,11,10, 9, 6, 5},
  {14,13,10, 9, 8, 5, 4},
  {13,12, 9, 8, 7, 4, 3},
  {10, 9, 6, 5, 4, 2, 1},
  { 9, 8, 5, 4, 3, 1, 0}
};

int main() {
  while(1){
    string s;
    cin>>s;
    if (s=="#")break;
    reverse(begin(s),end(s));
    bitset<128> bs(s);
    bool ok = true;
    REP(i,1<<19) {
      bitset<19> fd(i);
      bitset<7> nx;
      REP(j,7) {
        int v = 0;
        REP(k,7) {
          v |= fd[ary[j][k]] << k;
        }
        nx[j] = bs[v];
      }
      int v = 0;
      REP(j,7) v |= nx[j] << j;
      if (bs[v] != nx[3]) ok = false;
    }
    if (ok)
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
char a[1];

int main(){
  cin >> a[0];
  if(a[0]=='A') cout<< 'T'<<endl;
  else if(a[0]=='T') cout << 'A'<<endl;
  else if(a[0]=='C') cout << 'G'<<endl;
  else cout<< 'C'<<endl;
  
  return 0;
}

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

bool Check(string t){
    
    int t_len = t.size();
    vector<char> tt{};

    for(int i=0;i<t_len;i++){
        if(t[i] != 'A') tt.push_back(t[i]);
        else{
            if(i != t_len-1 && t[i+1] == 'A') return false;
            if(i-1 >= 0 && t[i-1] == 'I') return false;
            if(i+1 < t_len-1 && t[i+1] == 'I') return false;
        }
    }
    
    string s="";
    for(int i=0;i<tt.size();i++) s+=tt[i];
    if(s == "KIHBR") return true;
    else return false;
}

int main(){
   
  string t; cin >> t;
  if(t.size() > 9){
      cout << "NO" << endl;
  }
  else{
      if(Check(t)) cout << "YES" << endl;
      else cout << "NO" << endl;
  }
}

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

int main() {
    int N,K;
    int ans = 0;
    cin >> N >> K;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < K; i++) {
    ans += vec.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632