akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s;
ll n,m;
ll arr[500000];
ll brr[500000];

int main()
{__
        ll i,j,a,b;
        cin>>a>>b;
        arr[a]++;
        arr[b]++;

        for(i=1;i<=3;i++){
            if(arr[i]==0) cout<<i<<endl;
        }
}



Measured memory_bytes: 2304
import sys
input=sys.stdin.readline
k,q=map(int,input().split())
D=[int(i) for i in input().split()]
for _ in range(q):
  n,x,m=map(int,input().split())
  DD=[d%m for d in D]
  x%=m
  ans=n-1
  u,v=(n-1)//k,(n-1)%k
  z1,z2,r,s=0,0,0,0
  for i,d in enumerate(DD):
    s+=d
    if i<v:
      r+=d
      if d==0:
        z1+=1
        z2+=1
    elif d==0:
      z2+=1
  ans-=(z2*u+z1)+(x+s*u+r)//m
  print(ans)

Measured memory_bytes: 67036
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7

def main():
    N,X = cin.mapInt()
    A = cin.mapInt()
    ans = sum(A)
    for i in range(N - 1):
        if A[i + 1] + A[i] <= X:
            continue
        s = A[i + 1] + A[i] - X
        n = min(s,A[i + 1])
        A[i + 1]-=n
        s -= n
        A[i] -= s
    ans = ans - sum(A)
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 64240
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto Q = s[1];
    auto STX = N.iota.map!(_ => readln.split.map!(to!long).array).array;
    auto D = Q.iota.map!(_ => readln.chomp.to!long).array;

    auto rbt = new RedBlackTree!(Tuple!(long, int), "a[0] < b[0]", true);
    foreach (i, d; D) rbt.insert(tuple(d, i.to!int));

    STX.sort!"a[2] < b[2]";
    auto ans = new long[](Q);
    ans[] = -1;

    foreach (stx; STX) {
        auto S = stx[0];
        auto T = stx[1] - 1;
        auto X = stx[2];
        auto l = S - X;
        auto r = T - X;
        auto lb = rbt.upperBound(tuple(l-1, 0));
        Tuple!(long, int)[] to_remove;
        foreach (x; lb) {
            if (x[0] > r) break;
            ans[x[1]] = X;
            to_remove ~= x;
        }
        foreach (x; to_remove) {
            rbt.removeKey(x);
        }
    }

    ans.each!writeln;
}

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

int main() {
    string s;
    cin >> s;
    string check;
    bool a = true;

    while (s.size() >= 8) {
        check = "";
        for (int i = 0; i < 8; i++) {
            check.push_back(s.at(i));
        }
        if (check == "dreamdre" || check == "dreamera" || check == "erasedre" || check == "eraseera") {
            s.erase(0, 5);
        }
        else if (check == "eraserdr" || check == "eraserer") {
            s.erase(0, 6);
        }
        else if (check == "dreamerd" || check == "dreamere") {
            s.erase(0, 7);
        }
        else {
            a = false;
            break;
        }
    }

    if (a == true && s.size() >= 5) {
        if (s != "dream" && s != "dreamer" && s != "erase" && s != "eraser") {
            a = false;
        }
    }
    if (a == true && s.size() < 4) {
        a = false;
    }

    if (a == true) {
        cout << "YES" << endl;
    }
    if (a == false) {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
N,K,Q = map(int,input().split())

A = [int(input()) for _ in range(Q)]

life = [K] * N

for i in range(Q):
    life[A[i]-1] += 1

life = list(map(lambda x: x-Q,life))

for l in life:
    if l > 0:
        print("Yes")
    else:
        print("No")

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<long long> vll;
typedef vector<pii> pxx;
typedef vector<int> vi;
#define pb push_back
#define mod  1000000007
#define PI 2*acos(0.0)
#define REP(i,a,b)  for(i = a; i <= b; i++)
#define f(a,b)  for(a=0 ; a<b; a++)



main()
{
    ll n,k,d,pd,q;
    cin >> n >> k >> d;
    if(n<0) n*=-1;
    if(k<=n/d)
    {
        cout << n-k*d << endl;
    }
    else
    {
        q=n/d;
        pd=n%d;
        if((k-q)%2)
        {
            cout << d-pd << endl;
        }
        else cout << pd << endl;
    }
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}

int bsum[128][128]={0};

int cbz(int fx,int fy,int tx,int ty){
    if(fx>tx || fy>ty){return 0;}
    if(fx==0 && fy == 0){return bsum[tx][ty];}
    else if(fx==0){
        return bsum[tx][ty]-bsum[tx][fy-1];
    }
    else if(fy==0){
        return bsum[tx][ty]-bsum[fx-1][ty];
    }
    else{
        return bsum[tx][ty]-bsum[tx][fy-1]-bsum[fx-1][ty]+bsum[fx-1][fy-1];
    }
}

int main(){
  int i,j,h,w,n,a,b,r;
  int bf[128][128];
  while(scanf("%d",&n),n!=0){
    r=0;
    scanf("%d%d",&h,&w);
    for(i=0;i<128;i++){
      for(j=0;j<128;j++){
        bf[i][j]=0;
      }
    }
    for(i=0;i<n;i++){
      scanf("%d%d",&a,&b);
      a--;b--;
      bf[a][b]=1;
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(j==0){
            bsum[i][j]=bf[i][j];
        }
        else{
            bsum[i][j]=bsum[i][j-1]+bf[i][j];
        }
      }
    }
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(i!=0){
            bsum[i][j]=bsum[i-1][j]+bsum[i][j];
        }
      }
    }
    scanf("%d%d",&a,&b);
    for(i=a-1;i<h;i++){
      for(j=b-1;j<w;j++){
        r=max(cbz(i-a+1,j-b+1,i,j),r);
      }
    }
    printf("%d\n",r);
  }
  return 0;
}



