akhauriyash/Code-Regression huggingface dataset:
// for AtCoder
"use strict";(function(){let t,n,i;this.input?t=this.input:require&&(t=require("fs").readFileSync("/dev/stdin","utf8"));let e=0;this.debug=function n(i){"object"==typeof i?n(i[0]):t=i.trim()},this.next=s,this.nextNumber=function(){return+s()},this.write=function(t){void 0===t&&(t="");var n=(r+=t).match(/([\s\S]*)\n([^\n]*)/);n&&(log(n[1]),r=n[2])},this.flush=function(t){void 0===t&&(t="");""!=(r+=t)&&(log(r),r="")},this.getLine=function(){n||(n=t.split(/[\n\r]+/));return i=null,n[o++]},this.log=console.log.bind(console),this.err=console.error.bind(console);let o=0,r="";function s(){return n||(n=t.split(/[\n\r]+/)),(!i||i.length-1<=e)&&(e=0,i=n[o++].split(/\s+/)),i[e++]}function u(t,n,i){for(var e=t;e<n&&i(e)!==BREAK;e++);}function l(t,n,i){for(var e=n-1;e>=0&&i(e)!==BREAK;e--);}this.FOR=u,this.RFOR=l,this.REP=function(t,n){u(0,t,n)},this.RREP=function(t,n){l(0,t,n)},this.CONTINUE=0,this.BREAK=1,this.range=function t(n,i){if(void 0===i)return t(0,n);return Array.apply(null,{length:i-n}).map((t,n)=>n)},"function"==typeof main&&main()}).call(global);
//
let n = nextNumber()
log(n * (n + 1) / 2)

Measured memory_bytes: 7372
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!long;
    char[] res;
    while (N) {
        auto n = N % 26;
        if (n == 0) {
            n = 25;
            N -= 1;
        } else {
            n -= 1;
        }
        res ~= 'a' + n.to!char;
        N /= 26;
    }
    res.reverse();
    writeln(res);
}

Measured memory_bytes: 2740
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	for(int tc = 0; tc < N; ++tc) {
	    int[] len = new int[3];
	    for(int i = 0; i < 3; ++i) {
		len[i] = s.nextInt();
	    }
	    Arrays.sort(len);
	    if(len[0]*len[0] + len[1]*len[1] == len[2]*len[2]) {
		System.out.println("YES");
	    } else {
		System.out.println("NO");
	    }
	}
    }
}

Measured memory_bytes: 12000
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    mod = 10**9+7

    fact = [1]

    for i in range(1, n+1):
        fact.append(fact[-1]*i % mod)

    def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)
    def nCr(n, r, mod=10**9+7): return inv_n(fact[n-r]
                                             * fact[r] % mod, mod)*fact[n] % mod

    ans = 0

    for i in range(n-k+1):
        ans = (ans+nCr(n-i-1, k-1)*(a[n-i-1]-a[i])) % mod
    print(ans)


main()


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    long long k;
    cin >> n >> k;
    vector<long long> as(n);
    for (auto& a : as) {
        cin >> a;
    }
    auto try_x = [&](long long x) {
        long long s = 0;
        for (auto& a : as) {
            s += a ^ x;
        }
        return s;
    };
    if (k == 0) {
        cout << try_x(0) << endl;
        return 0;
    }
    long long best = max(try_x(k), try_x(k-1));
    long long unconstrained_best = try_x(0);
    long long unconstrained_x = 0;
    // 10^12 = (10^3)^4 < 1024^4 = 2^40
    for (int bit = 0; (1LL << bit) <= k; ++bit) {
        long long tmp_x = unconstrained_x + (1LL << bit);
        long long tmp_sum = try_x(tmp_x);
        if (tmp_sum > unconstrained_best) {
            unconstrained_best = tmp_sum;
            unconstrained_x = tmp_x;
        }
    }
    for (int bit = 1; (1LL << bit) <= k; ++bit) {
        if (k & (1LL << bit)) {
            long long x = ((k >> (bit+1)) << (bit+1)) ^ (((1LL << bit)-1) & unconstrained_x);
            best = max(best, try_x(x));
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 1152
import           Control.Monad
import qualified Data.ByteString.Char8       as BS
import           Data.List
import           Data.Maybe
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM


readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt

  vs <- VBM.new (n+1)
  VBM.set vs ([] :: [Int])

  replicateM (n-1) $ do
    [a, b] <- getIntList
    la <- VBM.read vs a
    VBM.write vs a (b:la)
    lb <- VBM.read vs b
    VBM.write vs b (a:lb)

  vs' <- VB.freeze vs

  cs <- getIntList
  let cs' = sortBy (flip compare) cs

  ws <- VM.new (n+1)
  VM.set ws (0::Int)

  let bfs [] _ = return ()
      bfs (x:xs) cs = do
        w <- VM.read ws x
        if w == 0
          then do VM.write ws x (head cs)
                  let cs' = tail cs
                      xs' = (vs' VB.! x) ++ xs
                  bfs xs' cs'
          else bfs xs cs

  bfs [1] cs'

  print $ sum $ tail cs'

  forM_ [1..n] $ \i -> do
    when (i > 1) $ putStr " "
    w <- VM.read ws i
    (putStr . show) w

  putStrLn ""

Measured memory_bytes: 5500
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a==b)){ a=b; return true; } return false; }
template<typename T> inline bool isin(const T& x, const T& l, const T& r){ return l <= x and x < r; }
inline ostream& fcout(int n = 10){ return cout << fixed << setprecision(n); }
inline ostream& rcout(int n = 2){ return cout << right << setw(n); }
constexpr int64_t INF = numeric_limits<int64_t>::max();
constexpr int32_t INF32 = numeric_limits<int32_t>::max();
constexpr int64_t MOD = 1000000007LL;
constexpr double PI = 3.14159265358979323846264338327950288;
constexpr double EPS = 1e-10;


