akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  string s;

  cin >> s;

  for(char c : s) {
    if (c == '9') cout << '1';
    else cout << '9';
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#define rep1(i,s,e,c) for(int i=s;i<e;i=i+c)
#define rep2(i,s,e,c) for(int i=s;i<=e;i=i+c)
#define rep3(i,e,s,c) for(int i=e;i>=s;i=i-c)
using namespace std;
typedef long long ll;
const int MAX=1e5+5;
const int MOD=1e9+7;
int main()
{    
    int a,b,c,d,e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    cout<<max(max(c,d),e);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL<<60;
using namespace std;

int n, k;

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

    priority_queue<long, vector<long>, greater<long> > q;
    // priority_queue<long> q;
    long long value_max = -INF;
    // 左からl回、右からr回取り出す
    // 戻すのは、k - (l + r) まで
    for(int l = 0; l <= k; l++) {
        for(int r = 0; r <= k;r++) {
            if( l + r > n || l + r > k )
                continue;

            for(int i = 0; i < l; i++)
                q.push(v[i]);
            for(int i = 0; i < r; i++)
                q.push(v[n-i-1]);

            long long value = 0;
            for(int i = l + r; i < k; i++) {
                if(!q.empty() && q.top() < 0)
                    q.pop();
            }

            while(!q.empty()) {
                value += q.top(); q.pop();
            }
            value_max = max(value, value_max);
        }
    }
    cout << value_max << endl;
}

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

int main() {
  int n;
  int h,m;
  bool timetables[24][60] = {false};
  while(cin >> n) {
    for(int i=0;i<n;i++) {
      cin >> h >> m;
      timetables[h][m] = 1;
    }
  }

  vector<pair<int,int> > disp;
  for(int h = 0;h < 24;h++) {
    for(int m = 0;m < 60;m++) {
      if(timetables[h][m])
        disp.push_back(make_pair(h,m));
    }
  }
  for(int i=0;i<disp.size();i++) {
    cout << disp[i].first << ":";
    if(disp[i].second < 10)
      cout << 0;
    cout << disp[i].second;
    if(i+1 == disp.size())
      cout << endl;
    else
      cout << " ";
  }
}

Measured memory_bytes: 1204
N,Q = map(int,input().split())
S = ["N"] + list(input())

A_ruiseki = [0 for i in range(N+1)]
C_ruiseki = [0 for i in range(N+1)]

for i in range(0,N,1):
    if S[i]=="A" and S[i+1]=="C":
        A_ruiseki[i]+=1
        C_ruiseki[i+1]+=1

for i in range(1,N+1,1):
    A_ruiseki[i]+=A_ruiseki[i-1]
    C_ruiseki[i]+=C_ruiseki[i-1]

ans = []
for i in range(Q):
    l,r = map(int,input().split())
    A = A_ruiseki[r]-A_ruiseki[l-1]
    C = C_ruiseki[r]-A_ruiseki[l-1]
    ans.append(min(A,C))

for i in range(Q):
    print(ans[i])

Measured memory_bytes: 91064
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w;
string s[51];

bool contain(int y, int x){
   return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    rep(i, 0, h){
        cin >> s[i];
    }
    rep(i, 0, h){
        rep(j, 0, w){
            if(s[i][j] == '#') continue;
            int cnt = 0;
            rep(k, 0, 3){
                rep(l, 0, 3){
                    if(k == 1 && l == 1) continue;
                    int y = i + k - 1;
                    int x = j + l - 1;
                    if(!contain(y, x)) continue;
                    if(s[y][x] == '#') cnt++;
                }
            }
            s[i][j] = '0' + cnt;
        }
    }
    rep(i, 0, h){
        cout << s[i] << endl;
    }
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

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

    int ans = a + a*a + a*a*a;
    cout << ans << endl;

    return 0;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  vector<string> S(N);

  rep(i, N)
    cin >> S[i];
  sort(all(S));
  vector<int> s;
  int sum = 0;
  // rep(i, N)
  //   cout << S[i] << ' ';
  // cout << endl;
  int cnt = 0;
  rep(i, N) {
    cnt++;
    if ((i != N-1 && S[i] != S[i+1]) || i == N-1) {
      sum = max(cnt, sum);
      cnt = 0;
      s.pb(i);
    }
  }
  // rep(i, s.size())
  //   cout << s[i] << ' ';
  // cout << endl;
  rep(i, s.size()) {
    if (i == 0) {
      if(s[i]+1 == sum)
        cout << S[s[i]] << endl;
    }
    else {
      if (s[i]-s[i-1] == sum) {
        cout << S[s[i]] << endl;
      }
    }
  }
}


Measured memory_bytes: 13812
h, w = map(int, input().split())
s = [input() for _ in range(h)]
L = [[0] * w for _ in range(h)]
R = [[0] * w for _ in range(h)]
U = [[0] * w for _ in range(h)]
D = [[0] * w for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if j != 0:
            L[i][j] = L[i][j - 1]
        if s[i][j] == ".":
            L[i][j] += 1
        else:
            L[i][j] = 0
for i in range(h):
    for j in range(w - 1, -1, -1):
        if j != w - 1:
            R[i][j] = R[i][j + 1]
        if s[i][j] == ".":
            R[i][j] += 1
        else:
            R[i][j] = 0
for j in range(w):
    for i in range(h):
        if i != 0:
            U[i][j] = U[i - 1][j]
        if s[i][j] == ".":
            U[i][j] += 1
        else:
            U[i][j] = 0
for j in range(w):
    for i in range(h - 1, -1, -1):
        if i != h - 1:
            D[i][j] = D[i + 1][j]
        if s[i][j] == ".":
            D[i][j] += 1
        else:
            D[i][j] = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
print(ans)

Measured memory_bytes: 180356
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int t,x,y;
        scanf("%d %d %d",&t,&x,&y);
        if(t%2==0 && x+y <=t)
        {
          //  cout<<x<<"[0:0]"<<y<<"\n";
          if((x+y)%2==0){continue;}
          else{cout<<"No"; return 0;}
        }
        else 
        if(t%2==1 && x+y <=t)
        {
         //   cout<<x<<"[0:1]"<<y<<"\n";
         if((x+y)%2==1){continue;}
         else{cout<<"No"; return 0;}
        }
        else{cout<<"No"; return 0;}
        
    }
    
    cout<<"Yes";
    return 0;
    
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define fi first
#define se second

const ll MOD = 1e9 + 7LL;

map<int, int> cinioci;

ll modPow(ll a, ll n)
{
    if(n == 0)
        return 1LL;

    ll pola = modPow(a, n/2) % MOD;
    ll celo = (pola*pola)%MOD;

    if(n % 2 == 0)
    {
        return celo;
    }
    else
    {
        return (celo*a)%MOD;
    }
}

map<int, int> fact(int n)
{
    map<int, int> odgovor;

    for(int i = 2; i * i <= n; ++i)
    {
        int brojac = 0;

        while(n % i == 0)
        {
            n /= i;
            ++brojac;
        }

        if(brojac > 0)
        {
            odgovor[i] = brojac;
        }
    }

    if(n > 1)
    {
        odgovor[n] = 1;
    }

    return odgovor;
}

int main()
{
    int n;
    cin >> n;
    vi v(n);

    for(auto &z : v)
        cin >> z;

    for(int i = 0; i < n; ++i)
    {
        map<int,int> ciniociBroja = fact(v[i]);

        for(map<int,int>::iterator it = ciniociBroja.begin(); it != ciniociBroja.end(); ++it)
        {
            //cout << it->fi << ' ' << it->se << '\n';
            cinioci[it->fi] = max(cinioci[it->fi], it->se);
            //cout << cinioci[it->fi] << '\n';
        }
    }

    ll nzs = 1LL;

    for(map<int,int>::iterator it = cinioci.begin(); it != cinioci.end(); ++it)
    {
        //cout << it.fi << ' ' << it.se << '\n';
        nzs = (nzs * modPow(it->fi, it->se))%MOD;
    }

    ll resenje = 0LL;

    for(int i = 0; i < n; ++i)
    {
        ll izraz = (nzs*modPow(v[i], MOD-2))%MOD;
        resenje = (resenje + izraz) % MOD;
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 768
#D問題
mod = 10007
N = int(input())
S = list(str(input()))
dp = [[0 for i in range(7)] for j in range(N)]#j,o,i,jo,oi,ij,joi

for i in range(N):
    s = S[i]
    if i == 0:
        if s == "J":
            dp[0][0]+=1
            dp[0][3]+=1
            dp[0][5]+=1
            dp[0][6]+=1
        elif s == "O":
            dp[0][3]+=1
            dp[0][6]+=1
        else:
            dp[0][5]+=1
            dp[0][6]+=1
    else:
        if s == "J":
            dp[i][0] = dp[i-1][0]+dp[i-1][3]+dp[i-1][5]+dp[i-1][6]
            dp[i][3] = dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][5] = dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][6] = dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
        elif s == "O":
            dp[i][1] = dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][6]
            dp[i][3] = dp[i-1][0]+dp[i-1][1]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][4] = dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][6] = dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
        elif s == "I":
            dp[i][2] = dp[i-1][2]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][4] = dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][5] = dp[i-1][0]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
            dp[i][6] = dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3]+dp[i-1][4]+dp[i-1][5]+dp[i-1][6]
    
