akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

typedef pair<int,int> P; //cost, id

int n;
int t[102][102];
bool closed[102];
string label[102];
string got[102];

void solve(){
  priority_queue<P, vector<P>, greater<P> > open;
  open.push(P(0, 0));
  memset(closed, 0, sizeof(closed));

  while(!open.empty()){
    P p = open.top();
    open.pop();

    if(closed[p.second]) continue;
    closed[p.second] = true;

    if(p.second == n){
      cout << p.first << endl;
      return;
    }

    for(int i = 0; i <= n; i++){
      if(t[p.second][i] == -1) continue;
      open.push(P(p.first + t[p.second][i], i));
    }
  }
}

int main(){
  while(cin >> n){
    memset(t, -1, sizeof(t));

    for(int i = 0; i < n; i++){
      label[i] = "";
      got[i] = "";
    }

    for(int i = 0; i < n; i++){
      string op;
      cin >> op;

      if(op == "goto"){
        string s;
        cin >> s;
        got[i] = s.substr(0, s.size() - 1);
      }
      else{
        label[i] = op.substr(0, op.size() - 1);
      }
    }

    for(int i = 0; i < n; i++){
      if(got[i] == ""){
        t[i][i + 1] = 0;
      }
      else{
        t[i][i + 1] = 1;

        for(int j = 0; j < n; j++){
          if(got[i] != label[j]) continue;
          t[i][j] = 0;
          break;
        }
      }
    }

    solve();
  }
}

Measured memory_bytes: 1276
x, k, d = map(int, input().split())

kaisu = abs(x) // d

if kaisu >= k:
    print(abs(x) - k * d)
else:
    left = k - kaisu
    if left % 2 == 0:
        print(abs(x) % d)
    else:
        print(abs((abs(x) % d) - d))


Measured memory_bytes: 9172
d = int(input())
c = list(map(int,input().split()))
like=0
but=0
s=[]
last=[]
show=''
for i in range(26):
    last.append(0)
for i in range(d):
    keys=list(map(int,input().split()))
    s.append(keys)
for i in range(d):
    show+=str(s[i].index(max(s[i]))+1)
    show+='\n'
print(show)

Measured memory_bytes: 9396
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = LLONG_MAX, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    double l;
    cin >> l;
    long double ld = (l/3)*(l/3)*(l/3);
    cout << setprecision(14) << ld;
}


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

string cmd;
int m, n, x, y, dd[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}, d;

int main(){
    cin >> m >> n;
    while( m + n > 0 ){
        d = 0;
        x = 1, y = 1;
        while( getline(cin, cmd) ){
            if( cmd == "STOP" ) break;
            else if( cmd == "RIGHT" ) d = (d+1)%4;
            else if( cmd == "LEFT" ) d = (d+3)%4;
            else if( cmd[0] == 'B' || cmd[0] == 'F' ){
                int i = 9 - (cmd[0] - 'B')/4, j = 0;
                while( i < cmd.length() ){
                    j *= 10;
                    j += cmd[i] - '0';
                    i++;
                }
                x += dd[d][1] * j * (cmd[0] - 'D') / 2;
                y += dd[d][0] * j * (cmd[0] - 'D') / 2;
                if( x < 1 ) x = 1;
                if( x > m ) x = m;
                if( y < 1 ) y = 1;
                if( y > n ) y = n;
            }
        }
        cout << x << ' ' << y << endl;
        cin >> m >> n;
    }
    return 0;
}

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

/*
  >>>v
  v<<<
  >>>v
*/
struct snake {
        int h, w;
        int cury = 0, curx = 0;
        snake(int _h, int _w) : h(_h), w(_w) {}
        pair<int, int> cur() {
                return make_pair(cury, curx);
        }
        bool move() {
                if (((h & 1) && cury == h - 1 && curx == w - 1) ||
                    (!(h & 1) && cury == h - 1 && curx == 0)) {
                        return false;
                }
                if (cury % 2 == 0) {
                        if (curx == w - 1) cury ++;
                        else curx ++;
                } else {
                        if (curx == 0) cury ++;
                        else curx --;
                }
                return true;
        }
};