template<typename T>
struct CumulativeSum2D {
    vector<vector<T>> dat;
    CumulativeSum2D() = default;
    CumulativeSum2D(int h, int w) : dat(h+1, vector<T>(w+1)){}
    CumulativeSum2D(const vector<vector<T>>& v){
        int h = v.size(), w = v[0].size();
        dat.resize(h+1);
        for(int i = 0;i < h+1;++i) dat[i].resize(w+1);
        for(int i = 0;i < h;++i) for(int j = 0;j < w;++j) dat[i+1][j+1] = dat[i+1][j]+dat[i][j+1]-dat[i][j]+v[i][j];
    }
    inline void add(int x, int y, T a){
        dat[y+1][x+1] += a;
    }
    inline void build(){
        int h = dat.size()-1, w = dat[0].size()-1;
        for(int i = 0;i < h;++i) for(int j = 0;j < w;++j) dat[i+1][j+1] += dat[i+1][j]+dat[i][j+1]-dat[i][j];
    }
    //[x1, x2)×[y1, y2)
    inline T query(int x1, int x2, int y1, int y2) const {
        return dat[y2][x2]-dat[y2][x1]-dat[y1][x2]+dat[y1][x1];
    }
};


int N, M, Q;
CumulativeSum2D<int> S;


int32_t main(){
    cin >> N >> M >> Q;
    S = CumulativeSum2D<int>(N, N);
    rep(i, 0, M){
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        S.add(r, l, 1);
    }
    S.build();
    rep(i, 0, Q){
        int p, q;
        cin >> p >> q;
        p--;
        q--;
        cout << S.query(p, q+1, p, q+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 5596
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<ll>().max()

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> v(n);
	for(ll i=0; i<n; i++) {
		cin >> v[i];	
	}
	sort(v.begin(), v.end());
	ll pos = n-k-1;
	ll s = 0;
	for(ll i=0; i<=pos; i++) {
		s += v[i]; 
	}
	cout << s << endl;

}


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

ans = False
for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        ans = True
        break
YesNo = lambda tf: print('Yes') if tf else print('No')
YesNo(ans)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[n+10]={};
ll f=0;
ll q=0;
ll w=0;
for(ll i=0; i<n; i++){
cin>>a[i];}
for(ll i=0; i<n; i++){
if(q==2){
cout<<"No"<<endl;
f=1;
break;}
else if(a[i]-a[i+1]>=2&&a[i+1]!=0){
cout<<"No"<<endl;
f=1;
break;}
else if(a[i]==1+a[i+1]){
q++;}
else if(a[i]<a[i+1])
q=0;}
if(f!=1){
cout<<"Yes"<<endl;}}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> fs(M + 1, 0);
  int K;
  for(int i = 0; i < N; ++i) {
    cin >> K;
    int a;
    for(int k = 0; k < K; ++k) {
      cin >> a;
      fs[a]++;
    }
  }
  int ans = count_if(fs.begin(), fs.end(), [&](int x) { return x == N; });
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> c(n);
        for (int i = 0; i < n; i++) {
            char cc; cin >> cc;
            c[i] = cc - 'A';
        }

        vector<int> vote(30, 0);
        bool flag = true;
        for (int i = 0; i < n; i++) {
            int remain = n - i - 1;
            vote[c[i]]++;

            int c1 = -1, v1 = -1, v2 = -1;
            for (int j = 0; j < 30; j++) {
                if (vote[j] > v1) {
                    v1 = vote[j];
                    c1 = j;
                }
            }
            for (int j = 0; j < 30; j++) {
                if (j == c1) continue;
                if (vote[j] > v2) {
                    v2 = vote[j];
                }
            }

            if (v1 > v2 + remain) {
                cout << (char)(c1 + 'A') << " " << i + 1 << endl;
                flag = false;
                break;
            }
        }
        if (flag)
            cout << "TIE" << endl;
    }
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>

