akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 55
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
struct P{int x,y,t;};
queue<P> q;
int n,m;
char c[maxn][maxn];
int d[maxn][maxn];
main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%s",c[i]);
    int cnt=0;
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)
        if(c[i][j]=='.')cnt++;
    q.push({0,0,1});
    while(!q.empty())
    {
        P t=q.front();q.pop();
        if(d[t.x][t.y])continue;
        d[t.x][t.y]=t.t;
        for(int i=0;i<4;i++)
        {
            int a=t.x+dx[i],b=t.y+dy[i];
            if(a<0 || a>=n || b<0 || b>=m)continue;
            if(c[a][b]=='#' || d[a][b])continue;
            q.push({a,b,t.t+1});
        }
    }
    /*
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)printf("%d ",d[i][j]);puts("");
    }
    */
    if(!d[n-1][m-1])return 0*puts("-1");
    printf("%d\n",cnt-d[n-1][m-1]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,A[102][102],ans,fo,o;
int main() {
	scanf("%d %d",&n,&m);
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			scanf("%d",&A[i][j]);
		}
		for(int j=1; j<i; j++) {
			fo=0;
			for(int k=1; k<=m; k++) {
				fo+=(A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
			}
			o=sqrt(fo);
			if(o*o==fo)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<int>> mat(h, vector<int>(w, 0));
	{
		string temp;
		for (int i = 0; i < h; ++i) {
			cin >> temp;
			for (int j = 0; j < w; ++j) {
				if (temp[j] == '#') {
					mat[i][j] = 1;
				}
			}
		}
	}

	vector<int> existIchigoVec(h, 1);
	int currentNum = 1;
	vector<vector<int>> ret(h, vector<int>(w, 0));
	for (int i = 0; i < h; ++i) {
		bool existIchigo = false;
		for (int j = 0; j < w; ++j) {
			ret[i][j] = currentNum;
			if (mat[i][j] == 1) {
				++currentNum;
				existIchigo = true;
			}
		}

		if (existIchigo) {
			if (mat[i][w - 1] == 0) {
				for (int j = w - 1; 0 <= j; --j) {
					if (ret[i][j] == currentNum) {
						ret[i][j] = currentNum - 1;
					}
				}
			}
		}
		else {
			existIchigoVec[i] = 0;
		}
	}

	for (int i = 0; i < h; ++i) {
		if (existIchigoVec[i] == 0) {
			if (i == 0) {
				for (int j = 1; j < h; ++j) {
					if (existIchigoVec[j] == 1) {
						ret[i] = ret[j];
						break;
					}
				}
			}
			else {
				ret[i] = ret[i-1];
			}
		}
	}

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cout << ret[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

#define faster     ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define read       freopen("input.txt", "r", stdin);
#define write      freopen("output.txt", "w", stdout);
#define endd        '\n'
#define ll         long long
#define sq(a)      ((a) * (a))

using namespace std;
int main()
{
      faster;
      double pi = 2 * acos(0.0);
      ll int n,i,t,j,k,m=0,a=0,b=0,c=0,d=0,p,q,r,x=250,y=10,z,count=0;
      string str;
      cin>>str;
      n=str.size();
      for(i=0;i<n;i++){
            if(i%2==0 && str[i]=='1')a++;
            else  if(i%2==1 && str[i]=='0')a++;
            else if(i%2==0 && str[i]=='0')b++;
            else  if(i%2==1 && str[i]=='1')b++;
      }
      cout<<n-max(a,b);
      return 0;
}
//Sheikh Tafsir Rahman
//CSE IUT

Measured memory_bytes: 3788
ai = lambda: list(map(int,input().split()))

n,k = ai()
a = ai()

sa = [0]
for i in range(n):
    sa.append(sa[-1]+a[i])

spa = [0]
for i in range(n):
    spa.append(spa[-1]+max(a[i], 0))

ans = -float('inf')
for i in range(n-k+1):
    ans = max(ans, max(0, sa[i+k]-sa[i]) + spa[i] + (spa[n]-spa[i+k]))
print(ans)


Measured memory_bytes: 16556
n = int(input())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = [int(j) for j in input().split()]
a.sort()
b.sort()
if n % 2 == 1:
    print(b[n//2] - a[n//2] + 1)
else:
    print(b[n//2] + b[n//2-1] - a[n//2] - a[n//2-1] + 1)

Measured memory_bytes: 25364
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 1e5 + 10;
int a[MAXN], dp[MAXN], p[MAXN];
void solve() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i], dp[i] = 2e9;
    dp[1] = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; i + j <= n && j <= k; ++j) {
            int res = dp[i] + abs(a[i + j] - a[i]);
            if(res < dp[i + j]) {
                dp[i + j] = res;
                p[i + j] = i;
            }
        }
    }
    cout << dp[n];
    /// << '\n';
    ///while(n != 0) cout << n << ' ', n = p[n];
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 4780
#include <stdio.h>
int main ()
{
    int h,w,x,y;
    while(1){
        scanf("%d %d",&h,&w);
        if (h==0 && w==0) break;
        for(x=0;x<w;x++){
            printf("#");
        }
        printf("\n");
        for(y=1;y<=h-2;y++){
             printf("#");
             for(x=1;x<=w-2;x++){
                  printf(".");
              }
              printf("#\n");
        }
                for(x=0;x<w;x++){
            printf("#");
        }
        printf("\n\n");
    }
    return 0;
}


Measured memory_bytes: 1964
#include <iostream>

using namespace std;

int main(void)
{
    int R;

    cin >> R;

    if(R<1200){
        cout << "ABC" << endl;
    }

    else if(R<2800){
        cout << "ARC" << endl;
    }

    else{
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/* ***************************************************
 *	Author        :mutinner
 *	Created Time  :Sat 05 May 2018 08:07:02 PM CST
 *	File Name     :20:07:02.cpp
 *************************************************** */

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

int main() {
	vector< int > cnt( 3 );
	for ( auto& it : cnt ) {
		cin >> it;
	}
	int k;	cin >> k;
	sort( cnt.begin(), cnt.end(), []( int x, int y ) {
			return x > y;
			});
	for ( int i = 0; i < k; i++ ) {
		cnt[ 0 ] *= 2;
	}
	int sum = 0;
	for ( auto it : cnt ) {
		sum += it;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
def cmb(n,r,mod=10**9+7):
    if r<0 or r>n:return 0
    return g1[r]*g2[r]%mod


mod=10**9+7
n,a,b=map(int,input().split())
k=max(a,b)
g1=[1,n]
g2=[1,1]
inverse=[0,1]

for i,j in enumerate(range(n-1,((n-k+1)-1),-1)):
    i=i+2
    g1.append((g1[-1]*j)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

print((2**n-1-cmb(n,a)-cmb(n,b))%mod)

Measured memory_bytes: 287572
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N], B[N], C[N-1];
  int i;
  for(i=0; i<N ; i++)
    cin >> A[i];
  for(i=0; i<N; i++)
    cin >> B[i];
  for(i=0; i<N-1; i++)
    cin >> C[i];

  int sum = 0;
  for(i=0; i<N; i++){
    sum += B[A[i]-1];
    if(A[i-1]+1 ==  A[i])
      sum += C[A[i-1]-1];

  }

  cout << sum << endl;
    
  return 0;
}


Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.12.28 20:13:56
 */

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

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

int main() {
    int n, a, b;
    scanf("%d", &n);
    if (n == 1) {
        printf("Hello World\n");
    } else {
        scanf("%d%d", &a, &b);
        printf("%d\n", a + b);
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if(a > k){
        a-=k;
    }
    else{
        k-=a;
        a = 0;
        b = max((ll)0,b-k);
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val Array(a, p)  =  StdIn.readLine().split(" ").map(_.toDouble)

  def solve(a: Double, p: Double): Int = {
    Math.floor((a * 3 + p) / 2).toInt
  }
  println(solve(a, p))

}
  



Measured memory_bytes: 25540
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Aseq = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var result = 0;
            for(var i =0; i<Aseq.Length; i++)
            {
                for(var j=i+1; j<Aseq.Length; j++)
                {
                    var x = Math.Abs(Aseq[i] - Aseq[j]);
                    if (x > result) result = x;
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

#define REP(i,a,b) for(int i=a;i<(int)(b);i++)
#define rep(i,n) REP(i,0,n)

int constexpr INF = 1L<<29;

constexpr bool in_range(int y, int x, int H, int W) {
	return 0 <= x && x < W && 0 <= y && y < H;
}

int bfs(vector<string> const& g) {
	const int H = g.size(), W = g[0].size();
	queue<pair<int, int>> q;
	vector<vector<int>> dist(H, vector<int>(W, INF));
	dist[0][0] = 0;
	q.emplace(0, 0);
	while(!q.empty()) {
		auto p = q.front(); q.pop();
		int y = p.first, x = p.second;
		int constexpr dy[] = {0,-1,0,+1};
		int constexpr dx[] = {-1,0,+1,0};
		rep(k, 4) {
			int ny = y + dy[k], nx = x + dx[k];
			if (!in_range(ny, nx, H, W)) continue;
			if (g[ny][nx] == '#') continue;
			if (dist[ny][nx] < INF) continue;
			dist[ny][nx] = dist[y][x] + 1;
			q.emplace(ny, nx);
		}
	}
	return dist[H - 1][W - 1];
}

int main() {
	int H, W; cin >> H >> W;
	vector<string> g;
	rep(i, H) {
		string s; cin >> s;
		g.push_back(s);
	}
	int shiro = 0;
	rep(i, H) rep(j, W) {
		shiro += g[i][j] == '.';
	}
	auto min_dist = bfs(g);
	if (min_dist == INF) {
		cout << -1 << "\n";
		return 0;
	}
	cout << shiro - min_dist - 1 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,x,s1,s2,a[2001],c[2001],b[2001][2001],w[2001][2001],dp[2001][2001];
char ch;
inline long long read()
{
   long long sum=0,x=1;
   char ch=getchar();
   while (ch<'0'||ch>'9')
   {
       if (ch=='-')
	     x=-1;
	   ch=getchar();
   }
   while (ch>='0'&&ch<='9')
   {
   	   sum=sum*10+ch-'0';
	   ch=getchar();
   }
   return sum*x;
}
inline void write(long long x)
{
    if (x<0)
	{
        putchar('-');
        x=-x;
    }
    if (x>9)
      write(x/10);
    putchar(x%10+'0');
    return;
}
int main()
{
	n=read();
	for (register int i=1;i<=2*n;++i)
	{
		cin>>ch;
		x=read();
		if (ch=='B')
		  c[x]=i;else
		  a[x]=i;
	}
	for (register int i=1;i<=n;++i)
	{
		for (register int j=1;j<i;++j)	
		  if (c[i]<c[j])
			++b[0][i];
		for (register int j=1;j<=n;++j)
		{
			b[j][i]=b[j-1][i];
			if (c[i]<a[j])
			  ++b[j][i];
		}
	}
	for (register int i=1;i<=n;++i)
	{
		for (register int j=1;j<i;++j)
		  if (a[i]<a[j])
			++w[i][0];
		for (register int j=1;j<=n;++j)
		{
			w[i][j]=w[i][j-1];
			if (a[i]<c[j])
			  ++w[i][j];	
		}
	}
	for (register int i=1;i<=n;++i)
      dp[0][i]=dp[0][i-1]+b[0][i];
	for (register int i=1;i<=n;++i)
	  dp[i][0]=dp[i-1][0]+w[i][0];
	for (register int i=1;i<=n;++i)
	  for (register int j=1;j<=n;++j)
	    dp[i][j]=min(dp[i][j-1]+b[i][j],dp[i-1][j]+w[i][j]);
	write(dp[n][n]);
	return 0;
}

Measured memory_bytes: 97480
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    set<string> s;
    char c;
    rep(i,n) {
        string w;
        cin >> w;
        if(i == 0) {
            c = w[w.size()-1];
            s.insert(w);
        } else {
            if(w[0] != c || s.count(w)) {
                cout << "No" << endl;
                return 0;
            }
            c = w[w.size()-1];
            s.insert(w);
        }
    }
    cout << "Yes" << endl;
}

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

for i in range(H):
	for j in range(W):
		if picture[i][j] == '#':
			if i == 0 or picture[i-1][j] == '.':
				if j == 0 or picture[i][j-1] == '.':
					if i == H-1 or picture[i+1][j] == '.':
						if j == W-1 or picture[i][j+1] == '.':
							print('No')
							exit()

print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll n,a,b;
  cin >> n >> a >> b;
  ll x[n]; REP(i,n) cin >> x[i];

  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ll d = x[i] - x[i-1];
    ans += min(d*a, b);
  }
  COUT(ans);
  return 0;
}

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

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

    int ans = 100000000;

    for (int i = 0; i < N; i++) {
        int a, cnt = 0;
        cin >> a;

        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        if (ans > cnt) {
            ans = cnt;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> >A(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >>A[i][j];
        }
    }
    vector<int>B(m);
    for(int i = 0; i < m; i++){
        cin >> B[i];
    }
    
    vector<int>AB(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
        AB[i] += A[i][j]*B[j];
    }
    
    for(int i = 0; i < n; i++){
        cout << AB[i] << endl;
    }
}


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

int main(){
int n;
int num[3],invnum[3],res,ans;

cin >> n;

num[0] = n/100;
res = n%100;

num[1] = res/10;

num[2] = res%10;

for(int i = 0; i < 3; ++i){

if(num[i] == 1){
invnum[i] = 9;
}else{
invnum[i] = 1;
}

}

ans = invnum[0]*100+invnum[1]*10+invnum[2];

cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(lint &a, lint b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
    }
} iosetup;

int main() {
  string s, s1, s2;
  cin >> s;
  int n = s.size();
  int cnt = 0;
  if (n % 2 == 0) {
    s1 = s.substr(0, n/2);
    s2 = s.substr(n/2, n/2);
    reverse(s2.begin(), s2.end());
    for (int i = 0; i < n/2; ++i) {
      if (s1[i] != s2[i]) cnt++;
    }
  } else {
    s1 = s.substr(0, (n-1)/2);
    s2 = s.substr((n+1)/2, (n-1)/2);
    reverse(s2.begin(), s2.end());
    for (int i = 0; i < (n-1)/2; ++i) {
      if (s1[i] != s2[i]) ++cnt;
    }
  }
  cout << cnt << '\n';
}


Measured memory_bytes: 256
N=int(input())
A=[]
B=[]
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)

ans=0
for i in range(N-1,-1,-1):
  a=A[i]+ans
  b=B[i]
  if a ==0 or a % b ==0:
    continue
  else:
    ans+=(a+b)//b*b-a
    
print(ans)

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

int main()
{
	int n,a,b;
	while(cin>>n>>a>>b){
		int m=b-a-1;
		int l=a-1+m/2+m%2;
		int r=n-b+m/2;	
		if(l==0 || m%2==0)
			cout<<"Borys"<<endl;
		else
			cout<<"Alice"<<endl;
	}
	return 0;
}

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

if N < 10:
    print(N)
    exit()

def digitSum(n):
    return sum([int(a) for a in str(n)])

ans = max(digitSum(10**(len(str(N)) - 1) - 1) + int(str(N)[0]) - 1, digitSum(N))
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int min = 0;
		int max = 0;

		for (int i=1; i<=n; i++){
			int a = sc.nextInt();
			if (i == 1){
				min = a;
				max = a;
			} else {
				min = Math.min(min, a);
				max = Math.max(max, a);
			}
		}
		System.out.println(max - min);
	}

}


Measured memory_bytes: 21844
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

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

  int n; cin >> n;
  int a[n][3];

  for (int i = 0; i < n; ++i) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }

  int dp[101010][3] = {};
  for (int i = 0; i < 3; ++i) {
    dp[0][i] = a[0][i];
  }

  for (int i = 1; i < n; ++i) {
    dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
    dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]);
    dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2]);
  }
  print(max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}));

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   string x;cin>>x;
   for(int i=0;i<x.length();i++)
   {
       if(x[i]=='B')
       {
           x[i]='*';
           if(i-1>=0){
           for(int j=i-1;j>=0;j--)
           {
               if(x[j]=='*')continue;
               else {
                x[j]='*';break;
               }
           }
           }
       }
   }
   for(int i=0;i<x.length();i++)
   {
       if(x[i]!='*')cout<<x[i];
   }
}


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