print(sum(dp[N-1])%mod)



Measured memory_bytes: 6160
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
        lazyFlag.resize(2*n-1, false);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            //node[k] = (r-l)*lazy[k]; // change
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] += lazy[k]/2; // change
                lazy[k*2+2] += lazy[k]/2; // change
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazy[k] = 0;
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            //lazy[k] = x;// change
            lazy[k] += (r-l)*x; //del
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return vl+vr;
    }
};
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl lr = vv(n, 3, 0, ll);
  for(int i=0;i<n;i++){
    std::cin >> lr[i][1] >> lr[i][2];
    lr[i][0] = lr[i][2] - lr[i][1] + 1;
  }
  vector<int> c(m+1, 0);
  LazySegmentTree seg(c);
  sort(lr.begin(), lr.end());
  for(int i=1, j=0;i<=m;i++){
    while(j!=n&&lr[j][0]<=i){
      seg.update(lr[j][1], lr[j][2]+1, 1);
      j++;
    }
    ll ans = n - j;
    for(int j=1;j*i<=m;j++){
      ans += seg.find(j*i, j*i+1);
    }
    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 21240
def find(sequence):
    result_list = []
    for i in range(len(sequence)):
        for j in reversed(list(range(len(sequence)))):
            if sequence[j] == j + 1:
                result_list.append(sequence.pop(j))
                break
    if len(sequence) != 0:
        return [-1]
    return result_list


if __name__ == "__main__":
    n = input()
    sequence = input()
    data = [int(item) for item in sequence.split(" ")]
    print("\n".join(map(str, reversed(find(data)))))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N=200010;
int n,num_edge,a[N],f[N],ans[N],head[N];
struct Edge 
{
	int to; 
	int Next;
}edge[N<<1];
void add_edge(int from,int to) 
{
	edge[++num_edge].to=to;
	edge[num_edge].Next=head[from];
	head[from]=num_edge;
}
void dfs(int x,int fa) 
{
	int last;
	int l=1,r=ans[fa];
	if(fa==0)
	{
		f[1]=a[x];
		ans[1]=1;
	}
	else 
	{
		while(l<=r) 
		{
			int mid=(l+r)>>1;
			if(a[x]<=f[mid]) 
				r=mid-1;
			else 
				l=mid+1;
		}
		last=f[l];
		f[l]=a[x];
		ans[x]=ans[fa];
		if(l>ans[fa]) 
			ans[x]++;
	}
	for(int i=head[x];i;i=edge[i].Next) 
	{
		int y=edge[i].to;
		if(y!=fa) 
			dfs(y,x);
	}
	f[l] = last;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n-1;i++) 
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 23628
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    a_sum = 0
    sign = "plus"
    ans1 = 0
    for i in range(0, n):
        if sign == "plus":
            sign = "minus"
            if a_sum + a_list[i] == 0:
                ans1 += 1
                a_sum = -1
            elif a_sum + a_list[i] > 0:
                ans1 += a_sum + 1 + a_list[i]
                a_sum = -1
            else:
                a_sum += a_list[i]
        elif sign == "minus":
            sign = "plus"
            if a_sum + a_list[i] == 0:
                ans1 += 1
                a_sum = 1
            elif a_sum + a_list[i] < 0:
                ans1 += -1 * a_sum + 1 + -1 * a_list[i]
                a_sum = 1
            else:
                a_sum += a_list[i]

    a_sum = 0
    sign = "minus"
    ans2 = 0
    for i in range(0, n):
        if sign == "plus":
            sign = "minus"
            if a_sum + a_list[i] == 0:
                ans2 += 1
                a_sum = -1
            elif a_sum + a_list[i] > 0:
                ans2 += a_sum + 1 + a_list[i]
                a_sum = -1
            else:
                a_sum += a_list[i]
        elif sign == "minus":
            sign = "plus"
            if a_sum + a_list[i] == 0:
                ans2 += 1
                a_sum = 1
            elif a_sum + a_list[i] < 0:
                ans2 += -1 * a_sum + 1 + -1 * a_list[i]
                a_sum = 1
            else:
                a_sum += a_list[i]

    print(min(ans1, ans2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (B < A) swap(A, B);
    if (A < C && C < B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int N = 16, p = 1e9 + 7, S = 1 << N | 5;
int n, m, s, a[N], f[N + 1][S];
int fac[S], inv[S];
inline void A(int &x, int y) { x += y; if (x >= p) x -= p; }
inline int C(int x, int y) { return 1ll * fac[x] * inv[y] % p * inv[x - y] % p; }
inline int Bc(int x) {
	int ans = 0;
	while (x) ans += x & 1, x >>= 1;
	return ans;
}
int main() {
	fac[0] = 1; for (int i = 1; i < S; ++i) fac[i] = 1ll * fac[i - 1] * i % p;
	inv[0] = inv[1] = 1; for (int i = 2; i < S; ++i) inv[i] = 1ll * inv[p % i] * (p - p / i) % p;
	for (int i = 2; i < S; ++i) inv[i] = 1ll * inv[i - 1] * inv[i] % p;
	scanf("%d%d", &n, &m); s = 1 << n;
	for (int i = 0; i < m; ++i) scanf("%d", a + i);
	f[m][0] = 1;
	for (int i = m - 1; ~i; --i)
		for (int o = 0; o < s; ++o) {
			int rp = s - a[i] - o; // the number of remain person.
			A(f[i][o], f[i + 1][o]);
			for (int j = 0; j < n; ++j) if (!(o >> j & 1) && (1 << j) - 1 <= rp) 
				A(f[i][o | 1 << j], 1ll * f[i + 1][o] * C(rp, (1 << j) - 1) % p * fac[1 << j] % p);
		}
	int ans = 0;
	for (int o = 0; o < s; ++o) {
		int rst = 1ll * f[0][o] * fac[s - o - 1] % p;
		if (Bc(o) & 1) A(ans, p - rst); else A(ans, rst);
	}
	printf("%lld\n", 1ll * ans * s % p);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(n-1) - vec.at(0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ int n;
    cin >> n;
    float arr[n];
    for(int i=0;i<n;i++)
    {
      cin >> arr[i];
    }
  sort(arr,arr+n);
  float ans =arr[0];
  for(int i=1;i<n;i++)
      ans = (ans+arr[i])/2;
  cout << ans << endl;
     return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  sum=1;
  while(sum<=N)sum*=2;
  Out(sum-1);
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h+1,vector<char> (w+1,'.'));

  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
    }
  }

  int current_x = 0, current_y = 0;
  bool flag = 0;
  a.at(0).at(0) = '.';

  while(current_x != h - 1  || current_y != w - 1 ) {
    if(a.at(current_x + 1).at(current_y) == '#' && a.at(current_x).at(current_y + 1) != '#') {
      current_x++;
      a.at(current_x).at(current_y) = '.';
      if(current_x == h - 1 && current_y == w - 1) flag = 1;
      continue;
    }
    else if(a.at(current_x + 1).at(current_y) != '#' && a.at(current_x).at(current_y + 1) == '#') {
      current_y++;
      a.at(current_x).at(current_y) = '.';
      if(current_x == h - 1 && current_y == w - 1) flag = 1;
      continue;
    }
    else {
      break;
    }

    
  }

  // rep(i,h){
  //   rep(j,w){
  //     cout << a.at(i).at(j);
  //   }
  //   cout << endl;
  // }

  // cout << current_x << ' ' << current_y << endl;
  // 
  // cout << "flag" << flag << endl;

  if(flag == 1){
    bool flag2 = 1;
    rep(i,h){
      rep(j,w){
        if(a.at(i).at(j) == '#') flag2 = 0;
      }
    }
    flag = flag2;
  }

  if(flag == 0) cout << "Impossible" << endl;
  else{
    cout << "Possible" << endl;
  }
}



Measured memory_bytes: 256
import Data.List
import Data.List.Split

fib :: Int -> Int -> Int -> Int
fib 0 x _ = x
fib n x y = fib (n-1) y (x+y)

main = do
  lines <- getContents
  let s:_ = splitOn "\n" lines
  print
    $ foldr (+) 0
    $ take 2
    $ sort
    $ map (read::String -> Int)
    $ splitOn " " s


Measured memory_bytes: 508
#include <cstring>
#include <iostream>
using namespace std;
int main() {
    const int MAX_N = 100, MAX_W = 10000;
    int N, W, v[MAX_N], w[MAX_N], m[MAX_N];
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> v[i] >> w[i] >> m[i];
    }
    int dp[MAX_W + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < N; ++i) {
        int num = m[i];
        for (int k = 1; num > 0; k <<= 1) {
            int mul = min(k, num);
            for (int j = W; j >= w[i] * mul; --j) {
                dp[j] = max(dp[j], dp[j - w[i] * mul] + v[i] * mul);
            }
            num -= mul;
        }
    }
    cout << dp[W] << endl;
    return 0;
}



Measured memory_bytes: 3176
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
        int a[5001] = { 0 };
        int n;
    while (1) {
        cin >> n;
        if (n == 0)break;
       // a[0] = 0;
        int maxv = -100000;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        for (int i = 1; i <= n; i++) {
            a[i] = max(a[i], a[i] + a[i - 1]);
            maxv = max(maxv, a[i]);
        }
        cout << maxv << endl;
    }
}

