akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s; cin >> s;
	string t = s.substr(0, (s.size() - 1) / 2);
	string u = s.substr((s.size() + 3) / 2 - 1);
	bool flag = true;
	for (int i = 0; i < s.size() / 2; ++i)
		if (s[i] != s[s.size() - i - 1]) flag = false;
	for (int i = 0; i < t.size() / 2; ++i)
		if (t[i] != t[t.size() - i - 1]) flag = false;
	for (int i = 0; i < u.size() / 2; ++i)
		if (u[i] != u[u.size() - i - 1]) flag = false;
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    n,s=map(int,input().split())
    cnt=0
    if n==0:
        break
    for i in range(2**10):
        a=[]
        for j in range(10):
            if i>>j & 1:
                a+=[j]
        if len(a)==n and sum(a)==s:
            cnt+=1
    print(cnt)


Measured memory_bytes: 5596
while true do
  n=STDIN.gets.split[0].to_i
  break if n==0
  ar=STDIN.gets.split
  sum=0
  0.upto(n-1){|i|
    sum += ar[i].to_f }
  mean = sum / n
  sum2=0
  0.upto(n-1){|i|
    sum2 += (ar[i].to_f-mean)*(ar[i].to_f-mean) }
  sd = Math::sqrt(sum2/n)
  puts "#{sd}"
end

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

using namespace std;

int main()
{
    int N, M;

    cin >> N >> M;

    vector<vector<int>> A(N, vector<int>(M));
    vector<int> B(M);

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A.at(i).at(j);
        }
    }
    for(int i = 0; i < M; i++){
        cin >> B.at(i);
    }

    vector<int> C(N, 0);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            C.at(i) += A.at(i).at(j) * B.at(j);
        }
    }

    for(int i = 0; i < N; i++){
        cout << C.at(i) << endl;
    }

}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B >= 10)
    cout << "error" << endl;
  else
    cout << A + B << endl;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N = INT()
a = LIST()
b = LIST()

a_cnt = 0
b_cnt = 0

for i in range(N):
	if a[i] < b[i]:
		a_cnt += -(a[i]-b[i])//2
	elif a[i] > b[i]:
		b_cnt += a[i]-b[i]


if b_cnt <= a_cnt:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 11972
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;