long long n, cnt[30];
string s;

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

    for(auto c : s)
        cnt[c-'a']++;

    long long ans = 0;

    for(int i = 0; i < 26; ++i)
        ans = (ans + ((ans * cnt[i])%MOD + cnt[i])%MOD)%MOD;

    cout << ans << endl;
}

Measured memory_bytes: 512
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

x,a,b = map(int,input().split())


if (b-a<=0):
    print("delicious")
elif (b-(a+x)<=0):
    print("safe")
else:
    print("dangerous")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    // Here your code !
    int a,b;
    char op;
    int flag = 1;
    while(flag){
        scanf("%d %c %d", &a, &op, &b);
        switch(op){
            case '+':
                printf("%d\n", a+b);
                break;
            case '-':
                printf("%d\n", a-b);
                break;
            case '*':
                printf("%d\n", a*b);
                break;
            case '/':
                printf("%d\n", a/b);
                break;
            case '?':
                flag = 0;
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 600
N, T, L, B = map(int, input().split())
while (N != 0 and T != 0):
    Llist = []
    Blist = []
    for i in range(L):
        Llist.append(int(input()))
    for i in range(B):
        Blist.append(int(input()))
    prob = [0for i in range(N+1)]
    prob[0] = 1 ## t행
    copy1 = [0for i in range(N+1)]  ##(t-2)행
    copy2 = prob[:] ## (t-1)행
    cntp = 0
    for t in range(1,T+1):
        for i in range(N, -1, -1):
            prob_i = 0
            if (i != 0):
                prob_i = 0
                for k in range(i-6,i):
                    if (k in Blist):
                        prob_i += 0
                    elif (k in Llist):
                        prob_i += (1/6)*copy1[k]
                    elif (k >= 0):
                        prob_i += (1/6)*copy2[k]
            if(N-5<= i <N):
                if ((N-1) in Blist):
                    prob_i += 0
                elif ((N-1) in Llist):
                    prob_i += (1/6)*copy1[N-1]
                else:
                    prob_i += (1/6)*copy2[N-1]
            if(N-4<= i <N):
                if ((N-2) in Blist):
                    prob_i += 0
                elif ((N-2) in Llist):
                    prob_i += (1/6)*copy1[N-2]
                else:
                    prob_i += (1/6)*copy2[N-2]
            if(N-3<= i <N):
                if ((N-3) in Blist):
                    prob_i += 0
                elif ((N-3) in Llist):
                    prob_i += (1/6)*copy1[N-3]
                else:
                    prob_i += (1/6)*copy2[N-3]
            if(N-2<= i <N):
                if ((N-4) in Blist):
                    prob_i += 0
                elif ((N-4) in Llist):
                    prob_i += (1/6)*copy1[N-4]
                else:
                    prob_i += (1/6)*copy2[N-4]
            if(N-1<= i <N):
                if ((N-5) in Blist):
                    prob_i += 0
                elif ((N-5) in Llist):
                    prob_i += (1/6)*copy1[N-5]
                else:
                    prob_i += (1/6)*copy2[N-5]
            
            if(i == 0):
                for b in Blist:
                    prob_i += prob[b]
            prob[i] = prob_i
            
        copy1 = copy2[:]
        copy2 = prob[:]
        cntp += prob[-1]
    print('{0:.6f}'.format(cntp))
    N, T, L, B = map(int, input().split())


Measured memory_bytes: 5648
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	ll i;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int k = 1; k <= n; k++)
		{
			for (int l = 1; l <= n; l++)
			{
				ans += gcd(gcd(i, k), l);
			}
		}
	}
	cout << ans << endl;
}


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