Measured memory_bytes: 1184
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**18


if __name__ == "__main__":
    s = input()
    if "R" in s:
        cnt = 1
    else:
        cnt = 0
    for i in range(len(s)-1):
        if s[i] == "R" and s[i+1] == "R":
            cnt+=1
    print(cnt)

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}

bool IsPrime(LL N){
  if(N >= 1) return false;
  for(int i = 2; i*i <= N; ++i){
    if(N%i == 0) return false;
  }
  return true;
}

bool ComPaiSec(PII a, PII b){
  if(a.SE != b.SE){
    return a.SE < b.SE;
  }else{
    return a.FI < b.FI;
  }
}

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  cin >> N >> M;
  VI P(M), Y(M),ID(M);
  
  VVI v(N);
  
  REP(i,M){
    cin >> P.at(i) >> Y.at(i);
    P.at(i)--;
    v.at(P.at(i)).PB(Y.at(i));
  }
  
  REP(i,N){
    SORT(v.at(i));
  }
  
  REP(i,M){
    ID.at(i) = LB(ALL(v.at(P.at(i))),Y.at(i)) - v.at(P.at(i)).begin();
  }
  
  REP(i,M){
    printf("%06d",P.at(i)+1);
    printf("%06d\n",ID.at(i)+1);
  }
  
  return 0;
}