int main(){
	int n;
	string s;

	cin >> n >> s;
	
	int ans = 0;
	for(int i=0;i+2<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define v(T) vector<T>
#define yn {puts("Yes");}else{puts("No");}
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double eps = 1e-10;

void solve() {
  int n;
  string str;
  cin >> n;
  cin >> str;
  int ans = 0;
  rep(i, n - 2)
  {
    string b = str.substr(i, 3);
    if (b == "ABC") {
      ans++;
    }
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


#define HW(h,w) (W*(h)+(w))

int solve(int H, int W, int K, vs& a) {
    vvi d(H, vi(W));
    for(int i=0,j=H-1; i<=j; ++i,--j){
        int k = (i+K-1)/K;
        rep(c,W) d[i][c] = d[j][c] = k;
    }
    for(int i=0,j=W-1; i<=j; ++i,--j){
        int k = (i+K-1)/K;
        rep(r,H) {
            d[r][i] = min(d[r][i], k);
            d[r][j] = min(d[r][j], k);
        }
    }

    int best = INT_MAX;

    ii start;
    rep(i,H) rep(j,W) {
        if (a[i][j] == 'S') { start=ii(i,j); break; }
    }
    queue<pair<ii,int>> q; // (x,y),d
    q.push(cons(start, 0));
    vvi v(H, vi(W, 0));
    while (!q.empty()) {
        ii p = q.front().first; int k = q.front().second;
        int i=p.first, j=p.second;
        q.pop();
        if (v[i][j]) continue;
        if (a[i][j] == '#') continue;
        if (k > K) break;
        v[i][j] = 1; // visited

        best = min(best, 1+d[i][j]);

        if (0 < i) q.push(cons(ii(i-1,j), k+1));
        if (i < H-1) q.push(cons(ii(i+1,j), k+1));
        if (0 < j) q.push(cons(ii(i,j-1), k+1));
        if (j < W-1) q.push(cons(ii(i,j+1), k+1));
    }
    return best;
}

int main() {
    int H, W, K; cin >> H >> W >> K;
    vs a(H); rep(i,H) cin >> a[i];
    cout << solve(H,W,K,a) << endl;
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111, TN = 44444, V = 111;
double dp[TN][V];
int t[N], v[N], vm[TN];
int n;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> n;
    int tn = 0;
    for(int i = 1; i <= n; i++) {
        cin >> t[i];
        //t[i] *= 2;
        tn += t[i];
    }
    int tnn = 0;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        for(int j = 0; j < t[i]; j++) {
            vm[tnn++] = v[i];
        }
    }
    for(int tt = 0; tt <= tn; tt++) {
        double maxi = 0;
        for(int vv = 0; vv < V; vv++) {
            if(vv > vm[tt]) {
                dp[tt][vv] = -1;
                continue;
            }
            dp[tt][vv] = -1;
            for(int nv = vv - 1; nv <= vv + 1; nv++) {
                if(nv < 0 || nv > vm[tt]) continue;
                if(tt == 0) {
                    dp[0][vv] = vv == 0 ? .25 : (vv == 1 ? .5 : -1);
                } else {
                    if(dp[tt - 1][nv] < 0) continue;
                    double cur = dp[tt - 1][nv] + (double)(vv + nv) / 2.;
                    if(nv == vv && vv < vm[tt]) {
                        cur += .25;
                    }
                    dp[tt][vv] = max(dp[tt][vv], cur);
                }
            }
            maxi = max(maxi, dp[tt][vv]);
        }
    }
    cout << fixed << setprecision(14) << dp[tn][0] << endl;
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

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

  int ans = 0;
  if(s[0] == 'R') {
    ans ++;
    if(s[1] == 'R'){
      ans ++;
      if(s[2] == 'R'){
        ans ++;
      }
    }
  }else if(s[1] == 'R'){
    ans ++;
    if(s[2] == 'R') ans ++;
  }else if(s[2] == 'R'){
    ans ++;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3624
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();
    if((a*b)%2==0) System.out.println("Even");
    else System.out.println("Odd");
  }
}

Measured memory_bytes: 22356
#include <stdio.h>

#define inf 100000
#define WHITE 1
#define BLACK 0
#define MAX 100

int d[MAX],pi[MAX],color[MAX],A[MAX][MAX];
int n,i,j,v,u;
int min,count=0;

int main(){

  int i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&A[i][j]);
    }
  }

  for(i=0;i<n;i++){
    d[i]=inf;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    min=inf;
    for(i=0;i<n;i++){
      if(color[i]==WHITE && d[i]<min){
	min=d[i];
	u=i;
      }
    }

    if(min==inf)break;
    color[u]=BLACK;
    count+=min;

    for(v=0;v<n;v++){
      if(A[u][v]==-1)continue;
      if(d[v]>A[u][v])d[v]=A[u][v];
    }
  }

  printf("%d\n",count);

  return 0;
  
}

Measured memory_bytes: 2768
#include <iostream>
using namespace std;
int main(){
   int H,W;
   int i=0;
   while(1){
       cin>>H>>W;
       if(H==0&&W==0){
           break;
       }
       for(int n=1;n<=H;n++){
           for(int i=1;i<=W;i++){
               if(n==1){
                   cout<<"#";
               }
                else if(n==H){
                   cout<<"#";
               }
               else{
                   if(i==1){
                       cout<<"#";
                   }
                   else if(i==W){
                       cout<<"#";
                   }
                   else{
                       cout<<".";
                   }
               }
           }
           cout<<endl;
       }
       cout<<endl;
   }
   return 0;
}


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

long long gcd(long long x, long long y)
{
    while(1)
    {
        if (x == 0 || y == 0)
        {
            return max(x,y);
        }
        else
        {
            if (x > y)
            {
                x = x % y;
            }
            else
            {
                y = y % x;
            }
        }
    }
}

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> A(N+1);
    for (long long i = 1; i < N+1; i++)
    {
        cin >> A[i];
    }
    vector<long long> L(N+2);
    vector<long long> R(N+2);
    L[0] = 0;
    for (long long i = 1; i < N; i++)
    {
        L[i] = gcd(L[i-1], A[i]);
    }
    R[N+1] = 0;
    for (long long i = N; i > 0; i--)
    {
        R[i] = gcd(R[i+1], A[i]);
    }
    vector<long long> M(N+1);
    M[0] = 0;
    for (long long i = 1; i <N+1; i++)
    {
        M[i] = gcd(L[i-1], R[i+1]);
    }
    sort(M.begin(), M.end());
    cout << M[N] << endl;
}