Measured memory_bytes: 2096
include Math
n=gets.to_i
l=[0]
n.times{|i|l=l.flat_map{|v|[v,v+1,v-1,v]}}

x=y=0.0
puts"0 0"
r=100.0/3**n
l.map{|i|
x+=r*cos(2*i*PI/6)
y+=r*sin(2*i*PI/6)
puts"%f %f"%[x,y]
}

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

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

    ll n, m, k, pf = 0;
    cin >> n >> m >> k;
    vl a(n), b(m);
    for (ll &i : a)
    {
        cin >> i;
        pf += i;
    }
    for (ll &i : b)
        cin >> i;

    ll at = n, bt = 0, ans = 0;
    while (1)
    {
        if (pf > k)
        {
            if (at == 0)
                break;
            at--;
            pf -= a[at];
        }
        else
        {
            ans = max(ans, at + bt);

            if (bt < m)
            {
                pf += b[bt];
                bt++;
            }
            else
                break;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int s,w,b,c;
  cin >> s>>w >> b >>c;
  for(int i=0;i<200;i++)
  {
    if(i%2==0)	b-=w;
    else	s-=c;
    if(s<=0){	cout <<"No";break;}
    else if(b<=0){	cout << "Yes";break;}
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int N, M; cin >> N >> M;
    vi L(M), R(M);
    rep(i, M) cin >> L[i] >> R[i];

    int X = 0, Y = N;

    rep(i, M) X = max(X, L[i]), Y = min(Y, R[i]);

    int Z = Y - X + 1;

    if (Z > 0) { cout << Z << endl; }
    else { cout << 0 << endl; }

}

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

using namespace std;

int main(int argc, char *argv[]) {
        string s;
        cin >> s;

        int min_abs = INT_MAX;
        int answer = 0;
        for (int i = 0; i < s.size() - 2; i++) {
                int cur = stoi(s.substr(i, 3));
                int cur_abs = abs(753 - cur);
                if (min_abs >= cur_abs) {
                        min_abs = cur_abs;
                }
        }
        cout << min_abs << endl;
        return 0;
}

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

int main(){
    int N;
    cin >> N ;
    vector<int> v(N);
    double ans=0;

    for(int i=0; i<N; i++){
	cin >> v[i];
    }
    sort(v.begin(), v.end());
    ans = (double)v[0];
    for(int i=0; i+1<N; i++){
	ans = (ans + v[i+1])/2.0;
    }

    printf("%.6f\n", ans);

}


Measured memory_bytes: 256
#include <iostream>
// g++ hello.cpp && ./a.out
using namespace std;


int main() {
	int X, Y, Z, temp, temp1;
	cin >> X >> Y >> Z;
	temp = X;
	X = Z;
	temp1 = Y;
	Y = temp;
	Z = temp1;
	cout << X <<" " << Y <<" " << Z << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,m=0,n,a,b;
    cin>>a>>b;
    m=min(a,b);
    if(m==a)
    {
        for(i=0;i<b;i++)
        {
            cout<<a;
        }
    }
    else
    {
        for(i=0;i<a;i++)
        {
            cout<<b;
        }
    }

}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n, k, sum = 0;
    cin >> n >> k;

    vector<long long> a(n), f(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < n; i++)
        cin >> f[i];
    
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<long long>());
    
    auto C = [&a, &f, &k, &n](long long x){
        long long cnt = 0;
        for (int i = 0; i < n; i++){
            if (a[i] * f[i] > x)
                cnt += a[i] - x / f[i];
        }

        return cnt <= k ? true : false;
    };

    long long lb = -1, ub = 1e15;
    while (ub - lb > 1LL){
        long long mid = (lb + ub) / 2;
        if (C(mid))
            ub = mid;
        else
            lb = mid;
    }

    cout << ub << '\n';

    return 0;
}


