akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define pp push_back
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,i,p,l,j,x,u;
    double k,q,r,t,y;
    string s;
     cin>>s;
     k=0;
     if(s[0]=='R' && s[1]=='R' && s[2]=='R'){
     cout<<3<<endl;
     }
     else if(s[0]=='R' && s[1]=='R' && s[2]=='S'){
     cout<<2<<endl;
     }
     else if(s[0]=='S' && s[1]=='R' && s[2]=='R'){
     cout<<2<<endl;
     }
     else if(s[0]=='R' || s[1]=='R' || s[2]=='R'){
     cout<<1<<endl;
     }
     else {
     cout<<0<<endl;
     }
}


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

int main(){
  int S;
  cin >> S;
  int h, m, s;
  h = S/3600;
  m = (S%3600)/60;
  s = S-3600*h-60*m;

  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1164
main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn . unwords . map show $ solve n

solve n = take n $ filter ((== 1) . (`mod` 5)) primes

primes :: [Int]
primes = [2, 3, 5, 7] ++ filter isPrime ns
    where
      ns = [11, 13..]
      isPrime n = all ((/= 0) . (n `mod`)) $ takeWhile ((<= n) . (^2)) primes


Measured memory_bytes: 764
n = int(input())
a = list(map(int,input().split()))
count = 0
mina = abs(a[0])
ans = 0
zflag = False

for i in range(0,n):
    if a[i] == 0:
        zflag = True
        continue
    elif a[i] < 0:
        count += 1
        a[i] *= -1
    ans += a[i]
    mina = min(mina,a[i])

if zflag == False and count%2 == 1:
    ans -= 2*mina
print(ans)

Measured memory_bytes: 14412
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r, dg,d, s, h;};
struct Node T[MAX]; // Tree

int count1 = 0, n;
int getdepth(int);
int prinr(int);
int getheight(int, int);
void walk(int);
void walk1(int);
void walk2(int);

int getdepth(int d){

  if(d == NIL){
    return count1;
  }

  else{
    count1++;
    return getdepth(T[d].p);
  }

}

int getheight(int h, int c){

  int a=0, b=0;
  
  if(T[h].r != NIL){
    a = getheight(T[h].r, c+1);
  }
  
  if(T[h].l != NIL){
    b = getheight(T[h].l, c+1);
  } 
  
  if(T[h].l == NIL && T[h].r == NIL){
    return c;
  }
  
  if(a>=b){
    return a;
  }
  return b;
  
}
  

void print(key){
  int i;
 
  printf("Preorder\n");
  walk(key);

  printf("\n");

  printf("Inorder\n");
  walk1(key);

  printf("\nPostorder\n");
  walk2(key);

  printf("\n");

}

void walk(int v){

  printf(" %d", v);
  if(T[v].l!=NIL){
    walk(T[v].l);
  }
  if(T[v].r!=NIL){
    walk(T[v].r);
  }

}

void walk1(int v){

  if(T[v].l!=NIL){
    walk1(T[v].l);
    printf(" %d", v);
  }
  else{
    printf(" %d", v);
  }

  if(T[v].r!=NIL){
    walk1(T[v].r);
  }
}

void walk2(int v){

  if(T[v].l!=NIL){
    walk2(T[v].l);

  }
  if(T[v].r!=NIL){
    walk2(T[v].r);

  }

  printf(" %d", v);

}

int prinr(int u){

  if(T[u].p == NIL){
    return 1;
  }
  
  else{
    return 0;
  }

}

main(){
  int i, j, d, v, c, l, r, key;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = T[i].dg = T[i].s = NIL;
  }

  for ( i = 0; i < n; i++ ){
    c=0;
    scanf("%d %d %d", &v, &l, &r);

    T[v].l = l;
    T[v].r = r;

    T[l].p = v;
    T[l].s = r;

    T[r].p = v;
    T[r].s = l;

    if(l == NIL){
      c++;
    } 
    if(r == NIL){
      c++;
    }

    if(c == 0){
      T[v].dg = 2;
    }
    else if(c == 1){
      T[v].dg = 1;
    }
    else{
      T[v].dg = 0;
    }

  }
 

  for(i=0; i<n; i++){
    count1 = 0;

    T[i].d  = getdepth(T[i].p);
    T[i].h = getheight(i, 0);

  }

  for(i=0; i<n; i++){
    if(prinr(i)==1){
      key = i;
      break;
    }
  }


  print(key);
  return 0;
}

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

