akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}


int main(){
  int N; cin >> N;
  vector<int> H(N); rep(i,N) cin >> H[i];
  int ans = 0;
  int now = 0;
  rep(i,N){
    ans += chmax(now, H[i])? 1:0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A_raw = list(map(int, input().split()))

flg = 1
prev = 0
A = []
for i in range(N):
    if A_raw[i] <= prev:
        flg = 0
    prev = A_raw[i]
    if A_raw[i] <= 50:
        A.append(A_raw[i])

if flg:
    print(1)
    exit()

N = len(A)
if N <= 1:
    print(2)
    exit()

ok = N
ng = 1
mid = (ok + ng) // 2
while ok - ng > 1:
    ng_flg = 0
    word = [1] * A[0]
    for i in range(1, N):
        if A[i] > A[i-1]:
            word.extend([1] * (A[i] - A[i-1]))
        else:
            word_prev = word[:A[i]]
            k = A[i] - 1
            while True:
                if k == -1:
                    ng_flg = 1
                    break
                if word_prev[k] != mid:
                    word_prev[k] += 1
                    word = word_prev
                    break
                else:
                    word_prev[k] = 1
                    k -= 1
        if ng_flg == 1:
            break
    if not ng_flg:
        ok = mid
    else:
        ng = mid
    mid = (ok + ng) // 2

print(ok)


Measured memory_bytes: 84944
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

using arr = array<array<int, 32>, 32>;

arr fold1(arr &a, int c){
    arr ret;
    rep(i, 32)rep(j, 32) ret[i][j] = 0;
    rep(i, 32)rep(j, c) ret[i][c-1-j] = a[i][j];
    rep(i, 32)For(j, c, 32) ret[i][j-c] += a[i][j];
    return ret;
}

arr fold2(arr &a, int c){
    arr ret;
    rep(i, 32)rep(j, 32) ret[i][j] = 0;
    rep(j, 32)rep(i, c) ret[c-1-i][j] = a[i][j];
    rep(j, 32)For(i, c, 32) ret[i-c][j] += a[i][j];
    return ret;
}

int main(){
    int n, m, t, p, d, c, x, y;
    while(scanf("%d%d%d%d", &n, &m, &t, &p) && n){
        arr a;
        rep(i, 32)rep(j, 32) a[i][j] = 0;
        rep(i, m)rep(j, n) a[i][j] = 1;
        rep(_, t){
            scanf("%d%d", &d, &c);
            a = (d == 1 ? fold1(a, c) : fold2(a, c));
        }
        rep(_, p){
            scanf("%d%d", &x, &y);
            printf("%d\n", a[y][x]);
        }
    }
}


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

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e6 + 4;


  void solve(){
	map<pair<int,int>,int> mp;
	ll ans=0;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		int f = i%10;
		int l = f;
		int k = i;
		int newnum=0;
		while(k>0){
			l = k%10;
			k/=10;
			newnum = newnum*10+l;
		}
		mp[{l,f}]++;
		ans += max(2*(mp[{f,l}])-(l==f && f==l),0);
	}
	cout << ans;
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n, k; cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];

    sort(all(p));
    int sum = 0;
    rep(i, k) sum += p[i];

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

Measured memory_bytes: 3652
n,m=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
c.sort()
ans,cnt=0,0
for a,b in c:
    if cnt+b>=m:
        ans+=a*(m-cnt)
        break
    else:
        cnt+=b
        ans+=a*b
print(ans)        

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

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

  ll x  = 0;
  ll mn = LLONG_MAX;
  for (int i = 0; i < n - 1; i++) {
    x += a[i];
    ll y = X - x;

    mn = min(mn, abs(x - y));
  }
  cout << mn << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  int c = 0;
  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
    c += A.at(i);
  }
  if (c > N) {
    cout << "-1" << endl;
  }
  else {
    cout << N - c << endl;
  }
}


Measured memory_bytes: 3664
N = int(input())
vs = [int(s) for s in input().split()]

import heapq
heapq.heapify(vs)
while len(vs) > 1:
  a = heapq.heappop(vs)
  b = heapq.heappop(vs)
  c = float(a+b)/2
  heapq.heappush(vs, c)
print (vs[0])

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

using namespace std;

int a[10] = {};