int main(void)
{
  char c[10];
  int N,i,n;
  int count=0;

  scanf("%d",&N);

  for(i=1;i<=N;i++){
  sprintf(c,"%d",i);
  n=strlen(c);
  if(n%2==1){
    count++;
  }
 }
  printf("%d\n",count);

  return 0;
 }


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

int main(){
std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test;
    test=1;
    // cin>>test;
    while(test--)
    {
        
        long long i,a,j,n,q,e=0,b,t,o=0,c=0,temp,k,maxpeak=0,peak,d;
        string s;
        cin>>n;
        cin>>s;
        long x=0,maxi=0;
        for(i=0;i<n;i++)
        {
            if(s[i]=='I')
            {
                x++;
                if(x>maxi)maxi=x;
            }
            else x--;
        }
        cout<<maxi;
    }
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 31) - 1;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const ll MOD = 1000000007;
int ans = 0, n,k;
int main() {
	cin >> n;
	vector<pair<int, int>> a(n), c(n);
	int p, q; vector<bool> b(100, true);
	rep(i, n) {
		cin >> p >> q;
		a[i] = make_pair(q, p);
	}
	rep(i, n) {
		cin >> p >> q;
		c[i] = make_pair(p, q);
	}
	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	rep(i, n) {
		k = -1;
		rep(j, n) {
			if (c[i].first > a[j].second &&c[i].second >a[j].first &&b[j])
				k = j;
		}
		if (k != -1) {
			ans++; b[k] = false;
		}
	}cout << ans << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  let weatherInThreeDays = lines[0];
  var mostContinuousRainyDays = 0;
  var currentContinuousRainyDays = 0;
  
  for (var i = 0; i < weatherInThreeDays.length; i++) {
    var weatherToday = weatherInThreeDays.substr(i, 1);
    if (weatherToday === 'S') {
      if (mostContinuousRainyDays < currentContinuousRainyDays) {
          mostContinuousRainyDays = currentContinuousRainyDays;
      }
      currentContinuousRainyDays = 0;
    } else {
      currentContinuousRainyDays++;
      if (mostContinuousRainyDays < currentContinuousRainyDays) {
          mostContinuousRainyDays = currentContinuousRainyDays;
      }
    }
  }
  console.log(mostContinuousRainyDays);
});

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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> sp;
  rep(i, n)
  {
    string s;
    int p;
    cin >> s >> p;
    sp.push_back(make_tuple(s, -p, i+1));
  }

  sort(sp.begin(), sp.end());

  rep(i, n)
  {
    cout << get<2>(sp.at(i)) << endl;
  }

}


Measured memory_bytes: 3608
H, W = map(int, input(). split())
S = [input() for _ in range(H)]
new_S = [[0 for _ in range(W)] for _ in range(H)]
point = []
for h in range(H):
  for w in range(W):
    if S[h][w] == '#':
      point.append([h,w])
      if h > 0:
        new_S[h-1][w] += 1
        if w > 0:
          new_S[h-1][w-1] += 1
        if w < W-1:
          new_S[h-1][w+1] += 1
      if h < H-1:
        new_S[h+1][w] += 1
        if w > 0:
          new_S[h+1][w-1] += 1
        if w < W-1:
          new_S[h+1][w+1] += 1
      if w > 0:
        new_S[h][w-1] += 1
      if w < W-1:
        new_S[h][w+1] += 1

for p in point:
  new_S[p[0]][p[1]] = '#'

for s in new_S:
  print(''.join(map(str, s)))


Measured memory_bytes: 3316
def is_palindrome(s)
  (s.size / 2).times do |i|
    return false if s[i] != s[(s.size - 1) - i]
  end

  return true
end