int main(int argc, char const *argv[]) {
	string s; cin >> s;
	vector<char> v; set<char> st;
	for (auto u : s) {
		v.push_back(u);
		st.insert(u);
	}
	sort(v.begin(), v.end());
	
	if (st.size() == 2 && v[1] != v[2]) printf("Yes\n");
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	int n, k, d, A,a[101] = {0},ans=0;
	scanf("%d %d",&n,&k);
	rep(i, k) {
		scanf("%d", &d);
		rep(j, d) {
			scanf("%d", &A);
			a[A]++;
		}
	}
	Rep(i, 1, n + 1) {
		if (a[i] == 0)ans++;
	}
	printf("%d", ans);
}

Measured memory_bytes: 1724
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

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

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int m1 = -1;
    int m2 = -1;
    int index = -1;
    rep(i, n) {
        int a;
        cin >> a;
        if (m1 <= a) {
            m2 = m1;
            m1 = a;
            index = i;
        }
        else if (m1 > a && m2 < a) m2 = a;
    }
    rep(i, n) {
        if (i==index) cout << m2 << endl;
        else cout << m1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
/*
 * FileName:     C
 * CreatedDate:  2020-07-06 00:44:59 +0900
 * LastModified: 2020-07-06 21:02:07 +0900
 */

#include <stdio.h>
void print(int h, int w, int matrix[h][w]){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            printf("%d",matrix[i][j]);
        }
        printf("\n");
    }
}
int main(void){
    int h, w, k;scanf("%d%d%d", &h, &w, &k);
    int matrix[h][w], h_list[h], w_list[w];
    for(int i=0;i<h;i++)h_list[i]=0;
    for(int i=0;i<w;i++)w_list[i]=0;

    for(int i=0;i<h;i++){
        char line[w];scanf("%s", line);
        for(int j=0;j<w;j++){
            if( line[j]=='.' ){
                matrix[i][j] = 0;
            }
            else{
                matrix[i][j] = 1;
                h_list[i]++;
                w_list[j]++;
            }
        }
    }
    int sum_matrix = 0;
    for(int i=0;i<h;i++)sum_matrix += h_list[i];
//    print(h, w, matrix);



    int h_total[1<<h], w_total[1<<w], hcondition[1<<h][h], wcondition[1<<w][w];
    for(int i=0;i<1<<h;i++){
        h_total[i] = 0;
        for(int j=0;j<h;j++){
            if(1&i>>j){
                h_total[i] += h_list[j];
                hcondition[i][j] = 1;
            }
            else{
                hcondition[i][j] = 0;
            }
        }
    }
    for(int i=0;i<1<<w;i++){
        w_total[i] = 0;
        for(int j=0;j<w;j++){
            if(1&i>>j){
                w_total[i] += w_list[j];
                wcondition[i][j] = 1;
            }
            else{
                wcondition[i][j] = 0;
            }
        }
    }
    int cnt=0;
    for(int i=0;i<1<<h;i++){
        for(int j=0;j<1<<w;j++){
            int total = 0;
            total += h_total[i];
            total += w_total[j];
            for(int s=0;s<h;s++){
                for(int t=0;t<w;t++){
                    if(matrix[s][t]==1 && hcondition[i][s]==1 && wcondition[j][t]==1){
                        total--;
                    }
                }
            }
            if(sum_matrix-total==k){
                cnt++;
            }

        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1736
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Nickname
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[64];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  for (int i = 0; i < 3; i++) putchar(s[i]);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 3192
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
// mt19937 rng; rng.seed(std::chrono::high_resolution_clock::now().time_since_epoch().count());
// template<typename T> int bins(vector<T> &v, T key) {int imin=0,imax=v.size();while(imin<imax) {int imid=(imin+imax)>>1;if (v[imid]<key) imin=imid+1;else imax=imid;}return imin;}

const int mn=204;
int n;
vector<int> g[mn];
bitset<mn> seen;
int dist[mn];
int bfs(int init) {
	memset(dist,-1,sizeof dist);
	queue<int> q; seen.reset();
	seen[init]=true;
	q.push(init);
	dist[init]=0;
	int ans=0;
	while(!q.empty()) {
		int x=q.front(); q.pop();
		chkmax(ans,dist[x]);
		for (auto &y:g[x]) {
			if (!seen[y]) {
				seen[y]=true;
				dist[y]=dist[x]+1;
				q.push(y);
			} else {
				if (abs(dist[y]-dist[x])%2==0) return -1;
			}
		}
	}
	return ans+1;
}


int main(){
    cin>>n;
	for (int x=0;x<n;x++) {
		string s; cin>>s;
		for (int y=0;y<n;y++) {
			if (s[y]=='1') g[x].PB(y);
		}
	}
	int final=-1;
	for (int init=0;init<n;init++) {
		chkmax(final,bfs(init));
	}
	printf("%d\n",final);
}



Measured memory_bytes: 512
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    for(int i= 1; i<=B; i++){
      if((A*i) % B == C){
        System.out.println("YES");
        return;
      }
    }    
    System.out.println("NO");
  }
}

Measured memory_bytes: 35664
#!/usr/bin/env python3
import sys
from collections import defaultdict


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0 for i in range(W+1)] for i in range(N)]
    for i in range(N):
        for j in range(W+1):
            if j - w[i] >= 0:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
            else:
                dp[i][j] = dp[i - 1][j]
    # print(dp)
    print(max(dp[-1]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 171656
using System;

namespace ITP1_8
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string s = Console.ReadLine().Trim('\n');
                if(s == "0") break;
                int sum = 0;
                foreach(char c in s.ToCharArray())
                    sum += int.Parse(c.ToString());
                Console.WriteLine("{0}", sum);
            }
        }
    }
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll N,D; cin>>N>>D;
    vector<ll> X(N),Y(N);
    int res = 0;
    rep(i,N){
        cin>>X.at(i)>>Y.at(i);
        ll tmp = X.at(i)*X.at(i) + Y.at(i)*Y.at(i);
        if(tmp<=D*D)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

struct edge{lint to,cost;};
lint V;
vector<edge> G[200000]; // MAX_V
lint d[200000]; // MAX_V
void dijkstra(lint S){
  priority_queue<plint,vector<plint>,greater<plint>> que;
  fill(d,d+V,LINF);
  d[S]=0;
  que.push(plint(0,S));
  while(!que.empty()){
    plint p=que.top();
    que.pop();
    lint v=p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(plint(d[e.to],e.to));
      }
    }
  }
}