int main() {
        int h, w, n;
        scanf("%d%d%d", &h, &w, &n);
        vector<int> a(n);
        rep(i, n) {
                scanf("%d", &a[i]);
        }
        snake s(h, w);
        vector<vector<int>> ans(h, vector<int> (w));
        int cur = 0;
        while (true) {
                int y, x;
                tie(y, x) = s.cur();
                ans[y][x] = cur + 1;
                a[cur] --;
                if (a[cur] == 0) cur ++;
                if (!s.move()) {
                        break;
                }
        }
        rep(i, h) {
                rep(j, w) {
                        printf("%d ", ans[i][j]);
                }
                printf("\n");
        }
        return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
#define pb(i) push_back(i)
#define fs first
#define sc second
#define X first
#define Y second

#include<algorithm>
#include<functional>
#define all(X) X.begin(),X.end()
#define rep(X,Y) for(int X=0;(X)<(Y);++(X))

using namespace std;

typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;

template<class T,class S> ostream& operator<<(ostream &os,pair<T,S> &p){
  cout<<"("<<p.X<<","<<p.Y<<")";
  return os;
}

int val;

int var(char c){ 
  if(c=='T') return 1;
  if(c=='F') return 0;
  return val>>(c-'a')&1;}

pii eval(string &str,int pos=0){
  pii re;
  if(str[pos]=='-'){
    re=eval(str,pos+1);
    re.X=1-re.X;
  }else if(str[pos]=='('){
    pii l=eval(str,pos+1);
    if(str[l.Y]=='*'){
      re=eval(str,l.Y+1);
      //cout<<l<<re<<endl;
      re.X&=l.X;
    }else if(str[l.Y]=='+'){
      re=eval(str,l.Y+1);
      re.X|=l.X;
    }else{
      re=eval(str,l.Y+2);
      re.X|=1-l.X;
    }
    ++re.Y;
  }else{
    re.X=var(str[pos]);
    re.Y=pos+1;
  }
  //cout<<str<<":"<<re.X<<","<<re.Y<<endl;
  return re;
}

int main(){
  string str;
  while(cin>>str,str[0]!='#'){
    int n=str.size();
    string s,t;
    rep(i,n)if(str[i]=='='){
      s=str.substr(0,i);
      t=str.substr(i+1);
    }
    int m='k'-'a'+1,f=1;
    rep(i,1<<m){
      val=i;
      if(eval(s).X!=eval(t).X){
	/*cout<<i<<endl;
	cout<<s<<":"<<eval(s).X<<endl;
	cout<<t<<":"<<eval(t).X<<endl;*/
	f=0;
	break;
      }
    }
    cout<<(f?"YES":"NO")<<endl;
  }
}

Measured memory_bytes: 1232
# 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

N = int(input())
if N % 1000 != 0:
    print(1000 - N % 1000)
else:
    print(0)


Measured memory_bytes: 61788
#include <stdio.h>

int main(void)
{
    int first = 0, second, third;
    int i, tmp;

    for (i = 0; i < 10; i++) {
        scanf("%d", &tmp);

        if (tmp >= first) {
            third = second;
            second = first;
            first = tmp;
        } else if (tmp >= second) {
            third = second;
            second = tmp;
        } else if (tmp >= third) {
            third = tmp;
        }
    }

    printf("%d\n%d\n%d\n", first, second, third);

    return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 10000000000000000
int n,m;
ll start[100005];
ll goal[100005];
ll d[100005];
pair<ll,ll> qwe[100005];
struct edge{
	int to; ll cost;
	edge(int a,int b):to(a),cost(b){}
};
vector<edge>vec[100005];
void dijkstra1(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.pu(mp(0,0));
	fill(start,start+n,INF);
	start[0]=0;
	while(!que.empty()){
		P p=que.top(); que.pop();
		int V=p.second;
		if(start[V]<p.first) continue;
		for(int i=0;i<vec[V].size();i++){
			edge e=vec[V][i];
			if(start[e.to] > start[V]+e.cost){
				start[e.to]=start[V]+e.cost;
				que.push(mp(start[e.to],e.to));
			}
		}
	}
}
void dijkstra2(){
	priority_queue<P,vector<P>,greater<P> > que;
	que.pu(mp(0,n-1));
	fill(goal,goal+n,INF);
	goal[n-1]=0;
	while(!que.empty()){
		P p=que.top(); que.pop();
		int V=p.second;
		if(goal[V]<p.first) continue;
		for(int i=0;i<vec[V].size();i++){
			edge e=vec[V][i];
			if(goal[e.to] > goal[V]+e.cost){
				goal[e.to]=goal[V]+e.cost;
				que.push(mp(goal[e.to],e.to));
			}
		}
	}
}
vector<ll>seg[1<<18];
ll limits,limite;
void update1(vector<ll> x,int a){
	seg[a+(1<<17)-1]=x;
}
void update(){
		for(int i=(1<<17)-2;i>=0;i--){
		seg[i].resize(seg[i*2+1].size()+seg[i*2+2].size());
		merge(seg[i*2+1].begin(),seg[i*2+1].end(),seg[i*2+2].begin(),seg[i*2+2].end(),seg[i].begin());
		}
}
int sum(int a,int b,int k,int l,int r){
	if(l>b || a>r){
		return 0;
	}else if(a<=l && r<=b){
		int rp=lower_bound(seg[k].begin(),seg[k].end(),limite)-seg[k].begin();
		return seg[k].size()-rp; 
	}else{
		return sum(a,b,k*2+1,l,(l+r)/2)+sum(a,b,k*2+2,(l+r)/2+1,r);
	}
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		ll c;
		scanf("%d %d %lld",&a,&b,&c);
		vec[a].pb(edge(b,c)); vec[b].pb(edge(a,c));
	}
	dijkstra1();
	dijkstra2();
	for(int i=0;i<n;i++){
		qwe[i]=mp(start[i],goal[i]);
	}
	sort(qwe,qwe+n);
	for(int i=0;i<n;i++){
		vector<ll>er; er.pb(qwe[i].second);
		update1(er,i); start[i]=qwe[i].first;
	}
	update();
	int Q;
	scanf("%d",&Q);
	for(int i=0;i<Q;i++){
		scanf("%lld %lld",&limits,&limite);
		int eo=upper_bound(start,start+n,limits)-start;
		printf("%d\n",sum(0,eo-1,0,0,(1<<17)-1));
	}
}

Measured memory_bytes: 36592
#include<iostream>

using namespace std;

int main(){
	
	char ch[8000];
	int n,m;
	char l,r;
	
	while(1){
		cin>>n;

		if(n==0) break;

		for(int i=0;i<3000;i++){
			ch[i]='@';
		}

		for(int i=0;i<n;i++){
			cin>>l>>r;
			ch[l]=r;
		}

		cin>>m;

		for(int i=0;i<m;i++){
			cin>>l;
			if(ch[l]=='@') cout<<l;
			else cout<<ch[l];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;

string solve(){
    cin >> n;
    int curx = 0, cury = 0, curt = 0;
    bool ok = 1;
    for(int i = 0, t, x, y; i < n; ++i){
        cin >> t >> x >> y;
        if(!ok) continue;
        int need = abs(curx - x) + abs(cury - y);
        if(t - curt < need) ok = 0;
        if((t - curt - need) % 2 != 0) ok = 0;
        curx = x, cury = y, curt = t;
    }
    return ok ? "Yes" : "No";
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/extc++.h>
#include <bits/stdc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-3
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
const ll mod = 1e9 + 7;
const ll maxn = 1e3 + 10;

signed main()
{

   ll n;
   cin >> n;
   ll x = n/ 500;
    n %= 500;
    ll y = n / 5;
    cout << x * 1000 + y * 5<<endl;
}


Measured memory_bytes: 256
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--) 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    ll n;
    cin>>n;
    ll c[n+1]={0},v[n+1],k=0,p=1e9+7,i;
    for(i=1;i<=n;i++){
        cin>>v[i];
        c[i]=(c[i-1]+v[i])%p;
    }
    for(i=1;i<=n;i++){
        k=(k+(v[i]*((c[n]-c[i]+p)%p))%p)%p;
    }
    cout<<k;
}

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

string rep(string A, string B, string C)
{
  string Q = "";
  for(int i = 0; i < A.size(); i++) {
    if(A.substr(i).find(B) == 0) {
      Q += C;
      i += B.size() - 1;
    } else {
      Q += A[i];
    }
  }
  return(Q);
}

int main()
{
  int N;
  string A[10], B[10];
  string S, T;

  while(cin >> N, N) {
    for(int i = 0; i < N; i++) {
      cin >> A[i] >> B[i];
    }
    cin >> S;
    cin >> T;

    queue< string > que;
    que.push(S);
    map< string, int > v;
    v[S] = 0;
    while(!que.empty()) {
      string p = que.front(); que.pop();
      if(p.size() > T.size()) continue;
      if(p == T) break;
      for(int i = 0; i < N; i++) {
        string q = rep(p, A[i], B[i]);
        if(v.find(q) == v.end()) {
          v[q] = v[p] + 1;
          que.push(q);
        }
      }
    }
    if(v.find(T) == v.end()) {
      cout << -1 << endl;
    } else {
      cout << v[T] << endl;
    }                   
  }
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,aa[1001];
	cin>>a>>b;
    aa[1]=a+b;
	aa[2]=a-b;
	aa[3]=a*b;
	sort(aa+1,aa+3+1);
	cout<<aa[3];
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
#define vi vector<int> 
#define pii pair<int,int>
const int N = 2e5 +5;
main(){
	ios::sync_with_stdio(0);  
	cin.tie(0);
	int l,r,d;
	cin >> l >> r >> d;
	int cnt = 0;
	for (int i = l; i <= r; i++ )
		if (i % d == 0) cnt ++;
	cout << cnt;
}

Measured memory_bytes: 3580
package main

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

func exists(target int, elems []int) bool {
	n := len(elems)
	low, high := 0, n-1

	for low <= high {
		i := (high + low) /2
		if elems[i] == target {
			return true
		} else if elems[i] > target {
			high = i-1
		} else {
			low = i+1
		}
	}

	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	s := make([]int, n)
	for i := 0; i < n; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		s[i] = x
	}

	q, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	t := make([]int, q)
	for i := 0; i < q; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		t[i] = x
	}

	var count int
	for _, v := range t {
		if exists(v, s) {
			count++
		}
	}
	fmt.Println(count)
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


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

using namespace std;

int main(void) {
  int N, K;

  cin >> N >> K;

  long long MOD = pow(10, 9) + 7;

  long long pat;
  long long result = 0;

  // K個の中から、N個以上選ぶ。
  // N個選ぶ時、和が同じならはじく
  // nCk - 同じ組み合わせ

  long long mini = 0;
  for (int i = 1;i < K;i++) {
    mini += i;
  }

  long long maxi = 0;
  for (int i = 0;i < K;i++) {
    maxi += N - i;
  }

  result += (maxi-mini)+1 % MOD;

  for (int i = K;i < N+1;i++) {

    // かぶりを算出
    mini += i;//1 - Kまでの和
    maxi += N - i;

    result += (maxi - mini)+1 % MOD;
  }

  cout << result % MOD << endl;

  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

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

int X[4],Y[4];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X[0]>>Y[0]>>X[1]>>Y[1];
	int dx=-(Y[1]-Y[0]),dy=(X[1]-X[0]);
	X[2]=X[1]+dx;
	Y[2]=Y[1]+dy;
	X[3]=X[0]+dx;
	Y[3]=Y[0]+dy;
	cout<<X[2]<<" "<<Y[2]<<" "<<X[3]<<" "<<Y[3]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int N, K; cin >> N >> K;
	string s; cin >> s;
	s[K - 1] += ('a' - 'A');
	cout << s << endl;
	return 0;
}


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

constexpr int64_t mod = 998244353;

int64_t power(int64_t n, int64_t k) {
    if (k == 0) return 1;
    int64_t res = power(n * n % mod, k / 2);
    if (k % 2) res = res * n % mod;
    return res;
}

int64_t inv(int64_t n) {
    return power(n, mod - 2);
}

const int64_t inv9 = inv(9);

vector<int64_t> p;

struct S {
    int64_t a, size;
};

using F = int64_t;

S op(S l, S r) {
    return S{(p.at(r.size) * l.a + r.a) % mod, l.size + r.size};
}

S e() {
    return S{0, 0};
}

S mapping(F l, S r) {
    if (l == 0) return r;
    return S{(p.at(r.size) + mod - 1) % mod * inv9 % mod * l % mod, r.size};
}

F composition(F l, F r) {
    if (l == 0) return r;
    return l;
}

F id() {
    return 0;
}

int main() {
    int n, q;
    cin >> n >> q;
    for (int i = 0; i <= n; i++) {
        p.push_back(power(10, i));
    }
    vector<S> v(n, {1, 1});
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    for (int i = 0; i < q; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().a << "\n";
    }
}


Measured memory_bytes: 18292
import Enum

defmodule Main do
  def main do
    n = IO.read(:line) |> String.trim |> String.split(" ") |> Enum.at(0) |> String.to_integer()
    s = IO.read(:line) |> String.trim |> String.split(" ") |> Enum.map(fn x -> String.to_integer(x) end) |> Enum.sum();
    #IO.puts(n - IO.read(:line) |> String.trim |> String.split(" ") |> Enum.map(fn x -> String.to_integer(x) end) |> Enum.sum())
    if (n < s) do
      IO.puts(-1)
    else
      IO.puts(n-s)
    end
  end
end


Measured memory_bytes: 32168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

  int a, b, t;
  cin >> a >> b >> t;

  P(int((t+0.5)/a) * b);

  return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for i in range(H)]

dxy = [(0,1),(1,0),(0,-1),(-1,0)]
from collections import deque
ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] == '#': continue
        dist = [[0]*W for i in range(H)]
        visited = [[0]*W for i in range(H)]
        visited[y][x] = 1
        q = deque([(x,y)])
        while q:
            x,y = q.popleft()
            for dx,dy in dxy:
                nx,ny = x+dx,y+dy
                if not 0 <= nx < W: continue
                if not 0 <= ny < H: continue
                if visited[ny][nx]: continue
                if S[ny][nx] == '#': continue
                visited[ny][nx] = 1
                dist[ny][nx] = dist[y][x] + 1
                q.append((nx,ny))


        for i in range(H):
            ans = max(ans, max(dist[i]))
        #ans = max(ans, max(max(row) for row in dist))
print(ans)



Measured memory_bytes: 3316
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static ArrayList<Integer>[] e = null;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] S = new String[n];
		for (int i = 0; i < n; i++) {
			S[i] = sc.next();
		}
		sc.close();

		int[] cnt = new int[26];
		Arrays.fill(cnt, 1000);
		for (int j = 0; j < S.length; j++) {
			int[] tmp = new int[26];
			for (int i = 0; i < S[j].length(); i++) {
				tmp[S[j].charAt(i) - 'a']++;
			}
			for (int i = 0; i < cnt.length; i++) {
				cnt[i] = Math.min(cnt[i], tmp[i]);
			}
		}
		StringBuffer buf = new StringBuffer();
		for (int i = 0; i < cnt.length; i++) {
			for (int j = 0; j < cnt[i]; j++) {
				buf.append((char) ('a' + i));
			}
		}
		System.out.println(buf.toString());
	}
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};