Measured memory_bytes: 3328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    int ans = 1e9;
    rep(i, n-m+1) {
        int cnt = 0;
        rep(d, m) {
            if (s[i+d] != t[d]) cnt++;
        }
        //cout << cnt << endl;
        chmin(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <bitset>


using namespace std;

int main() {
  long n,m;
  cin >> n >> m;
  vector<long> costs;
  vector<long> open;
  vector<long> dp(1<<n, -1);

  for (int i=0; i<m; i++) {
    long a,b;
    cin >> a >> b;

    long cnt = 0;
    for (long j=0; j<b; j++) {
      long c;
      cin >> c;
      cnt += 1<<(c-1);
    }
    // cout << cnt << endl;
    costs.push_back(a);
    open.push_back(cnt);
  }

  dp[0] = 0; 
  for (long i=0; i<m; i++) {
    dp[open[i]] = costs[i];
  }

  for (long i=0; i<(1<<n); i++) {
    if(dp[i]<0) continue;

    for (long j=0; j<m; j++) {
      long index = (i | open[j]);
      if (dp[index]<0) dp[index] = dp[i] + costs[j];
      else 
        dp[index] = min(dp[index], dp[i] + costs[j]);
    }
  }

  cout << dp[(1<<n)-1] << endl;
}

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

int main() {
	int N;
	cin >> N;
	int h[N] = {};
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int ans[N] = {};
	ans[1] = abs(h[0] - h[1]);
	ans[2] = min(ans[1] + abs(h[2] - h[1]), ans[0] + abs(h[2] - h[0]));
	for (int i = 2; i < N; i++) {
		ans[i] = min(ans[i - 1] + abs(h[i] - h[i - 1]), ans[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << ans[N-1];
	return 0;
}

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

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

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

template<class S, class T> inline void chmin(S &a, T b){if(a>b)a=b;}

int N, A[4000], B[2000], X;

int main(){
  int i, j, k;
  ll res, tmp;

  reader(&N,&X);
  rep(i,N) reader(A+i);

  res = accumulate(A, A+N, 0LL);
  rep(i,N) B[i] = A[i];
  rep(i,N) A[N+i] = A[i];
  REP(k,1,N){
    j = N - k;
    rep(i,N) chmin(B[i], A[j+i]);
    tmp = accumulate(B, B+N, (ll)k*X);
    chmin(res, tmp);
  }

  writerLn(res);

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)

	board := make([][]string, H)
	for i := range board {
		board[i] = make([]string, W)
	}

	for i := 0; i < H; i++ {
		var s string
		fmt.Scan(&s)
		for j := 0; j < W; j++ {
			board[i][j] = string(s[j])
		}
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if board[i][j] == "." {
				sum := 0
				if i != 0 {
					if j != 0 {
						if board[i-1][j-1] == "#" {
							sum++
						}
					}
					if j != W-1 {
						if board[i-1][j+1] == "#" {
							sum++
						}
					}
					if board[i-1][j] == "#" {
						sum++
					}
				}
				if i != H-1 {
					if j != 0 {
						if board[i+1][j-1] == "#" {
							sum++
						}
					}
					if j != W-1 {
						if board[i+1][j+1] == "#" {
							sum++
						}
					}
					if board[i+1][j] == "#" {
						sum++
					}
				}
				if j != 0 {
					if board[i][j-1] == "#" {
						sum++
					}
				}
				if j != W-1 {
					if board[i][j+1] == "#" {
						sum++
					}
				}

				board[i][j] = strconv.Itoa(sum)
			}
		}
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Print(board[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <stack>
#include <tuple>
#include <queue>

using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;

string sUp   = "..##";
string sDown = ".#.#";

string throwQuery(string query)
{
    string bbUp, bbDown;
    for (int i = 0; i < query.size(); i++)
    {
        if (i % 2 == 0) bbUp += query[i];
        else bbDown += query[i];
    }
    cout << bbUp << endl;
    cout << bbDown << endl;
    string ret;
    cin >> ret;
    return ret;
}

int main()
{
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < s.size(); i++) if (s[i] != t[i]) ans++;
    cout << ans << endl;
    return 0;
}

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

int main() {
    long long a, b, v, w, t;
    cin >>a >>v >>b >>w >>t;
    string ret = "NO";
    if (v>w) {
        if (abs(b-a)<=(v-w)*t) {ret ="YES";}
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int dp[1111111][2];

int main(){
    string S;
    cin >> S;
    int N = S.size();
    S += '0';

    for(int i=0; i<1111111; i++)
        dp[i][0] = dp[i][1] = 1<<30;
    dp[0][0] = 0;

    for(int i=0; i<N; i++){
        int d = S[N-1-i] - '0';
        dp[i+1][0] = min(dp[i+1][0], dp[i][0] + d);
        dp[i+1][1] = min(dp[i+1][1], dp[i][0] + (10 - d));
        dp[i+1][0] = min(dp[i+1][0], dp[i][1] + (d + 1));
        dp[i+1][1] = min(dp[i+1][1], dp[i][1] + (10 - (d + 1)));
    }
    int ans = min(dp[N][0], dp[N][1] + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N; cin >> N;
    VL S(N);
    REP(i,N) cin >> S[i];
    LL ans = -LINF;

    for(LL c = 1; c < N; c++){ // c = a-b
        LL score = 0;
        set<LL> used;
        for(LL x = 0; x < N; x++){
            LL A = N-1-x*c;
            if(A <= 0) break;
            LL B = A - c;
            if(B <= 0) break;
            if(x*c > N-1 || N-1-x*c < 0) break;
            if(x*c == N-1-x*c) break;

            //if(used.find(x*c) != used.end()) break;
            //if(used.find(N-1-x*c) != used.end()) break;

            if(used.find(x*c) != used.end()) break;
            score += S[x*c];
            used.insert(x*c);

            if(used.find(N-1-x*c) != used.end()) break;
            score += S[N-1-x*c];
            used.insert(N-1-x*c);

            dump(c)
            dump(x)
            dump(score)

            chmax(ans,score);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 5760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = Integer.valueOf(a + b);

            for (int i = 0; i <= 330; i++) {
                if (n == i * i) {
                    out.print("Yes");
                    return;
                }
            }
            out.print("No");
        }

    }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int a[N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,k,ans=inf;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>a[i];
  // sort(a+1,a+n+1);
  int l=1,r=1e9+10;
  while(l<=r)
  {
    int m=(l+r)>>1,cnt=0;
    // cout<<m<<endl;
    for(int i=1;i<=n;i++)
    {
      int x=(a[i]/m)+((a[i]%m)!=0);
      x=max(x-1,0);
      // cout<<cnt<<" ";
      cnt+=x;
    }
    // break;
    // cout<<endl;
    if(cnt<=k)
    {
      ans=min(ans,m);
      // cout<<ans<<" "<<cnt<<endl;
      r=m-1;
    }
    else
    {
      l=m+1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4368
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

const int calc(int n,const int q){
	for(;;){
		if(n<=q) return n==q;
		int d=n%q,step=n/q+1;
		if(d==0) return step-1;
		n-=(d+step-1)/step*step;
	}
	assert(0);
	return 0;
}

int main(){
	int ans=0;
	for(int i=nxi(); i; --i){
		int n=nxi(),q=nxi();
		ans^=calc(n,q);
	}
	puts(ans?"Takahashi":"Aoki");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		String cs = "";
		for(int i=0;i<26;i++) cs += (char) ('a' + i);
		for(int i=0;i<26;i++) cs += (char) ('A' + i);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			
			int[] a = new int[n];
			for(int i=0;i<n;i++) a[i] = sc.nextInt();
			String code = sc.next();
			String ret = "";
			for(int i=0;i<code.length();i++) {
				int p = 0;
				for(;p<cs.length();p++) if(cs.charAt(p) == code.charAt(i)) break;
				ret += cs.charAt((p + cs.length() - a[i%a.length]) % cs.length());
			}
			System.out.println(ret);
		}
	}

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

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 27040
s = input()

used = [0] * 26

for x in s:
    idx = ord(x) % 26
    used[idx] += 1

if len(s) < 26:
    for i in range(97, 97+26+1):
        if not used[i%26]:
            print(s+chr(i))
            exit()

decrease_point = 0
for i in range(len(s)-1):
    if s[i] < s[i+1]:
        decrease_point = i + 1

if decrease_point == 0:
    print(-1)
    exit()

add_chr = s[decrease_point]
for x in s[decrease_point:]:
    if x > s[decrease_point-1] and x < add_chr:
        add_chr = x

print(s[:decrease_point-1] + add_chr)


Measured memory_bytes: 9040
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    put!(n/2*(n-n/2));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

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


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

void solve() {
	string s; cin >> s;
	if (s[0] == '?')s[0] = 'D';
	for (int i = 1; i < s.length(); i++) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();


}

Measured memory_bytes: 3744
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
	char s[100];
	scanf("%s",&s);
	for (int i=0;i<strlen(s);i++)
	if (s[i]=='A'&&s[i+1]=='C') {
		printf("Yes");
		return 0;
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int n, k, a[101010];
int dp[101010];

void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	fill(dp+1,dp+101010,INF);
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k && i+j < n; j++){
			chmin(dp[i+j], dp[i]+(abs(a[i]-a[i+j])));
		}
	}
	cout << dp[n-1] << endl;
}

int main(){
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<set>
#include<vector>
using namespace std;

int solve(){
  int a, b, c;  cin >> a >> b >> c;
  int role = a+b+c;
  cout << (role>21?"bust":"win") << endl;;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string S;
	cin >> S;
	int A=0, B=0;
	rep(i, S.size())
	{
		if(S.at(i)=='A') A++;
		else B++;
	}
	if(A==0 || B==0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X, A, B;
    cin >> X >> A >> B;
    ll d = B - A;
    if (d <= 0)
        cout << "delicious";
    else if (d <= X)
        cout << "safe";
    else
        cout << "dangerous";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <math.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  int i;
  ll a[n+10],b[n+10];
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  int ans = 0;
  if(n%2 == 1){
    int l = a[n/2];
    int r = b[n/2];
    ans = r-l+1;
  }else{
    int l2 = a[n/2-1]+a[n/2];
    int r2 = b[n/2-1]+b[n/2];
    ans = r2-l2+1;
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const int INF = 1000;
int tile[20][20], A[11][11], dist[20][20], dp[1<<10][11], cnt;

int dpdp(int state, int v) {
  if (state == (1 << cnt) - 1) return dp[state][v] = 0;
  if (dp[state][v] != -1) return dp[state][v];

  int ret = INF;
  REP(i, cnt) {
    if (!(state >> i & 1)) {
      ret = min(ret, dpdp(state | 1 << i, i + 1) + A[v][i+1]);
    }
  }
  return dp[state][v] = ret;;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int R, C;
    cin >> C >> R;
    if (R == 0 && C == 0) break;
    cnt = 0;
    REP(i, R) {
      string row;
      cin >> row;
      REP(j, C) {
	if (row[j] == 'o') tile[i][j] = 0;
	else if (row[j] == '*') tile[i][j] = ++cnt;
	else if (row[j] == 'x') tile[i][j] = -1;
	else tile[i][j] = -2;
      }
    }
    REP(i, cnt + 1) REP(j, cnt + 1) A[i][j] = INF;
    REP(i, R) REP(j, C) {
      if (tile[i][j] >= 0) {
	REP(r, R) REP(c, C) dist[r][c] = INF;
	dist[i][j] = 0;
	queue<T> que;
	que.push(T(0, i, j));
	while (!que.empty()) {
	  int d, r, c;
	  tie(d, r, c) = que.front(); que.pop();
	  if (dist[r][c] != d) continue;
	  
	  REP(i, 4) {
	    int nr = r + dr[i], nc = c + dc[i];
	    if (0 <= nr && nr < R && 0 <= nc && nc < C && tile[nr][nc] != -1 && d + 1 < dist[nr][nc]) {
	      dist[nr][nc] = d + 1;
	      que.push(T(d + 1, nr, nc));
	    }
	  }
	}
	REP(r, R) REP(c, C) if (tile[r][c] >= 0) A[tile[i][j]][tile[r][c]] = dist[r][c];
      }
    }
    //REP(i, cnt + 1) REP(j, cnt + 1) cout << A[i][j] << (j == cnt ? '\n' : ' ');

    bool flag = true;
    REP(i, cnt + 1) REP(j, cnt + 1) if (A[i][j] == INF) flag = false;
    if (!flag) {
      cout << -1 << endl;
      continue;
    }

    memset(dp, -1, sizeof(dp));
    cout << dpdp(0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
int n, m;
vector<vector<int> > g;
vector<int> v;
bool vis[N];
void dfs(int u) {
	v.push_back(u + 1);
	vis[u] = true;
	for (int i = 0, v; i < g[u].size(); ++i) {
		v = g[u][i];
		if (!vis[v]) {
			dfs(v);
			break;
		}
	}
}

int main() {
	scanf("%d%d", &n, &m);
	g.resize(n);
	for (int i = 0, u, v; i < m; ++i) {
		scanf("%d%d", &u, &v);
		--u, --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0);
	reverse(v.begin(), v.end());
	int x = v.back() - 1;
	v.pop_back();
	dfs(x);
	printf("%d\n", (int)v.size());
	for (int i = 0; i < v.size(); ++i)
		printf("%d%c", v[i], " \n"[i == v.size() - 1]);
	return 0;
}


Measured memory_bytes: 9720
s = gets.chomp.split(//)
t = gets.chomp.split(//)

UN = 'UNRESTORABLE'

candidates = []

flg = true
(s.size - t.size).downto(0).each do |i|
  flg = true
  t.size.times do |j|
    unless s[i+j] == '?' || s[i+j] == t[j]
      flg = false
      break
    end
  end

  if flg
    can = s.dup
    t.size.times do |j|
      can[i+j] = t[j]
    end
    can.size.times do |j|
      can[j] = 'a' if can [j] == '?'
    end
    candidates.push can.join('')
  end
end

if candidates.empty?
  puts UN
else
  puts candidates.sort.first
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int mod=1000000007,INF=1099999999999999999;
void YES_OR_NO(bool check){
    if(check){cout<<"YES"<<endl;}
    else{cout<<"NO"<<endl;}
}

long long int m,k,n,a,b,res=0,sum;
string str;
int main() {
	cout << fixed << setprecision(10);
    cin>>n>>str;
    if(n>=3200){cout<<str<<endl;}
    else{cout<<"red"<<endl;}
    
    
} 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int n, count = 0;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> S(N);
  int mm=0,nn=10000000000;
  for(int i=0;i<N;i++){
    cin>>S.at(i);
    if(S.at(i)>mm){
      mm=S.at(i);
    }
    if(S.at(i)<nn){
      nn=S.at(i);
    }
  }
  cout<<mm-nn<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll a, b;
  cin >> a >> b;

  ll rec = b - a;

  if((a <= 0 && b >= 0) || (a == 0 || b == 0)){
    cout << "Zero" << endl;
    return 0;
  }

  if(b < 0){
    if(rec % 2) cout << "Positive" << endl;
    else cout << "Negative" << endl;
    return 0;
  }

  cout << "Positive" << endl;
  return 0;

}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CITY_MAX		100000									// 最大都市数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1City[D_CITY_MAX + 5];								// 都市
static int siCCnt;												// 都市数
static int si1Len[D_CITY_MAX];									// 都市間距離

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// 昇順
	if (*lipVal1 > *lipVal2) {
		return(1);
	}
	else if (*lipVal1 < *lipVal2) {
		return(-1);
	}

	return 0;
}

// 全て割り切れるかチェック
int
fChkDiv(
	int piVal					// <I> 値
)
{
	int i;

	for (i = 0; i < siCCnt - 1; i++) {
		if (si1Len[i] % piVal != 0) {
			return -1;
		}
	}

	return 0;
}

// 最大値 - 取得
int
fGetMax(
	int piMin					// <I> 最小値
)
{
	int i, liRet;

	// チェック範囲
	double ldVal = sqrt((double)piMin);
	int liRng = (int)ldVal;

	// 約数の全パターンをチェック
	int liMax;
	for (i = 1; i <= liRng; i++) {

		// 約数チェック
		if (piMin % i != 0) {
			continue;
		}

		// 約数(大)
		int liVal = piMin / i;

		// 約数(大)で全て割り切れるかチェック
		liRet = fChkDiv(liVal);
		if (liRet == 0) {
			return liVal;
		}

		// 約数(小)で全て割り切れるかチェック
		liRet = fChkDiv(i);
		if (liRet == 0) {
			liMax = i;
		}
	}

	return liMax;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 都市数・開始位置 - 取得
	int liX;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siCCnt, &liX);

	// 都市 - 取得
	for (i = 0; i < siCCnt; i++) {
		fscanf(szpFpI, "%d", &si1City[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 開始位置を都市に追加
	si1City[siCCnt] = liX;
	siCCnt++;

	// 都市 - ソート
	qsort(si1City, siCCnt, sizeof(int), fSortFnc);

	// 都市間距離・最小値 - セット
	int liMin = INT_MAX;
	for (i = 0; i < siCCnt - 1; i++) {
		si1Len[i] = si1City[i + 1] - si1City[i];
		if (liMin > si1Len[i]) {
			liMin = si1Len[i];
		}
	}

	// 最大値 - 取得
	int liMax = fGetMax(liMin);

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liMax);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 1020
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin>>str;
  int ans=0;
  for(int i=1;i<str.size();i++){
    if(str[i-1]==str[i]){
      ans++;
      if(str[i]=='0'){
        str[i]='1';
      }
      else{
        str[i]='0';
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
b='b'
d='d'
p='p'
q='q'
m=[(b,d),(p,q),(d,b),(q,p)]
ans='Yes'
s=input()
if len(s)%2==1:
    ans='No'
else:
    A=s[:len(s)//2]
    B=s[len(s)//2:]
    B=B[::-1]
    for i in range(len(s)//2):
        if (A[i],B[i]) in m:
            continue
        else:
            ans='No'
print(ans)

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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = s[0];
            int B = s[1];
            int K = s[2];

            for(int i = 1; i <= B; i++)
            {
                if(A<=i && i <= B)
                {
                    if (i - A < K || B - i< K)
                    {
                        Console.WriteLine(i);
                    }
                }
            }
        }
    }
}


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

double s[100000];

int main()
{
	int n,m,j,k,i,t,ans,T,a,b;
	cin>>n;
	cin>>a>>b;
	for (i=0;i<n;i++)
	{
		cin>>s[i];
		s[i]  = a - 0.006*s[i];
	}
	double min = 1000000000.0;
	for (i=0;i<n;i++)
	{
		if (fabs(s[i] - b)<= min)
		{
			min = fabs(s[i]-b);
			ans = i;
		}
	}
	cout<<ans+1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a<=c && c<=b){
		cout << "Yes" << endl;
	}else if(b<=c && c<=a){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s;
    cin >> s;
    int n = s.size();
    if( n%2==0 ^ s[0]==s.back()){
        cout << "Second" << endl;
    }else cout << "First" << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

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

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

map<LL,int>cnt;
int n;

int main(){
	n=get();
	LL now=0;
	cnt[0]++;
	LL ans=0;
	fo(i,1,n){
		int x=get();
		now=now+x;
		ans=ans+cnt[now];
		cnt[now]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12800
#include <stdio.h>

int main (void)
{
    int a, b, c, temp;
    int n, i;
    scanf("%d", &n);
    

    for (i = 1; i <= n; i++){
        scanf("%d%d%d", &a, &b, &c);
        if (a > c){
            temp = c;
            c = a;
            a = temp;
        }
        if(b > c){
            temp = c;
            c = b;
            b = temp;
        }
        if (a * a + b * b == c * c)  printf("YES\n");
        else printf("NO\n");
    }
    return (0);
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=0;
    int n=s.size();
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[n-1-i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256