Measured memory_bytes: 6392
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int INF = 1LL << 60;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> &P){
    os << P.first;
    os << " ";
    os << P.second;
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
void insertion_sort(vector<int>& A,int N){
    REP(i,N){
        int v = A[i];
        int j=i-1;
        while(A[j]>v && j>=0){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        cout << A;
    }
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    insertion_sort(A,N);

}


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

int main(){
    int D,G;
    cin >> D >> G;
    int p[D],c[D];

    for(int i = 0;i < D;i++){
        cin >> p[i] >> c[i];
    }
    int ans = INT32_MAX;
    for(int bit = 0;bit < (1<<D);bit++){
        int Gtmp = 0;
        int anstmp = 0;
        for(int i = 0;i < D;i++){
            if(bit & (1<<i)){
                Gtmp += p[i] * (i+1)*100 + c[i];
                anstmp += p[i];
            }
        }

        int j;
        for(j = D-1;j >= 0;j--){
            if(!(bit & (1<<j))){
                break;   
            }
        }

        for(int k = 0;k < p[j];k++){
            if(Gtmp >= G){
                break;
            }
            Gtmp += (j+1)*100;
            anstmp++;
        }
        if(Gtmp >= G){
            if(ans > anstmp)ans = anstmp;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
from collections import deque
K = int(input())
q = deque(list(range(1, 10)))
for i in range(K):
    x = q.popleft()
    if x % 10 != 0:
        q.append(10*x + (x%10) - 1)
    q.append(10*x + (x%10))
    if x % 10 != 9: 
        q.append(10*x + (x%10) + 1)
print(x)

Measured memory_bytes: 11908
#include<stdio.h>

int main(void)
{
  int X,Y,A;
  A=0;
  scanf("%d%d",&X,&Y);
  if(X==1){
    A=A+300000;
  }else if(X==2){
    A=A+200000;
  }else if(X==3){
    A=A+100000;
  }
  if(Y==1){
    A=A+300000;
  }else if(Y==2){
    A=A+200000;
  }else if(Y==3){
    A=A+100000;
  }
  if(X==1&&Y==1){
    A=A+400000;
  }
  
  printf("%d",A);
  
  return 0;
}

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

int euclidean_gcd(int a, int b) {
  if(a < b) return euclidean_gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    int n=euclidean_gcd(a,b);
    vector<int> ret;
    for(int i=1 ; i<=n ; ++i)
    {
        if(n%i == 0)
        {
            ret.push_back(i);\
        }
    }
    sort(ret.begin(),ret.end());
    reverse(ret.begin(),ret.end());
    cout<<ret.at(k-1)<<endl;
    return 0;
}


Measured memory_bytes: 256
a = input()
b = input()
c = input()

turn = 'a'
while True:
    if turn == 'a':
        if a == '':
            print('A')
            exit()
        elif a[0] == 'a':
            turn = 'a'
        elif a[0] == 'b':
            turn = 'b'
        else:
            turn = 'c'
        a = a[1:]
    elif turn == 'b':
        if b == '':
            print('B')
            exit()
        elif b[0] == 'a':
            turn = 'a'
        elif b[0] == 'b':
            turn = 'b'
        else:
            turn = 'c'
        b = b[1:]
    else:
        if c == '':
            print('C')
            exit()
        elif c[0] == 'a':
            turn = 'a'
        elif c[0] == 'b':
            turn = 'b'
        else:
            turn = 'c'
        c = c[1:]


Measured memory_bytes: 9168
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	long long x,y,a;
	int cnt;
	scanf("%lld %lld",&x,&y);
	a=x;	cnt=1;
	while(a<=y)	{
		a*=2;
		cnt++;
	}
	cnt--;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.OptionalInt;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AGettingDifference solver = new AGettingDifference();
        solver.solve(1, in, out);
        out.close();
    }

    static class AGettingDifference {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), k = in.ints();
            int[] a = in.ints(n);
            int max = IntStream.of(a).max().orElse(0);
            int gcm = -1;
            for (int x : a) {
                if (x == max) {
                } else if (gcm < 0) {
                    gcm = max - x;
                } else {
                    gcm = IntMath.gcd(gcm, max - x);
                }
            }
            if (k <= max && (max - k) % gcm == 0) {
                out.println("POSSIBLE");
            } else {
                out.println("IMPOSSIBLE");
            }
        }

    }

    static final class IntMath {
        private IntMath() {
        }

        public static int gcd(int a, int b) {
            int t;
            while (a % b > 0) {
                t = b;
                b = a % b;
                a = t;
            }
            return b;
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 38876
a, b, k = map(int, input().split())
a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)
u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))
for i in sorted(list(u|v)):
  print(i)

Measured memory_bytes: 3064
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int n; 
   while(cin>>n)
   {
     int a=n/1000;
     int b=(n/100)%10;
     int c=(n/10)%10;
     int d=n%10;
     if((a==b&&b==c)||(b==c&&c==d)) cout<<"Yes"<<endl;
     else cout<<"No"<<endl; 
   }
   return 0;
 }
 

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s,r;
	int t=0, u=0,i=0;
	cin >> s;
	while (1) {
		if (i+1 > s.length())break;
		r = s.substr(i, 1);
		if (r!="A"&&r != "T"&&r != "G"&&r != "C") {
				if (i > t)t = i;
				s.erase(0, i+1);
				i = 0;
				continue;
		}
		if (i >= t)t = i+1;
		++i;
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <cstdlib>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))