int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(ALL(a));
  sort(RALL(f));

  ll ng = -1, ok = 1000000000000ll;
  while (abs(ok-ng) > 1)
  {
    ll mid = (ok+ng)/2;
    ll count = 0;
    rep(i, n) {
      if(f[i]*a[i] - mid <= 0) continue;
      ll add = (f[i]*a[i] - mid) / f[i];
      if((f[i]*a[i] - mid) % f[i] != 0) ++add;
      count += add;
    }
    if(count <= k) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  
}

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

int main()
{
	int a[12];

	for(int i = 0; i < 12; i++)
		cin >> a[i];

	sort(a, a + 12);

	if (a[0] == a[3] && a[4] == a[7] && a[8] == a[11])
		cout << "yes" << endl;
	else
		cout << "no" << endl;

	return 0;
}


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

int main() {
  int a, b, c, ans;
  cin >> a >> b >> c;
  if (a != b && b != c && c != a) {
    ans = 3;
  } else if (a == b && b == c) {
    ans = 1;
  } else {
    ans = 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define em emplace_back
#define test ll t;cin>>t;while(t--)
#define M 1000000007
#define input ll x;cin >> x
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
	string s;
	cin >> s;
	if(s[s.length()-1] == 's'){
		cout << s << "es" << endl;
	}
	else cout << s << "s" << endl;	
}


Measured memory_bytes: 3660
n,y=map(int,input().split())
for i in range(n+1):
	for j in range(n+1):
		if (y-(10000*i+5000*j))/1000\
		==n-i-j and n-i-j>=0:
			print(i,j,n-i-j)
			exit()
print(-1,-1,-1)

Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
long long extgcd(long long a, long long b, long long &x, long long &y){
  if(b==0){
    x=1; y=0;
    return a;
  }
  long long d=extgcd(b,a%b,y,x);
  y-=(a/b)*x;
  return d;
}
int main(){
  long long N;
  cin>>N;
  N*=2;
  long long M=N;
  vector<long long> d;
  for(long long i=2;i*i<=M;i++){
    if(M%i==0){
      long long k=1;
      while(M%i==0){
        M/=i; k*=i;
      }
      d.push_back(k);
    }
  }
  if(M!=1) d.push_back(M);
  long long answer=N;
  long long l=1;
  for(int i=0;i<d.size();i++) l*=2;
  for(long long i=0;i<l;i++){
    long long dev=1;
    long long judge=1;
    for(int j=0;j<d.size();j++){
      if((i%(judge*2))/judge==1) dev*=d[j];
      judge*=2;
    }
    long long x,y;
    extgcd(N/dev,dev,x,y);
    y*=-1;
    if(y>0) y%=(N/dev);
    else{
      y+=(abs(y)/(N/dev)+1)*(N/dev);
    }
    answer=min(answer,y*dev);
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  vector<long long> a(N+1,0);
  vector<int> noentry(M,0);
  for(int i=0; i<M;i++){
    cin>>noentry[i];
  }
  a[0]=1;
  if(M!=0){
    a[noentry[0]]=-1;
    for(int i=1; i<noentry.size(); i++){
      if(noentry[i]-1==noentry[i-1]){
        cout<<0<<endl;
        return 0;
      }
      a[noentry[i]]=-1;
    }
  }
  
  if(a[1]==0){
    a[1]=1;
  }
  for(int i=2; i<a.size(); i++){
    if(a[i]==-1) continue;
    if(a[i-1]==-1){ a[i] = a[i-2]; continue;}
    if(a[i-2]==-1){ a[i] = a[i-1]; continue;}
    a[i] = (a[i-1] + a[i-2])%1000000007;
  }
  cout<<a.back()<<endl;
  return 0;
}
  


Measured memory_bytes: 1408
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    let d=read::<i32>();
    println!("{}",(a-c)*(b-d))
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int n, m, x, y;
vector<int> graph[100010];
int dp[100010];
int indeg[100010];
queue<int> q;

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> x >> y;
        --x; --y;
        graph[x].push_back(y);
        indeg[y]++;
    }
    rep(i, n) {
        if (!indeg[i])
            q.push(i);
    }
    while (q.size()) {
        x = q.front(); q.pop();
        for (int y: graph[x]) {
            chmax(dp[y], dp[x] + 1);
            if (!--indeg[y]) {
                q.push(y);
            }
        }
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, dp[i]);
    }
    cout << ans << endl;
}


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

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

    int k, t; cin >> k >> t;
    vector<int> a(101);
    rep(i, t) cin >> a[i];
    // sort(a.begin(), a.end(), [](int& a, int& b){ return a > b; });
    // a[0]--;

    if (t == 1) {
        cout << k - 1 << endl;
        return 0;
    }
    else {
        string s = "";
        while (true) {
            sort(a.begin(), a.end(), [](int& a, int& b){ return a > b; });
            if (a[0] && a[1]) {
                a[0]--;
                a[1]--;
            }
            else {
                break;
            }
        }
    }
    if (a[0] != 0) a[0]--;

    cout << a[0] << endl;

    return 0;
}


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

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

  int count = 0;
  for(int i=0; i <=s.size(); i+=2){
    if(s[i]=='L'){
      count = 1;
      //cout << "No" << endl;
      break;
    }
  }
  for(int i=1; i <=s.size(); i+=2){
      if(s[i]=='R'){
        count = 1;
        //cout << "No" << endl;
        break;
        //break;
      }
  }
  if(count==1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        ArrayList<String> aa = new ArrayList<>();
        for (int i = 0; i < a.length(); i++) {
            aa.add(a.substring(i, i + 1));
        }
        String b = sc.next();
        ArrayList<String> bb = new ArrayList<>();
        for (int i = 0; i < b.length(); i++) {
            bb.add(b.substring(i, i + 1));
        }
        String c = sc.next();
        ArrayList<String> cc = new ArrayList<>();
        for (int i = 0; i < c.length(); i++) {
            cc.add(c.substring(i, i + 1));
        }
        String s = aa.get(0);
        while(true) {
            if(s.equals("a")) {
                if(aa.size() == 0) {
                    System.out.println("A");
                    return;
                }
                s = aa.get(0);
                aa.remove(0);
            } else if(s.equals("b")) {
                if(bb.size() == 0) {
                    System.out.println("B");
                    return;
                }
                s = bb.get(0);
                bb.remove(0);
            } else if(s.equals("c")) {
                if(cc.size() == 0) {
                    System.out.println("C");
                    return;
                }
                s = cc.get(0);
                cc.remove(0);
            }
        }
    }
}