def main(argv)
  s = gets.chomp

  t = ''
  s.size.times{ |i| t += s[i] if s[i] != 'x' }

  unless is_palindrome(t) then
    puts (-1).to_s
    return
  end

  if t.size == 0 then
    puts 0.to_s
    return
  end

  m = t.size / 2
  m += 1 if t.size % 2 == 1

  c = 0
  k1 = -1
  0.upto(s.size - 1).each do |i|
    if s[i] != 'x' then
      c += 1
      k1 = i
      break if c == m
    end
  end

  c = 0
  k2 = -1
  (s.size - 1).downto(0).each do |i|
    if s[i] != 'x' then
      c += 1
      k2 = i
      break if c == m
    end
  end

  v = [0]
  0.upto(k1).each do |i|
    if s[i] != 'x' then
      v.push(0)
    else
      v[v.size - 1] += 1
    end
  end

  u = [0]
  (s.size - 1).downto(k2).each do |i|
    if s[i] != 'x' then
      u.push(0)
    else
      u[u.size - 1] += 1
    end
  end

  s = 0
  v.size.times do |i|
    s += (v[i] - u[i]).abs
  end
  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 118208
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int K; 
	cin >> K; 
	long long int A[100010] = {}; 
	for(int i = 0; i < K; i++){
		cin >> A[i]; 
	}
	long long int mn = 2; long long int mx = 2; 
	for(int i = K-1; i >= 0; i--){
		mn = (mn + A[i] - 1)/ A[i] * A[i]; 
		mx = mx / A[i] * A[i] + A[i] - 1; 
		if(mn > mx){
			mn = -1; break; 
		}
	}
	if(mn == -1) cout << -1 << endl; 
	else cout << mn << " " << mx << endl; 
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;	cin>>s;
	int n=s.size();
	int ans=0;
	int now=0;
	while(now<n){
		while(now<n&&s[now]!='J')	now++;
		int jcnt=0;
		while(now+jcnt<n&&s[now+jcnt]=='J')	jcnt++;
		now+=jcnt;
		int ocnt=0;
		while(now+ocnt<n&&s[now+ocnt]=='O')	ocnt++;
		now+=ocnt;
		int icnt=0;
		while(now+icnt<n&&s[now+icnt]=='I')	icnt++;
		now+=icnt;
		int level=min(jcnt,min(ocnt,icnt));
		if(level!=ocnt)	continue;
		ans=max(ans,level);
	}
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    string s;
    cin >> s;
    int k;
    cin >> k;

    vector<int> c(s.size());
    rep(i, s.size()) c[i] = 'z' - s[i] + 1;

    rep(i, s.size() - 1) {
        if (k >= c[i] && s[i] != 'a') {
            s[i] = 'a';
            k -= c[i];
        }
    }

    s[s.size() - 1] = (s[s.size() - 1] - 'a' + k) % 26 + 'a';

    cout << s << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    vector <int> L(n), R(n);
    vector <pair <int, int>> st;
    for (int i = 0; i < n; ++i) {
        while (!st.empty() && st.back().first >= p[i]) st.pop_back();
        if (st.empty()) L[i] = -1;
        else L[i] = st.back().second;
        st.push_back({p[i], i});
    }
    st.clear();
    for (int i = n - 1; i >= 0; --i) {
        while (!st.empty() && st.back().first >= p[i]) st.pop_back();
        if (st.empty()) R[i] = n;
        else R[i] = st.back().second;
        st.push_back({p[i], i});
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) ans += (ll)p[i] * (i - L[i]) * (R[i] - i);
    cout << ans << '\n';
}

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

int main() {
  int N;
  scanf("%d", &N);

  vector<string> W(N);
  set<string> st;
  bool follow_rule = true;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    W.at(i) = s;
    if (st.count(s) == 0) {
      st.insert(s);
    } else {
      follow_rule = false;
    }
  }

  for (int i = 0; i < N - 1; i++) {
    string first = W.at(i);
    string second = W.at(i + 1);
    if (first.at(first.size() - 1) != second.at(0)) {
      follow_rule = false;
    }
  }

  if (follow_rule) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 256
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define ld             long double
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

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

const int N = 200005;
int a[N], n, m, k;

