akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, n, m, now, ans, t;
  scanf("%lld%lld", &n, &m);
  ll a[n], sum[n + 1];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]);
  sort(a, a + n);
  sum[0] = 0;
  for(i = 0; i < n; ++i) sum[i + 1] = sum[i] + a[i];
  pair<ll, ll> b[m];
  for(i = 0; i < m; ++i) {
    scanf("%lld%lld", &b[i].second, &b[i].first);
    now = upper_bound(a, a + n, b[i].first) - a;
    if(b[i].second > now) b[i].second = now;
  }
  sort(b, b + m, greater< pair<ll, ll> >());
  ans = sum[n];
  now = 0;
  for(i = 0; i < m; ++i) {
    t = upper_bound(a, a + n, b[i].first) - a;
    if(t <= now) break;
    if(now + b[i].second > t) {
      ans += -(sum[t] - sum[now]) + b[i].first * (t - now);
      now = t;
    } else {
      ans += -(sum[now + b[i].second] - sum[now]) + b[i].first * (now + b[i].second - now);
      now += b[i].second;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 3328
from collections import deque

r,c = [int(x) for x in input().split()]
sy,sx = [0,0]
gy,gx = [r-1,c-1]
m = []
for _ in range(r):
    m.append(list(input()))

##########################################

q = deque()
d = [[-1]*c for i in range(r)]

q.append([sy,sx])
d[sy][sx] = 0
while q:
    v = q.popleft()
    if v == [gy,gx]:
        break
    for i in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny = v[0]+i[0]
        nx = v[1]+i[1]
        if 0<=ny<r and 0<=nx<c and m[ny][nx] == "." and d[ny][nx] == -1:
            q.append([ny,nx])
            d[ny][nx] = d[v[0]][v[1]] + 1

##########################
count = 0
for i in m:
    for j in i:
        if j==".":
            count += 1
if d[gy][gx] == -1:
    print(-1)
else:
    ans = count - d[gy][gx] - 1
    print(ans)




Measured memory_bytes: 3316
#include <iostream>
using namespace std;
 int main(){
     int r,c;
   	 cin>>r>>c;
	 int a[r][c];
	 int n;
	 int w;
	 int x=0;
	 for(int i=0;i<r;i++){
		 for(int j=0;j<c;j++){
			 cin>>a[i][j];
		}
	}
	 for(int k=0;k<r;k++){
		  for(int l=0;l<c;l++){
		      cout<<a[k][l]<<" ";
		      n+=a[k][l];
		     }
		  cout<<n<<endl;
		  n=0;
		 }
		 for(int m=0;m<c;m++){
			 for(int o=0;o<r;o++){
			     w+=a[o][m];
			    }
			  cout<<w<<" ";
			  x+=w;
              w=0;
         }
			 cout<<x<<endl;
 return 0;
 }


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main()
{
	int r, w, h, x, y;
	cin >> w >> h >> x >> y >> r;
	if ((r <= x && x <= (w - r)) && (r <= y && y <= (h - r)))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        double x = Math.PI;
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = r * r * x;
        double length = 2 * r * x;

        System.out.printf("%f %f", area, length);
        System.out.printf("\n");
    }
}


Measured memory_bytes: 28288
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int coprime(int);

int main(){
	int i,j,k,l,n;
	char ch[256],ch2[256];
	scanf("%d",&n);
	fgets(ch,256,stdin);
	for(i = 0;i < n;i++){
		fgets(ch,255,stdin);
		for(j = 0;j < 26;j++){
				for(k = 0;k < 26;k++){
					strcpy(ch2,ch);
					for(l = 0;l < strlen(ch);l++) {
						if(islower(ch[l])) {
							ch2[l] = ((ch[l] - 'a') * j + k) % 26 + 'a';
						}
					}
					if(strstr(ch2,"this") || strstr(ch2,"that")){
						printf("%s",ch2);
						goto loopend;
					}
				}
		}
		loopend:
		continue;
	}
	return 0;
}

int coprime(int n){
	int flag = 1;
	if(n % 2 == 0 || n % 13 == 0) flag = 0;
	return flag;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> sumE(N + 1), sumW(N + 1);
  sumE[0] = 0, sumW[0] = 0;
  for (int i = 1; i <= N; i++) {
    sumE[i] = sumE[i - 1] + (S[i - 1] == 'E');
    sumW[i] = sumW[i - 1] + (S[i - 1] == 'W');
  }
  int ans = N - 1;
  for (int i = 0; i < N; i++) {
    ans = min(ans, sumW[i] + sumE[N] - sumE[i + 1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3076
N = int(input())

dsts = []
for x in range(1, N + 1):
    if x ** 2 > N: break
    #
    if N % x == 0:
        dsts.append((x, N // x))

MY_INF = 10 ** 18
ans = MY_INF
for dst_x, dst_y in dsts:
    ans_tmp = abs(dst_x - 1) + abs(dst_y - 1)
    ans = min(ans, ans_tmp)

print(ans)

Measured memory_bytes: 3352
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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();
		List<Integer> list = new ArrayList<Integer>();
		list.add(a + b);
		list.add(a - b);
		list.add(a * b);
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(0));
		sc.close();
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N = 5e5 + 1;
int in[N],val[N],n;
long long ans;
vector<int>g[N];
int main(){
	//freopen("input.txt","r",stdin);
	string s;
	cin >> s;
	n = s.size();
	for(int i = 0;i < s.size();i++)
		if(s[i] == '>'){
			in[i]++;
			g[i + 1].push_back(i);
		}
		else{
			in[i + 1]++;
			g[i].push_back(i + 1);
		}
	queue<int>q;
	n++;
	for(int i = 0;i < n;i++)
		if(!in[i])
			q.push(i);
	while(!q.empty()){
		int x = q.front();
		ans+=val[x];
		q.pop();
		for(auto i : g[x]){
			val[i] = max(val[i],val[x] + 1);
			if(!--in[i])q.push(i);
		}
	}
	printf("%lld\n",ans);
}

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

int main() {
  int N, K, ans=0;
  cin >> N >> K;
  
  rep (i, N) {
    int x;
    cin >> x;
    
    if (x <= K/2) ans += x;
    else ans += K-x;
  }
      
  cout << ans*2 <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        string S;
        cin >> S;
        mp[S]++;
    }
    int ma = 0;
    for(auto& p:mp) ma = max(ma,p.second);
    for(auto& p:mp) if(ma==p.second) cout << p.first << "\n";
}

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

using namespace std;

#define int long long

const int N = 1e6;
int n, s;
vector<int> vec;

bool check(int b, int num) {
    int cnt = 0;
    while(num) {
        cnt += num % b;
        num /= b;
    }
    return cnt == s;
}

signed main () {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    if(n == s) return cout << n + 1, 0;

    for (int i = 1; i * i <= n - s; ++i) {
        if((n - s) % i == 0) {
            if(check(i + 1, n)) vec.push_back(i + 1);
            if(check((n - s) / i + 1, n)) vec.push_back((n - s) / i + 1);
        }
    }

    sort(vec.begin(), vec.end());
    if(vec.size()) cout << vec[0];
    else cout << -1;

    return 0;
}


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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var t0 = decimal.Parse(Console.ReadLine());
        decimal currentGdc = t0;
        decimal currentLcm = t0;
        for (int i=1;i<N;++i)
        {
            var T = decimal.Parse(Console.ReadLine());
            var a = currentLcm < T ? T : currentLcm;
            var b = a == currentLcm ? T : currentLcm;
            currentGdc = GetGcd(a, b);
            currentLcm = currentLcm < T ? T / currentGdc * currentLcm : currentLcm / currentGdc * T;
        }
        Console.WriteLine(currentLcm);
    }
    //最大公約数を出す
    static decimal GetGcd(decimal a, decimal b)
    {
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <cstring>

using namespace std;

const int MAXH = 105;
const int MAXW = 105;
char tiles[MAXH][MAXW];
int dir[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
int vis[MAXH][MAXW];
int cnt;
int w,h;

void dfs(int x,int y)
{
    for(int i=0;i<4;++i){
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if(xx<0||xx>=h||yy<0||yy>=w)
            continue;
        if(tiles[xx][yy]==tiles[x][y]&&!vis[xx][yy]){
            vis[xx][yy] = 1;
            dfs(xx,yy);
        }
    }
}

int main()
{
    int sx,sy;
    while(cin>>h>>w){
        if(w==0||h==0) break;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                cin>>tiles[i][j];
            }
        }
        memset(vis,0,sizeof(vis));
        cnt = 0;
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                if(!vis[i][j]){
                    vis[i][j]=1;
                    dfs(i,j);
                    ++cnt;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,m;

int main(){
  cin>>n>>m;
  if(n==1&&m==1){
    cout<<1<<endl;
  }else if(n==1||m==1){
    cout<<n*m-2<<endl;
  }else{
    cout<<n*m-n*2-m*2+4<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var N = (int)vals[0];
        var K = vals[1];
        var Q = vals[2];
        var A = new int[Q];
        for (int i = 0; i < Q; i++)
        {
            A[i] = int.Parse(Console.ReadLine());
        }

        var points = new int[N + 1];
        foreach (var a in A)
        {
            points[a]++;
        }

        var result = points.Skip(1).Select(v => (v + K - Q > 0) ? "Yes" : "No").ToArray();
        Console.WriteLine(string.Join(Environment.NewLine, result));
    }
}

Measured memory_bytes: 20448
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

int x;
int F(int n) {
	if (n >= 0) {
		return n / x + 1;
	}
	else {
		return 0;
	}
}

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

	int a, b;
	cin >> a >> b >> x;

	cout << F(b) - F(a - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  string S; cin >> S;
  int K; cin >> K;
  for (int i = 0; i < K; ++i) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << S[K-1] << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    ll n, m, ans = 0;
    vector<P> v;
    cin >> n >> m;
    v.resize(n);
    REP(i,n){
        ll a, b;
        cin >> a >> b;
        v.push_back({-a, b});
    }
    SORT(v);
    priority_queue<ll> que;
    for(int i=m-1;i>=0;i--){
        while(!v.empty() && abs(v.back().first)+i<=m){
            que.push(v.back().second);
            v.pop_back();
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7012
import java.util.*;

class Main {
	static final long M = 998244353;

	static class BIT {
		private int n;
		private int[] a;

		BIT(int _n) {
			n = _n + 1;
			a = new int[n];
		}

		public int sum(int i) {
			int s = 0;
			for (int index = i; index > 0; index -= (index & -index)) {
				s += a[index];
			}
			return s;
		}

		public void add(int i, int x) {
			for (int index = i; index < n; index += (index & -index)) {
				a[index] += x;
			}
		}
	}


	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] xy = new int[n][2];
		NavigableMap<Integer, Integer> hx = new TreeMap<>();
		NavigableMap<Integer, Integer> hy = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			xy[i][0] = sc.nextInt();
			xy[i][1] = sc.nextInt();
			hx.put(xy[i][0], 0);
			hy.put(xy[i][1], 0);
		}

		int index = 0;
		for (Integer i : hx.keySet()) hx.put(i, index++);
		index = 0;
		for (Integer i : hy.keySet()) hy.put(i, index++);

		for (int i = 0; i < n; i++) {
			xy[i][0] = hx.get(xy[i][0]);
			xy[i][1] = hy.get(xy[i][1]);
		}

		Arrays.sort(xy, (a, b) -> Integer.compare(a[0], b[0]));
		long[] a = new long[n];
		long[] b = new long[n];
		long[] c = new long[n];
		long[] d = new long[n];
		BIT bit = new BIT(n + 1);
		for (int i = 0; i < n; i++) {
			int y = xy[i][1] + 1;
			a[i] = bit.sum(y);
			b[i] = i - a[i];
			bit.add(y, 1);
		}
		long[] t = a;
		a = c;
		c = t;

		t = b;
		b = d;
		d = t;
		bit = new BIT(n + 1);
		for (int i = n - 1; i >= 0; i--) {
			int y = xy[i][1] + 1;
			a[i] = bit.sum(y);
			b[i] = (n - 1 - i) - a[i];
			bit.add(y, 1);
		}

		long answer = 0;
		for (int i = 0; i < n; i++) {
			//System.out.printf("%d %d %d %d\n", a[i], b[i], c[i], d[i]);
			answer = (answer + f(a[i], b[i], c[i], d[i])) % M;
		}
		System.out.println(answer);
	}

	private static long pow(long x, long n, long M) {
		long a = 1;
		while (n > 0) {
			if ((n & 1) == 1) a = (a * x) % M;
			x = (x * x) % M;
			n >>= 1;
		}
		return a;
	}

	private static long f(long a, long b, long c, long d) {
		long result = 0;
		long[] abcd = {a, b, c, d};
		long[] o = new long[4];
		long[] ox = new long[4];
		for (int i = 0; i < 4; i++) {
			ox[i] = pow(2, abcd[i], M);
			o[i] = ox[i] - 1;
		}
		result += (((((ox[0] * o[1]) % M) * o[2]) % M) * ox[3]) % M;
		result += (((((o[0] * ox[1]) % M) * ox[2]) % M) * o[3]) % M;
		result -= (((((o[0] * o[1]) % M) * o[2]) % M) * o[3]) % M;
		if (result < 0) result += M;
		result += (((((ox[0] * ox[1]) % M) * ox[2]) % M) * ox[3]) % M;
		return result % M;
	}
}


Measured memory_bytes: 209200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mo 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second

ll arr[81];
int main()
{
    ll n;cin >> n;
    vector <int> v1;
    for(int i=1;i<=n;i++)
    {
        cin >> arr[i];
    }
    ll dp[n+1]={0};
    dp[0] = 1000;
    dp[1] = 1000;
    for(ll i=2;i<=n;i++)
    {
        dp[i] = max(dp[i],dp[i-1]);
        for(ll j=1;j<i;j++)
        {
            if(arr[j]>=arr[i]) continue; 
            ll stocks = dp[j]/arr[j];
            dp[i] = max(dp[i],dp[j]-stocks*arr[j]+stocks*arr[i]); 
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3596
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        string inpt = Reader.ReadLine();
        string target = Reader.ReadLine();

        string ans = "No";
        for (int i = 0; i < inpt.Length; i++) {
            if(inpt[i] != target[0]) {
                continue;
            }
            string tmp = inpt.Substring(i) + inpt.Substring(0, i);
            if(tmp.Substring(0, target.Length).Equals(target)) {
                ans = "Yes";
                break;
            }
        }
        Console.WriteLine(ans);


    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


vanceknowledgetoad
advance


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 8780
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
int main()
{ 
    IOS;
    ll p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e,lcm=1,ans=0;
        cin>>a;
        cout<<(a+1)%2<<endl;
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    rep (i, n) cin >> vec[i];
    sort(vec.begin(), vec.end());
    int ans = 0;
    for (int i = 0; i < k; i++) {
        ans += vec[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int s,hour,min,sec;
    cin >> s;
    sec = s % 60;
    s /= 60;
    min = s % 60;
    hour = s / 60;
    cout << hour <<":"<< min <<":"<< sec << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

const int maxn = 1e5 + 5;
vector<pair<int,int> >g[maxn];
int ans[maxn];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    s = " " + s;
    int dp[s.size() + 5][2];
    memset(dp, 0x3f, sizeof(dp));
    dp[0][1] = 1;
    dp[0][0] = 0;
    f1(s.size() - 1) {
        int x = s[i] - '0';
        if (x != 9) {
            dp[i][1] = min(dp[i][1], dp[i-1][0] + x + 1);
        }
        dp[i][1] = min(dp[i][1], dp[i-1][1] + 9 - x);
        dp[i][0] = min(dp[i][0], dp[i-1][1] + 10 - x);
        dp[i][0] = min(dp[i][0], dp[i-1][0] + x);
    }
    cout << dp[s.size()-1][0] << '\n';
}

Measured memory_bytes: 11464
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main ( void )
{
	int n, k, m;
	while ( cin >> n >> k >> m, n | k | m ) {
		vector<int> v( n );

		for ( int i = 0; i < n; ++i ) {
			v[i] = i + 1;
		}

		int pos = m - 1;

		while ( v.size() != 1 ) {
			v.erase( v.begin() + pos-- );
			if ( pos < 0 ) {
				pos = v.size() - 1;
			}
			pos = ( pos + k ) % v.size();
		}

		cout << v[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
/* ***********************************************
Author        :axp
Created Time  :2016/9/11 20:05:52
TASK		  :A.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
int n,m;
int T;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,w[300001],c;
    string s;
    cin>>n>>s;
    c=n;
    w[0]=0;
    for(int i=1;i<=n;i++){
        w[i]=w[i-1];
        if(s[i-1]=='W'){
            w[i]++;
        }
        
    }
    
    for(int i=0;i<n;i++){
        c=min(c,w[i]+n-1-i-w[n]+w[i+1]);
    }
    cout<<c<<endl;
    
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int s=0;
  for(int i=0;i<n;i++){
    s+=vec[i];
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if(vec[i]*(4*m)>=s)cnt++;
  }
  if(cnt>=m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>

#define ALL(v) (v).begin(), (v).end()

using namespace std;

int sum(int a)
{
  int res = 0;
  while (a)
  {
    res += a % 10;
    a = a / 10;
  }
  return res;
}

int main()
{
  int n;
  int res = 1e9;
  cin >> n;
  for (int i = 1; i < n; i++)
  {
    int a = i;
    int b = n - i;
    int temp = 0;
    temp += sum(a);
    temp += sum(b);
    res = min(res, temp);
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
#define print(x) cout<<'>'<<#x<<':'<<x<<endl;
#define F first
#define S second
const int mod=1000000007;

void solve(){
    int x[3][3];
    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            cin>>x[i][j];
        }
    }int n;cin>>n;
    bool arr[3][3]={false};
    int b[n];
    for (int i=0;i<n;i++){
        cin>>b[i];
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                if (x[j][k]==b[i]){
                    arr[j][k]=true;
                }
            }
        }
    }
    if ((arr[0][0]&&arr[0][1])&&arr[0][2])cout<<"Yes";
    else if ((arr[1][0]&&arr[1][1])&&arr[1][2])cout<<"Yes";
    else if ((arr[2][0]&&arr[2][1])&&arr[2][2])cout<<"Yes";
    else if ((arr[0][0]&&arr[1][0])&&arr[2][0])cout<<"Yes";
    else if ((arr[0][1]&&arr[1][1])&&arr[2][1])cout<<"Yes";
    else if ((arr[0][2]&&arr[1][2])&&arr[2][2])cout<<"Yes";
    else if ((arr[0][0]&&arr[1][1])&&arr[2][2])cout<<"Yes";
    else if ((arr[0][2]&&arr[1][1])&&arr[2][0])cout<<"Yes";
    else cout<<"No";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] redField = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            if (i % 2 == 0) {
                redField[i][0] = true;
            } else {
                for (int j = 0; j < w - 1; j++) {
                    redField[i][j] = true;
                }
            }
        }
        boolean[][] blueField = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            if (i % 2 == 1) {
                blueField[i][w - 1] = true;
            } else {
                for (int j = 1; j < w; j++) {
                    blueField[i][j] = true;
                }
            }
        }
        StringBuilder blueOut = new StringBuilder();
        StringBuilder redOut = new StringBuilder();
        for (int i = 0; i < h; i++) {
            char[] arr = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if (arr[j] == '#') {
                    redField[i][j] = true;
                    blueField[i][j] = true;
                }
                if (redField[i][j]) { 
                    redOut.append("#");
                } else {
                    redOut.append(".");
                }
                 if (blueField[i][j]) { 
                    blueOut.append("#");
                } else {
                    blueOut.append(".");
                }
            }
            redOut.append("\n");
            blueOut.append("\n");
        }
        System.out.println(redOut);
        System.out.print(blueOut);
    }
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    char str[222];
    cin>>str;
    int n=strlen(str);
    for(int i=n-2; i; i-=2){
        if(strncmp(str, str+i/2, i/2)==0){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

#define mod 1000000007

int n, s[100005], cur = -1;

int res = 1;

int main(){
	scanf("%d", &n);
	FI(i, 1, n){
		int x;
		scanf("%d", &x);
		if(x - cur >= 2){
			cur += 2;
			s[i] = cur;
		}
		else{
			cur = s[i] = x;
		}
	}
	
//	FI(i, 1, n) printf("%d%c", s[i], i == n ? '\n':' ');
	
	int p = n;
	FI(i, 1, n) if(s[i] <= (i - 1) * 2){
		p = i;
		break;
	}
	FI(i, 1, n){
//		printf("i = %d: current # choice = %d\n", i, p);
		res = 1LL * res * (p - i + 1) % mod;
		while(p < n && s[p] > (p - i - 1) * 2) p++;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 640
use std::io;
use std::str::FromStr;
fn main() {
    let stdin = io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    s.pop();
    let mut abc : Vec<i32> = Vec::new();
    let it = s.trim().split_whitespace();
    for arg in it {
        abc.push(i32::from_str(&arg).expect("e"));
    }
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];
    println!("{}", if b - a == c - b {"YES"} else {"NO"});
}

Measured memory_bytes: 4352
#include <stdio.h>
int main(){
  while(1==1){
   int n =0;
   int count =0;
   scanf("%d",&n);
   if(n == 0){break;}
   int sum = 0;
   int m[100004] = {0};
   for(int i = 0;i < n;i++){
     scanf("%d",&m[i]);
     sum = sum + m[i];
   }
   for(int j = 0; j < n;j++){
     if(n*m[j] <= sum){
       count++;
     }
   }
   printf("%d\n",count);
  }
return 0;
}



Measured memory_bytes: 2236
/*********************************************************************
* AUTHOR : ANSHU KUMAR                                               *
* ABOUT :  IT DOESN'T MATTER HOW SLOW I GO, AS LONG AS I NEVER STOP  *
* INSTITUTION : IEM KOLKATA                                          *
**********************************************************************/

//try to think at least 30min(with full concentration).

#include <bits/stdc++.h>

using namespace std;

#define int             long long
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define MOD             1000000007
#define INF             1e18
#define PI              3.1415926535897932384626433832795
#define sp(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define endl            '\n'
#define da(arr,type,n)  type *arr=new type[n];


/********** Euclidean Algorithm for GCD **********/
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



/********** Fast Power Exponentiation ***********/
int power(int a, int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res % MOD * a % MOD) % MOD;
		a = (a % MOD * a % MOD) % MOD;
		b >>= 1;
	}
	return res;
}



/********** FAST I/O ************/
void fastIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}



/********** PROGRAM START ***********/

int32_t main()
{
	fastIO();
	int A, B;
	cin >> A >> B;
	cout << A*B << endl;
	return 0;
}

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

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

Measured memory_bytes: 256
N,T = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key = lambda x:x[0])
dp = [0]*(T+1)
for A,B in AB:  #それぞれの食事について
    for i in range(T-1,-1,-1):
        if A+i>=T:  #時間オーバー
            dp[T] = max(dp[T], dp[i]+B)
        else:   #時間内
            dp[i+A] = max(dp[i+A],dp[i]+B)
#これが成り立つのはAB.sortしているから
print(max(dp))


Measured memory_bytes: 47080
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];

  sort(a.begin(),a.end());
  
  Int ans=0;
  for(Int i=0;i<n;i++) ans+=abs(a[i]-a[n/2])*2;
  
  if(n&1){
    ans-=min(a[n/2+1]-a[n/2],a[n/2]-a[n/2-1]);
  }else{
    ans-=a[n/2]-a[n/2-1];
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N,K;cin >> N >> K;
    map<int,int> A;
    rep(i,N){
        int a;
        cin >> a;
        A[a]++;
    }
    priority_queue<int, vector<int>, greater<int>> B;
    for(auto p : A){
        //cout << p.first << " - " << p.second << endl;
        B.push(p.second);
    }
    int ans = 0;
    while (B.size() > K) {
        ans += B.top();
        B.pop();
    }
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 10748
def main():
    
    n=int(input())
    h=list(map(int,input().split()))

    dp=[9999999999]*n
    dp[0]=0
    dp[1]=abs(h[1]-h[0])

    for i in range(2,n):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

    print(dp[n-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 13924
#include <vector>
#include <cstdio>
using namespace std;

int belong[100000];
int value[100000];

int update(int idx) {
    if (idx == belong[idx])
        return idx;
    else {
        int t = belong[idx];
        belong[idx] = update(belong[idx]);
        value[idx] += value[t];
        return belong[idx];
    }
}

bool merge(int l ,int r, int d) {
    int lb = update(l);
    int rb = update(r);
    if (lb == rb) {
        if (value[r] != (value[l]+d)) return false;
    } else {
        belong[rb] = lb;
        value[rb] = value[l] + d - value[r];
    }
    return true;
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        belong[i] = i;
        value[i] = 0;
    }
    while(m--) {
        int l, r, d;
        scanf("%d %d %d", &l, &r, &d);
        l--; r--;
        if (!merge(l, r, d)) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define kMaxIndex 2

int main(void){
    /* input */
    int inputIntArr[kMaxIndex + 1] = {0};
    std::cin >> inputIntArr[0] >> inputIntArr[1] >> inputIntArr[2];
    
    /* bubble sort */
    int index = 1;
    int loopCnt = kMaxIndex;
    int tmp = 0;
    while(loopCnt > 0)
    {
        if(inputIntArr[index-1] > inputIntArr[index])
        {
            tmp = inputIntArr[index-1];
            inputIntArr[index-1] = inputIntArr[index];
            inputIntArr[index] = tmp;
        }
        
        ++index;
        if(index > kMaxIndex) 
        {
            index = 1;
            --loopCnt;
        }
    }
    
    std::cout << inputIntArr[0] << " " << inputIntArr[1] << " "  << inputIntArr[2] << std::endl;
    
    return 0;
}

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    
    if ( (10*g+b)%4 == 0 ) {
        cout << "YES"<< endl;
    }else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        if(a==c)
        {
            printf("YES\n");
        }
        else if(a+b>c&&a<c)
        {
            printf("YES\n");
        }
        else
            printf("NO\n");
    }
}


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

s = S()
a,b,c,d = s[0],s[1],s[2],s[3]

def calc(i,j,k):
    if i == 0:
        i = 1
    else:
        i = -1
    if j == 0:
        j = 1
    else:
        j = -1
    if k == 0:
        k = 1
    else:
        k = -1       
    return int(a) + int(b)*i + int(c)*j + int(d)*k,i,j,k

def pm(s):
    if s == 0:
        return "+"
    else:
        return "-"
    
for i in range(2):
    for j in range(2):
        for k in range(2):
            if calc(i,j,k)[0] == 7:
                print(a+pm(i)+b+pm(j)+c+pm(k)+d+"=7")
                exit()

Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

ll n,av;
vector<ll> a;
ll dp[60][3000][60];

ll f(int i, int su, int cnt){
	if(i== n){
		return(su == cnt*av);
	}
	if(dp[i][su][cnt] != -1){
		return dp[i][su][cnt];
	}

	ll ans = 0;
	ans += f(i+1,su,cnt);
	ans += f(i+1,su+a[i],cnt+1);
	dp[i][su][cnt] = ans;
	return ans;
}


int main(){
	fastread;
	cin>>n>>av;
	a.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<f(0,0,0)-1<<endl;

	return 0;
}


Measured memory_bytes: 84608
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

int f[6][6];

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    loop(i, n) {
        loop(j, m) {
            char c; cin >> c;
            f[i][j] = c == '#';
        }
    }
    int ans = 0;
    loop(mask, (1 << (n + m))) {
        int calc = 0;
        loop(i, n) {
            if (mask & (1 << i))
                continue;
            loop(j, m) {
                if (mask & (1 << (j + n)))
                    continue;
                calc += f[i][j];
            }
        }
        ans += calc == k;
    }
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

int main()
{       
        string S;

        cin >> S;

        if(S.at(2) == S.at(3) && S.at(4) == S.at(5))
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }
        return 0;
}       

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
 
#define str string
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(a,b);
  int cou=0;
  FOR(i,a,b+1){
    str s = to_string(i);
    str ss = s;
    reverse(ALL(ss));
    cou+=(ss==s);
  }
  COUT(cou);




  return 0;
}


Measured memory_bytes: 256
A,B,C,K = map(int, input().split())
limit = K
count = 0

while limit > 0:
    #カードの枚数が選ぶ枚数以上の場合
    if 0 < A and limit <= A:
        count += 1 * limit
        limit = 0
        A -= limit
        break
    #カードの枚数が選ぶ枚数未満の場合
    elif 0 < A:
        count += 1 * A
        limit -= A
        A = 0
    
    if 0 < B and limit <= B:
        count += 0 * limit
        limit = 0
        B -= limit
        break
    elif 0 < B:
        count += 0 * B
        limit -= B
        B = 0
    
    if 0 < C and limit <= C:
        count += -1 * limit
        limit = 0
        C -= limit
        break
    elif 0 < C:
        count += -1 * C
        limit -= C
        C = 0

print(count)


Measured memory_bytes: 9224
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;

int count(int s) {
    int a = 0;
    while (s > 0) { if (s & 1) a++; s /= 2; }
    return a;
}

int check(int *c, int n, int s) {
    map<int, vector<int> > mp;
    for (int i = 0; i < n; i++) mp[c[i]].push_back(i);
    vector<int> perm;
    for (auto &p : mp) {
        int v = p.first;
        vector<int> v0, v1;
        for (int j : p.second) {
            if (((s >> j) & 1) ^ (j & 1)) v1.push_back(j);
            else v0.push_back(j);
        }
        if (perm.size() % 2) swap(v0, v1);
        if (v0.size() != (1 + p.second.size()) / 2) return -1;
        for (int i = 0; i < v0.size(); i++) {
            perm.push_back(v0[i]);
            if (i < v1.size()) perm.push_back(v1[i]);
        }
        
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i+1; j < n; j++)
            if (perm[i] > perm[j]) ans++;
    return ans;
}

int main() {
    int n; cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int ans = 1<<30;
    for (int s = 0; s < 1<<n; s++) {
        if (count(s) % 2) continue;
        int c[n];
        for (int i = 0; i < n; i++) c[i] = ((s >> i) & 1) ? b[i] : a[i];
        // cerr << "s = " << s << endl;
        // cerr << "c: "; for (int i = 0; i < n; i++) cerr << c[i] << ' '; cerr << endl;
        int r = check(c, n, s);
        if (r >= 0) {
            // cerr << "ok " << s << endl;
            ans = min(ans, r);
        }
    }
    cout << (ans == 1<<30 ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}


int n = 3010, maxn = 3000;
ll fac[3010], inv[3010];


void init(){
    fac[0]=1;
    REP(i, 1, maxn+1)fac[i]=1ll*fac[i-1]*i%mod;
    inv[maxn]=pow(fac[maxn], mod-2, mod);
    REPR(j,maxn-1,-1)inv[j]=1ll*inv[j+1]*(j+1)%mod;
}



int main() {
    sonic();
    map<char, string> mp;
    R mp['a'] >> mp['b'] >> mp['c'];
    char pre = 'a', nxt;
    while(mp[pre]!=""){
        nxt=mp[pre][0];
        mp[pre]=mp[pre].substr(1, mp[pre].length());
        pre=nxt;
    }
    pre-=32;
    co(pre);
}


Measured memory_bytes: 3668
#include<stdio.h>
int main(void)
{
int H,W,i,j;
	while(1)
	{
	scanf("%d %d",&H,&W);
		if(H==0&&W==0)
		{
			break;
		}
	for(i=0;i<H;i++)
	{
		for(j=0;j<W;j++)
		{
			printf("#");
		}
		printf("\n");
	}
		printf("\n");
}
	return 0;
}

Measured memory_bytes: 572