Measured memory_bytes: 35312
#include <iostream>
using namespace std;
typedef long long int LLI;

int main()
{
	LLI n, sum = 0;
	cin >> n;
	LLI a;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		while( a % 2 == 0 )
		{
			sum++;
			a /= 2;
		}
	}
	cout << sum;
}

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


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

   int ans;
   for(int i = 1; i <= 9; i++) {
      if(n <= 111*i) {
         ans = 111*i;
         break;
      }
   }

   std::cout << ans << std::endl;
}


Measured memory_bytes: 256
//g++  5.4.0

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll a;
    ll res[10]={111,222,333,444,555,666,777,888,999,1111};
    cin>>a;
    for(ll i=0;i<10;++i)
    {
        //cout<<a<<" "<<res[i]<<endl;
        if(a<=res[i])
        {
            cout<<res[i];
            break;
        }   
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 1000005
using namespace std;
int n,len,cnt[M];
string s;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    cin>>len>>s;
    memset(cnt,0,sizeof(cnt));
    for(int i=2;i<len;i++){
      if(s[i]=='I'&&s[i-2]=='I'&&s[i-1]=='O')
	cnt[i]=cnt[i-2]+1;
    }
    int ans=0;
    for(int i=0;i<len;i++)
      if(cnt[i]>cnt[i+2])
	ans+=max(0,cnt[i]-(n-1));
    cout<<ans<<endl;
  }
  return 0;
}

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