void solve()
{
	int i, j;
	cin >> n >> m;

	int x = 0;
	for (i = 0; i < n; i++)
	{
		x *= 10;
		x += m;
	}
	int y = 0;
	for (i = 0; i < m; i++)
	{
		y *= 10;
		y += n;
	}

	if (y > x)
		cout << y;
	else
		cout << x;


}

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

	cout << setprecision(9) << fixed;
	clock_t z = clock();
	solve();
	cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

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

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

    vector<int> t; t = a;
    
    sort(a.begin(), a.end(), greater<int>());
    int first = a[0];
    int second = a[1];

    for (int i = 0; i < n; ++i) {
        if (t[i] == first) {
            cout << second << endl;
        } else {
            cout << first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
typedef long long ll;
string s;
int num[100010];
int L[100010];
int R[100010];
int main()
{
	ios::sync_with_stdio(false);
    cin>>s;
    int len=s.length();
    int pos=0;
    for(int i=0;i<len;i++)
    {
    	if(s[i]=='R')
    		pos=i;
    	R[i]=pos;
	}
	pos=len;
	for(int i=len-1;i>=0;i--)
	{
        if(s[i]=='L')
			pos=i;
        L[i]=pos;
    }
	int step;
	for(int i=0;i<len;i++)
	{
		if(s[i]=='L')
		{
			step=i-R[i];
			num[R[i]+step%2]++;
		}
		else
		{
			step=L[i]-i;
            num[L[i]-step%2]++;
		}
	}
	for(int i=0;i<len;i++)
		cout<<num[i]<<" ";
    return 0;
}


Measured memory_bytes: 1872
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict

H, W, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

counter = defaultdict(int)
for a, b in AB:
  for aa in range(a - 1, a + 2):
    for bb in range(b - 1, b + 2):
      if 2 <= aa <= H - 1 and 2 <= bb <= W - 1:
        counter[(aa, bb)] += 1

answer = [0] * (10)
for (x, y), n in list(counter.items()):
  if n:
    answer[n] += 1
answer[0] = (H - 2) * (W - 2)
for i in range(1, 10):
  answer[0] -= answer[i]
  
for a in answer:
  print(a)

Measured memory_bytes: 183804
import java.util.*;
public class Main{
  public static Map<Long,Long> map = new HashMap<>();
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long P = sc.nextLong();
    bunkai(P);
    long ans = 1;
    for(Long n : map.keySet()){
      //System.out.println(n + ":" + map.get(n));
      if(map.get(n) >= N){
        long tmp = map.get(n) / N;
        ans *= pow(n, tmp);
      }
    }
    System.out.println(ans);
  }
  
  public static void bunkai(long n){
    while(n != 1){
      long num = sosuHantei(n);
      long count = 0;
      while(n % num == 0){
        count++;
        n /= num;
      }
      map.put(num, count);
    }
  }
  
  public static long sosuHantei(long n){
    for(long i = 2; i*i <= n; i++){
      if(n % i==0) return i;
    }
    return n;
  }
  
  public static long pow(long x, long y){
    long ans = 1;
    for(long i = 0; i < y; i++){
      ans *= x;
    }
    return ans;
  }
}


Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main()
{
	int n = in(), m = in(), q = in();
	vector<vector<int>>vv(n, vector<int>(n + 1));
	REP(i, m)
	{
		int l = in(), r = in();
		++vv[l - 1][r];
	}
	REP(i, n)REP(j, n)vv[i][j + 1] += vv[i][j];
	REP(i, q)
	{
		int l = in(), r = in();
		int sum = 0;
		for (int i = l; i <= r; ++i)sum += vv[i - 1][r] - vv[i - 1][l - 1];
		cout << sum << endl;
	}
}

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


int main() {
  string a;
  cin >> a;
  string ans = "No";
  if(a[0] == a[2]) ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf LLONG_MAX/10000000
#define INF LLONG_MAX/3
#define P pair<int,int>
using namespace std;
signed main(){
	int n,t;
	cin>>n>>t;
	int ans=INF;
	rep(i,n){
		int a,b;
		cin>>a>>b;
		if(b<=t)ans=min(ans,a);
	}
	if(ans==INF)cout<<"TLE"<<endl;
	else cout<<ans<<endl;
	return 0;	
}


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

int main() {
	int N;
	cin >> N;
	vector<ll> L(N + 1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N] << endl;
}


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

bool f(vector<ll> &a, vector<ll> &ruiseki, int x){
    ll y = ruiseki.at(x);
    ll z = x;
    while(true){
        auto it = upper_bound(a.begin(),a.end(),y*2);
        ll xx = it - a.begin();
        if(xx == n) return true;
        if(xx - 1 == z) return false;
        y = ruiseki.at(xx - 1);
        z = xx - 1;
    }
}

int main(){
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    vector<ll> ruiseki(n,0);
    ruiseki.at(0) = a.at(0);
    for(int i=1;i<n;i++) ruiseki.at(i) = ruiseki.at(i-1) + a.at(i);
    
    int l = -1, r = n - 1;
    int c = (l+r)/2;
    while(r-l!=1){
        if(f(a,ruiseki,c)) r = c; else l = c;
        c = (l+r)/2;
    }
    cout << n-r << endl;
    //rep(i,n) cout << i << " " << a.at(i) << " " << ruiseki.at(i) << " " << f(a,ruiseki,i) << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	int x[220],a,b,c = 0,n;
	scanf("%d %d",&a,&b);
	for(int i = 0;i < a;i++){
		scanf("%d",&x[i]);
	}
	sort(x,x + a);
	for(int i = a - 1;i > a - 1 - b;i--){
		c += x[i];
	}
	printf("%d",c);
	return 0;
}

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

const ll INF = 1LL << 60;

struct Doubling
{
  const int LOG;
  vector< vector< int > > table;
  
  Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_clzll(lim_t))
  {
    table.assign(LOG, vector< int >(sz, -1));
  }

  void set_next(int k, int x)
  {
    table[0][k] = x;
  }

  void build()
  {
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
        if(table[k][i] == -1) table[k + 1][i] = -1;
        else table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }

  // どこから、どこまで？
  int query(int k, int64_t t)
  {
     //  cout << t << endl;
    for(int i = LOG - 1; i >= 0; i--) {
      if((t >> i) & 1) k = table[i][k];
    }
    return k;
  }
};

ll N, K;

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

    // Doubling d = Doubling(N, 1LL << 61);
    // Doubling d = Doubling(N, 1LL << 60);
    Doubling d = Doubling(N, INF);

    rep(i, N) {
        ll dest;
        cin >> dest;
        dest--;
        d.set_next(i, dest);
    }
    d.build();

    // cout << d.query(0, 1) + 1 << endl;
    // cout << d.query(0, 2) + 1 << endl;
    cout << d.query(0, K) + 1 << endl;
    // rep(i, 20) {
    //     cout << i << " " << d.query(K, i) << endl;
    // }
}


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