int input() {
    char buf[6];
    int size = read(0, buf, 6);
    int n = 0;
    REP (i, 5) {
        n = n * 10 + buf[i] - '0';
    }
    return n;
}
void output(int n) {
    char buf[20];
    char *s = buf + sizeof buf;
    *(-- s) = '\n';
    if (not n) *(-- s) = '0';
    for (; n; n /= 10) {
        *(-- s) = (n % 10) + '0';
    }
    write(1, s, buf + sizeof buf - s);
}


__attribute__((constructor))
static void _main() {
    int a = input();
    int b = input();
    int cnt = 0;
    REP (x, 10) REP (y, 10) REP (z, 10) {
        int n = x * 10000 + y * 1000 + z * 100 + y * 10 + x;
        cnt += (a <= n and n <= b);
    }
    output(cnt);
    exit(EXIT_SUCCESS);
}

int main() {
}


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

int main(){
	/*input*/
	int n, m, x;	cin >> n >> m >> x;
	vector<int>a(m);
	for(int i = 0; i < m; i++){
		cin >> a[i];
	}
	/*calculation*/
	int left = 0, right = 0;
	for(int i = 1; i < n; i++){
		if(i < x){
			for(int j = 0; j < m; j++){
				if(i == a[j])left++;
			}
		}else if(i > x){
			for(int j = 0; j < m; j++){
				if(i == a[j])right++;
			}
		}
	}
	/*output*/
	cout << min(left, right) << endl;
}


Measured memory_bytes: 256
def calc_term(k):
    # [i] = 10 ^ i (mod k) 
    power_ten_mod_k = [1] * k
    for i in range(1, k):
        power_ten_mod_k[i] = (10 * power_ten_mod_k[i-1]) % k
    # [i] = 111...11 (1 が i + 1 個) (mod k)
    one_consec_mod_k = power_ten_mod_k[:]
    for i in range(1, k):
        one_consec_mod_k[i] = (one_consec_mod_k[i] + one_consec_mod_k[i-1]) % k
    for i in range(k):
        if one_consec_mod_k[i] == 0:
            return i + 1
    return -1
    


def main():
    k = int(input())
    if k % 7 == 0:
        k //= 7
    if k == 1:
        print(1)
    else:
        print(calc_term(k))


if __name__ == '__main__':
    main()



Measured memory_bytes: 87880
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n=I()
    ans='bon'
    n=n%10
    if n==2 or n==4 or n==5 or n==7 or n==9:
        ans='hon'
    elif n==0 or n==1 or n==6 or n==8:
        ans='pon'
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,Q; cin >> N >> Q;
	string S; cin >> S;
	S = "*"+S+"*";
	int x = 0, y = N+1;
	int l = 0, r = N+1;
	vector<char> t(Q),d(Q);
	repp(i,0,Q) cin >> t[i] >> d[i];
	repm(i,Q-1,-1){
		if(d[i] == 'L'){
			if(S[l+1] == t[i]) ++l;
			if(S[r] == t[i]) ++r;
		} else {
			if(S[l] == t[i]) --l;
			if(S[r-1] == t[i]) --r;
		}
		x = max(x,l);
		y = min(y,r);
	}
	cout << N-min(N,l+N+1-r) << endl;
	return 0;
}


Measured memory_bytes: 896
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

ll h, w, n, sr, sc;