int main()
{
	int n;
	long long max, x = 0, y = 1, ans;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] % 2 == 0)
		{
			x++;
		}
	}
	max = (long long)pow(3.0, n);
	if (x > 0)
	{
		y = (long long)pow(2.0, x);
	}
	ans = max - y;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w,k,ans=LINF;
	cin>>h>>w>>k;
	vvb vv(h,vb(w));
	char ch;
	rep(i,h)rep(j,w)cin>>ch,vv[i][j]=(ch=='1');
	rep(l,1<<(h-1)){
		ll scr=0;
		vl tab(h);
		ll cnt=0;
		rep(i,h-1){
			if((1<<i)&l)cnt++;
			tab[i+1]=cnt;
		}
		scr=cnt;
		cnt++;
		vl sum(cnt);
		rep(j,w){
			rep(i,h){
				if(vv[i][j])sum[tab[i]]++;
			}
			bool lim=false;
			rep(i,cnt){
				if(sum[i]>k)lim=true;
			}
			if(lim){
				scr++;
				rep(i,cnt)sum[i]=0;
				rep(i,h){
					if(vv[i][j])sum[tab[i]]++;
					if(sum[tab[i]]>k)ans=LINF;
				}
			}
		}
		chmin(ans,scr);
	}
	puta(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
template<typename T>
ostream& operator+(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out<<x<<" ";
    }
    out<<"\n";
    return out;
}
template<typename T>
ostream& operator*(ostream& out, const vector<T> &vec){
    for(const auto &x : vec){
        out+x;
    }
    return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &vec){
    for(auto &x : vec){
        in>>x;
    }
    return in;
}
void solve(){
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size()<=k){
        cout<<s<<"\n";
        return;
    }
    for(int i=0;i<k;i++){
        cout<<s[i];
    }
    cout<<"...\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 3636
import java.lang.reflect.Array;
import java.util.*;
public class Main {
	static Queue<Integer> queue_x = new ArrayDeque<>();
	static Queue<Integer> queue_y = new ArrayDeque<>();
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int cnt[][] = new int[H][W];
		for(int i = 0; i < H; i++) {
			Arrays.fill(cnt[i], -1);
			String temp = sc.next();
			for(int j = 0; j < W; j++) {
				if(temp.substring(j, j + 1).equals("#")) {
					queue_x.add(j);
					queue_y.add(i);
					cnt[i][j] = 0;
				}
			}
		}
		
