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

public class Main {

	/**
	 * @param args
	 * @throws IOException
	 * @throws NumberFormatException
	 */
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		//System.out.println("???????????°:");
		int tateLine = sc.nextInt();
		// System.out.println("?¨?????????°:");
		int yokoLine = sc.nextInt();
		int[] numList = new int[tateLine]; // ??????????????¨????????????????????????
		for (int i = 0; i < tateLine; i++) {
			numList[i] = i + 1;
		}
		int[][] yoko = new int[yokoLine][2]; // ?¨????????§??????¨???????????????????????????????´?
		for (int i = 0; i < yokoLine; i++) {
			// ??????????????????????????§????????????
			String[] s = sc.next().split(",");

			// System.out.println("????????¨");
			yoko[i][0] = Integer.parseInt(s[0]) - 1;
			// System.out.println("??????");
			yoko[i][1] = Integer.parseInt(s[1]) - 1;

		}

		for (int i = 0; i < yokoLine; i++) {
			int b = numList[yoko[i][0]];
			numList[yoko[i][0]] = numList[yoko[i][1]];
			numList[yoko[i][1]] = b;
		}

		for (int i = 0; i < tateLine; i++) {
			System.out.println(numList[i]);
		}
	}

}

Measured memory_bytes: 17396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

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

mint dp0[2005][2005];
mint dp1[2005][2005];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n + 1), t(m + 1);
  rep(i, n) cin >> s[i];
  rep(i, m) cin >> t[i];
  dp0[0][0] = 1;
  rep(i, n + 1) rep(j, m + 1) {
    dp0[i + 1][j] += dp0[i][j];
    dp1[i][j] += dp0[i][j];
    dp1[i][j + 1] += dp1[i][j];
    if (s[i] == t[j]) dp0[i + 1][j + 1] += dp1[i][j];
  }
  mint ans = dp1[n][m];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 63104
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), t = 0;
		while (N-->0) {
			int a = sc.nextInt(), b = sc.nextInt();
			t+=(b-a)+1;
		}
		System.out.println(t);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 39280
NN = 2020202
MOD = 10**9+7
INF = float("inf")

f = [0]*NN
rf = [0]*NN
inv = [0]*NN
f[0], f[1] = 1, 1
rf[0], rf[1] = 1, 1
inv[1] = 1