class Program
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int a = input[0];
        int b = input[1];
        Console.WriteLine("{0} {1}", a * b, 2 * (a + b));
    }
}

Measured memory_bytes: 9532
S = input()
for i in range(2, len(S), 2):
    s = S[0:-i]
    mid_s = int(len(s) / 2)
    s_1 = s[:mid_s]
    s_2 = s[mid_s:]
    if s_1 == s_2:
        ans = len(s_1) * 2
        break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=(int(s[0])-48)*10+(int(s[1])-48);
  int b=(int(s[2])-48)*10+(int(s[3])-48);
  int p=0,q=0;
  if(0<=a && a<=99){
    if(1<=b&&b<=12)p++;
  }
  if(1<=a&&a<=12){
    if(0<=b && b<=99)q++;
  }
  if(p==1&&q==1)cout<<"AMBIGUOUS"<<endl;
  else if(p==1 && q!=1)cout<<"YYMM"<<endl;
  else if(p!=1 && q==1)cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;
}


Measured memory_bytes: 256
import math
import numpy as np
import queue
from collections import deque
import heapq

def cmb(n,r):
    c = 1
    for i in range(r):
        c *= (n-i)
    for i in range(r):
        c //= (i+1)
    return c

n = input()
k = int(input())
ln = len(n)
ans = 0