void swich_by_val(bool isT, char val, ll &l, ll &r, ll &u, ll &d) {
    switch (val) {
        case 'L':
            if (isT) l++;
            else r = min(w - 1, r + 1);
            break;
        case 'R':
            if (isT) r--;
            else l = max(0LL, l - 1);
            break;
        case 'U':
            if (isT) u++;
            else d = min(h - 1, d + 1);
            break;
        case 'D':
            if (isT) d--;
            else u = max(0LL, u - 1);
            break;
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string s, t;
        cin >> h >> w >> n >> sr >> sc;
        cin >> s >> t;
        sr--, sc--;

        ll l = 0, r = w - 1, u = 0, d = h - 1;
        repr(i, s.size()) {
            char aoki = t[i];
            swich_by_val(false, aoki, l, r, u, d);
            char taka = s[i];
            swich_by_val(true, taka, l, r, u, d);

            if (r < l || d < u) {
                break;
            }
        }
        if (l <= sc && sc <= r && u <= sr && sr <= d) cout << "YES" << endl;
        else cout << "NO" << endl;


#ifdef MY_DEBUG
    }

#endif
    return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
#define vi vector<int>
int INF=1e8;

int main(){
    int a,b;
    while(cin>>a>>b,a+b){
        vector<vector<int> >dp(1001,vi(1001,0));
        int n; cin>>n;
        rep(i,n){
            pair<int,int> hoge; cin>>hoge.first>>hoge.second;
            dp[hoge.first][hoge.second]=-INF;
        }
        dp[1][1]=1;
        for(int i=1; i<=a;i++){
            for(int j=1;j<=b;j++){
                if(j-1>=0)dp[i][j]+=max(dp[i][j-1],0);
                if(i-1>=0)dp[i][j]+=max(dp[i-1][j],0);
            }
        }
       /* for(int i=0; i<=a;i++){
            for(int j=0;j<=b;j++)
                cout<<dp[i][j]<<" ";
            cout<<endl;
        }*/
        cout<<dp[a][b]<<endl;
    }
}

Measured memory_bytes: 6744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] L = new int[N * 2];
        for (int i = 0; i < N * 2; i++) {
            L[i] = scan.nextInt();
        }
        Arrays.sort(L);
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += L[2 * i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
}


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

const int MAX = 100001;
char p[MAX] = {0};