int main(){
int a, b, c;
cin >> a >> b >> c;
if(a == 5 && b == 5 && c == 7) cout << "YES" << endl;
else if(a == 5 && b ==7 && c == 5) cout << "YES" << endl;
else if(a == 7 && b == 5 && c == 5) cout << "YES" << endl;
else cout << "NO" << endl;

return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
  int a,b;
  long d=1000000,e=-1000000,sum=0;
  scanf("%d",&a);

  for (int i=0;i<a;i++) {
    scanf("%d",&b);
    if (d>b) d=b;
    if (e<b) e=b;
    sum += b;
  }

  printf("%ld %ld %ld\n",d,e,sum);
  return 0;
}


Measured memory_bytes: 2100
puts ([0,0]+STDIN.read.lines.drop(1).first.split.map(&:to_i).group_by{ |e| e }.sort.map{ |e| [e[0], e[1].length]}+[0,0]).each_cons(3).map{ |a, b, c| (a[0]==b[0]-1 ? a[1] : 0)+b[1]+(b[0]+1==c[0] ? c[1] : 0) }.max


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

int main()
{
	int xx, yy, zz;
	int n, y;

	cin >> n >> y;

	y /= 1000;
	int remain5 = y % 5;
	bool b = false;
	for( ; remain5 <= y; remain5 += 5 ) {
		int remain = n - remain5;
		for( int i = 0; i <= remain; i++ ) {
			if( i * 10 + (remain - i) * 5 == y - remain5 ) {
				xx = i;
				yy = remain - i;
				zz = remain5;
				b = true;
				break;
			}
		if( b == true ) {
			break;
		}
		}
	}
	if( b == false ) {
		xx = -1;
		yy = -1;
		zz = -1;
	}

	cout << xx << " " << yy << " " << zz << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        final String S = sc.next();
        final String T = sc.next();
        sc.close();

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<N; i++) {
            sb.append(S.substring(i, i+1));
            sb.append(T.substring(i, i+1));
        }

        System.out.println(sb);
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t A, B, K;
  cin >> A >> B >> K;
  if(A >= K){
    cout << A - K << " " << B << endl;
  }
  else if(A+B >= K){
    cout << 0 << " " << A+B-K << endl;
  }
  else{
    cout << 0 << " " << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int mod=1e9+7;
const int N=3e5+7;
inline void upd(int& x,int y){
	x+=y;if(x>=mod)x-=mod;
}
int qpow(int a,int b){
	int aa=a,res=1;
	for(;b;b>>=1){
		if(b&1)res=1ll*res*aa%mod;
		aa=1ll*aa*aa%mod;
	}
	return res;
}
int bin[N],pin[N];
int C(int n,int m){
	if(m>n)return 0;
	return 1ll*bin[n]*pin[m]%mod*pin[n-m]%mod;
}
void init(){
	int n=200000;
	bin[0]=pin[0]=1;
	rep(i,1,n)bin[i]=1ll*bin[i-1]*i%mod;
	pin[n]=qpow(bin[n],mod-2);
	rep2(i,n-1,1)pin[i]=1ll*pin[i+1]*(i+1)%mod;
}
int a[N],n,cnt[N],mx,mi;
int main(){
	init();
	scanf("%d",&n);
	rep(i,1,n+1){
		scanf("%d",&a[i]);
		if(cnt[a[i]])mx=i;
		cnt[a[i]]++;
	}
	rep2(i,n+1,1)if(cnt[a[i]]>1)mi=i;
	rep(i,1,n+1){
		int res=C(n+1,i);
		res=(1ll*res - 1ll*C(n+1-mx + mi-1,i-1) + 2ll*mod)%mod;
		printf("%d\n",res);
	}
}

Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int[] alph = new int[26];
		char[] target = S.toCharArray();
		for (int i = 0; i < target.length; i++) {
			alph[target[i] - 'a']++;
		}
		sc.close();
		for (int i = 0; i < alph.length; i++) {
			if (alph[i] % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main() {
  int N; cin >> N;
  vector<vector<ll> > L;
  rep(i,N){
    ll a, b; cin >> a >> b;
    vector<ll> v;
    v.push_back(b);
    v.push_back(a);
    L.push_back(v);
  }
  sort(ALL(L));
  ll t = 0;
  string ans = "Yes";
  rep(i,N){
    t += L[i][1];
    if(L[i][0]<t) ans = "No";
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 13228
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

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

  int A,B;
  cin >> A >> B;
  cout << (B%A==0 ? A+B : B-A) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
				C++
				encoding: UTF-8
				Last Modified: 2019/09/01 17:40:46

*/

#include <bits/stdc++.h>
#ifdef LOCAL_PROJECT
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		 ll                     long long
#define		 ve                     vector
#define		 pb                     push_back
#define		 endl                   "\n";
#define		 ff                     first
#define		 ss                     second
#define		 pii                    pair<int, int>
#define		 len(v)                 int(v.size())
#define		 all(v)                 v.begin(), v.end()
#define		 reset(a, b)            memset(a, b, sizeof(a));
#define		 fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		 dfr(i, s, n)           for (int i = s ; i > n ; --i)

void pr () {
    cout << "\n";
}

template < typename T, typename... ARGS > void pr (const T& t, ARGS... args) {
    cout << t << " ";
    pr (args...);
}

// clang-format on

signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int a, b;
	cin >> a >> b;
	int curr = 1;
	int ans = 0;
	while (curr < b) {
		curr += (a - 1);
		ans++;
	}
	pr (ans);
	return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let S = rl().chars().collect::<Vec<_>>();

    let mut good = true;
    for i in 0..S.len() - 1 {
        if S[i] == S[i + 1] {
            good = false;
            break;
        }
    }

    println!("{}", if good { "Good" } else { "Bad" })
}


Measured memory_bytes: 4352
N = int(input())
W1 = input()
A = [W1]
c = W1[-1]
for i in range(N-1):
    W = input()
    if W in A:
        print('No')
        exit()
    elif c != W[0]:
        print('No')
        exit()
    A.append(W)
    c = W[-1]
print('Yes')

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    if (s.size() == 3) reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.PriorityQueue;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    PriorityQueue<Restaurant> pq = new PriorityQueue<>();
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      int n = Integer.parseInt(br.readLine());
      for (int k=0;k<n;k++) {
        String[] s = br.readLine().split("\\s+");
        pq.offer(new Restaurant(s[0],Integer.parseInt(s[1]),k+1));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    while (!pq.isEmpty()) System.out.println(pq.poll().id);
  }
  private class Restaurant implements Comparable<Restaurant> {
    private String name;
    private int value;
    private int id;
    Restaurant(String name,int value,int id) {
      this.name = name;
      this.value = value;
      this.id = id;
    }
    @Override
    public int compareTo(Restaurant other) {
      if (name.equals(other.name)) return -Integer.compare(value,other.value);
      return name.compareTo(other.name);
    }
  }
}

Measured memory_bytes: 20692
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n;
vector<pair<int,int> >adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int> > PQ;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int,int>f=PQ.top();
    PQ.pop();
    int u=f.second;
    color[u]=BLACK;

    if(d[u]<f.first*(-1)) continue;

    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK) continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
  }
}