nn0 = 0
for i in range(ln):
    if int(n[i]) > 0:
        ans += cmb(ln-i-1,k-nn0)*(9**(k-nn0))
        nn0 += 1
        ans += (int(n[i])-1)*cmb(ln-i-1,k-nn0)*(9**(k-nn0))
    if nn0 == k:
        ans += 1
        break

print(ans)


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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, A[100001];
int cnt[100001];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    int latte = 0, exist = 0;
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
        ++cnt[A[i]];
        chmax(latte, A[i]);
    }
    int malta = 0;
    for(int i = 1; i <= latte; ++i) {
        if(cnt[i] > 1) malta += cnt[i] - 1;
        if(cnt[i] >= 1) ++exist;
    }
    cout << exist - ((malta % 2) ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
  int n ;
  cin >> n ;
  cout << a[n-1] <<endl ;
  
  
  
  return 0 ;
}



Measured memory_bytes: 256
s=list(input())
total=[]
for i in range(len(s)):
    if s[i]=="0":
        total.append(0)
    if s[i]=="1":
        total.append(1)
    if s[i]=="B":
        if len(total)==0:
            continue
        else:
            total.pop()
total_i=""
for i in range(len(total)):
    total_i+=str(total[i])
print(total_i)

Measured memory_bytes: 3060
MOD = 1000000007
N, M = gets.split.map(&:to_i)
a = []
c = []
c[0] = 1
M.times do |i|
  a[i] = gets.to_i