Measured memory_bytes: 8192
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

static uint32_t getPowBLessThanOREqualToX(const uint32_t b, const uint32_t X) {
	uint32_t powB = b;
	while (1) {
		if (powB * b <= X) {
			powB *= b;
		}
		else {
			break;
		}
	}

	return powB;
}

int main(void) {
	uint32_t X;
	uint32_t maxPow = 1;

	scanf("%"PRIu32, &X);

	const uint32_t maxB = (uint32_t)sqrt((double)X);

	for (uint32_t b = 2; b <= maxB; b++) {
		const uint32_t maxPowBLessThanOrEqualToX = getPowBLessThanOREqualToX(b, X);
		if (maxPowBLessThanOrEqualToX > maxPow) {
			maxPow = maxPowBLessThanOrEqualToX;
		}
	}

	printf("%"PRIu32, maxPow);

	return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n, z, w;
vint a;

int dp[2][2002][2002];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> n >> z >> w;
  resz(a, n);
  rep(i, n) cin >> a[i];
  int ans = abs(a[n-1]-w);
  for(int i = 0; i < n-1; i++) {
    chmax(ans, min(abs(a[n-1]-a[i]), abs(a[n-1]-a[n-2])));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000007;

ll max(ll a, ll b) { return (a > b) ? a : b; }

int main() {
    int n, m;
    cin >> n >> m;
    int *a = new int[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }

    ll *dp = new ll[n + 10];
    for (int i = 0; i < n; i++) {
        dp[i] = 0;
    }

    // cout << "*********************" << endl;
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 0; i < m; i++) {
        if (a[i] == 1) {
            dp[1] = 0;
        }
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j < m; j++) {
            if (i + 1 == a[j]) {
                dp[i + 1] = 0;
                break;
            }
        }
        dp[i + 2] = (max(dp[i + 2], dp[i] + dp[i + 1])) % MOD;
        // cout << dp[i] << endl;
    }
    // cout << "*****************" << endl;
    cout << dp[n] % MOD << endl;
    return 0;
}