int main(){
	int x1,y1,x2,y2;cin >> x1 >> y1 >> x2 >> y2;
	int x3,y3,x4,y4;
	x3=x2-(y2-y1);
	x4=x1-(y2-y1);
	y3=y2+(x2-x1);
	y4=y1+(x2-x1);
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

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

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int lli;
using namespace std;
typedef pair<int, int> ii;
// #define int long long int

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

signed main() {
    int H, W; cin >> H >> W;
    vector<vector<int> > zs(2002, vector<int>(2002, 0));
    vector<vector<char> > S(2002, vector<char>(2002, 0));
    for (int i = 0; i < H; i++) {
        string s; cin >> s;
        for (int j = 0; j < W; j++) {
            S[i + 1][j + 1] = s[j];
        }
    }
    for (int i = 0; i <= H + 1; i++) {
        S[i][0] = '#';
        S[i][W + 1] = '#';
    }
    for (int j = 0; j <= W + 1; j++) {
        S[0][j] = '#';
        S[H + 1][j] = '#';
    }

    for (int y = 1; y <= H; y++) {
        int x = 0;
        while (x <= W) {
            int pos = x;
            while (S[y][pos] == '.') {
                pos++;
            }
            int val = pos - x;
            do {
                zs[y][x] = val;
                x++;
            } while (x < pos);
        }
    }

    for (int x = 1; x <= W; x++) {
        int y = 0;
        while (y <= H) {
            int pos = y;
            while (S[pos][x] == '.') {
                pos++;
            }
            int val = pos - y;
            do {
                zs[y][x] += val - 1;
                y++;
            } while (y < pos);
        }
    }

    int ans = 0;
    for (int x = 1; x <= W; x++) {
        for (int y = 1; y <= H; y++) {
            ans = max(ans, zs[y][x]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19968
#include<cstdio>

int A[5]={1,100,10000};

int main(){
    int D,N;
    scanf("%d%d",&D,&N);
    if(D==0&&N==100) printf("101");
    else if(D==1&&N==100) printf("10100");
    else if(D==2&&N==100) printf("1010000");
    else printf("%d",N*A[D]);
}


Measured memory_bytes: 128
#include<stdio.h>

long long N,a[200000];
long long sum,fsum, ans;

long long abs(long long a){
	if(a<0){return -a;}else{return a;}
}

int main(void){
	int i;
	scanf("%lld",&N);
	for(i=0;i<N;i++){
		scanf("%lld",&a[i]);
	}

	sum = 0;
	for(i=0;i<N;i++){
		sum = sum + a[i];
	}

	fsum = 0;
	ans = 300000000000000;
	for(i=0;i<N-1;i++){
		fsum = fsum + a[i];
		if(abs(fsum - (sum - fsum)) < ans){ans = abs(fsum - (sum - fsum));}
	}

	printf("%lld\n",ans);
}

Measured memory_bytes: 1664
#define LOCAL

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 


using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const long double PI = acos(-1.0);

int main() {
	IOS;
	int k; cin >> k;
	for (int i = 0; i < k; i++) cout << "ACL";
}

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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) {
            break;
        }

        int s[n] = {};
        double t[n] = {};
        int i;
        for(i = 0; i < n; i++){
            cin >> s[i];
        }

        int sum1 = 0;
        double avg;
        for(i = 0; i < n; i++){
            sum1 += s[i] * 10000;
        }
        avg = sum1 / n;

        for(i = 0; i < n; i++){
            if (avg > s[i] * 10000) {
                t[i] = avg - s[i] * 10000;
            }
            else {
                t[i] = s[i] * 10000 - avg;
            }
        }

        double sum2 = 0;
        for(i = 0; i < n; i++){
            sum2 += t[i] * t[i];
        }

        double result;
        result = sum2 / n;

        cout << fixed << setprecision(7) << sqrt(result) / 10000 << endl;
    }
}



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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll MOD =  1e9+7;
ll POW(ll b, ll e) {
	ll res = 1;
	while(e) {
		if(e & 1) {
			res *= b; res %= MOD;
		}
		b *= b; b %= MOD;
		e/=2;
	}
	return res;
}
ll INV(ll a) {
	return POW(a, MOD-2);
}

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	ll sum = 0;
	ll squares = 0;
	M00(i, n) {
		ll x;
		cin >> x;
		sum += x; sum %= MOD;
		squares += x * x; squares %= MOD;
	}
	ll ans = (POW(sum, 2) - squares) * INV(2); ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define max 100000
#define nil -1

int n;
vector<int> g[max];
int color[max];

void dfs(int r, int c) {
	stack<int> s;
	s.push(r);
	color[r] = c;
	while (!s.empty()) {
		int u = s.top(); s.pop();
		for (int i = 0; i < g[u].size(); i++) {
			int v = g[u][i];
			if (color[v] == nil) {
				color[v] = c;
				s.push(v);
			}
		}
	}
}

void assigncolor() {
	int id = 1;
	for (int i = 0; i < n; i++) color[i] = nil;
	for (int u = 0; u < n; u++) {
		if (color[u] == nil) dfs(u, id++);
	}
}

int main() {
	int s, t, m, q;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		g[s].push_back(t);
		g[t].push_back(s);
	}
    
	assigncolor();

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> s >> t;
		if (color[s] == color[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 9024
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    int N, M;
    string s;
    s = "";
    cin >> N >> M;
    if(N >= M){

        for(int i=0 ; i<N; i++){
           s += to_string(M) ;
        }
        
    }else    {
        for(int i=0; i<M; i++){
            s += to_string(N);
        } 
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])

Measured memory_bytes: 20652
#include<bits/stdc++.h>
using namespace std;   
int main(){
    int a,b;
    string s,t;
    cin>>s>>t;
    a=s.size();
    b=t.size();
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a,b,c,k;
    cin >> a >> b >>c >>k;
    int m = a + b + c;
    int mm = max({a,b,c});
    m -= mm;
    for (int i = 0; i < k; ++i) {
        mm*=2;
    }
    cout << m+mm << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

unordered_map<int,int> a;

int main()
{
	FAST;
	int n;
	cin >> n;

	int index = 1;
	while(1)
	{	
		if(a.count(n) == 1)
		{
			cout << index;
			return 0;
		}
		a[n] = index;
		index++;
		if(n&1)
		{
			n = 3*n + 1;
		}
		else
		{
			n = n / 2;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  if(n%2==0) cout<<n<<endl;
  else cout<<n*2<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
using namespace std;
typedef long long ll;
inline void debug() {
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout);
	#endif
	}
int main(){
	string s,t;
	cin>>s>>t;

		int ans=0;
	for(int i=0;i<(int)t.size();i++){
		if(t[i]!=s[i])
			ans++;
	}
	cout<<ans;




}


Measured memory_bytes: 3916
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
x = a[-1]
y = 4
if x != 2:
  print(-1)
  exit(0)
for i in range(N - 2, -1, -1):
  p = a[i]
  t = -(-x // p)
  x = t * p
  u = -(-y // p)
  y = u * p
t = x + 0
for i in range(N):
  t -= t % a[i]
if t == 2:
  print(x, y - 1)
else: print(-1)

Measured memory_bytes: 59632
#include<stdio.h>

int main(){
	int p,q,r,max;
	scanf("%d%d%d",&p,&q,&r);
	max=p>q?p:q;
	max=max>r?max:r;
	
	printf("%d",p+q+r-max);
	
	
	return 0;
}

Measured memory_bytes: 128
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, ans = 0;
	cin >> a >> b;
	for (int i = a; i <= b; ++i) {
		stringstream ss;
		ss << i;
		string x;
		ss >> x;
		string y = x;
		reverse(y.begin(), y.end());
		ans += x == y;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct p{
public:
    int y,x;
};
void clear( queue<p> &q )
{
   queue<p> empty;
   swap( q, empty );
}

int main(void){
    int h,w,n,i,j,ans=0;
    cin>>h>>w>>n;
    char c;
    vector<vector<char>> field(h,vector<char>(w));
    vector<vector<int>> mem(h,vector<int>(w, 0));
    queue<p> q;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>c;
            field[i][j]=c;
            if(c=='S'){
                q.push((p){i,j});
            }
        }
    }
    for(i='1';i<n+'1';i++){
        p po;
        while(!q.empty()){
            po=q.front();q.pop();
            if(field[po.y][po.x]==i) break;
            if(po.y+1<h && field[po.y+1][po.x]!='X' && mem[po.y+1][po.x]==0){
                mem[po.y+1][po.x]=mem[po.y][po.x]+1;
                q.push((p){po.y+1,po.x+0});
            }
            if(po.x+1<w && field[po.y][po.x+1]!='X' && mem[po.y][po.x+1]==0){
                mem[po.y][po.x+1]=mem[po.y][po.x]+1;
                q.push((p){po.y+0,po.x+1});
            }
            if(po.y-1>=0 && field[po.y-1][po.x]!='X' && mem[po.y-1][po.x]==0){
                mem[po.y-1][po.x]=mem[po.y][po.x]+1;
                q.push((p){po.y-1,po.x});
            }
            if(po.x-1>=0 && field[po.y][po.x-1]!='X' && mem[po.y][po.x-1]==0){
                mem[po.y][po.x-1]=mem[po.y][po.x]+1;
                q.push((p){po.y,po.x-1});
            }
        }
        ans+=mem[po.y][po.x];
        clear(q);
        q.push((p){po.y,po.x});
        mem=vector<vector<int>>(h,vector<int>(w, 0));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11624
#include <stdio.h>

int main(void)
{
    int a[3],i,j,t;
    for(i=0;i<3;i++)scanf("%d",&a[i]);
    for(i=0;i<2;i++){
        for(j=2;j>i;j--){
            if(a[j]<a[j-1]){
                t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
            }
        }
    }
    printf("%d\n",a[2]-a[1]+(a[1]-a[0]));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int n,c = 0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	sort(a, a+n);
	
	for(int i = n-2; i >= 0; i--){
		c += (a[i + 1] - a[i]); 
	}
	
	cout << c << endl;
	
 	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val length = StdIn.readInt
    val array = StdIn.readLine().split(" ")

    val bsresult = bubbleSort(array)
    val ssresult = selectionSort(array)
    println(bsresult._1.mkString(" "))
    println(bsresult._2)

    var flag = true
    for (i <- 0 to bsresult._1.length - 1) if (bsresult._1(i) != ssresult(i)) flag = false
    println(ssresult.mkString(" "))
    println(judge(flag))


  }

  def judge(flag: Boolean): String = if (flag) "Stable" else "Not stable"

  def bubbleSort(array: Array[String]): (Array[String], String) = {
    var arr = array.clone()
    var flag = true
    var count = 1
    while (flag) {
      flag = false
      for (j <- arr.length - 1 to count by -1) {
        if (arr(j).substring(1) < arr(j - 1).substring(1)) {
          val a = arr(j)
          arr(j) = arr(j - 1)
          arr(j - 1) = a
          flag = true
        }
      }
      count += 1
    }
    (arr, judge(true))
  }

  def selectionSort(array: Array[String]): Array[String] = {
    var arr = array.clone()
    for (i <- 0 to arr.length - 1) {
      var min = i
      for (j <- i to arr.length - 1) {
        if (arr(j).substring(1) < arr(min).substring(1)) min = j
      }
      if (min != i) {
        swap(arr, i, min)
      }
    }
    arr
  }

  def swap(array: Array[String], a: Int, b: Int): Unit = {
    val tmpValue = array(a)
    array(a) = array(b)
    array(b) = tmpValue
  }
}

Measured memory_bytes: 44000
# abc158_c.py
# https://atcoder.jp/contests/abc158/tasks/abc158_c

# C - Tax Increase /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 消費税率が 8%のとき A 円、10 ％のとき B円の消費税が課されるような商品の税抜き価格を求めてください。
# ただし、税抜き価格は正の整数でなければならないものとし、消費税の計算において小数点以下は切り捨てて計算するものとします。
# 条件を満たす税抜き価格が複数存在する場合は最も小さい金額を出力してください。
# また、条件を満たす税抜き価格が存在しない場合は -1 と出力してください。

# 制約
#     1≤A≤B≤100
#     A,Bは整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 条件を満たす税抜き価格が存在する場合は最小の金額を表す整数を、存在しない場合は -1 を出力せよ。

# 入力例 1
# 2 2

# 出力例 1
# 25

# 税抜き価格が 25円の場合、消費税率が 8%のとき消費税は ⌊25×0.08⌋=⌊2⌋=2円です。
# 消費税率が 10%のとき消費税は ⌊25×0.1⌋=⌊2.5⌋=2円です。
# よって 25円は条件を満たし、また 26 円のときなども条件を満たしますが、これが最小であるので 25を出力してください。

# 入力例 2
# 8 10

# 出力例 2
# 100

# 税抜き価格が 100円の場合、消費税率が 8%のとき消費税は ⌊100×0.08⌋=8円です。
# 消費税率が 10%のとき消費税は ⌊100×0.1⌋=10円です。

# 入力例 3
# 19 99

# 出力例 3
# -1

# 条件を満たす税抜き価格は存在しないので、-1 を出力してください。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    for n in range(1020):
        a = int(n * 0.08)
        b = int(n * 0.1)
        if a == A and b == B:
            return [n]

    return [-1]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 2']
        lines_export = [25]
    if pattern == 2:
        lines_input = ['8 10']
        lines_export = [100]
    if pattern == 3:
        lines_input = ['19 99']
        lines_export = [-1]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
#include <iostream>
#include <math.h> 


using namespace std;



int main()
{
	int L,R,d;
	int count = 0;
	if (R % d == 0)
		count ++;
	cin >> L >> R >> d;
	if(!d) {
		cout << 0;
		return 0;
	}
	while(L <= R && L % d != 0)
		L++;
	if(L <= R)
		count++;
	while(L + d <= R) {
		count++;
		L += d;
	}
	
	cout <<  count;
	return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i=0;i<n;i++)
	  cin>>arr[i];
	  sort(arr.begin(),arr.end());
	int count=0;
	for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( arr[l] + arr[r] > arr[i]){ 
                count = (count+(r - l)) ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
	cout<<count;
	return 0;
}

Measured memory_bytes: 256