end

i=0
1.upto N do |j|
  # jが通れない床の場合c[j]=0
  if a[i] == j
    c[j] = 0
    i += 1
  # jが通れる床の場合c[j]=c[j-1]+c[j-2]
  else
    # 床1が通れるならc[1]=1
    if j == 1
      c[j] = 1
    else
      c[j] = (c[j-1] + c[j-2]) % MOD
    end
  end
  # 2回連続0なら今後もずっと0なので
  if c[j] == 0 and c[j-1] == 0
    # puts "#{c}"
    puts 0
    exit
  end
end

# puts "#{c}"
puts c[N]

Measured memory_bytes: 3400
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    int N, K;
    cin >> N >> K;
    int x[N];
    REP(i, N){
        cin >> x[i];
    }

    int minimum = INT_MAX;
    REP(i, N-K+1){
        if(abs(x[i + K - 1]) > abs(x[i])){
            minimum = min(abs(x[i]) + x[i + K - 1] - x[i], minimum);
        }else{
            minimum = min(abs(x[i + K - 1]) + x[i + K - 1] - x[i], minimum);
        }
    }

    cout << minimum << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
//#include<bits/extc++.h> inavilable in dev-cpp
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define me(i,k) memset(i,k,sizeof(i))
#define fr1(a,n) for(int a=1;a<=(n);a++)
#define frab(i,a,b) for(int i=(a);i<(b);i++)
#define fr0(i,n) for(int i=0;i<(n);i++)
#define trav(a,n) for(auto& a : n)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const ll modn=1000000007;

int main(){
	int ans=0,a,b;
	cin>>a>>b;
	for(int w=a;w<=b;w++){
		int ju=0;
		string a=to_string(w);
		for(int q=0,t=4;q<2,t>2;q++,t--){
			if(a[q]!=a[t])ju=1;
			if(ju)break;
		}
		if(ju==0)ans++;
	}
	cout<<ans<<'\n';
	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++)
int main(){
int N, M=0; cin >> N; long x[N], y[N]; map<pair<long, long>, int> m;
REP(i, N){ cin >> x[i] >> y[i]; }
REP(i, N-1){ for(int j=i+1; j<N; j++){
  long X=x[j]-x[i], Y=y[j]-y[i];
  if(Y==0){ X=abs(X); }else if(Y<0){ X=-X; Y=-Y; }
  pair<long, long> p=make_pair(X, Y);
  M=max(M, ++m[p]);  
} }
cout << N-M << "\n";
}

Measured memory_bytes: 3712
#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>

using namespace std;

struct P{
     double x;
    double y;
    
    double sqrt(P p){
        return std::sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y));
    }
};

int main(){
    P p1,p2;
    
    cin>>p1.x>>p1.y>>p2.x>>p2.y;
    
    printf("%lf\n",p1.sqrt(p2));
    
    
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(){
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  
  int ans = 0;
  
  if(k <= a){
    ans = k;
    k = 0;
  }else{
    ans = a;
    k -= a;
  }
  
  k -= b;
  
  if(k>0){
    ans -= k;
  }
  
  printf("%d\n",ans);
}


Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a + b >= 10) {
			System.out.print("error");
		} else {
			System.out.print(a + b);
		}
		sc.close();
	}

}