Measured memory_bytes: 4700
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let cs = Array.make 9 0
let f i = cs.(i) <- cs.(i) + 1
let mi = Array.(iter (fun a -> f @@ min 8 @@ a / 400) a_s; fold_left (fun s c -> s + if c > 0 then 1 else 0) 0 cs - min 1 cs.(8))
let _ = Printf.printf "%d %d\n" (max 1 mi) @@ mi + cs.(8)

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

int main(){
    int j = 0,x,n,mn = 10000,d,mind = 10000;
  
  	cin >> x >> n;
    
  	vector<int>a(n),b(102);
  
  	for(int i = 0;i < n;i++)
      cin >> a.at(i);
  	sort(a.begin(),a.end());
  
  	for(int i = 0;i < 102;i++){
      b.at(i) = i;
      if(j < n && i == a.at(j)){
        b.at(i) = 0;
        j++;
      }
    }
  	sort(b.begin(),b.end());
  
  	for(int i = n;i < 102;i++){
      d = abs(x - b.at(i));
      if(mind > d){
        mn = b.at(i);
        mind = d;
      }  
    }
  	cout << mn << endl;
  
}

Measured memory_bytes: 3628
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=0;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

string s;
int main(int argc,char** argv){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n>>s;
	int len=s.size();
	rep(i,len){
		char c=s[i];
		int d=(c-'A');
		d=(d+n)%26;
		//cout<<d<<endl;
		c=char('A'+d);
		s[i]=c;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int A,B;
	int anser;

	scanf("%d%d",&A,&B);

	if(A>B){
		anser=A+(A-1);
	}
	if(A<B){
		anser=B+(B-1);
	}
	if(A==B){
		anser=A+B;
	}
	printf("%d",anser );
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>

using namespace std;

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  float d = numeric_limits<float>::max();
  int best = 1;
  for (int i = 1; i <= n; i++) {
    int h;
    cin >> h;
    const float x = fabs(t - a - h * 0.006);
    if (x < d) {
      d = x;
      best = i;
    }
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 256
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b = list(map(int,ipti().split()))
    
    if a >= 13:
        print(b)
    elif a <= 5:
        print(0)
    else:
        print(b//2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#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<int> vec(N);
  rep(i,N){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int count=1;
  rep(i,N){
    if(i!=N-1 && vec[i]>vec[i+1]){count++;}
  }
  cout << count << endl;
}




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

int dp[100001][3] = {};

int rec(int mat[][3] , int type, int idx);

int main(){
	memset(dp,-1,sizeof(dp));
	int n;
	cin >> n;
	int mat[n][3];
	for(int i= 0 ; i < n ; ++i){
		cin >> mat[i][0] >> mat[i][1] >> mat[i][2];
	}
	dp[0][0] = mat[0][0];
	dp[0][1] = mat[0][1];
	dp[0][2] = mat[0][2];

	for(int i=1 ; i < n ; ++i){
		for(int j=0; j < 3 ; ++j){
			if(j==0) dp[i][j] = mat[i][j] + max(dp[i-1][1],dp[i-1][2]);
			if(j==1) dp[i][j] = mat[i][j] + max(dp[i-1][0],dp[i-1][2]);
			if(j==2) dp[i][j] = mat[i][j] + max(dp[i-1][0],dp[i-1][1]);
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
	int n;bool yes=false;cin>>n;
	if(n/1000==n%1000/100 && n%1000/100==n%100/10)yes=true;
	else if(n%1000/100==n%100/10 && n%100/10==n%10)yes=true;
	if(yes)cout<<"Yes";else cout<<"No";
	return 0; 
}

Measured memory_bytes: 256
s = input()
d = s.replace('x','')
l = ''
r=''
if d!= d[::-1]:
    print(-1)
    exit()
ans =0
l=[]
cnt = 0
for i in s:
    if i=='x':
        cnt+=1
    else:
        l.append(cnt)
        cnt=0
l.append(cnt)
l1 = l[:len(l)//2]
l2 = l[::-1]
for i in range(len(l1)):
    ans+=abs(l1[i]-l2[i])
print(ans)

Measured memory_bytes: 5236
#cited from maspy
import itertools
import numpy as np

N, M, Q = map(int, input().split())
A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))
n = len(A)
score = np.zeros(n, np.int32)
m = [list(map(int, input().split())) for i in range(Q)]
for a, b, c, d in m:
    cond = A[:, b - 1] - A[:, a - 1] == c
    score += d * cond
print(score.max())

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

public class Prog
{
    public void run()
    {
        string S = Console.ReadLine();
        bool flag = false;
        if(S[0] == S[1])
        {
            flag = true;
        }
        if(S[1] == S[2])
        {
            flag = true;
        }
        if(S[2] == S[3])
        {
            flag = true;
        }
        if(flag == true)
        {
            Console.WriteLine("Bad");
        }
        else
        {
            Console.WriteLine("Good");
        }
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
}

//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 11092
import Control.Monad
import qualified Data.IntSet as S

main :: IO ()
main = do
  [n, _] <- readInts
  sets <- replicateM n readFavo
  print $ solve sets

readInts :: IO [Int]
readInts =map read . words <$> getLine

readFavo :: IO S.IntSet
readFavo = do
  (_ : as) <- readInts
  return $ S.fromList as

solve :: [S.IntSet] -> Int
solve [x] = S.size x
solve (x:y:zs) = solve $ (x `S.intersection` y) : zs

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <stack> 
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    stack<int> S;
    string s;
    int a, b;

    while(cin >> s){
        if(s == "+"){
            a = S.top();S.pop();
            b = S.top();S.pop();
            S.push(a+b);
        }
        else if(s == "-"){
            a = S.top();S.pop();
            b = S.top();S.pop();
            S.push(b-a);
        }
        else if(s == "*"){
            a = S.top();S.pop();
            b = S.top();S.pop();
            S.push(a*b);
        }
        else
        {
            S.push(atoi(s.c_str())); //c_str で s からcharのポインタを取り出す
        }

        
    }
    cout << S.top() << endl;

    
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int max_l=0,r=0,l=0;
  for(int i=0;i<s.size();i++){
    r=i;
    l=i;
    if((s.at(i) =='A') || (s.at(i)=='C') || (s.at(i)=='G') || (s.at(i)=='T')){ 
      for(int j=i;j<s.size() ;j++){
        if((s.at(j)=='A') || (s.at(j)=='C') || (s.at(j)=='G') || (s.at(j)=='T')){ r++;
      }else{break;}
      }}
    max_l = max(max_l,r-l);
      }
  cout << max_l << endl;
}


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


int main(){
  
  string s;
  cin >> s;
  
  sort(s.begin(), s.end());
  
  if(s == "abc"){
	cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = []
for i in range(N):
    A.append(int(stdin.readline().rstrip().split()[0]))

L_max = [0]
R_max = [0]

for i in range(N-1):
    L_max.append(max(L_max[-1], A[i]))

for i in range(N-1,0,-1):
    R_max.append(max(R_max[-1], A[i]))

R_max=R_max[::-1]
noi_max = []
for i in range(N):
    noi_max.append(max(L_max[i], R_max[i]))

for i in range(N):
    print(noi_max[i])


Measured memory_bytes: 26252
P = map(int, raw_input().split())
N = int (raw_input())*4
for i in range(1,4):
    if P[i] > P[i-1]*2:
        P[i]=P[i-1]*2
ans=0
t=8
for i in range(1,5):
    ans += N/t*P[-i]
    N %= t
    t/=2
print ans



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

using namespace std;
#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);
const int N = 3000 + 9;
int n, m;
long double mem[N][N];
long double arr[N];
const int mod = 1e9 + 7;

long double solve(int i = 0, int count = 0) {
    if (i == n)
        return (count > (int) (n / 2)) ? 1.0 : 0;
    if (mem[i][count]==mem[i][count])return mem[i][count];
    return mem[i][count] = (solve(i + 1, count) * (1 - arr[i])) + (solve(i + 1, count + 1) * arr[i]);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)cin >> arr[i];
    memset(mem,-1,sizeof mem);
    cout << fixed << setprecision(10) << solve() << endl;
}



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

// 最大公倍数
long long  gcd(long long  x, long long  y) {
    return y ? gcd(y, x % y) : x;
}


//long long a(long long x, long long y) {
//    return x * y;
//}

int main() {
    int n;
    long long  g;
    long long answer = 1;
    cin >> n;

    for (int i=0; i< n; i++){
        long long x;
        cin >> x;
        answer = x/gcd(x, answer) * answer;
    }
    
    



    cout << answer  << endl;

    return 0;
}

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

int main(){
    char n[3]; cin>>n;
    REP(i,3){
        if(n[i]=='1'){
            n[i]='9';
        }else{
            n[i]='1';
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}

unsigned long long nCr(long n, long r) {
    unsigned long long ans = 1;
    for (long i = 1 ; i < r + 1; ++i) {
        ans = ans * (n-i+1) % mop;
//        cout << ans << endl;
        ans = ans * modinv(i,mop) % mop;
//        cout << ans << endl;
    }
//    cout << ans << endl;
    return ans;
}


int main() {
   
    ll n,k;
    cin >> n >> k;
//    cout << nCr(3,2) << endl;
    for (ll i=1;i<=k;i++){
        cout << nCr(n-k+1,i) * nCr(k-1, i-1) % mop << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    double  H, A;
    cin >> H >> A;
    cout << ceil(H / A)<< endl;
}

Measured memory_bytes: 256
a, b, h, m = gets.split.map(&:to_i)

h_deg = 360.0 / (12 * 60) * (60 * h + m)
m_deg = 360 / 60 * m
theta = [h_deg - m_deg, m_deg - h_deg].max

theta_radian = theta * Math::PI / 180

ans = a ** 2 + b ** 2 - 2 * a * b * Math.cos(theta_radian)
puts Math.sqrt(ans)


Measured memory_bytes: 14736
//#include "bits/stdc++.h"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define int long long
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define REV(i, a, n) for (int i = n; i >= a; --i)
#define all(e) e.begin(), e.end()
#define rall(e) e.rbegin(), e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr << #n << " = " << n << endl
#define showp(n) cerr << n.fs << ", " << n.sc << endl
#define shows(n)       \
  for (auto z : n) {   \
    cerr << z << ", "; \
  }                    \
  cerr << endl
#define showsp(n)                       \
  for (auto z : n) {                    \
    cerr << z.fs << " " << z.sc << ", " \
  }                                     \
  cerr << endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case (i) printf("Case #%lld: ", i)

using namespace std;

using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int, int>;

const int INF = 1LL << 55;

int n;
int xsum = 0, sum = 0, ans = 0;

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

  cin>>n;
  vi vec(n);
  rep(i,n) cin>>vec[i];



  for(int l=0,r=0;r<n;l++){
    while(r<n){
      if(sum+vec[r]!=(xsum^vec[r])) break;
      sum+=vec[r];
      xsum^=vec[r];
      ans+=r-l+1;
      r++;
    }
    sum-=vec[l];
    xsum^=vec[l];
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1792
import scala.io.StdIn

object Main {

  def digitSum(n: String): Int = n.toList.map(_.asDigit).sum

  def main(args: Array[String]): Unit = {
    val N: Long = StdIn.readLine.toLong
    val s: String = (N+1).toString
    println(digitSum((s(0).asDigit-1).toString + "9" * (s.length-1)))
  }
}


Measured memory_bytes: 27188
import scala.io.StdIn

/**
  * Created by yusaku on 2017/02/15.
  */

object Main {
  def main(args: Array[String]): Unit = {
    val ab = StdIn.readLine().split(" ").map(_.toInt)
    println(s"${ab.product} ${ab.sum * 2}")
  }
}

Measured memory_bytes: 43756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int a, b; cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
int main(){
    int x, y;
    while(true){
        std::cin >> x >> y;
        if(x!=0 || y!=0){
            if(x-y>=0)
            std::cout << y << " " << x << std::endl;
            else
            std::cout << x << " " << y << std::endl;
        }else break;
    }
    return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    LL K,a,b;
    cin>>K;
    if(K<=1000000){
        cout<<2<<endl;
        
        if(K%2==0){
            a=b=1+K/2;  
        }
        else{
        a=b=1+K/2;
        a--;
        b+=2;
        }
        cout<<a<<" "<<b<<endl;
    }
    else{
        cout<<50<<endl;
        LL t=(K+49)/50;
        LL now=t*50;
        vector<LL> a(50,49+t);
        while(now>K){
            sort(ALL(a));
            a.back()-=51;
            for(auto &it:a)it++;
            now--;
        }
        REP(i,50)cout<<" "+(!i)<<a[i];
        cout<<endl;

    }
    return 0;
}


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

int main() {
int A;
cin>>A;
int B;
cin>>B;
int C;
cin>>C;
int D;
cin>>D;
int x=A*B;
int y=C*D;
bool zyoukena=x>=y;
bool zyoukenb=x<y;
if(zyoukena){cout<<x<<endl;}
if(zyoukenb){cout<<y<<endl;}
 return 0;
}



Measured memory_bytes: 256