int main(void){
    lint N,M,S;
    cin >> N >> M >> S;
    V=N*2500;
    S=min(S,2499LL);
    lint U[M],V[M],A[M],B[M];
    rep(i,M) cin >> U[i] >> V[i] >> A[i] >> B[i];
    lint C[N],D[N];
    rep(i,N) cin >> C[i] >> D[i];
    rep(i,M){
        U[i]--,V[i]--;
        rep(j,2500){
            if(j-A[i]>=0){
                G[U[i]*2500+j].push_back({V[i]*2500+j-A[i],B[i]});
                G[V[i]*2500+j].push_back({U[i]*2500+j-A[i],B[i]});
            }
        }
    }
    rep(i,N) rep(j,2500) if(j+C[i]<2500) G[i*2500+j].push_back({i*2500+j+C[i],D[i]});
    dijkstra(S);
    for(int i=1;i<N;i++){
        lint ans=LINF;
        rep(j,2500) ans=min(ans,d[i*2500+j]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 25500
N = int(input())
T = ["3", "5", "7"]
l = T.copy()
ans = 0
while l:
    n = l.pop()
    if int(n) > N:
        continue
    if len(set(n)) == 3:
        ans += 1
    for t in T:
        l.append(n + t)
print(ans)

Measured memory_bytes: 9052
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

using state=string::const_iterator;
ll expr(state &);
ll term(state &);
ll fuct(state &);
ll expr(state &s)
{
    ll ret = term(s);
    while (true) {
        char opr = *(s++);
        if (opr == '+') {
            ll arg = term(s);
            if (ret == 2 || arg == 2)ret = 2;
            else if (ret == 1 || arg == 1)ret = 1;
            else ret = 0;
        } else if (opr == '*') {
            ll arg = term(s);
            if (ret == 0 || arg == 0)ret = 0;
            else if (ret == 1 || arg == 1)ret = 1;
            else ret = 2;
        } else {
            break;
        }
    }
    return ret;
}
ll term(state & s)
{
    if (*s == '-') {
        ++s;
        return 2 - term(s);
    } else {
        return fuct(s);
    }
}
ll fuct(state & s)
{
    if (*s == '(') {
        ++s;
        ll ret = expr(s);
        return ret;
    } else if (isdigit(*s)) {
        ll ret = *s - '0';
        ++s;
        return ret;
    }
}
int main()
{
    while (true) {
        string inp = in<string>();
        if (inp[0] != '.') {
            ll ans = 0;
            for (char p = '0'; p <= '2'; ++p) {
                for (char q = '0'; q <= '2'; ++q) {
                    for (char r = '0'; r <= '2'; ++r) {
                        string exstr = inp;
                        replace(ALL(exstr), 'P', p);
                        replace(ALL(exstr), 'Q', q);
                        replace(ALL(exstr), 'R', r);
                        auto s = exstr.cbegin();
                        ans += expr(s) == 2;
                    }
                }
            }
            cout << ans << endl;
        } else {
            break;
        }
    }
}


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

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans;
    ans = (h2 - h1) * 60 + m2 - m1 - k;
    if (ans < 0) {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <stdlib.h>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main()
{
	char c;
	cin >> c;
	
	char ans = c + 1;
	

	cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
string s,h;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
	}else{
		cout<<"win";
	}
	return 0;
}

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

int main() {
  long long n,c=0,b;
  cin >> n;
  vector <long long> a(n);
  for(int i=0; i < n ; i++) cin >> a.at(i);
  b = a.at(0);
  for(int i=0; i < n ; i++){
    if(i>0){
      if(a.at(i)  < b){
        c += b - a.at(i);
      }
      else b = a.at(i);
    }
  }
  cout << c;
  
}


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

int main(){
  int k, x;
  cin >> k >> x;
  
  int b = max(-1000000, x - k + 1);
  int t = min(1000000, x + k - 1);
  
  for(int i = b; i < t; i++){
    cout << i << " ";
  }
  cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C,D;
    cin >> A>>B>>C>>D;
    string ans="No";
    while(A>0){
        C-=B;
        if(C<=0){
            ans="Yes";
            break;
        } 
        A-=D;

    }
    cout << ans<< endl;




}

Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int X, A, B;
   cin >> X >> A >> B;
   X -= A;
   int tmp = X / B;
   X -= B * tmp;
   cout << X << endl;
   return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	if (A > B) {
		ans += 2 * A - 1;
	}
	else if (A == B) {
		ans += 2 * A;
	}
	else {
		ans += 2 * B - 1;
	}

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

Measured memory_bytes: 256
import sys
import bisect

A, B, Q = map(int, sys.stdin.readline().split())
INF = 10 ** 18
S = [-INF] + [int(sys.stdin.readline()) for _ in range(A)] + [INF]
T = [-INF] + [int(sys.stdin.readline()) for _ in range(B)] + [INF]
X = [int(sys.stdin.readline()) for _ in range(Q)]


# def binary_search(q, A):
#     l, r = 0, len(A)
#     while r - l > 1:
#         mid = (l + r) // 2
#         if q > A[mid]:
#             l = mid
#         else:
#             r = mid
#     return A[l], A[r]


def main():
    for x in X:
        ids, idt = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
        print(min(abs(s-t) + min(abs(s-x), abs(t-x)) for s in S[ids-1:ids+1] for t in T[idt-1:idt+1]))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 16128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int n5 = 0;
		int n7 = 0;
		for (int i = 0; i < 3; i++) {
			if (nextInt() == 5) {
				n5++;
			} else {
				n7++;
			}
		}

		out.println(n5 == 2 && n7 == 1 ? "YES" : "NO");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	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;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	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();
		}
	}
}

