akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// LongestIncreasingSubsequence
template<class T> int LongestIncreasingSubsequence(vector<T>& v, T v_inf = (T)1e18 ) {
    int n = v.size();
    vector<T> dp(n+1, v_inf);  // dp[i]:長さi+1の増加部分列の最後の値の最小値
    for ( int i = 0; i < n; i++ ) {
        int p = lower_bound(dp.begin(), dp.end(), v[i]) - dp.begin();
        dp[p] = v[i];
    }
    int r = lower_bound(dp.begin(), dp.end(), v_inf) - dp.begin();
    return r;
};

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    int u, v;
    vector<vector<int>> G(N);
    for ( int i = 0; i < N-1; i++ ) {
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<ll> ans(N);
    ll INF = 1LL<<60;
    vector<ll> dp(N+1, INF);
    function<void(int,int)> dfs = [&](int v, int p) {
        ll j = lower_bound(dp.begin(), dp.end(), A[v]) - dp.begin();
        ll prev = dp[j];
        dp[j] = A[v];
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            dfs(u, v);
        }
        ll aa = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
        ans[v] = aa;
        dp[j] = prev;
    };
    dfs(0,-1);

    for ( int i = 0; i < N; i++ ) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

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

Measured memory_bytes: 38700
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    a, b = read_values()
    print(str(min(a, b)) * max(a, b))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();

        long m = n;
        String ans = "";
        while (m > 0) {
            if (m % 26 == 0) {
                ans = 'z' + ans;
                m -= 26;
            } else {
                ans = (char)((m % 26) + 'a' - 1) + ans;
            }
            m /= 26;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 39576
#![allow(non_snake_case)]

use std::cmp::min;

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let (N, A, B) = {
        let v: Vec<i32> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
        (v[0], v[1], v[2])
    };
    println!("{}", min(A*N, B));
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int ma[6010];

int main() {
	cin >> N;

	for (int i = 1; i <= 5000; ++i) {
		ma[i] = i*(i+1)/2;
	}

	int i = 5000;

	while (N>0) {
		while (ma[i-1] >= N) --i;
		printf("%d\n", i);
		N -= i;--i;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  double a;
  double b;
  cin >> a >> b;
  b *= 100;
  cout << (ll)a * (ll)(b + 0.5) / 100 << endl;
  //double memo = 9.99;
  //cout << (ll)(memo * 100) << endl;
}

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

using namespace std;

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

class UnionFind {
 private:
  std::vector<int> parent;

 public:
  UnionFind(int n) : parent(n, -1) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    return parent[x] = root(parent[x]);
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N < 2 * (N - M - 1)) {
    cout << "Impossible" << '\n';
    return 0;
  }
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    uf.unite(u, v);
  }
  if (uf.size(0) == N) {
    cout << 0 << '\n';
    return 0;
  }
  map<int, vector<int64_t>> mp;
  vector<int64_t> X;
  for (int i = 0; i < N; i++) {
    mp[uf.root(i)].emplace_back(A[i]);
  }
  int64_t res = 0;
  for (auto &[key, value] : mp) {
    sort(value.begin(), value.end());
    res += value.front();
    for (int i = 1; i < (int)value.size(); i++) {
      X.emplace_back(value[i]);
    }
  }
  sort(X.begin(), X.end());
  for (int i = 0; i < N - M - 2; i++) {
    res += X[i];
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 10832
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <random>
#include <cstdlib>
#include <cmath>
#include <sstream>
using namespace std;


long long int dp[11][1001] = { 0 };

void q97() {
	dp[0][0] = 1;
	for (int i = 0; i <= 100; i++) {
		for (int j = 10; j > 0; j--) {
			for (int k = 1000; k >= i; k--) {
				dp[j][k] += dp[j - 1][k - i];
			}
		}
	}
	int n, s;
	for (; cin >> n >> s;) {
		if (!n && !s) break;
		cout << dp[n][s] << endl;
	}
}

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

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

int main(void) {
	int K;
	char S[1024];
	if (scanf("%d", &K) != 1) return 1;
	if (scanf("%512s", S) != 1) return 1;
	if (strlen(S) > (unsigned int)K) strcpy(S + K, "...");
	puts(S);
	return 0;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string s;
    cin>>s;
    char curr = s[0];
    ll ans=(curr=='R');
    ll temp=ans;
    for(int i=1;i<s.length();i++){
        if(curr==s[i]){
            temp++;
        }
        else{
            if(curr=='R')
                ans = max(temp,ans);
            temp=1;
            curr=s[i];
        }
    }
    if(curr=='R')   ans = max(temp,ans);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
package main

import "fmt"

func isMatched(s, t string) (matched bool, p, q int) {
	matched = false
	a := []rune(t)
L:
	for i := 0; i <= len(s)-len(t); i++ {
		for j, r := range s[i : i+len(t)] {
			if r != a[j] && r != '?' {
				continue L
			}
		}
		matched = true
		p = i
		q = i + len(t) - 1
	}
	return
}

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	matched, i, j := isMatched(S, T)
	if matched {
		for k, r := range S {
			if i <= k && k <= j {
				fmt.Printf(T[k-i : k-i+1])
			} else {
				if r == '?' {
					fmt.Printf("a")
				} else {
					fmt.Printf(string(r))
				}
			}
		}
		fmt.Printf("\n")
	} else {
		fmt.Println("UNRESTORABLE")
	}
}


Measured memory_bytes: 512
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int h,w;
int res;
char m[500][500];
int r[500][500];
int c1,c2;

int dfs(int i, int j){
  if (i<0 || h<=i) return 0;
  if (j<0 || w<=j) return 0;

  dump(i, j);
  if (r[i][j]==0) {
    r[i][j]=1;
    if (m[i][j]=='.') c1++;
    else c2++;

    rep(k, 4){
      if (m[i][j]!=m[i+dx[k]][j+dy[k]]){
        dfs(i+dx[k], j+dy[k]);
      }
    }
  }
  return 0;
}

int solve(){
  cin>>h>>w;
  rep(i,h)rep(j,w)cin>>m[i][j];
  dump_2d(m, h, w);

  rep(i,h)rep(j,w){
    if (r[i][j]==1) continue;
    c1=0;c2=0;
    dfs(i, j);
    res+=c1*c2;
  }
  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 9472
object Main extends App {
  val N = io.StdIn.readLine.toLong
  val A = io.StdIn.readLine.toLong
  val B = io.StdIn.readLine.toLong
  val C = io.StdIn.readLine.toLong
  val D = io.StdIn.readLine.toLong
  val E = io.StdIn.readLine.toLong

  val bottleneck = Seq(A, B, C, D, E).min

  val btime =
    if (N % bottleneck == 0) (N / bottleneck)
    else (N / bottleneck) + 1

  println(btime + 4)
}


Measured memory_bytes: 27316
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
ll dp[3010][3010];
int main(void){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    dp[A][B]=1;
    for(int i=A;i<=C;i++){
        for(int j=B;j<=D;j++){
            if(i==A&&j==B)continue;
            dp[i][j] = ((i*dp[i][j-1])%M+(j*dp[i-1][j])%M)%M;
            dp[i][j] = dp[i][j]-((i-1)*(j-1)*dp[i-1][j-1])%M;
            dp[i][j] = (dp[i][j]+M)%M;
        }
    }
    cout<<dp[C][D]%M<<endl;
    return 0;
}

Measured memory_bytes: 74064
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main()
{
	dhoom;
	int n;
	cin >> n;
	ll mini = inf , maxi = -inf;
	for(int i = 0 ; i < n ; i++)
	{
		ll x;
		cin >> x;
		mini = min(mini , x);
		maxi = max(maxi , x);
	}
	cout << maxi - mini << endl;
	return 0;
} 



Measured memory_bytes: 256
W,H,x,y = map(int,input().split())

x_test = False
y_test = False

if W%2 == 0 and W//2 == x:
    x_test = True
if H%2 == 0 and H//2 == y:
    y_test = True

if x_test and y_test:
    print(W*H/2,1)
elif x_test or y_test:
    print(W*H/2,0)

elif x*H%W == 0:
    print(W*H/2,0)

elif x == H or y == H:
    x_cent = x > W/2
    y_cent = y > H/2
    s1 = max((H-y)*W, (W-x)*H)
    s2 = max((H-y)*W, x*H)
    s3 = max(y*W, x*H)
    s4 = max(y*W, (W-x)*H)
    if x_cent and y_cent:
        print(s1,0)
    elif y_cent:
        print(s2,0)
    elif x_cent:
        print(s3,0)
    else:
        print(s4,0)   

else:
    x_cent = x > W/2
    y_cent = y > H/2
    s1 = max((H-y)*W, (W-x)*H)
    s2 = max((H-y)*W, x*H)
    s3 = max(y*W, x*H)
    s4 = max(y*W, (W-x)*H)
    if x_cent and y_cent:
        print(s1,1)
    elif y_cent:
        print(s2,1)
    elif x_cent:
        print(s3,1)
    else:
        print(s4,1)

Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		BigInteger[] arr = new BigInteger[n+1];
		BigInteger[] maxnl = new BigInteger[n+1];
		maxnl[0] = v(1);
		for(int i = 0; i <= n; i++) {	
			arr[i] = v(sc.nextInt());
			if(i > 0) {
				maxnl[i] = sub(m(v(2),maxnl[i-1]), arr[i]);
			}
		}
		if(n == 0) {
			if(arr[0].equals(v(1))) {
				System.out.println(1);
			}
			else {
				System.out.println(-1);
			}
			return;
		}
		if(gr(arr[0],v(0))) {
			System.out.println(-1); return;
		}
		BigInteger res = arr[n];
		BigInteger[] nl = new BigInteger[n+1]; //not leaves
		nl[n] = v(0);
		for(int i = n-1; i >= 0; i--) {
			nl[i] = s(nl[i+1],arr[i+1]);
			if(gr(nl[i],maxnl[i])) {
				nl[i] = maxnl[i];
				if(gr(s(nl[i+1],arr[i+1]), m(v(2),nl[i]))) {
					System.out.println(-1); return;
				}
			}
			res = s(res, nl[i], arr[i]);
		}
		System.out.println(res);
	}
	
	static BigInteger v(long x) {
		return BigInteger.valueOf(x);
	}
	static BigInteger s(BigInteger... as) {
		BigInteger res = v(0);
		for(BigInteger a: as) {
			res = res.add(a);
		}
		return res;
	}
	static BigInteger m(BigInteger... as) {
		BigInteger res = v(1);
		for(BigInteger a: as) {
			res = res.multiply(a);
		}
		return res;
	}
	static BigInteger sub(BigInteger a, BigInteger b) {
		return a.subtract(b);
	}
	static BigInteger div(BigInteger a, BigInteger b) {
		return a.divide(b);
	}
	static boolean gr(BigInteger a, BigInteger b) {
		return a.compareTo(b) > 0;
	}
	static boolean geq(BigInteger a, BigInteger b) {
		return a.compareTo(b) >= 0;
	}
	
	static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }
    }
	

}

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

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

    static class B121 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int cnt = 0;
            int temp = b;
            while (temp != 0) {
                cnt++;
                temp /= 10;
            }
            a = a * (int) Math.pow(10, cnt) + b;
            for (int i = 1; i * i <= a; i++) {
                if (i * i == a) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MAXN 330
#define pii pair<int, int>
#define pll pair<long long, pair<long long, long long>>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const int mod = 1e9 + 7;
const ll oo = 1e17 + 7;


int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    int ini, final;
    cin >> s;

    for (int i=0; i<s.size(); i++){
        if (s[i] == 'A') {
            ini = i;
            break;
        }
    }

    for (int i = s.size() - 1; i>=0; i--){
        if (s[i] == 'Z') {
            final = i;
            break;
        }
    }

    cout << final - ini+1 << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#define maxn 300005
using namespace std;

int n,a[maxn],Max[maxn],sMax[maxn],Ans[maxn];

inline void upd(int now,int pre)
{
	if(Max[pre]>Max[now])
		if(sMax[pre]>Max[now]) Max[now]=Max[pre],sMax[now]=sMax[pre];
		else sMax[now]=Max[now],Max[now]=Max[pre];
	else 
		if(Max[pre]>sMax[now]) sMax[now]=Max[pre];
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<1<<n;i++) scanf("%d",&a[i]),Max[i]=a[i];
	for(int i=0;i<n;i++)
		for(int sta=0;sta<1<<n;sta++)
			if(!(sta>>i & 1))
				upd(sta | (1<<i),sta);
	for(int sta=1;sta<1<<n;sta++)
	{
		Ans[sta]=max(Ans[sta-1],Max[sta]+sMax[sta]);
		printf("%d\n",Ans[sta]);
	}
}