for i in range(2, NN):
    f[i] = (f[i-1] * i) % MOD
    inv[i] = (-inv[MOD % i] * (MOD // i)) % MOD
    rf[i] = (rf[i-1] * inv[i]) % MOD


def C(n, r):
    # if r < 0 or n < r:
    #     return 0
    # r = min(r, n - r)
    return (f[n] * rf[r] * rf[n-r]) % MOD


r1, c1, r2, c2 = map(int, input().split())
ans = 0
for r in range(r1+1, r2+2):
    ans += (C(c2+r, r) - C(c1+r-1, r)) % MOD
    # print(ans)
print(ans % MOD)

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

string make_str(int num, int times) {
	string s = "";
	for (int i = 0; i < times; i++) {
		s += to_string(num);
	}
	return s;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << make_str(b, a) << endl;
	}
	else {
		cout << make_str(a, b) << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Measured memory_bytes: 3864
// Problem : F - Distributing Integers
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_f
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;
vector<int> e[200005];
long long siz[200005],f[200005],n;
long long fpow(long long x,long long y)
{
 long long ans=1;
 while(y)
 {
  if(y&1)ans=ans*x%MOD;
  x=x*x%MOD;
  y>>=1;
 }
 return ans;
}
void dfs1(int u,int fa)
{
 siz[u]=1;
 for(auto v:e[u])
  if(v!=fa)
  {
   dfs1(v,u);
   siz[u]+=siz[v];
  }
 f[1]=f[1]*siz[u]%MOD;
}
void dfs2(int u,int fa)
{
 for(auto v:e[u])
  if(v!=fa)
  {
   f[v]=f[u]*(n-siz[v])%MOD*fpow(siz[v],MOD-2)%MOD;
   dfs2(v,u);
  }
}
int main()
{
 cin>>n;
 for(int i=1;i<n;i++)
 {
  int u,v;
  cin>>u>>v;
  e[u].push_back(v);
  e[v].push_back(u);
 }
 f[1]=1;
 dfs1(1,0);
 dfs2(1,0);
 long long ans=1;
 for(int i=1;i<=n;i++)
  ans=ans*i%MOD;
 for(int i=1;i<=n;i++)
  cout<<ans*fpow(f[i],MOD-2)%MOD<<endl;
 return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }
        long cnt = 0;
        for (int i = 0; i < n; i++) {
            if (s[i].equals("A")) {
                cnt++;
            } else if (s[i].equals("Un")) {
                cnt--;
                if (cnt < 0) {
                    System.out.println("NO");
                    return;
                }
            }
        }
        if (cnt != 0) {
            System.out.println("NO");
            return;
        }
        System.out.println("YES");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}



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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	string str;
	cin>>str;
	map<char,int> board;
	for(int i =0;i <str.length();i++){
		if(str[i]=='K'||str[i]=='U'||str[i]=='P'||str[i]=='C'){
			board[str[i]]++;
		}
	}
	int ans =min(min(board['K'],board['U']),min(board['P'],board['C']));
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1192
s = []
t = []

N = gets.to_i

N.times {
  s << gets.chomp
}

M = gets.to_i

M.times {
  t << gets.chomp
}

sss = s.uniq

ans = 0
sss.each do |ss|
  score = s.count(ss) - t.count(ss)
  if score > 0
    ans = [ans, score].max
  end
end

p ans

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

int main() {
    int i, n = 0;
    int a[3], score;
    vector<vector<int>> vec;
    
    while(1) {
        cin >> a[0] >> a[1] >> a[2];
        if(a[0] < 0 && a[1] < 0 && a[2] < 0) break;
        vec.push_back(vector<int>(a, a+sizeof(int)));
        ++n;
    }

    for(i=0; i<n; ++i) {
        if(vec[i][0] < 0 || vec[i][1] < 0) cout << 'F' << endl;
        else if(vec[i][0] + vec[i][1] >= 80) cout << 'A' << endl;
        else if(vec[i][0]+vec[i][1]>=65&&vec[i][0]+vec[i][1]<80)
            cout << 'B' << endl;
        else if(vec[i][0]+vec[i][1]>=50&&vec[i][0]+vec[i][1]<65)
            cout << 'C' << endl;
        else if(vec[i][0]+vec[i][1]>=30&&vec[i][0]+vec[i][1]<50) {
            if(vec[i][2] >= 50) {
                cout << 'C' << endl;
                continue;
            }
            cout << 'D' << endl;
        }
        else cout << 'F' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int sy[100010];
int sx[100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w, h;
    cin >> n >> w >> h;
    rep(i, 0, n){
        int x, y, a;
        cin >> x >> y >> a;
        int l = max(0LL, x - a);
        int r = min(w, x + a);
        sx[l]++;
        sx[r]--;
        l = max(0LL, y - a);
        r = min(h, y + a);
        sy[l]++;
        sy[r]--;
    }
    bool ans = false;
    rep(i, 1, w) sx[i] += sx[i - 1];
    rep(i, 1, h) sy[i] += sy[i - 1];
    bool f = true;
    rep(i, 0, w) if(sx[i] <= 0) f = false;
    ans |= f;
    f = true;
    rep(i, 0, h) if(sy[i] <= 0) f = false;
    ans |= f; 
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 4800
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t, a, ans = -1;
	double best = numeric_limits<double>::infinity();
	cin >> n;
	cin >> t >> a;
	vector<int> h(n);
	for (auto&& hh : h) cin >> hh;
	for (int i = 0; i < n; ++i) {
		double tmp = t - 0.006 * h[i];
		if (fabs(tmp - a) < best) {
			ans = i + 1;
			best = fabs(tmp - a);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int m = Integer.parseInt(scan.next());
		int[] ans = new int[n];
		Arrays.fill(ans, 0);

		int input_a,input_b;
		for (int i = 0;i < m; ++i){
			input_a = Integer.parseInt(scan.next());
			input_b = Integer.parseInt(scan.next());
			if (input_a == 1){
				++ans[input_b];
			}
			if (input_b == n){
				++ans[input_a];
			}
		}

		boolean bool = false;
		for(int i:ans){
			if (i == 2){
				bool = true;
				break;
			}
		}

		System.out.print(bool?"POSSIBLE":"IMPOSSIBLE");
	}
}
//end


Measured memory_bytes: 65088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 110000
 
vector<ll> a(N,0);
vector<ll> b(N,0);
map<ll,ll> BIT;
 
bool cnter(ll x, ll y){
	BIT.clear();
	b[0]=0;
	ll minb=b[0]; ll maxb=b[0];
	REP(i,y){
		if (a[i]<x) b[i+1]=b[i]-1;
		else b[i+1]=b[i]+1;
		minb=min(minb,b[i+1]);
		maxb=max(maxb,b[i+1]);
	}
	REP(i,y+1) b[i]+=(1-minb);
	ll ans = 0;
	REP(i,y+1){
		ll p = b[i];
		ll q = b[i];
		while(p>0){
			ans+=BIT[p];
			p-=p&-p;
		}
		if (ans>=(y*y+y+2)/4) return true;
		while(q<maxb+2-minb){
			BIT[q]++;
			q+=q&-q;
		}
	}
	return false;
}
 
int main(){
	ll n; cin >> n;
	ll maxa = 0;
	REP(i,n) {
		cin >> a[i];
		maxa=max(maxa,a[i]);
	}
	ll left = -1;
	ll right = maxa+1;
	while (right-left>1){
		ll mid = (right+left)/2;
		if (cnter(mid,n)) left = mid;
		else right = mid;
	}
	cout << left << endl;
}


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

    long long int n;
    long long int a[123456];
    long long int b[123456];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    long long int s=0;
    long long int cnt=0;
    long long int ck=0;
    for(int i=n;i>0;i--){
            a[i]+=cnt;
            s=a[i];

        if(a[i]%b[i]){
            long long int p=a[i]/b[i];
            p++;
            a[i]=p*b[i];
            //a[i]=p-a[i];
            //cout<<a[i]<<endl;
        }
        cnt+=(a[i]-s);
        //cout<<cnt<<endl;
    }
    printf("%lld\n",cnt);

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int x, n;
	cin >> x >> n;
	vector<bool> a(102, true);
	rep(i,n){
		int p; cin >> p;
		a[p] = false;
	}
	int min = 103;
	int ans = 0;
	rep(i,102){
		if(!a[i]) continue;
		int dist = abs(i-x);
		if(dist < min){
			min = dist;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

// #include <bits/extc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> // tree
// #include <ext/pb_ds/hash_policy.hpp> // hash
// #include <ext/pb_ds/trie_policy.hpp> // trie
// #include <ext/pb_ds/priority_queue.hpp> // priority_queue
// using namespace __gnu_pbds;

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

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define Push push_back

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
using Double = long double;
template<typename T>
using Vector = vector<vector<T>>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

const lli mod = 1E9 + 7;
const Double PI = 3.1415926535846;
const Double eps = 1e-8;

lli fastPow(lli base, lli exp, lli module = mod) {
	lli ans = 1;
	base %= module;
	while (exp) {
		if (exp & 1) ans = ans * base % module;
		base = base * base % module;
		exp >>= 1;
	}
	return ans;
}

bool millerRabin(lli n, lli a) {
	/*
	 * n < 4,759,123,141		3 : {2, 7, 61}
	 * n < 1,122,004,669,633	4 : {2, 13, 23, 1662803}
	 * n < 3,474,749,660,383	6 : {p in [2, 13]}
	 * n < 2^64					7 : 
	 * {2, 325, 9375, 28178, 450775, 9780504, 1795265022}
	 *
	 * else, random everytime gives a 75% of correction
	 */
	
	if (n < 2) return 0;
	if ((a = a%n) == 0) return 1;
	if (n & 1 ^ 1) return n == 2;
	
	lli lowb = (n - 1) & -(n - 1);
	lli tmp = (n - 1) / lowb; // lowbit of (n-1)
	lli t = __lg(lowb);
	lli x = 1;
	
	for (; tmp; tmp /= 2, a = a*a%n) {
		if (tmp & 1) x = x * a % n;
	}
	
	if (x == 1 or x == n - 1) return 1;
	
	while (--t) {
		if ((x = x*x%n) == n - 1) return 1;
	}
	
	return 0;
}

bool MR_PrimeFilter(lli n) {
	vector<lli> v[4];
	v[0] = {2, 7, 61};
	v[1] = {2, 13, 23, 1662803};
	v[2] = {2, 3, 5, 7, 11, 13};
	v[3] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};
	
	if (n < 4759123141LL) {
		for (lli x : v[0]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	if (n < 1122004669633LL) {
		for (lli x : v[1]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	if (n < 3474749660383LL) {
		for (lli x : v[2]) {
			if (!millerRabin(n, x)) return false;
		}
		return true;
	}
	for (lli x : v[3]) {
		if (!millerRabin(n, x)) return false;
	}
	return true;
}

void solve() {
	lli T1, T2, A1, A2, B1, B2, S1, S2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	
	S1 = T1 * (A1 - B1);
	S2 = T2 * (A2 - B2);
	
	if (S1 + S2 == 0) {
		cout << "infinity\n";
		return;
	}
	
	if ((S1 < 0 and S1 + S2 < 0) or (S1 > 0 and S1 + S2 > 0)) {
		cout << 0 << "\n";
		return;
	}
	
	cout << abs(S1) / abs(S1 + S2) * 2 + (abs(S1) % abs(S1 + S2) > 0) << "\n";
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char s[3];
    int i,s0=0,s1=0,s2=0;

    scanf("%s",s);
    if(s[0]=='a'||s[1]=='a'||s[2]=='a')s0++;
    if(s[0]=='b'||s[1]=='b'||s[2]=='b')s1++;
    if(s[0]=='c'||s[1]=='c'||s[2]=='c')s2++;

    if(s0+s1+s2==3){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  string a, b, c;
  cin >> N >> a >> b >> c;

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] == b[i] && b[i] == c[i]) continue;
    if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i]) {
      ans += 2;
    } else if (a[i] == b[i]) {
      ans++;
    } else if (a[i] == c[i]) {
      ans++;
    } else if (b[i] == c[i]) {
      ans++;
    }
  }

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



Measured memory_bytes: 256
class Array
  def even; select.with_index{|_,i| i.even? } end
  def odd; select.with_index{|_,i| i.odd? } end
  def counter; h = Hash.new(0); each{ |t| h[t]+=1 }; h end
end

n = gets.to_s.to_i
v = gets.to_s.split.map{|t| t.to_i }

s =  v.even.counter.sort_by{|_,s|-s}
t =  v.odd.counter.sort_by{|_,s|-s}

if s.first != t.first
  puts n - s[0].last - t[0].last
else
  ans = n - s[0].last
  n1 = n - t[0].last
  n2 = n3 = 10 ** 5 + 1
  t[1] && n2 = n - s[0].last - t[1].last
  s[1] && n3 = n - s[1].last - t[0].last
  
  ans = n1 if ans > n1
  ans = n2 if ans > n2
  ans = n3 if ans > n3
  
  puts ans
end

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int P = 700;
	string S;
	cin >> S;
	int cnt = count(ALL(S), 'o');
	P += cnt * 100;
	cout << P << endl;
}

Measured memory_bytes: 256
const MOD: usize = 1_000_000_007;

struct DFS {
    n: usize,
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    g: Vec<Vec<usize>>,
    c: Vec<usize>,
    ans: Vec<usize>,
}

impl DFS {
    fn pow(mut a: usize, mut n: usize) -> usize {
        let mut res = 1;
        while n > 0 {
            if n & 1 > 0 {
                res = res * a % MOD;
            }
            a = a * a % MOD;
            n >>= 1;
        }
        res
    }

    fn new(n: usize) -> DFS {
        let mut fact = vec![1; n];
        let mut inv_fact = vec![1; n];
        for i in 1..n {
            fact[i] = fact[i - 1] * i % MOD;
        }
        inv_fact[n - 1] = Self::pow(fact[n - 1], MOD - 2);
        for i in (1..n).rev() {
            inv_fact[i - 1] = inv_fact[i] * i % MOD;
        }

        DFS {
            n,
            fact,
            inv_fact,
            g: vec![vec![]; n],
            c: vec![1; n],
            ans: vec![1; n],
        }
    }

    fn search(&mut self, from: usize, prev: usize) {
        for to in self.g[from].clone() {
            if to == prev { continue; }
            self.search(to, from);
            self.c[from] += self.c[to];
            self.ans[from] *= self.ans[to];
            self.ans[from] %= MOD;
            self.ans[from] *= self.inv_fact[self.c[to]];
            self.ans[from] %= MOD;
        }
        self.ans[from] *= self.fact[self.c[from] - 1];
        self.ans[from] %= MOD;
    }

    fn research(&mut self, from: usize, prev: usize) {
        for to in self.g[from].clone() {
            if to == prev { continue; }
            self.ans[to] = {
                self.ans[from] *
                self.c[to] % MOD *
                Self::pow(self.n - self.c[to], MOD - 2) % MOD
            };
            self.research(to, from);
        }
    }
}

use std::io::{BufRead, Write};

fn main () {
    let stdin = std::io::stdin();
    let stdout = std::io::stdout();
    let mut reader = std::io::BufReader::new(stdin.lock());
    let mut writer = std::io::BufWriter::new(stdout.lock());

    let n: usize = {
        let mut buf = String::new();
        reader.read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let mut dfs = DFS::new(n);

    for _ in 0..(n - 1) {
        let (a, b): (usize, usize) = {
            let mut buf = String::new();
            reader.read_line(&mut buf).unwrap();
            let mut iter = buf.split_whitespace();
            (
                iter.next().unwrap().parse::<usize>().unwrap() - 1,
                iter.next().unwrap().parse::<usize>().unwrap() - 1,
            )
        };

        dfs.g[a].push(b);
        dfs.g[b].push(a);
    }

    dfs.search(0, !0);
    dfs.research(0, !0);
    for i in 0..n {
        writeln!(writer, "{}", dfs.ans[i]).unwrap();
    }
}

Measured memory_bytes: 22776
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut ans = vec![];
    traverse(String::new(), &mut ans, n);
    ans.sort();
    for ans in ans.into_iter() {
        sc.write(ans);
        sc.write("\n");
    }
}

fn traverse(cur: String, ans: &mut Vec<String>, remain: usize) {
    if remain == 0 {
        ans.push(cur);
        return;
    }
    let next_max = cur
        .chars()
        .map(|c| c as usize - 'a' as usize)
        .max()
        .map(|max| max + 1)
        .unwrap_or(0);
    for next in 0..(next_max + 1) {
        let next_c = ('a' as u8 + next as u8) as char;
        let mut next = cur.clone();
        next.push(next_c);
        traverse(next, ans, remain - 1);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

int main(){
 int n;
  cin >>n;
  vector<long long> l(n+1);
  
  l[0]=2;
  l[1]=1;
  
  for(int i=2;i<=n;i++) l[i]=l[i-1]+l[i-2];
  
  cout << l[n] << endl;

}

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

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

  return 0;
}

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

int main() {
	int n;
	cin >> n;
	double res = 0;
	for(int i = 1; i <= n; ++i) {
		double x;
		cin >> x;
		res += 1 / x;
	}
	cout << fixed << setprecision(10) << 1 / res;
}


Measured memory_bytes: 3736
k,n = map(int,input().split())
a = list(map(int,input().split()))
if a[0] == 0:
	dis = [k - a[n-1]]
else:
	dis = [k - a[n-1] + a[0]]
for i in range(n-1):
	dis.append(a[i+1] - a[i])
print(k - max(dis))


Measured memory_bytes: 26444
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#define maxn 200005
#define lowbit(x) x&-x

using namespace std;

struct node
{
    int x,d;
    bool operator <(const node &a)const
    {
        return x<a.x;
    }
}a[maxn];
int n,C[maxn<<1],R[maxn],dp[maxn];
map<int,int> mp;
map<int,int>::iterator it;

int query(int x)
{
    int ret=0;
    while (x)
    {
        ret=max(ret,C[x]);
        x-=lowbit(x);
    }
    return ret;
}

void add(int x,int p)
{
    while (x<=2*n)
    {
        C[x]=max(C[x],p);
        x+=lowbit(x);
    }
}

int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d%d",&a[i].x,&a[i].d);
    sort(a,a+n);
    for (int i=0;i<n;i++)
    {
        a[i].d+=a[i].x-1;
        mp[a[i].d]=1;
        mp[a[i].x]=1;
    }
    int cur=1;
    for (it=mp.begin();it!=mp.end();it++) it->second=cur++;
    for (int i=0;i<n;i++) a[i].x=mp[a[i].x],a[i].d=mp[a[i].d];
    for (int i=n-1;i>=0;i--)
    {
        int u=query(a[i].d);
        R[i]=max(i,u);
        add(a[i].x,R[i]);
    }
    dp[n]=1;
    for (int i=n-1;i>=0;i--) dp[i]=(dp[R[i]+1]+dp[i+1])%998244353;
    printf("%d\n",dp[0]);
    return 0;
}


Measured memory_bytes: 23680
import java.util.LinkedList;
import java.util.Scanner;

class Graph {
	
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for (int i = 0; i < totalVertex; i++) {
			for (int j = 0; j < totalVertex; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> endpoints = adjList.get(i);
			for (int end : endpoints) {
				adjMatrix[i][end] = 1;
			}
		}
		for (int i = 0; i < totalVertex; i++) {
			for (int j = 0; j < (totalVertex - 1); j++) {
				System.out.print(adjMatrix[i][j] + " ");
			}
			System.out.println(adjMatrix[i][totalVertex-1]);
		}
	}

}

public class Main {
	
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}

}



Measured memory_bytes: 32612
#include<bits/stdc++.h>
#define ll long long

using namespace std;
ll arr[100010];
int main()
{
	 ll n;
	scanf("%lld",&n);
	map<ll,ll> cnt;
	for(int i = 0;  i< n ; i++)
	{
		ll input;
		scanf("%lld",&input);
		if(cnt[input] == 1)
		{
			cnt[input]--;
		}
		else
		cnt[input]++;
	}
	map<ll,ll> :: iterator it;
	ll ans = 0;
	for(it=  cnt.begin() ; it!= cnt.end() ; ++it)
	{
		if(it->second == 1)
		{
			ans++;
		}
	}
	printf("%lld\n",ans);
	
}

Measured memory_bytes: 6528
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

void solve() {
	string s;
	cin >> s;
	int a = 0, b = s.size() - 1;
	while (s.at(a) != 'A')
		a++;
	while (s.at(b) != 'Z')
		b--;
	cout << b - a + 1 << endl;
}
int main() {
	solve();
	return 0;
}


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


using namespace std;

#define ll long long

int main(){
    ll n;
    cin>>n;
    ll a=1;
    ll ans=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(x==a){
            a++;
        }else{
            ans++;
        }
    }
    if(a==1){
        cout<<"-1";
    }else{
        cout<<ans;
    }
    
    
    
}

Measured memory_bytes: 256
package main

import "fmt"

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	w, b := 0, 0
	for i := 0; i < n; i++ {
		if s[i] == '.' {
			w++
		}
	}
	ans := w
	for i := 0; i < n; i++ {
		if s[i] == '#' {
			b++
		} else {
			w--
		}
		ans = min(ans, w+b)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define dd c=getchar()
inline int read(){
	int a=0,b=1,dd;
	while(!isdigit(c)){if(c=='-')b=-b;dd;}
	while(isdigit(c)){a=a*10+c-'0';dd;}
	return a*b;
}
inline void print(int x){
	static int c[23];
	static int n;
	if(x==0){
		putchar('0');
		return;
	}
	if(x<0){
		putchar('-');
		x=-x;
	}
	n=0;
	while(x>0){
		c[n++]=x%10;
		x/=10;
	}
	while(n-->0){
		putchar(c[n]+'0');
	}
}
inline void printsp(int x){
	print(x);
	putchar(' ');
}
inline void println(int x){
	print(x);
	putchar('\n');
}
#undef dd
int n,a,b;
int main(){
	n=read();
	a=read();
	b=read();
	printsp(min(a,b));
	println(max(a+b-n,0));
	return 0;
}

Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
d={}
mod=10**9+7
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y
z=0
for i in range(n):
    a,b=ab[i]
    if a==0 and b==0:
        z+=1
        continue
    if a==0:
        b=1
        y=(a,b)
        if y in d:
            d[y]+=1
        else:
            d[y]=1
        continue
    if b==0:
        a=1
        y=(a,b)
        if y in d:
            d[y]+=1
        else:
            d[y]=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    if a<0:
        a*=-1
        b*=-1
    y=(a,b)
    if y in d:
        d[y]+=1
    else:
        d[y]=1
ans=1
re={}
for t,v in d.items():
    if t in re:
        continue
    a,b=t
    c=0
    if (b,-a) in d:
        c+=d[(b,-a)]
        re[(b,-a)]=1
    if (-b,a) in d:
        c+=d[(-b,a)]
        re[(-b,a)]=1
    ans*=(2**v-1+2**c-1+1)
    ans%=mod
ans-=1
ans+=z
ans%=mod
print(ans)


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

int main(){
  long h;
  cin >> h;
  int c=0;
  while(h>0){
    h/=2;
    c++;
  }
  long ret=1;
  for(int i=0; i<c; i++)ret*=2;
  ret--;
  cout << ret;
  return 0;
}  

Measured memory_bytes: 888
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

use std::cmp::*;

fn main() {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];

    let mut h = vec![0_u64; n];
    for i in 0..n
    {
        h[i] = read();
    }

    // 値が低い順にソート
    h.sort();

    let mut maxmin_min = 1_000_000_000_u64;
    for i in 0..(n - k + 1)
    {
        maxmin_min = min(maxmin_min, h[i + k - 1] - h[i]);
    }

    println!("{}", maxmin_min);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 1;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin>>s;
    int no = 0;
    for (char c : s)
        if (c == 'o')
            no++;
    no += 15-S(s);
    cout<<(no >= 8 ? "YES\n" : "NO\n");
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include<stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int main(){
    int n,k; scanf("%d%d", &n,&k);
    int A[202020];
    rep(i,n) scanf("%d", A+i);

    rep(i,n-k){
        if(A[i] < A[i+k]) puts("Yes");
        else puts("No");
    }
}


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

const int SIZE=1e6;
int main(){
    int l,r;
    cin>>l>>r;
    r++;
    vector<int> cnt(r-l);
    vector<int> v(r-l);
    for(int i=0;i<r-l;i++) v[i]=i+l;
    vector<int> isPrime(SIZE,true);
    isPrime[0]=isPrime[1]=false;
    for(int i=2;i<SIZE;i++){
        if(isPrime[i]){
            for(int j=2*i;j<SIZE;j+=i){
                isPrime[j]=false;
            }
            for(int j=(i-l%i)%i;j<r-l;j+=i){
                while(v[j]%i==0) cnt[j]++,v[j]/=i;    
            }
        }
    }
    int res=0;
    for(int i=0;i<r-l;i++){
        if(v[i]!=1) cnt[i]++;
        if(isPrime[cnt[i]]) res++;
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 14456
#include <iostream>
#include <array>

using namespace std;

bool dislike(int ans, array<int, 10> &available)
{
  while(ans > 0)
  {
	int v = ans % 10;
	if (!available[v])
	{
	  return true;
	}
	ans /= 10;
  }
  return false;
}

int main()
{
  int n, k;
  cin >> n >> k;
  array<int, 10> available;
  fill(available.begin(), available.end(), true);
  
  for(int i = 0; i < k; i++)
  {
	int v;
	cin >> v;
	available[v] = false;
  }

  int ans = n;
  while(dislike(ans, available))
  {
	ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC104C_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var DG = Console.ReadLine().Split(' ');
            var D = int.Parse(DG[0]);
            var G = int.Parse(DG[1]);
            int[,] vs = new int[D,2];
            foreach(var i in Enumerable.Range(0,D))
            {
                var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                vs[i, 0] = x[0];
                vs[i, 1] = x[1];
            }
            var sm = new ScoreManager(D, G, vs);
            Console.WriteLine(sm.BitAllSearch());
        }
    }
    public class ScoreManager
    {
        private readonly int D;
        private readonly int G;
        private int[,] scoreTable;

        public ScoreManager(int v1, int v2, int[,] scoreTable)
        {
            D = v1;
            G = v2;
            this.scoreTable = scoreTable;
        }
        public int BitAllSearch()
        {
            int result = int.MaxValue;
            for (int i = 0; i < (1 << D); i++)
            {
                int tmpCount = 0;
                int tmpScore = 0;
                for (int j = 0; j < D; j++)
                {
                    if (((i >> j) & 1) == 1)
                    {
                        tmpCount += scoreTable[j, 0];
                        tmpScore += (j + 1) * 100 * scoreTable[j, 0] + scoreTable[j, 1];
                    }
                }
                if(tmpScore >= G)
                {
                    result = Math.Min(result, tmpCount);
                }
                else
                {
                    for (int j = 0; j < D; j++)
                    {
                        if (((i >> j) & 1) == 0)
                        {
                            if (G - tmpScore <= (scoreTable[j, 0] - 1) * (j + 1) * 100)
                            {
                                tmpCount += (G - tmpScore) / ((j + 1) * 100);
                                if((G - tmpScore) % ((j + 1) * 100) > 0)
                                {
                                    tmpCount++;
                                }
                                result = Math.Min(result, tmpCount);
                            }
                        }
                    }
                }
            }
            return result;
        }

    }

}


Measured memory_bytes: 13396
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n,k,m,t,x int
  fmt.Scan(&n,&k)
  var a []int = []int{}
  m = n
  for i:=0;i<n;i++ {
    fmt.Scan(&t)
    if t >= k {
      m--
    } else {
      a = append(a,t)
    }
  }
  n = m
  sort.Ints(a)
  t = 0
  m--
  x = n
  for m > 0 {
    t += a[m]
    if t+a[m-1] < k {
      m--
      continue
    }
    if t+a[0] >= k {
      x = 0
      break
    }
    var l,r int = 0,m-2
    for r-l > 1 {
      var c int = (l+r)/2
      if t+a[c] >= k {
        r = c
      } else {
        l = c
      }
    }
    x -= m-r
    m = r-1
  }
  fmt.Println(x)
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

int w, h;
//r, c, magareru 
int memo[101][101][2][2];
const int MOD = 100000;
int dfs(int r, int c, bool preChoku, bool preTate)
{
	if(r == h - 1 && c == w - 1)
		return 1;
	if(!inRange(h, r) || !inRange(w, c)) 
		return 0;
	if(memo[r][c][preChoku][preTate]) return memo[r][c][preChoku][preTate];

	int ret = 0;
	if(preTate)
	{
		if(preChoku)
			ret += dfs(r, c + 1, false, false);
		ret += dfs(r + 1, c, true, true);
	}
	else
	{
		if(preChoku)
			ret += dfs(r + 1, c, false, true);
		ret += dfs(r, c + 1, true, false);
	}

	return memo[r][c][preChoku][preTate] = (ret % MOD);
}

int main(void)
{
	ios::sync_with_stdio(false);
	while(cin >> w >> h && w)
	{
		memset(memo, 0, sizeof(memo));
		cout << (dfs(1, 0, true, true) + dfs(0, 1, true, false)) % MOD << endl;
	}
	return 0;
}

Measured memory_bytes: 1372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
    int n;cin>>n;  
    if(n==3){
        cout<<"2 5 63"<<"\n";
        return 0;
    }
    vector<int> res;
    res.push_back(3);
    res.push_back(9);
    int rem=n-2;
    int cur=2;
    while(rem>1){
        rem-=2;
        res.push_back(cur);
        res.push_back(cur+2);
        cur+=6;
        if(cur>=30000-2)break;
    }
    cur=15;
    while(rem>1){
        rem-=2;
        res.push_back(cur);
        res.push_back(cur+6);
        cur+=12;
        if(cur>=30000-6)break;
    }
    cur=6;
    while(rem>0){
        --rem;
        res.push_back(cur);
        cur+=6;
    }
    for(auto& val:res){
        cout<<val<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3724
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####
def main():
	N = I()
	X = LI()
	L = I()
	Q = I()
	

	r = [[0 for _ in range(100010)] for _ in range(20)]

	for i in range(N):
		r[0][i] = bisect_right(X, X[i]+L) -1

	for i in range(1,20):
		for j in range(N):
			r[i][j] = r[i-1][r[i-1][j]]


	for q in range(Q):
		a,b =LI()
		a-=1; b-=1

		if a>b: a,b = b,a
		
		ans = 0
		now = a
		for i in range(0,20)[::-1]:
			if r[i][now]<b:
				now = r[i][now]
				ans += 2**i
		print(ans+1)



if __name__ == '__main__':
	main()

Measured memory_bytes: 28308
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

S = input()
ans = 999
for i in range(len(S) - 3):
    ans = min(abs(int(S[i:i+3])-753), ans)
print(ans)


Measured memory_bytes: 9152
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (m == 1) {
			System.out.println(n);
			return;
		}
		int[][] all = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				all[i][j] = sc.nextInt();
			}
		}
		int[] idxes = new int[n];
		int min = Integer.MAX_VALUE;
		HashSet<Integer> set = new HashSet<>();
		for (int i = 0; i < m - 1; i++) {
			int[] counts = new int[m + 1];
			int max = 0;
			int maxSport = 0;
			for (int j = 0; j < n; j++) {
				int x = all[j][idxes[j]];
				counts[x]++;
				if (max < counts[x]) {
					max = counts[x];
					maxSport = x;
				}
			}
			if (min > max) {
				min = max;
			}
			set.add(maxSport);
			for (int j = 0; j < n; j++) {
				while (set.contains(all[j][idxes[j]])) {
					idxes[j]++;
				}
			}
		}
		System.out.println(min);
	}
}


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

#define whln(t) while(t--)
#define whlp(t) while(t++)


ll i,j;
int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
    //ll t ;
    //cin>>t ;
    //whln(t){
   	string a,b;
   	cin>>a>>b;
   	ll cnt = 0 ;
   	rep(i,a.length()){
   		if(a[i]!=b[i])
   			cnt++;
   	}

   	cout<<cnt<<"\n";
    //}
}

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

using namespace std;
int d[10002];
struct Edge{
    int from,to,w;
};
const int inf=1<<30;
vector<Edge> E;
vector<int> G[10002];
struct node{
    int to,w;
    friend bool operator < (const node& a, const node& b){
        return a.w>b.w;
    }
};
bool vis[10002];
int V;
void dijkstar(int start=0){
    priority_queue<node> que;
    que.push(node {start,0});
    d[start]=0;
    while(!que.empty()){
        node s=que.top();
        que.pop();
        int nowV=s.to,w=s.w;
        if(vis[nowV]) continue;
        vis[nowV]=true;
        for(int i=0;i<G[nowV].size();i++){
            Edge ee=E[G[nowV][i]];
            if(d[ee.to]>d[nowV]+ee.w){
                d[ee.to]=d[nowV]+ee.w;
                que.push(node {ee.to,d[ee.to]});
            }
        }
    }
}

int main(){
    cin>>V;
    for(int i=0;i<V;i++){
        int id,k;
        cin>>id>>k;
        vis[i]=false;
        d[i]=inf;
        while(k--){
            int out,val;
            cin>>out>>val;
            E.push_back(Edge{id,out,val});
            G[id].push_back(E.size()-1);
        }
    }
    dijkstar();
    for(int i=0;i<V;i++){
        cout<<i<<" "<<d[i]<<endl;
    }
}

Measured memory_bytes: 3456