Measured memory_bytes: 20820
#include <stdio.h>
#include <limits.h>

int main(void){
	int i,j,k;
	int n,pre,max;

	while(1){
		scanf("%d",&n);
		if(n==0) break;

		int x[n];
		for(i=0;i<n;i++) scanf("%d",&x[i]);
		max = INT_MIN;
		for(k=1;k<=n;k++){
			for(i=0,pre=0;i<k;i++) pre+=x[i];
			if(max < pre) max=pre;
			for(j=1;j<=n-k;j++){
				pre = pre - x[j-1] + x[k+j-1];
				if(max < pre) max = pre;
			}
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >>N;
    if(N==22)cout<< "Christmas Eve Eve Eve"<<endl;
    if(N==23)cout<<"Christmas Eve Eve"<<endl;
    if(N==24)cout<<"Christmas Eve"<<endl;
    if(N==25)cout<<"Christmas"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll; 
typedef long double ld;
#define PB push_back
#define MP make_pair
#define F first 
#define S second 
#define P push
#define vvi vector<vector<ll> >
#define vi vector<ll>  
#define vpi vector< pair<ll,ll> >  
#define sz(a) (ll)a.size()
const ll N = 1e9 + 7 , N1 =  1e6+4;              
signed main()
{   
string t;
cin>>t;
cout<<t[0]<<t[1]<<t[2];
return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>

int n,k,s;
int dp[31][15][190];
int main(void){
	while(1){
		scanf("%d %d %d",&n,&k,&s);
		if(n+k+s==0)break;
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		for(int i=0;i<n;i++){
			for(int l=0;l<=k;l++){
				for(int j=0;j<=s;j++){
					if(dp[i][l][j]>0){
						dp[i+1][l][j]+=dp[i][l][j];
						dp[i+1][l+1][j+i+1]+=dp[i][l][j];
					}
				}
			}
		}
		printf("%d\n",dp[n][k][s]);
	}
	return 0;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    vector<int>V(N);
    long long sum=0;
    long long m=100000000;
    int count=0;
    for(int i=0;i<N;i++){
        cin>>V[i];
        if(m>abs(V[i]))m=abs(V[i]);
        if(V[i]<0)count++;
        sum+=abs(V[i]);
    }
    if(count%2==0)cout<<sum;
    else cout<<sum-2*m<<endl;
}

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

using int64 = long long;

int64 gcd(int64 a, int64 b) {
  if (b == 0)
    return a;

  int64 c = a % b;
  while (c) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

int64 lcm(int64 a, int64 b) {
  int64 g = gcd(a, b);
  return (a / g) * b;
}

int main() {
  int64 n;
  cin >> n;
  int64 l = 0;
  for (int64 i = 0; i < n; ++i) {
    int64 t;
    cin >> t;
    if (l == 0) {
      l = t;
    } else {
      l = lcm(l, t);
    }
  }
  cout << l << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	int n;
	while (std::cin >> n) {
		int c = 0;
		for (int i = 0; i <= 9; i++)
			for (int j = 0; j <= 9; j++)
				for (int k = 0; k <= 9; k++)
					for (int l = 0; l <= 9; l++)
						if (i + j + k + l == n)
							c++;
		std::cout << c << std::endl;
	}
}

Measured memory_bytes: 1160
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
use std::collections::VecDeque;
type I = usize;

fn main() {
    input!{
      h: usize,
      w: usize,
      mut aa: [chars; h]
    }
    let mut q = VecDeque::new();

    for i in 0..h {
        for j in 0..w {
            if aa[i][j] == '#' {
                q.push_back((i, j, 1));
            }
        }
    }

    let mut ans = 0;
    while q.len() > 0 {
        let (i, j, d) = q.pop_front().unwrap();
        let dirs = [
            (1, 0),
            (-1, 0),
            (0, 1),
            (0, -1),
        ];
        for &(dx, dy) in dirs.iter() {
            let x = (i as i64) + dx;
            let y = (j as i64) + dy;
            if !(x >= 0 && x < h as i64 && y >= 0 && y < w as i64) {
                continue;
            }
            let x = x as usize;
            let y = y as usize;
            if aa[x][y] == '.' {
                aa[x][y] = '#';
                q.push_back((x, y, d+1));
                ans = max(ans, d);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 31480
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	printf("%c%c%c\n",s1[0]-32,s2[0]-32,s3[0]-32);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
S = input()
# 出力
O = S[:K-1] + chr(ord(S[K-1]) + 32) + S[K:] 
print(O)

Measured memory_bytes: 2940