Measured memory_bytes: 7424
n,t = map(int,input().split())

a = []

for i in range(n):
    a.append(list(map(int,input().split())))

min = 9999

for i in a:
    if i[1] <= t and i[0] < min:
        min = i[0]

if min > 1000:
    print("TLE")
else:
    print(min)


Measured memory_bytes: 2940
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
using namespace boost::multiprecision;  
using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
//inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
//inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int h,a;
    cin >> h >> a;

    cout << (h + a - 1) / a << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int max1 = -1, max2 = -1;
		int index1 = -1, index2 = -1;
		for(int i = 0;i < N;i++) {
			int Ai = scn.nextInt();
			if(max1 <= Ai) {
				max2 = max1;
				max1 = Ai;
				index2 = index1;
				index1 = i;
			}else {
				if(max2 <= Ai) {
					max2 = Ai;
					index2 = i;
				}
			}
		}
		for(int i = 0;i < N;i++) {
			System.out.println((i==index1)?max2:max1);
		}
	}

}

Measured memory_bytes: 82712
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=1e6+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 	
}
LL solve(){
	cin >> N;
	VI v(N);
	REP(i,N){
		cin >> v[i];
	}
	UNIQUE(v);
	OUT(SI(v));
	return 0;
}
signed main(){
	solve();
	return 0;
}