Measured memory_bytes: 20948
n = int(input())
a1 = list(map(int, input().split()))

a2 = a1[:]
a2.sort()

diff = 0
for i in range(n):
    if a1[i] != a2[i]:
        diff += 1
print('YES' if diff == 0 or diff == 2 else 'NO')


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 500005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	string s;
	cin >> s;
	int a = (s[0] - 48) * 10 + (s[1] - 48);
	int b = (s[2] - 48) * 10 + (s[3] - 48);
	if((a > 12 && b > 12) || (a == 0 && b == 0) || (a > 12 && b == 0) || (a == 0 && b > 12))
	{
		cout << "NA";
		return 0;
	}
	if(a == 0)
	{
		cout << "YYMM";
		return 0;
	}
	if(b == 0)
	{
		cout << "MMYY";	
		return 0;
	}
	if(a <= 12 && b <= 12)
	{
		cout << "AMBIGUOUS";
		return 0;
	}
	if(a <= 12)
	{
		cout << "MMYY";
	}
	else
	{
		cout << "YYMM";
	}
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

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


Measured memory_bytes: 3900
#include<bits/stdc++.h>
#define int long long
using namespace std;
char s[1000000];
int l,ans,a[200];
signed main(){
	ios::sync_with_stdio(false);
	cin>>s;l=strlen(s);
	for (int i=0;i<l;i++)
		ans+=i-a[s[i]],a[s[i]]++;
	cout<<ans+1<<endl; 
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int A, B;

    static void input()
    {
        cin = new Scanner();
        A = cin.nextInt();
        B = cin.nextInt();
    }
    static void solve()
    {
        input();
        WriteLine(Max(A + B, Max(A - B, A * B)));
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }
        
        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	for(int64 ii = 1;ii < 10;ii++)
	{
		for(int64 jj = 1;jj < 10;jj++)
		{
			if(nn == ii * jj)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

int main(void) {
  int a, b, x = 0, ans = 0;

  if(scanf("%d %d", &a, &b) == 1);

  x = b - a;
  while(x) {
    ans += x;
    x--;
  }

  ans = ans - b;

  printf("%d", ans);

  return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[310];
ll X, S;

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

  rep( i, N ) {
    std::cin >> A[i];

    if( i >= 2 )
      X ^= A[i];
    else
      S += A[i];
  }

  if( (S-X)&1 || S-X < 0 ) {
    puts("-1");

    return 0;
  }

  ll D = (S-X)/2;
  ll Y = 0;

  if( (D&X) ) {
    puts("-1");

    return 0;
  }

  repd( b, 41 ) if( X>>b&1 ) {
    if( (D^(Y^(1ll<<b))) <= A[0] )
      Y ^= (1ll<<b);
  }

  if( !(D^Y) || A[0]-(D^Y) < 0 ) {
    puts("-1");

    return 0;
  }

  std::cout << A[0]-(D^Y) << std::endl;

  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main () {
  int a,b;
  scanf("%d",&a);
  b=0;
  if (a%10==1){
    b=b+1;
  }
  if ((a/10)%10==1){ 
    b=b+1;
  }
  if (a/100==1){
    b=b+1;
  }
  printf("%d",b);
  return 0;
}
    

Measured memory_bytes: 1680
import java.util.Scanner;
import java.math.BigInteger;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		
		int n;
		BigInteger a,b,c;
		n = cin.nextInt();
		while(n-- > 0)
		{
			a = cin.nextBigInteger();
			b = cin.nextBigInteger();
			c = a.add(b);
						
			if(c.toString().length()>80)
			{
				System.out.println("overflow");			
			}
			else
			{
				System.out.println(c);
			}
		}
	}
}

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

const int mod=998244353;
const int MAXN=400010;
using ll = long long;
ll po10[MAXN], popsum[MAXN];

using PII = pair<int,int>;
using PIII = pair<PII,int>;
set<PIII> st;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    po10[0] = 0;
    po10[1] = 1;
    for (int i=2;i<=n;i++) {
        po10[i] = po10[i-1]*10%mod;
    }
    popsum[0] = 0;
    for (int i=1;i<=n;i++) {
        popsum[i]=(popsum[i-1]+po10[i])%mod;
    }
    ll ans=popsum[n];
    st.insert({{1,n},1});
    queue<PIII> q;
    for (int i=1;i<=m;i++) {
        int l,r,x;
        scanf("%d%d%d",&l,&r,&x);
        l = n+1-l;
        r = n+1-r;
        swap(l,r);
        PIII p{{l,r},x};
        auto it = st.upper_bound(p);
        if (it==st.end() || it->first.first > l) {
            --it;
        }
        int xb = it->second;
        int lb = it->first.first;
        int rb = it->first.second;
        while (lb <= r) {
            // printf("%d %d %d\n",lb,rb,xb);
            int low = max(l,lb);
            int high = min(r,rb);
            ans+=(popsum[high]-popsum[low-1]+mod)%mod*((ll)x-xb+mod)%mod;
            ans%=mod;
            it = st.erase(it);
            if (lb<=l-1) q.push({{lb,l-1},xb});
            if (r+1<=rb) q.push({{r+1,rb},xb});
            if (it==st.end()) break;
            xb = it->second;
            lb = it->first.first;
            rb = it->first.second;
        }
        while (!q.empty()) {
            st.insert(q.front());
            q.pop();
        }
        st.insert(p);
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 19416
#include<bits/stdc++.h>
using namespace std;
int jl[100100];
int main()
{
    int n;
    cin>>n;;
    vector<int> v;
    bool flag=false;
    for(int i=0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
        if(i!=0&&tmp!=v[i-1])
        {
            flag=true;
        }
    }
    if(!flag)
    {
        return 0*printf("%d\n",n/2);
    }
    map<int,int> mp1,mp2;
    for(int i=0;i<v.size();i+=2)
    {
        mp1[v[i]]++;
    }
    for(int i=1;i<v.size();i+=2)
    {
        mp2[v[i]]++;
    }
    vector<pair<int,int> >v1,v2;
    for(auto i=mp1.begin();i!=mp1.end();++i)
    {
        v1.push_back(make_pair(i->second,i->first));
    }
    for(auto i=mp2.begin();i!=mp2.end();++i)
    {
        v2.push_back(make_pair(i->second,i->first));
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    if(v1[v1.size()-1].second!=v2[v2.size()-1].second)
    {
        return 0*printf("%d\n",n-(v1[v1.size()-1].first+v2[v2.size()-1].first));
    }
    if(v1[v1.size()-1].first+v2[v2.size()-2].first>v1[v1.size()-2].first+v2[v2.size()-1].first)
    {
        return 0*printf("%d\n",n-(v1[v1.size()-1].first+v2[v2.size()-2].first));
    }
    else
    {
        return 0*printf("%d\n",n-(v1[v1.size()-2].first+v2[v2.size()-1].first));
    }
    return 0;
}


Measured memory_bytes: 6520
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int N;
vector<int> dist;
vector<vector<int> > to;
void dfs(int v,int p=-1,int d=0){
  dist[v]=d;
  rep(i,to[v].size()){
    int nv=to[v][i];
    if(nv==p) continue;
    dfs(nv,v,d+1);
  }
}
vector<int> calcdist(int s){
  dist=vector<int>(N);
  dfs(s);
  return dist;
}

int main(){
  cin >> N;
  int u,v; cin >> u >> v;
  u--; v--;
  to.resize(N);
  rep(i,N-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> distT=calcdist(u);
  vector<int> distA=calcdist(v);
  int mx=0;
  rep(i,N){
    if(distT[i]<distA[i]){
      chmax(mx,distA[i]);
    }
  }
  int ans=mx-1;
  cout << ans << endl;
}

Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    rep(i,n){
        int h;
        cin >> h;
        if(h<k) continue;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll pre[10][10];
    ll pos[10][10];
    for(ll i=0;i<10;i++) {
    	for(ll j=0;j<10;j++) {
    		pre[i][j] = 0;
    		pos[i][j] = 0;
    	}
    }
    ll prec[n+1][10];
    ll posc[n+1][10];
    for(ll j=0;j<10;j++) {
    	prec[0][j] = 0;
    	posc[n-1][j] = 0;
    }
    for(ll i=0;i<n;i++) {
    	for(ll j=0;j<10;j++) {
    		if(i!=0)prec[i][j] = prec[i-1][j];
    	}
    	prec[i][s[i]-'0']++;
    }
    for(ll i=n-1;i>=0;i--) {
    	for(ll j=0;j<10;j++) {
    		if(i!=n-1)posc[i][j] = posc[i+1][j];
    	}
    	posc[i][s[i]-'0']++;
    }
    ll ans = 0;
    ll check[1001] = {0};
    for(ll i=1;i<n-1;i++) {
    	for(ll g = 0 ; g < 10; g++ ) {
    		for(ll j = 0; j < 10 ; j++) {
    			if(prec[i-1][g] > 0 && posc[i+1][j] > 0) {
    				ll thisnum = g*100 + (s[i]-'0')*10 + j;
    				// cout << thisnum << "\n";
    				if(check[thisnum] == 0) {
    					check[thisnum] = 1;
    					// cout << thisnum << "\n";
    					ans++;
    				}
    			}
    		}
    	}
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4992
n = int(input())
h = list(map(int, input().split()))
a = 1
for j in range(1, n):
    flag=False
    for i in range(0, j):
        if h[i] <= h[j]:
            flag = True
        else:
            flag = False
            break
    if flag:
        a = a + 1

print(a)

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

using namespace std;

int main(){
	int n;
	cin>>n;
	int a[100000+1]={0};
	long long s=0;
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		a[b]++;
		s+=b;	
	}
	int q;
	cin>>q;
	while(q--){
		int b,c;
		cin>>b>>c;
		s+=a[b]*(c-b);
		a[c]+=a[b];
		a[b]=0;
		cout<<s<<endl;
	}
	
}



Measured memory_bytes: 4008
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	long A, B, K;
	cin >> A >> B >> K;

	if( A < K ) {
		K -= A;
		A = 0;
	}
	else {
		A -= K;
		K = 0;
	}

	if( B < K ) {
		B = 0;
	}
	else {
		B -= K;
	}

	cout << A << ' ' << B << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const ll MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);

    while (1) {
        int n,m;
        cin >> n >> m;
        if (n==0 && m==0) break;
        vector<int> c(m),x(n);
        rep(i,m) cin >> c[i];
        rep(i,n) cin >> x[i];
        sort(c.begin(),c.end());
        vector<vector<int>> dp(n+1,vector<int>(256,1e9));
        dp[0][128]=0;
        rep(i,n) {
            rep(j,256) {
                if (dp[i][j]<1e9) {
                    rep(k,m) {
                        int nx=j+c[k];
                        if (nx<0) nx=0;
                        if (nx>255) nx=255;
                        dp[i+1][nx]=min(dp[i+1][nx],dp[i][j]+(x[i]-nx)*(x[i]-nx));
                    }
                }
            }
        }
        int ans=1e9;
        rep(i,256) ans=min(ans,dp[n][i]);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 23764
//https://atcoder.jp/contests/abc166/tasks/abc166_a
//2020-05-03

#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num, numa, numb, numc, numd;
    string str , str1, str2, str3;
    cin >> str1;
    str = "ABC";
    if(str1==str){
        cout << "ARC\n";
    }else{
        cout << "ABC\n";
    }
    return 0;
}

Measured memory_bytes: 3132
def bite_eating(n, l):

    count = 0
    ans = 10**5
    ansmin = 0

    for i in range(1, n+1):
        if ans > abs(i+l-1):
            ans = abs(i+l-1)
            ansmin = i+l-1
        count += (i+l-1)

    return count - ansmin
def main():
    n, l = map(int, input().split())
    print(bite_eating(n, l))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <stdio.h>

int main(){

    char str[3];
    int count = 0;

    scanf("%s", str);

    if(str[0] == 'R'){

        count++;

        if(str[1] == 'R'){
            count++;

            if(str[2] == 'R'){
                count++;
            }
        }

    }else{
        if(str[1] == 'R'){

            count++;

            if(str[2] == 'R'){
                count++;
            }

        }else{

            if(str[2] == 'R'){
                count++;
            }
        }
    }

    printf("%d", count);

    return 0;
}

Measured memory_bytes: 1680
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>

int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld %ld", &n, &m);

    std::vector<std::pair<long, long> > aa(m);
    long i;
    for(i=0; i<m; i++) {
        scanf("%ld %ld", &(aa[i].second), &(aa[i].first));
    }
    std::sort( aa.begin(), aa.end());

    long count = 0;
    long save = 0;
    for(i=0; i<m; i++) {
        if(aa[i].second > save ) {
            count ++;
            save = aa[i].first - 1;
        }
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int n;
	static int ans = 0;

	static int edge[][];
	static boolean used[];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);

		edge = new int[n][n];
		used = new boolean[n];

		for (int i = 0; i < m; i++) {
			str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]) - 1;
			int b = Integer.parseInt(str[1]) - 1;

			edge[a][b] = 1;
			edge[b][a] = 1;
		}
		used[0] = true;
		dfs(0, 0);
		System.out.println(ans);
	}

	static void dfs(int s, int add) {
		if (add == n - 1) {
			ans++;
		} else {
			for (int i = 0; i < n; i++) {
				if (edge[s][i] == 1 && !used[i]) {
					used[i] = true;
					dfs(i, add + 1);
					used[i] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 20692
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int& x : h) {
    cin >> x;
  }
  
  vector<long long> dp(n, inf);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(0, i - k); j--) {
      dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    }
  }
  cout << dp[n - 1] << '\n';        
  return 0;
}

Measured memory_bytes: 1408
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;

ll sum(ll x) {
	ll ans = 0;
	if (x % 4 == 1 || x % 4 == 2) {
		ans = 1;
	}
	else {
		ans = 0;
	}
	rep(i, 40) {
		if (x >> (i + 1) & 1&&x%2==0) {
			ans +=pow(2,(i+1));
		}
	}
	return ans;
}

int main() {
	ll a, b;
	cin >> a >> b;
	cout << (sum(b)^sum(a-1)) << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 384
#include <stdio.h>
#define DEBT 100000
#define INTEREST 0.05
#define ROUNDDEV 1000
int main(void){
    int w,i;
    long int result = DEBT;
    scanf("%d",&w);
    for(i=0;i<w;i++){
        result*=(INTEREST+1.0);
        //printf("R*0.9=%ld\n",ROUNDDEV-ROUNDDEV/10);
        //printf("r+R*0.9=%ld\n",result+(ROUNDDEV-ROUNDDEV/10));
        //printf("(r+R*0.9)/R=%ld\n",(result+(ROUNDDEV-ROUNDDEV/10))/ROUNDDEV);
        //printf("((r+R*0.9)/R)*R=%ld\n",((result+(ROUNDDEV-ROUNDDEV/10))/ROUNDDEV)*ROUNDDEV);
        //if(result%ROUNDDEV!=0){
        //    result+=ROUNDDEV-(result%ROUNDDEV);
        //}
        result=((result+(ROUNDDEV-1))/ROUNDDEV)*ROUNDDEV;
        //printf("r=%ld\n",result);
    }
    printf("%ld\n",result);
    
    return 0;
}

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

#define int             long long int
#define ff              first
#define ss              second
#define pb              push_back

#define vi              vector <int>
#define pii             pair <int, int>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))

#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl



template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;


void solve()
{
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int cnt = 0;
	loop(i, 0, n)
	{
		if (s[i] != t[i]) cnt++;
	}
	cout << cnt << endl;

	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



	int t = 1;
	//cin >> t;
	while (t--) solve();

	return 0;
}

Measured memory_bytes: 3808
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()

ans = 10**18
for i in range(2**(N-1)):
    r = 0
    color = 1
    height = A[0]
    for j in range(N-1):
        if A[j+1] > height:
            color += 1
            height = A[j+1]
        else:
            if (i >> j) & 1:
                color += 1
                r += height-A[j+1]+1
                height += 1
    if color >= K:
        ans = min(ans,r)

print(ans)


Measured memory_bytes: 73428