int main(){
	for(int i=2 ; i < MAX ; i++ ) p[i] = 1;
	for(int i=2 ; i*i < MAX ; i++ ){
		if( p[i] ){
			for(int j=i+i ; j < MAX ; j += i ){
				p[j] = 0;
			}
		}
	}
	
	int n;
	while( cin >> n , n ){
		int a, b;
		for(int i=2 ; i <= n ; i++ ){
			if( p[i-2] && p[i] ){
				a = i-2;
				b = i;
			}
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 3084
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
		public static void main(String[] args) {
			int di[]=new int[6];
			for(int i=0;i<6;i++) di[i]=scan.nextInt();
			String str=scan.next();
			for(int i=0;i<str.length();i++) {
				char ch=str.charAt(i);
				di=dice(di,ch);
			}
			System.out.println(di[0]);
		}
		public static int[] dice(int d[],char ch) {
			int d1=d[0];
			int d2=d[1];
			int d3=d[2];
			int d4=d[3];
			int d5=d[4];
			int d6=d[5];
			int a[]=new int[6];
			switch(ch) {
			case'S':
				a[0]=d5;
				a[1]=d1;
				a[2]=d3;
				a[3]=d4;
				a[4]=d6;
				a[5]=d2;
				break;
			case'W':
				a[0]=d3;
				a[1]=d2;
				a[2]=d6;
				a[3]=d1;
				a[4]=d5;
				a[5]=d4;
				break;
			case'E':
				a[0]=d4;
				a[1]=d2;
				a[2]=d1;
				a[3]=d6;
				a[4]=d5;
				a[5]=d3;
				break;
			case'N':
				a[0]=d2;
				a[1]=d6;
				a[2]=d3;
				a[3]=d4;
				a[4]=d1;
				a[5]=d5;
				break;
			
			}
			return a;
		}
}


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

typedef long long ll;
typedef pair <int, int> pii;

const int N = 3e5 + 10;

string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

int main() {
	string t;
	cin >> t;
	for (int i = 0; i < 7; i++) {
		if(t == s[i]) {
			for (int j = i + 1; j < 8; j++) {
				if(s[j] == "SUN") {
					return cout << j - i << "\n", 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int m = s / 60;
		s = s - m * 60;
		int h = m / 60;
		m = m - h * 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26188
n = int(input()) 
t = [input().split() for i in range(n)] 
o = t
t =sorted(t)

result = []

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i][0] == arr[i+1][0] and int(arr[i][1]) < int(arr[i+1][1]):
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr
_list = bubble_sort(t)

for a in _list:
    for i, item in enumerate(o):
        i+=1
        if a == item:
            result.append(i)
for r in result:
    print(r)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=0;
  vll a(26);
  rep(i,n){
    a[s[i]-'a']++;
  }
  vll b(26);
  for(int i=0;i<n;i++){
    ll cu=0;
    rep(i,26){
      if(a[i]&&b[i]) cu++;
    }
    ans=max(cu,ans);
    a[s[i]-'a']--;
    b[s[i]-'a']++;
  }
  COUT(ans);
}


Measured memory_bytes: 256
while true do
    a,o,b=gets.chomp.split(" ")
    break if o == "?"
    a = a.to_i
    b = b.to_i

    ret = case o
    when "+"
        a+b
    when "-"
        a-b
    when "/"
        a/b
    when "*"
        a*b
    end

    puts ret
end


Measured memory_bytes: 6856
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
from heapq import heappop,heappush,heapify
import numpy as np
import sys
import os
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N, M = LI()
A = LI()

A_minus = [-x for x in A]

heapify(A_minus)

pop = lambda: -heappop(A_minus)
push = lambda x: heappush(A_minus,-x)

for _ in range(M):
    # 高速に値を取り出す。O(logN)
    x = pop()
    push(x//2)
 
answer = -sum(A_minus)
print(answer)

Measured memory_bytes: 37936
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=1e3+7;
const int INF=1e9+7;
struct pir{
	int x,y;
	friend bool operator < (pir a,pir b){
		if(a.y!=b.y)return a.y<b.y;
		return a.x<b.x;
	}
};
priority_queue<pir>Q[N];
int h,w,a,b;
int f[N][N],g1[N*N],g2[N*N];

int main(){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	memset(g1,-1,sizeof(g1));
	memset(g2,-1,sizeof(g2)); 
	rep0(i,h+1)g1[i*a+(h-i)*(w-a)]=i;
	rep0(i,w+1)g2[i*b+(w-i)*(h-b)]=i;
	rep0(i,h*w+1){
		if(~g1[i]&&~g2[i]){
			rep(j,g2[i])Q[1].push((pir){j,b});
			REP(j,g2[i]+1,w)Q[1].push((pir){j,h-b});
			rep(j,g1[i]){
				rep(k,a){
					pir p=Q[j].top();
					Q[j].pop();
					f[j][p.x]=1;
					if(p.y>1)Q[j+1].push((pir){p.x,p.y-1});
				}
				while(!Q[j].empty()){
					Q[j+1].push(Q[j].top());
					Q[j].pop();
				}
			}
			REP(j,g1[i]+1,h){
				rep(k,(w-a)){
					pir p=Q[j].top();
					Q[j].pop();
					f[j][p.x]=1;
					if(p.y>1)Q[j+1].push((pir){p.x,p.y-1});
				}
				while(!Q[j].empty()){
					Q[j+1].push(Q[j].top());
					Q[j].pop();
				}
			}
			rep(j,h){
				rep(k,w)putchar('0'+f[j][k]);
				puts("");
			}
			return 0;
		}
	}
	puts("-1"); 
	return 0;
}


Measured memory_bytes: 21120
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int before_t = 0;
        int t = 0;
        int before_x = 0;
        int x = 0;
        int before_y = 0;
        int y = 0;

        int dt = 0;
        int dxy = 0;
        boolean ans_flg = true;
        for (int i = 0; i < N; i++) {
            t = sc.nextInt();
            x = sc.nextInt();
            y = sc.nextInt();

            dt = t - before_t;
            dxy = Math.abs(x - before_x) + Math.abs(y - before_y);

            if ((dt < dxy) || (dt % 2 != dxy % 2)) {
                ans_flg = false;
                break;
            }

            before_t = t;
            before_x = x;
            before_y = y;
        }
        sc.close();
        System.out.println(ans_flg ? "Yes" : "No");
    }
}

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

int main(){
  int a, b, c, ans;
  cin >> a >> b >> c;
  
  if(c-a+b < 0) ans = 0;
  else ans = c - a + b;
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define LOCAL

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iostream>

#define R 10
#define C 10000

using namespace std;

int main(void){
#ifdef LOCAL
	freopen("data.in", "r", stdin);
#endif
	int r, c;

	while(scanf("%d%d", &r, &c), r || c){
		bitset<C> map[R];
		int ans = 0;

		bool x;
		for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++){
			cin >> x;
			map[i][j] = x;

			//cout << map[i][j] << endl;
		}

		for(int i = 0; i < 1 << r; i++){
			int sum = 0;

			for(int j = 0; j < r; j++){
				if(i & (1 << j))
					map[j].flip();
			}

			for(int j = 0; j < c; j++){
				int temp = 0;
				for(int i = 0; i < r; i++){
					if(map[i][j])
						temp++;
				}

				sum += max(temp, r - temp);
			}
			ans = max(ans, sum);

			for(int j = 0; j < r; j++){
				if(i & (1 << j))
					map[j].flip();
			}
		}

		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3148
#include<iostream>
using namespace std;
int main(){
  int n,cnt=1,ans;
  cin>>n;
  int a[n];
  cin>>a[0];
  ans=a[0];
  for(int i=1;i<n;i++){
    cin>>a[i];
    if(a[i]<=ans)
      cnt++;
    ans=min(ans,a[i]);
  }
  cout<<cnt;
  return 0;
}

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

int main(){
 int N,M,l,r,c,lm,rm;
  cin>>N>>M;
  c=0;
  lm=0;
  rm=N+100;
  for(int i=0;i<M;i++){
   cin>>l>>r;
  lm=max(l,lm);
    rm=min(r,rm);
  }
  if(lm>rm){
    cout<<0<<endl;
  }
  else{
       cout<<rm-lm+1<<endl;
  }
}


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

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    //a=0が想定内
    if (a == 0)
    {
        cout << b / x + 1 << endl;
    }
    else
    {
        cout << b / x - ((a - 1) / x) << endl;
    }
}

Measured memory_bytes: 256
h,w = list(map(int, input().split()))
# 初期位置
ch,cw = list(map(int, input().split()))
# ゴール位置
dh,dw = list(map(int, input().split()))
b = [['#']*(w+2)]
for _ in range(h):
    b.append(['#'] + list(input()) + ['#'])
b.append(['#']*(w+2))

from collections import deque
q = deque()
nq = deque()
q.append((ch, cw))

visit = [[False]*(w+2) for _ in range(h+2)]

warp = 0
while q or nq:
    while q:
        y,x = q.popleft()
        if (y,x) == (dh,dw):
            print(warp)
            exit()
        if visit[y][x]:
            continue
        visit[y][x] = True
        for dx,dy in ((-1,0),(1,0),(0,-1),(0,1)):
            if b[y+dy][x+dx] == '.':
                if not visit[y+dy][x+dx]:
                    q.append((y+dy, x+dx))
            else:
                for dx in (-2,-1,0,1,2):
                    for dy in (-2,-1,0,1,2):
                        if y+dy > h or x + dx > w:
                            continue
                        if b[y+dy][x+dx] == '.':
                            if not visit[y+dy][x+dx]:
                                nq.append((y+dy, x+dx))
    q = nq
    nq = deque()
    warp += 1
    
print(-1)

Measured memory_bytes: 177968
import java.util.*;
import java.io.*;
import java.math.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
    static long mod=1000000007;
    // static int dx[]={1,-1,0,0};
    // static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
    //ArrayList<Integer> lis = new ArrayList<Integer>();
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt(),a=0;
        long ans=0,e[]=new long[n];
        for( int i=0; i<n; i++ ){
            e[i] = sc.nextLong();
        }
        while(true){
            sort(e);
            int x=-1;
                if(e[n-1]<n) break;
            long c=e[n-1]/n;
            //db(c,x,e,++a);
            ans+=c;
            for( int i=0; i<n-1; i++ ){
                e[i] += c;
            }
            e[n-1] -= c * n;
        }
        out.println(ans); 
        out.flush();
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }
}

class Pair implements Comparable<Pair>{
    int x,y,id;
    Pair(int x, int y,int id) {
        this.x=x;
        this.y=y;
        this.id=id;
    } 
    public int compareTo(Pair p){
        return p.x -     x;
    } 
}

// class Pair implements Comparable<Pair>{
//     int x,y;
//     Pair(int x, int y) {
//         this.x=x;
//         this.y=y;
//     } 
//     public int compareTo(Pair p){//descend
//         return p.x - x;
//     } 

// }

class P implements Comparable<P>{
    int diff,id1,id2;
    P(int diff, int id1,int id2) {
        this.diff=diff;
        this.id1=id1;
        this.id2=id2;
    } 
      
    public int compareTo(P p){//ascend
        return diff - p.diff;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 26436
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int mi = 200001, ans = 0;
    for (int i = 0; i < N; i++) {
      int P = sc.nextInt();
      if (P < mi) {
        ans++;
        mi = P;
      }
    }
    System.out.println(ans);
  }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = a + b;
	ll tak = min(c, d + 1);
	cout << tak + b << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
  h,w=map(int,input().split())
  a=[input() for _ in range(h)]
  seen=[[1]*w for _ in range(h)]
  from collections import deque
  todo=deque([])
  for hi,ai in enumerate(a):
    for wj,aij in enumerate(ai):
      if aij=='#':
        seen[hi][wj]=0
        todo.append((hi,wj))
  ans=-1
  while todo:
    ans+=1
    next_todo=[]
    for hi,wi in todo:
      if hi>0 and seen[hi-1][wi]:
        next_todo.append((hi-1,wi))
        seen[hi-1][wi]=0
      if hi<h-1 and seen[hi+1][wi]:
        next_todo.append((hi+1,wi))
        seen[hi+1][wi]=0
      if wi>0 and seen[hi][wi-1]:
        next_todo.append((hi,wi-1))
        seen[hi][wi-1]=0
      if wi<w-1 and seen[hi][wi+1]:
        next_todo.append((hi,wi+1))
        seen[hi][wi+1]=0
    todo=next_todo
  print(ans)
if __name__=='__main__':
  main()

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

typedef long long ll;
    
//int n, k, t;
//vector<int> v(2e5 + 100);
//vector<int> a(2e5 + 100);
//vectior<vector<int>> dp(2e5 + 100, -1);
//map<pair<int,int>,int> m;
//int rec(int indexv,int indexa,  int tt, int cnt) {
	//9if (index[
	//if (m[{indexv,indexa}]) {
		//return m[{indexv,indexa}];
	//}
	//if (tt == t) {
		//return m[{indexv,indexa}] = cnt;
	//}
	//if (tt > t) {
		//return m[{indexv,indexa}] = cnt - 1;
	//}
	//if (indexv >= n && indexa >= k) {
		//return m[{indexv,indexa}] = 0;
	//}
	//int p = 0;
	//if (indexv >= n) {
		//p += rec(indexv,indexa + 1,tt + a[indexa], cnt + 1);
	//}
	//else if (indexa  >= k) {
		//p += rec(indexv + 1,indexa,tt + v[indexv], cnt + 1);
	//}else {
		//p += max(rec(indexv + 1,indexa,tt + v[indexv], cnt + 1),rec(indexv,indexa + 1,tt + a[indexa], cnt + 1));
	//}
	//return m[{indexv,indexa}] = p;
	//return dp[
//}



int main() {    
	ll n, k, t;
	cin >> n >> k >> t;
	vector<ll> v(n + 1);
	vector<ll> a(k + 1);
	for (int i = 1 ;i <= n; ++i) {
		cin >> v[i];
		v[i] = v[i] + v[i - 1];
	}
	for (int i = 1; i <= k; ++i) {
		cin >> a[i];
		a[i] = a[i] + a[i - 1];
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (t - v[i] < 0 ) {
			continue;
		}
		//cout << "222" << " ";
		auto it = lower_bound(a.begin(),a.end(),t - v[i]);
		if (it != a.end()) {
			//--it;
			 int p = it - a.begin();
			//cout <<  p << endl;
			if (t - v[i] == *it) {
				ans = max(ans,i + p);
			}else {
				ans = max(ans, i + p - 1);
			}
		}
	}
	cout << ans << endl;
}








Measured memory_bytes: 6424
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int ar[200004],br[200004];
string s;
map<ll,ll>mp,mp1;
vector<ll>vc;
vector<ll>::iterator it;
ll  c,c1;
ll i,j,k,l,x,sum,cnt;
int main()
{
    int a=0,t;
    cin>>s;


    (s[2]==s[3]&&s[4]==s[5])?
    cout<<"Yes"<<endl:cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    if A != B and A != C:
        print(A)
        return
    if B != A and B != C:
        print(B)
        return
    if C != B and C != A:
        print(C)
        return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == '__main__':
    main()


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

int main() {
    int n; cin >> n;
    vector<int> ds(n);
    for (int i = 0; i < n; i++) { cin >> ds[i]; }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += ds[i] * ds[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
///////

int main(){
  string s,t;
  cin >> s >> t;
  int len = t.size();
  rep(i,s.size()) {
    cout << s[i];
    if(len > i) cout << t[i]; 
  }
  cout << "\n";
}

Measured memory_bytes: 256