Measured memory_bytes: 24448
#include <stdio.h>
#include <math.h>

double D(double a){
	a =a * a;
	return a;
}

int main(void){
	int n, i;
	double score[1024], bun, ave, sum = 0, A,hensa;

	while(1){
		scanf("%d",&n);

		if(n == 0) break;

		for(i = 0,sum = 0; i < n; i++){
			scanf("%lf",&score[i]);
		sum =sum + score[i];
		}
		ave = sum / n;

		for(i = 0,A = 0;i < n; i++){
		A =A + D(score[i] - ave);
	}
	bun = A /n;
	hensa = sqrt(bun);
	printf("%f\n",hensa);
}
return 0;
}



Measured memory_bytes: 2044
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << endl;
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  Pr(n==m);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int cnt[26];
  for (int i = 0; i < 26; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < s.length(); i++) {
    cnt[s[i] - 'a']++;
  }
  bool None = true;
  char no_apper;
  for (int i = 0; i < 26; i++) {
    // cout << cnt[i] << " " << endl;
    if (cnt[i] == 0) {
      no_apper = (char)('a' + i);
      None = false;
      break;
    }
  }

  if (None) {
    cout << "None" << endl;
  } else {
    cout << no_apper << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int M, N;
	int MAX = 0;
	int sum;
	int a;
	cin >> M >> N;
	for (int i = 0; i < M; i++) {
		sum = 0;
		for (int j = 0; j < N; j++) {
			cin >> a;
			sum += a;
		}
		MAX = max(MAX, sum);
	}
	cout << MAX << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

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

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

/////////////////////////////////////////////////////////

bool isprime(int N){
  if(N == 1) return false;
  int n = 2;
  while(n != N){
    if(N % n == 0) return false;
    n++;
  }
  return true;
}

void Main(){
  int N; cin >> N;
  int cnt = 0;
  int n = 3;
  vector<int> res;
  while(true){
    if(isprime(n) && n % 5 == 1){
      res.push_back(n);
      cnt++;
    }
    if(cnt == N) break;
    n += 2;
  }
  rep(i, 0, N){
    cout << res[i];
    if(i == N - 1) cout << endl;
    else cout << " ";
  }
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

template<int n> struct DSU {
	ll parent[n], rank[n], size[n];

	DSU(){
	    for (int i=0;i<n;i++){
	        parent[i] = i;
	        rank[i] = 0;
	        size[i] = 1;
	    }
	}
	ll find(ll i){
	    if (parent[i] != i){
	        parent[i] = find(parent[i]);
	    }
	    return parent[i];
	}
	bool same(ll i, ll j){
	    return find(i) == find(j);
	}
	void Union(ll x, ll y)
	{
	    if(same(x, y))
	        return;

	    ll xpar = find(x);
	    ll ypar = find(y);

	    if (rank[xpar] < rank[ypar]){
	        parent[xpar] = ypar;
	        size[ypar]+=size[xpar];
	    }
	    else if (rank[xpar] > rank[ypar]){
	        parent[ypar] = xpar;
	        size[xpar]+=size[ypar];
	    }
	    else{
	        parent[ypar] = xpar;
	        rank[xpar]++;
	        size[xpar]+=size[ypar];
	    }
	}
};

DSU<N> D;
vector<pair<ll, pair<int, int> > > edges;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout<<fixed<<setprecision(10);

    ll n, m;
    cin>>n>>m;

    for(int i=0;i<m;i++){
		int a, b;
		cin>>a>>b;
		D.Union(a, b);
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		ans = max(ans, D.size[i]);
	}
	cout<<ans;
    return 0;
}


Measured memory_bytes: 8336
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[300]={0};
bool cmp(int a,int b)
{
	return abs(a)<abs(b); 
}
int main()
{
	int n,l;
	while(~scanf("%d%d",&n,&l))
	{
		int num=0;
		for(int i=1;i<=n;i++)
		{
			a[i]=i+l-1;
			num+=a[i];
		}
		sort(a+1,a+1+n,cmp);
		printf("%d\n",num-a[1]);
	}
}

Measured memory_bytes: 128
def f(t2,t1):
    return t2//t1 + (1 if t2 % t1 > 0 else 0)

n = int(input())
t,a = map(int,input().split())
for i in range(n-1):
    tn,an = map(int,input().split())
    k = max(f(t,tn), f(a, an))
    t,a = k*tn, k*an
print(t+a)

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

int main(){
  int n, k; cin >> n >> k;
  int a[n];
  rep(i, n) cin >> a[i];
  long mod = 1e9 + 7;
  long dp[n+1][k+1];
  long s[n+1][k+2];
  rep(i, k+1) dp[0][i] = 0;
  dp[0][0] = 1;
  rep(i, k+2) s[0][i] = 1;
  rep(i, n+1) s[i][0] = 0;
  for(int i=1; i<n+1; i++){
    rep(j, k+1){
      dp[i][j] = (s[i-1][j+1] - s[i-1][max(0, j-a[i-1])] + mod) % mod;
      s[i][j+1] = (s[i][j] + dp[i][j]) % mod;
    }
  }
  cout << dp[n][k] << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,c,k,i,x ;
    cin >> n >> c >> k;
    int A[n];
    for(i=0;i<n;i++)
        cin >> A[i];
        sort(A,A+n);
      x=0;
   int   now=0;
    for(i=0;i<n;++i){
            while (A[now] + k < A[i]) {
			++x;
			now = min(now + c, i);
		}
	}
	while (now < n) {
		++x;
		now = min(now + c, n);
	}



            cout << x << "\n";
    return 0;
}


Measured memory_bytes: 640
#include "stdio.h"

int main(void){
	long long X, Y;
	long long temp_int;
	int i;

	scanf("%ld%ld", &X, &Y);

	temp_int = Y/X;

	for(i=1;;i++){
		temp_int/=2;
		if(temp_int==0) break;
	}
	
	printf("%d\n", i);
	return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);

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

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

    int tmp = 0,
        ans = 0;
    for(i = 0; i < n; i++) {
        tmp += a[i];
        if (tmp <= x) {
            ans++;
        }
        else {
            break;
        }
    }

    int sum = 0;
    for(i = 0; i < n; i++) {
        sum += a[i];
    }
    if (ans == n && sum != x) {
        ans--;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    string ans = "";
    for(char c: s) {
        if (c != 'B')
            ans += c;
        else {
            if (!ans.empty())
                ans.pop_back();
        }
    }
    cout << ans << endl;


    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  int ans = 0;
  rep(i,n)rep(j,n)rep(k,n) {
    if (i < j && j < k) {
      if (l[i] == l[j]) continue;
      if (l[i] == l[k]) continue;
      if (l[k] == l[j]) continue;
      if ((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2) continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3604
def main():
    S = input()

    if len(S) % 2 == 1:
        print('{}'.format('No'))
        exit()

    for i in range(1, len(S), 2):
        if S[i - 1: i + 1] != 'hi':
            print('{}'.format('No'))
            exit()
    
    print('{}'.format('Yes'))

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
//全探索O(c^n)。以後の遷移が合同になるのは(今のボタンの組み合わせ,今までになったブザー音の回数)が一致するとき。そして、当然この時のスコアも最大のものになっている。
//よって、O(2^16nc)のDPなんだが、実装できるかなあ。
//スイッチのパターンを配列で記憶するとデータの保管が面倒くさい。そこで、Σ2^kの形で状態を保存する。すると、点灯はa | b,消灯は a & ~bでできそう。
//i回目のビート光る→i回目にcパターン押し方を試す→その後の結果をDP[i][65536]に保存(もちろん最大値を保存します)
//スコアの獲得 == (oned-pushedを2^iの形で表した時の項の数),前処理なしだとこの計算にO(16^2)かかってしまいTLEする。
//そこで、1、2^i(0 <= i <= 16)をメモ化する。2、消えたランプの組み合わせすべて(すなわち0 <= oned-pushed <= 65535)におけるスコアの獲得をあらかじめメモ化する。
//すると、O(16^2)のところをO(1)にできる。
#include<iostream>
using namespace std;

int ans[20],cor = 0;
int N,C,in[30],out[30];	//i番のボタンを押していたら2^(i-1)加える。(なお、底を状態数(2)より少なくすると、ボタンの点灯状態がただしく示せない)
int DP[31][65536];
int memo_pwd[16];		//memo_pwd[i] = 2^i;
int memo_GetScore[65536];	//GetScore[i] == oned-pushedがiのときのスコアの加点
int pwd(int tei,int sisuu){
	int ans = 1;
	for(int i = 0;i < sisuu;i++)
		ans *= tei;
	return ans;
}
int GetScore(int score){
	int ans = 0;
	for(int i = 0;i < 16;i++){
		if(score & memo_pwd[i])
			ans++;
	}
	return ans;
}
int main(){
	int i,j,k;
	int t;
	//メモを作る
	for(i = 0;i < 16;i++)
		memo_pwd[i] = pwd(2,i);
	for(i = 0;i < 65536;i++){
		memo_GetScore[i] = GetScore(i);
	}
	while(cin >> N >> C){
		if((N | C) == 0)
			break;
		for(i = 0;i < N;i++){
			in[i] = 0;
			for(j = 0;j < 16;j++){
				cin >> t;
				if(t)
					in[i] += memo_pwd[j];
			}
		}
		for(i = 0;i < C;i++){
			out[i] = 0;
			for(j = 0;j < 16;j++){
				cin >> t;
				if(t)
					out[i] += memo_pwd[j];
			}
		}
		//DP配列の値を初期値に戻す
		for(i = 0;i <= N;i++){
			for(j = 0;j < 65536;j++){
				DP[i][j] = -1;
			}
		}
		DP[0][0] = 0;
		//ここから探索
		int oned,pushed;
		for(i = 0;i < N;i++){
			for(j = 0;j < 65536;j++){
				if(DP[i][j] == -1)
					continue;
				//cout << "in = " << in[i] << endl;
				oned = (in[i] | j);
				//cout << "oned = " << oned << endl;
				for(k = 0;k < C;k++){
					int score;
					pushed = (oned & ~out[k]);
					//cout << "pushed = " << pushed << endl;
					score = memo_GetScore[oned-pushed];
					if(DP[i+1][pushed] < DP[i][j] + score)
						DP[i+1][pushed] = DP[i][j]+score;
				}
			}
		}
		for(i = 0;i < 65536;i++){
			if(ans[cor] < DP[N][i])
				ans[cor] = DP[N][i];
		}
		cor++;
	}
	for(i = 0;i < cor;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 9352
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    int N=0;
    cin>>N;
    long long count=0;
    for(int i=0;i<N;i++){
      long long a,b;
      cin>>a>>b;
      count+=b-a+1;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(O: str, E: str):
    A = [''] * (len(O) + len(E))
    for i in range(len(A)):
        if i % 2 == 0:
            A[i] = O[i//2]
        else:
            A[i] = E[(i-1)//2]
    print(''.join(A))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    O = next(tokens)  # type: str
    E = next(tokens)  # type: str
    solve(O, E)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int k;
	string s;
	cin >> k >> s;
	if (k >= s.size()) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#define N 100000


typedef struct Card{
  
  char mark;
  int num, index;

}Card;


int Partition( Card A[], int p, int r ){

  int i, j,n;
  Card c;

  n = A[r].num;
  i = p - 1;

  for( j = p; j < r; j++ ){
    if( A[j].num <= n){
      i++;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }

  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;

  return i+1;
}


void QuickSort( Card A[], int p, int r ){
  int q;
  if( p < r ){
    q = Partition( A, p, r );
    QuickSort( A, p, q-1 );
    QuickSort( A, q+1, r );
  }
}

int isStable( Card A[], int n ){
  int i;
  for( i = 1; i < n; i++ ){
    if( A[i-1].num == A[i].num ){
      if( A[i-1].index > A[i].index ){
    return 0;
      }
    }
  }
    return 1;
}

int main(void){
  int i, n;
  Card S[N];

  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf(" %c %d", &S[i].mark, &S[i].num);
    S[i].index = i;
  }

  QuickSort( S, 0, n-1 );

  if( isStable(S, n) == 1 ){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  for( i = 0; i < n; i++ ){
    printf("%c %d\n", S[i].mark, S[i].num);
  }
    return 0;
}



Measured memory_bytes: 2836
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll d,t,s;
int main()
{
	cin>>d>>t>>s;
	if(t*s<d) re("No")
	re("Yes")
	return 0;}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

bool dp[210000];
int main() {
	dp[0] = 1;
	ll n;
	cin >> n;
	REP(i, 100000) {
		FOR(j, 100, 106) {
			if (dp[i]) dp[i + j] = true;
		}
	}
	cout << dp[n] << endl;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int w, h;
  cin >> w >> h;
  
  vector<ll> p(w), q(h);
  for (int i = 0; i < w; i++) cin >> p.at(i);
  for (int i = 0; i < h; i++) cin >> q.at(i);
  
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  
  p.emplace_back(1e9);
  q.emplace_back(1e9);
  
  int itp = 0, itq = 0;
  ll ans = 0;
  while (itp < w || itq < h) {
    if (p.at(itp) < q.at(itq)) {
      ans += p.at(itp) * (h + 1 - itq);
      itp++;
    }
    else {
      ans += q.at(itq) * (w + 1 - itp);
      itq++;
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 2672
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var HW = Console.ReadLine().Split().Select(int.Parse);
        int H = HW.First(), W = HW.Last();
        var s = new string[H];
        for (int i = 0; i < H; i++)
        {
            s[i] = Console.ReadLine();
        }
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                var flg = s[i][j] == '#';
                if (i > 0 && s[i - 1][j] == '#')
                {
                   flg = false; 
                }
                if (i < H - 1 && s[i + 1][j] == '#')
                {
                    flg = false;
                }
                if (j > 0 && s[i][j - 1] == '#')
                {
                    flg = false;
                }
                if (j < W - 1 && s[i][j + 1] == '#')
                {
                    flg = false;
                }
                if (flg)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13396
s = int(input())

if s == 1 or s == 2:
    print(4)
    exit()

def function(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(n*3+1)
i = 0
count = 0
a = []
a.append(s)
while count < 2:
    a.append(function(a[i]))
    if a[i] == 4:
        count += 1
    i += 1
print(i)

Measured memory_bytes: 9164
S = input()

S_list = []
for s in S:
    if s not in S_list:
        S_list.append(s)

S_list.sort()

al_list = [chr(i) for i in range(97, 97+26)]

check_list = []
for i in range(len(S_list)):
    if S_list[i] == al_list[i]:
        check_list.append(True)
    else:
        check_list.append(False)

count = 0
for c in check_list:
    if c is True:
        count += 1
    else:
        count += 0

if count == 26:
    print('None')
else:
    print(al_list[count])




Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;

public class Main {
	static boolean debug = true;

	public static void main(String[] args) throws IOException {

		UserScanner scan = new UserScanner(System.in);
		PrintWriter pwriter = new PrintWriter(System.out);

		int n = scan.nextInt();
		int m = scan.nextInt();
		ChristmasParty crp = new ChristmasParty(n, m);

		for (int i = 0; i < m; i++)
			crp.setTarget(i, scan.nextInt());
		for (int i = 0; i < m; i++)
			for (int j = 1; j <= n; j++) // friends number is from 1, not zero
				crp.setResult(i, j, scan.nextInt());

		for (int i = 1; i <= n; i++)
			pwriter.println(crp.getPoint(i));

		pwriter.flush();

		scan.close();
		System.exit(0);
	}
}

class ChristmasParty {
	int[] target;
	int[] point;

	public ChristmasParty(int n, int m) {
		target = new int[m];
		point = new int[n + 1];
	}

	public int getPoint(int n) {
		return point[n];
	}

	public void setResult(int m, int n, int ans) {
		if (target[m] == ans)
			point[n]++;
		else
			point[target[m]]++;
	}

	public void setTarget(int m, int t) {
		target[m] = t;
	}

}

class UserScanner {
	private InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public UserScanner(InputStream inStream) {
		in = inStream;
	}

	private void read() {
		ptr = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(9);
		}
	}

	private byte getByte() {
		if (ptr >= buflen)
			read();
		if (buflen < 0 || isCtlSpace(buffer[ptr])) {
			return -1;
		} else
			return buffer[ptr++];
	}

	private void skipCtlSpace() {
		for (; ptr < buflen; ptr++)
			if (!isCtlSpace(buffer[ptr]))
				return;
		read();
		skipCtlSpace();
	}

	private boolean isCtlSpace(byte b) {
		if (b <= ' ' || b > '~')
			return true;
		else
			return false;
	}

	public void close() {
		try {
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(9);
		}
	}

	public String next() {
		skipCtlSpace();
		StringBuilder sb = new StringBuilder();
		byte b;
		while ((b = getByte()) != -1) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		skipCtlSpace();
		int n = 0;
		boolean minus = false;
		byte b;
		while ((b = getByte()) != -1) {
			if (b == '-')
				minus = true;
			else {
				n *= 10;
				n += (b - '0');
			}
		}
		if (minus)
			return n * -1;
		else
			return n;
	}
}

Measured memory_bytes: 24944
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int A, B;

int main() {
  cin >> A >> B;
  int max_val = A + B;
  max_val = max(max_val, A - B);
  max_val = max(max_val, A * B);
  cout << max_val << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a_dict = {i: 0 for i in range(1, M + 1)}
ans = 0
for i in range(N):
    a_lst = list(map(int, input().split()))
    for j in range(1, a_lst[0] + 1):
        a_dict[a_lst[j]] += 1

for key in a_dict:
    if a_dict[key] == N:
        ans += 1

print(ans)


Measured memory_bytes: 3060
/**
 * Author: Deb Natkh Maxim (debnatkh@gmail.com)
 * Date: 02.03.2019
 */

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

const int MAXN = 1e5;
vector <int> arr;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        arr.push_back(t);
    }
    vector <int> elems;
    while (!arr.empty()) {
        int mx = -1;
        for (int j = 0; j < arr.size(); j++) {
            if (arr[j] == j + 1) mx = j;
        }
        elems.push_back(mx + 1);
        if (mx == -1) {
            cout << -1 << endl;
            return 0;
        }
        arr.erase(arr.begin() + mx);
    }
    reverse(elems.begin(), elems.end());
    for (auto e : elems) {
        cout << e << "\n";
    }

    return 0;
}

Measured memory_bytes: 764
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	ans := 0
	for i := 1; i <= n; i++ {
		s := strconv.Itoa(i)
		ss := strings.Split(s, "")

		sum := 0
		for _, v := range ss {
			vi, _ := strconv.Atoi(v)
			sum += vi
		}

		if a <= sum && sum <= b {
			ans += i
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 1280