		int ans = 0;
		while(queue_x.size() != 0 && queue_y.size() != 0) {
			int y = queue_y.poll();
			int x = queue_x.poll();
			
			int dx[] = {0, 1, 0, -1};
			int dy[] = {1, 0, -1, 0};
			
			in : for(int i = 0; i < 4; i++) {
				if(x + dx[i] < 0) continue in;
				if(x + dx[i] >= W) continue in;
				if(y + dy[i] < 0) continue in;
				if(y + dy[i] >= H) continue in;
				
				if(cnt[y + dy[i]][x + dx[i]] == -1) {
					queue_x.add(x + dx[i]);
					queue_y.add(y + dy[i]);
					cnt[y + dy[i]][x + dx[i]] = cnt[y][x] + 1;
					ans = Math.max(ans, cnt[y + dy[i]][x + dx[i]]);
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 139484
fun main(args: Array<String>) = IO().exec {
    val n = long()
    val factors = mutableMapOf<Long, Long>()
    for (i in 1..n) {
        val f = primeFactors(i)
        for ((k, v) in f) factors[k] = (factors[k] ?: 0) + v
    }
    var c2 = 0L
    var c4 = 0L
    var c14 = 0L
    var c24 = 0L
    var c74 = 0L
    for (v in factors.values) {
        if (v >= 2) c2++
        if (v >= 4) c4++
        if (v >= 14) c14++
        if (v >= 24) c24++
        if (v >= 74) c74++
    }
    println(c4*(c4-1)/2*(c2-2)+c14*(c4-1)+c24*(c2-1)+c74)
}

fun primeFactors(n_: Long): MutableMap<Long, Long> {
    val ret = mutableMapOf<Long, Long>()
    var n = n_
    var i = 2L
    while (i * i <= n) {
        while (n % i == 0L) {
            ret[i] = (ret[i] ?: 0) + 1
            n /= i
        }
        i++
    }
    if (n != 1L) {
        ret[n] = 1
    }
    return ret
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31136
using static System.Math;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        getAns(a, n);
    }
    static void getAns(long[] a, int n)
    {
        var tmin = long.MaxValue;
        var s1 = 0L;
        var s2 = a.Sum();
        for (int i = 0; i < n - 1; i++)
        {
            s1 += a[i];
            s2 -= a[i];
            tmin = Min(tmin, Abs(s1 - s2));
        }
        Console.WriteLine(tmin);
    }
}


Measured memory_bytes: 33488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    vector<int> h(n);
    rep(i, n) cin>>h[i];
    sort(h.begin(), h.end());
    ll ans = 1e9;
    for(int i=0; i<n-k+1; i++){
        ll tmp=h[i+k-1]-h[i];
        ans = min(ans, tmp);
    }
    // vector<int> p;
    // rep(i, n-1){
    //     p.push_back(h[i+1]-h[i]);
    // }
    // sort(p.begin(), p.end());
    // ll ans = 0;
    // rep(i, k-1){
    //     ans += p[i];
    // }
    cout << ans <<endl;
}

Measured memory_bytes: 640
const p = 1000000007;
var
  a: array [1..300000] of int64;
  n, i, j, s, ans: longint;
function add(x, y: longint): longint; inline;
begin
  inc(x, y);
  if x >= p then dec(x, p);
  exit(x);
end;
function mul(x, y: longint): longint; inline;
begin
  exit(int64(x) * y mod p);
end;
begin
  read(n);
  for i := 1 to n do read(a[i]);
  for i := 0 to 59 do
  begin
    s := 0;
    for j := 1 to n do inc(s, (a[j] shr i) and 1);
    ans := add(ans, mul(mul(s, n - s), int64(1) shl i mod p));
  end;
  writeln(ans);
end.

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


int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		if ((i + 1) % 2 == 1 && a[i] % 2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

string T="ACGT";
    string S;
    int A[10]={0,0,0,0,0,0,0,0,0,0};
    
    int now=0;
    int ans=0;
int main(){
  
    cin>>S;
    for(int i=0;i<S.size();i++){
        for(int k=0;k<T.size();k++){
            if(S[i]==T[k]) A[i]=1;
        }
    }
    for(int j=0;j<10;j++){
        if(A[j]==1){
            now++;
            if(now>ans) ans=now;
        }else{
            now=0;
            
        }
    }


    cout<<ans<<endl;

    



    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int N,K;
  cin >> N >> K;

  vector<long>tree(N,0);

  for(int i=0;i<N;i++){
    cin >> tree[i];
  }

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

  int a = 0;
  int b = a + K - 1;
  long ans = 10000000000;

  while(b < N){
    ans = min(ans,tree[b] - tree[a]);
    a++;
    b++;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

    for (int i = 0; i < 3; i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int M=0;
  cin >> M;
  cout << 48 - M << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
int a;
int b;
int c;
int d;

int n;
int ans;

while( scanf( "%d", &n ) != EOF )
{
ans = 0;
for( a = 0; a < 10; a++ )
{
for( b = 0; b < 10; b++ )
{
for( c = 0; c < 10; c++ )
{
for( d = 0; d < 10; d++ )
{
if( a + b + c + d == n )
{
ans++;
}
}
}
}
}
printf( "%d\n", ans );
}
return (0);
}

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

int main(){
	vector <char> s;
	char a;
	while (cin >> a){
		s.push_back(a);
	}
	for (int i = 0; i < s.size() - 2; i++){
		if (s[i] == s[i + 1]){
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
		if (s[i] == s[i + 2]){
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	}
	if (s[s.size() - 2] == s[s.size() - 1]){
		cout << s.size() - 1 << ' ' << s.size() << endl;
		return 0;
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#define ll long long
using namespace std;
 
vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数
 
void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] += x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = value[i * 2 + 1]+value[i * 2 + 2];
    }
}
 
ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return 0; 
    else if (a <= l && r <= b) return value[k]; // ノード k の担当範囲がクエリ区間 [a, b) に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return c1+c2; 
    }
}
 
int main(void) {
    ll n , q;
    cin >> n >> q;
    N = 1;
    while (N <= n) N *= 2; // 葉の数を計算（n以上の最小の2冪数） //大きめに設定
    
    value = vector<ll>(2 * N - 1, 0); //二項目が初期値
    
    for(ll i=0; i<n; i++){
        ll p; cin>>p;
        update(i,p);
    }
 
    for (ll j = 0; j < q; j++) {
        ll c;
        cin >> c;
        if (c == 0) {
            ll i, x;
            cin >> i >> x;
            update(i, x);
        } else {
            ll s, t;
            cin >> s >> t;
            cout << query(s, t , 0, 0, N) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 12516
#include<bits/stdc++.h>
    using namespace std;
    
    #define ll long long
    #define pb push_back
    #define printV(v) for(int i=0;i<v._size();i++){cout << v[i]<< " ";} cout << endl
    #define printRev(v) for(int i=v._size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
    #define sortV(v) sort(v.begin(),v.end())
    #define revV(v) reverse(v.begin(),v.end())
    #define FOR(i,from,n) for(int i=from;i<n;i++)
    #define FOL(i,from,n) for(int i=from;i >= n;i--)

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;

        ll pow(ll base, ll q, ll mod){
            ll answer = 1;
            while(q > 0){
                if(q & 1LL)
                    answer = (answer * base) % mod;

                q = q >> 1LL;
                base = (base*base) % mod;
            }
            return answer % mod;
        }

        

        

        

        void solve1(){
            cin >> n;
            string s1,s2;
            cin >> s1 >> s2;
            if(s1 == s2){
                cout << "0\n";
                return;
            }
            int len1 = 0, len2 = 0;
            for(int i=0;i < n; i++){
                if(s1[i] == '1') len1++;
                if(s2[i] == '1') len2++;
            }
            if(len1 != len2) {cout << "-1\n"; return;}
        }


        void solvee(){
            
            cin >> n;
            string answer=  "";
            while(n > 0){
                answer.pb('a' + ( (n-1)%26));
                ll nashti = n%26;
                if(!nashti) nashti = 26;
                if(n == 26) break;
                n -= nashti;
                n /= 26;
            }
            revV(answer);
            cout << answer << endl;
        }

        void solve(){
            cin >> n;
            string answer = "";

            ll starting = 26;
            while(n > 0){
                ll nashti = n % starting;
                if(nashti == 0){
                    answer.pb('z');
                }else{
                    answer.pb('a' + nashti - 1);
                }
                
            }
            revV(answer);
            cout << answer << endl;

           
        }



       
    


        int main(){
            ios_base::sync_with_stdio(false);

           
            

            int cases = 1;
            //cin >> cases;

            while(cases--) solvee();
            return 0;

        }

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

typedef long long ll;

int main(void){
    int N;
    cin >> N;
    vector<ll> A;
    for(int i = 0 ; i < N ; i++){
        ll tmp;
        cin >> tmp;
        
        if(tmp == 0){
            cout << 0 << endl;
            return 0;
        }
        A.push_back(tmp);
    }
    
    ll mul = 1;
    for(int i = 0 ; i < N ; i++){
        if(A.at(i) > 1000000000000000000 / mul){
            cout << -1 << endl;
            return 0;
        }
        
        mul *= A.at(i);
    }
    cout << mul << endl;
    return 0;
}


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

#define int long long

const int MOD = 1e9 + 7;
string K;
int D;

int dp[10010][2][110] = {0}; // dp[i桁目][K未満?][mod D] = 総数

signed main() {
  cin >> K >> D;
  int n = K.size();

  dp[0][0][0] = 1;
  for (int digit = 0; digit < n; digit++) {
    for (int smaller : {0, 1}) {
      int lim = smaller == 1 ? 9 : K[digit] - '0';
      for (int num = 0; num <= lim; num++) {
        for (int modD = 0; modD < D; modD++) {
          dp[digit+1][smaller || num < lim][(modD + num) % D] += dp[digit][smaller][modD] % MOD;
        }
      }
    }
  }

  cout << (dp[n][0][0] + dp[n][1][0] - 1) % MOD << endl;

  return 0;
}


Measured memory_bytes: 17536
#include <iostream>

using namespace std;

int digit_sum(int n){
	int res = 0;
	while(n>0){
		res += (n%10);
		n /= 10;
	}
	return res;
}

int main()
{
	int n,a,b;
	cin >> n >> a >> b;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int x = digit_sum(i);
		if(a <= x && x <= b) ans += i;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_e
#include <bits/stdc++.h>
using namespace std;

char s[1050];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i < (1 << n); i++) {
        for (int j = 1; j < (1 << m); j++)
            s[j] = ((i & -i) == (j & -j)) + '0';
        puts(s + 1);
    }
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    string s;
    cin>>s;
    n = s.size();
    string t1, t2;
    int cur = 0;
    int i;
    FOR0(i, n)
    {
        if(!cur) t1 += '0';
        else t1 += '1';
        cur = 1 - cur;
    }
    cur = 1;
    FOR0(i, n)
    {
        if(!cur) t2 += '0';
        else t2 += '1';
        cur = 1 - cur;
    }
    int ans1 = 0, ans2 = 0;
    FOR0(i, n)
    {
        if(s[i] != t1[i]) ans1++;
        if(s[i] != t2[i]) ans2++;
    }
    cout<<MIN2(ans1, ans2);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 720
#include<stdio.h>
#include<limits.h>

int INF = 999999999;

long long int merge(int S[], int left, int mid, int right){
	int i=0, j=0;
	long long int count=0;
	int n1 = mid-left;
	int n2 = right - mid;
	int L[n1], R[n2];
	
	for(i=0; i<n1; i++){
		L[i] = S[left + i];
	}
	for(i=0; i<n2; i++){
		R[i] = S[mid + i];
	}
	L[n1] = INF;
	R[n2] = INF;
	i=0; j=0;
	for(int k=left; k<right; k++){
		if(L[i]<=R[j]){
			S[k] = L[i];
			i++;
		}
		else{
			S[k] = R[j];
			j++;
			count += n1 - i;
		}
	}
	return count;
}

long long int mergeSort(int S[], int left, int right){
	int mid;
	long long int v1, v2, v3;
	mid = (left + right)/2;
	if( left+1<right ){
		mid = (left + right)/2;
		v1 = mergeSort(S, left, mid);
		v2 = mergeSort(S, mid, right);
		v3 = merge(S, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main(void){
	int n, i, S[500000];
	long long sum;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &S[i]);
	}
	sum = mergeSort(S, 0, n);
	
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 3368
H,W,K=map(int,input().split())
C=[]
for _ in range(H):
    C.append(list(input()))
# シフト演算と&を使うと早い.
ans = 0
for i in range(1<<H): # 要するに2**Hのこと
    for j in range(1<<W): # 要するに2**Wのこと
        count = 0
        for i2 in range(H):
            for j2 in range(W):
                bit_i = i>>i2 & 1
                bit_j = j>>j2 & 1
                if bit_i == 1 or bit_j == 1:
                    continue
                if C[i2][j2] == '#':
                    count += 1
        if count == K:
            ans += 1

print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  int N, h, maxH = 0, ans = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++) {
    cin >> h;
	if(h >= maxH) maxH = h, ans++;
  }
  cout << ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 168, task b, 2020/05/18
//ms,
/*
*/

int main(void){
  string S;
  int K;
  string ans="";

  cin >>K >>S;

  if(K<S.size()) {
    for(int i=0;i<K;i++){
      ans += S.at(i);
    }
    cout <<ans;
    cout <<"..."<<endl;
  }
  else{
    for(int i=0;i<S.size();i++){
      ans += S.at(i);
    }
    cout <<ans<<endl;
  }



  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) cin >> p[i];
	bool ok = true;
	bool once = false;
	for (int i = 0; i < N; i++) {
		if (i + 1 != p[i]) {
			if (once) ok = false;
			else {
				swap(p[i], p[p[i] - 1]);
				once = true;
			}
		}
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


n = inp()
Blist = inpl()
ans = 0
for i in range(n-2):
    ans += min(Blist[i],Blist[i+1])

ans += Blist[0]+Blist[n-2]
print(ans)

Measured memory_bytes: 12444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int list[] = sc.nextIntArray(n);
		int count = 0;
		for (int i=0;i<n-2;i++) {
			int a = list[i];
			int b = list[i+1];
			int c = list[i+2];
			if ((a < b && b < c) || a > b && b > c) {
				count++;
			}
		}

		System.out.println(count);

	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int max_10n(int n) { return (n + 9) / 10 * 10; }

int r_time(int n) { return max_10n(n) - n; }

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;

  int total_time;
  total_time = max_10n(A) + max_10n(B) + max_10n(C) + max_10n(D) + max_10n(E);
  int r_timeMax = max({
      r_time(A),
      r_time(B),
      r_time(C),
      r_time(D),
      r_time(E),
  });
  cout << total_time - r_timeMax << endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
count = 0
if a%2==0 and b%2==0 and c%2!=0:
  print("NO")

else:
  for i in range(1,1000):
    x = a*i
    for j in range(1,1000):
      if x%b == c:
        count += 1
      else:
        continue
  if count==0:
    print("NO")
  else:
    print("YES")

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

typedef long long ll;

ll B(ll A){
    int cnt = 0;
    for(ll tmp = A;tmp;tmp/=2)cnt++;
    return ((1LL)<<cnt)-A;
}

int main(){

    int N;
    cin >> N;
    priority_queue<ll>Q;
    map<ll, ll>cnt;
    int ans = 0;
    rep(i, N){
        ll A;
        cin >> A;
        Q.push(A);
        cnt[A]++;
    }
    while(!Q.empty()){
        ll A = Q.top();
        Q.pop();
        if(cnt[A]==0)continue;
        cnt[A]--;
        if(cnt[B(A)]>0){
            cnt[B(A)]--;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 26864
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    
    int rem= N%10;
    
    if(rem==2 || rem==4|| rem==5|| rem==7||rem==9)
        cout<<"hon";
    else if(rem==0 || rem==1|| rem==6|| rem==8)
        cout<<"pon";
    else 
        cout<<"bon";
}


Measured memory_bytes: 3064
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if len(set([l[i],l[j],l[k]]))==3:
                if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                    ans+=1
print(ans)

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

alias LR = Tuple!(long, "l", long, "r");

void main()
{
    auto nxd = readln.split.to!(long[]);
    auto N = nxd[0];
    auto X = nxd[1];
    auto D = nxd[2];

    if (D == 0) {
        writeln(X == 0 ? 1 : N+1);
        return;
    }

    if (D < 0) {
        X = -X;
        D = -D;
    }

    auto kcm = new long[](N);
    foreach (i; 0..N) {
        if (i != 0) {
            kcm[i] = kcm[i-1] + i;
        }
    }

    LR[][long] CM;
    foreach (k; 0..N+1) {
        CM[(k*X)%D] ~= LR(kcm[max(0, k-1)] + k*X/D, kcm[N-1] - kcm[max(0, N-k-1)] + k*X/D);
    }
    long ret;
    foreach (_, lrs; CM) {
        sort!"a.l < b.l"(lrs);
        long l = long.max, r;
        foreach (lr; lrs) {
            if (l == long.max) {
                l = lr.l;
                r = lr.r;
            } else if (lr.l <= r) {
                r = max(r, lr.r);
            } else {
                ret += r - l + 1;
                l = lr.l;
                r = lr.r;
            }
        }
        if (l != long.max) {
            ret += r - l + 1;
        }
    }
    writeln(ret);
}

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

namespace Competition
{
    class Program
    {
        static void Main(string[] args)
        {
            var nl = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var n = nl[0]; var l = nl[1];
            var a = new List<Tuple<int,int>>();
            var res = 0;
            for (var i = 0; i < n; i++)
            {
                res += l + i;
                a.Add(new Tuple<int,int>(Math.Abs(l + i), i));
            }
            a.Sort();
            Console.WriteLine(res - (l + a[0].Item2));
        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N;
    cin >> N;
    vector<ll> A;
    A.push_back(0);
    rep(i, N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    A.push_back(0);

    ll sum = 0;
    rep(i, A.size() - 1) { sum += abs(A[i + 1] - A[i]); }

    rep(i, N) {
        ll n = i + 1;
        ll ans = sum - abs(A[n] - A[n - 1]) - abs(A[n + 1] - A[n]);
        ans += abs(A[n + 1] - A[n - 1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> L(N + 1);
  vector<int> R(N + 1);

  L[0] = 0;
  R[N] = 0;

  repp(i, 1, N) { L[i] = gcd(L[i - 1], A[i - 1]); }
  repr(i, N - 1, 0) { R[i] = gcd(R[i + 1], A[i]); }

  ll ans = 0;
  rep(i, N) { chmax(ans, gcd(L[i], R[i + 1])); }
  cout << ans << endl;
}

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

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

int main() {
    int N;
    cin >> N;
    vector<P> val(N);
    for (int i=0;i<N;i++){
        int a;
        cin >> a;
        val[i] = make_pair(a, i);
    }
    sort(val.begin(),val.end());
    reverse(val.begin(),val.end());
    int ans;
    for (int i=0;i<N;i++){
        if (val[0].second == i) ans = val[1].first;
        else ans = val[0].first;
        cout << ans << endl;
    }
}



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

int main() {
int x;
int i;
x = 5;
vector<int> szamok;
for (i = 0; i<x; i++) {
  int n;
  cin >> n;
  szamok.push_back(n);
 }
 int t; 
 for (t = 0; t<x; t++) { 
   if (szamok[t] == 0) { 
     cout << szamok[t - 1] + 1; 
     } 
     }
	return 0;
}

Measured memory_bytes: 3580
n = int(input())
lis = list(map(int,input().split()))
a = max(lis)
lis.remove(a)
ans = 100000000000
for i in range(n-1):
	if abs(a/2 - lis[i]) < ans:
		ans = abs(a/2 - lis[i])
		an = lis[i]
print(a,an)

Measured memory_bytes: 14052
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	char a,b;
	int c=1;
	cin>>a>>b;
	if(b=='D')
		c*=-1;
	if(a=='D')
		c*=-1;
	if(c==1)
		cout<<"H"<<endl;
	else
		cout<<"D"<<endl;

	return 0;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
h = LIST()
ans = 0
tmp = 0
for i in range(n):
    if tmp < h[i]:
        ans += h[i] - tmp
    tmp = h [i]
print(ans)


Measured memory_bytes: 10060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    string S;
    int N,d = 0;
    cin >> N >> S;
    for(int i = 0;i < S.length();i++){
        if(S[i] == '(')d++;
        else d--;
        if(d < 0){
            d = 0;
            S = "(" + S;
            i++;
        }
    }
    S += string(d,')');
    cout << S << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

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

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    
    char X;
    char Y;

    cin >> X >> Y;
    if(X<Y){
        cout << "<" << endl;
    }
    else if(X==Y){
        cout << "=" << endl;
    }
    else{
        cout << ">" << endl;
    }
    return 0;
}

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

int main(){
    vector<int> vec(3);
    cin >> vec.at(0) >>vec.at(1) >> vec.at(2);
    for (int i=0;i<2;i++){
        if (vec.at(0)>vec.at(1)){
            swap(vec.at(0),vec.at(1));}
        if(vec.at(1)>vec.at(2)){
            swap(vec.at(1),vec.at(2));}
    } 
    cout << vec.at(0) << " " << vec.at(1) << " " << vec.at(2) <<endl; 
    return 0;
}




Measured memory_bytes: 3084
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};
    static int[] x8 = {-1, -1, 0, 1, 1, 1, 0, -1};
    static int[] y8 = {0, -1, -1, -1, 0, 1, 1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s_ = in.next();
        String t = in.next();

        int lt = t.length();
        int st = s_.length();
        for(int i = st - lt; i >= 0; i--) {
            boolean cond = true;
            for(int j = 0; j < lt; j++) {
                if(s_.charAt(i+j) != '?' && s_.charAt(i+j) != t.charAt(j)) {
                    cond = false;
                    break;
                }
            }
            if(cond) {
                String s = s_.substring(0, i) + t + s_.substring(i+lt);
                s = s.replace("?", "a");
                System.out.println(s);
                return;
            }
        }

        System.out.println("UNRESTORABLE");
    }

    static public void printArray2D(char[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%c\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }

    static public void printArray2D(int[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%d\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }
}

Measured memory_bytes: 23892
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    println(readints().toSet().size)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

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

int main(){
	int a[1000];
	int b[1000];
	int c[1000];
	int n , m;

	cin >> n;
	m = 0;

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

		if (a[i] > b[i]){
			m = a[i];
			a[i] = b[i];
			b[i] = m;
		}
		if (b[i] > c[i]){
			m = b[i];
			b[i] = c[i];
			c[i] = m;
		}
	}

	for (int i = 0; i < n; i++){
		if (a[i] * a[i] + b[i] * b[i] == c[i] * c[i]){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int a;
        double b=0;
        double ans;

        for(int i=0;i<n;i++){
            a=scan.nextInt();
            b+=1.0/a;
//            System.out.println(b);
        }

        ans=1/b;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    vector<int> t(n);
    rep(i,n)cin>>t[i];
    int m;cin>>m;
    rep(i,m){
        int p,x;cin>>p>>x;
        int sum=0;
        rep(j,n){
            if(j==p-1)sum+=x;
            else sum+=t[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 256