int main(){
  int k,c,u,v;
  cin>>n;

  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  
  dijkstra();

  return 0;
}



Measured memory_bytes: 8012
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
using ll=long long;
const int M=1010;


int main(){
	int psum;	//税抜価格;
	int x[1010],y[1010]; //x:変更前税率,y:変更後税率;
	int s[1010];	//初期税率適用後金額後合計;
	int tmp=0;	//何パターン入力したか;
	int pans=0;
	float d,e,f,g;

	rep(i,0,1000){
		cin>>x[i]>>y[i]>>s[i];
		if(x[i]==0&&y[i]==0&&s[i]==0)break;
		tmp++;
	}

	rep(i,0,tmp){
		if(x[i]==1&&s[i]<102)psum=s[i];
		else if(((s[i]+2)*100)%(100+x[i])==0)psum=(s[i]*100)/(100+x[i])+1;
		else psum=floor(1.0*((s[i]+2)*100)/(100+x[i]));

		int k=0;
		if(psum%2)k=psum/2+1;
		else k=psum/2;
		
		//cout<<psum<<endl;
		pans=0;
		rep(j,1,k+2){
			d=floor((j*(100+x[i]))/100);
			e=floor(((psum-j)*(100+x[i]))/100);
			f=floor(((psum-j)*(100+y[i]))/100);
			g=floor((j*(100+y[i]))/100);
			if(d+e==s[i]&&f+g>pans){
				//cout<<j<<endl;
				pans=f+g;
			}
			if(j==k+1&&pans==0)j=0,psum--;
		}
		cout<<pans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int INF=(4e7);
const int maxn=(2e5)+10;
int n,k,a[maxn],b[maxn];

int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	for (int i=1;i<=n;i++) read(a[i]);
	k=min(k,INF/n);
	while (k--) {
		for (int i=1;i<=n;i++) b[i]=0;
		for (int i=1;i<=n;i++) b[max(1,i-a[i])]++,b[min(n+1,i+a[i]+1)]--;
		for (int i=1;i<=n;i++) b[i]+=b[i-1];
		for (int i=1;i<=n;i++) a[i]=b[i];
	}
	for (int i=1;i<=n;i++) printf("%d ",a[i]);
	printf("\n");
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 5208
H, W, D = map(int,input().split())
px = [0 for k in range(H*W+D+1)]
py = [0 for k in range(H*W+D+1)]
S = [list(map(int,input().split())) for k in range(H)]

for j in range(W):
    for i in range(H):
        px[S[i][j]] = i
        py[S[i][j]] = j

d = [0 for k in range(H*W+D+1)]
for k in range(H*W,0,-1):
    d[k] = d[k+D] + abs(px[k]-px[k+D]) + abs(py[k]-py[k+D])

Q = int(input())
for k in range(Q):
    L, R = map(int,input().split())
    print(d[L]-d[R])

Measured memory_bytes: 13448
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll d=0;
  ll count=0;
  ll n,x;cin>>n>>x;
  vl l(n);
  rep(i,n)cin>>l[i];
  while(d<=x ){
    if(count==n){
      cout<<n+1<<endl;
      return 0;
    }
    d+=l[count];
    count++;
    
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll ans = 0;
  vl V(N), C(N);
  REP(i, N) cin >> V[i];
  REP(i, N) cin >> C[i];

  REP(i, N) {
    if (V[i] > C[i])
      ans += V[i] - C[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	ll a[n+5],b[m+5];
	ll ans=0;
	for(int i=0;i<n;i++){
	    cin>>a[i];
	    if(i>0)a[i]+=a[i-1];
        if(a[i]<=k) ans=i+1;
	}
	
    ll temp=0;
    for(ll i=0; i<m; i++){
        cin>>b[i];
        temp+=b[i];
        if (temp>k) break;
        ll resto=k-temp;
        ll  in= upper_bound(a,a+n,resto)-a;
        ans=max(ans,in+i+1LL);
    }
    
    cout<<ans<<"\n";
	return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll a;
  cin>>a;
  cout<<48-a<<endl;
}


Measured memory_bytes: 256