akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  i64 ans = 1;
  int n, k; cin >> n >> k;
  rep(i, n) ans *= k, ans %= 1000000007;
  cout << ans << '\n';
}



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

bool isPrime(int n)
{
  int m = (int)std::sqrt((double)n);
  for (int p=2; p<=m; p++) {
    if (n%p==0) return false;
  }
  return true;
}

int main()
{
  int N;
  std::cin >> N;
  for (; !isPrime(N); N++);
  std::cout << N << std::endl;
  return 0;
}

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

const int MAXN = 3e3+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

char a[MAXN][MAXN];
ll dp[MAXN][MAXN];
pair<int,int> par[MAXN][MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    string s,t;cin >> s >> t;
    s = "." + s;
    t = "." + t;
    for(int i=1;i<s.size();++i){
        for(int j=1;j<t.size();++j){
            int first = dp[i-1][j],second = dp[i][j-1],third = 0;
            if(s[i] == t[j]) third = 1 + dp[i-1][j-1];
            dp[i][j] = max(first,max(second,third));
            if(dp[i][j] == first) par[i][j] = {i-1,j};
            else if(dp[i][j] == second) par[i][j] = {i,j-1};
            else par[i][j] = {i-1,j-1};
        }
    }
    string ans;
    pair<int,int> now;
    now.F = s.size()-1,now.S = t.size()-1;
    while(true){
        pair<int,int> pars = par[now.F][now.S];
        if(pars.F == now.F - 1 && pars.S == now.S - 1) ans += s[now.F];
        now.F = pars.F,now.S = pars.S;
        if(pars.F == 0 || pars.S == 0) break;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
}


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


void main() {
    int n;
    scan(n);

    int m;
    int dan;

    foreach (k ; 1 .. 1000) {
        m += k;

        if (m == n) {
            dan = k + 1;
            break;
        }
        if (m > n) {
            writeln("No");
            return;
        }
    }

    debug {
        writeln(m, " ", dan);
    }

    auto ans = new int[][](dan + 2, 0);

    writeln("Yes");
    writeln(dan);
    int of;

    foreach_reverse (i ; 1 .. dan) {
        foreach (j ; 0 .. i) {
            ans[dan - i] ~= of + j + 1;
            ans[dan - i + j + 1] ~= of + j + 1;
        }
        of += i;
    }

    debug {
        writeln(ans);
    }

    foreach (ansi ; ans[1 .. $-1]) {
        writefln("%d %(%s %)", ansi.length, ansi);
    }
}




































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2940
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
int n;
ll v[maxn];
ll a, b;
void solve() {
    while(cin >> n) {
        cin >> a >> b;
        ll res = 0;
        for (int i = 0; i < n; i++) {
            cin >> v[i];
            if(i) {
                ll t = a * (v[i] - v[i - 1]);
                res += min(t, b);
            }
        }
        cout << res << endl;
    }
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	ll a, b, k;
	cin >> a >> b >> k;

	ll a_sa = 0;
	if (k >= a) {
		k -= a;
		a = 0;
		b -= k;
		if (b < 0) b = 0;
	}
	else {
		a -= k;

	}

	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N = input()
N = int(N)
H_ = input().split()
H = np.zeros(N)

for i in range(N):
  H[i] = int(H_[N-i-1])
out = [0]

num = 0
for i in range(N-1):
  if H[i] <= H[i+1]:
    num += 1
  else:
    out.append(num)
    num = 0
out.append(num)

print(np.array(out).max())

Measured memory_bytes: 21852
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

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 h, w; cin >> h >> w;
	vector<string> c(h);
	for (int i = 0; i < h; i++) {
		cin >> c.at(i);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < 2; j++) {
			cout << c.at(i) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
def cm(a,b):
    t= a-b
    if t > 0:
        return t
    else:
        return 0

def dm(a,b):
    if a > b:
        return b
    else:
        return a
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
res = 0 
R = min(A[0]-B[0],0)
res+= dm(A[0],B[0])
# print(res)
for i , j in zip(A[1:],B[1:]):
    res += dm(i,-R)
    l = cm(i,-R)
    t =  l - j
    R = min(t,0)
    res+= dm(l,j)
    # print(res)
res +=  dm(A[-1],-R)

print(res)




Measured memory_bytes: 18752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

const int maxn=2e5+10;

int n,k,l;


int par1[maxn],par2[maxn];

void init(){
    for(int i=0;i<n;i++){
        par1[i]=i;
        par2[i]=i;
    }
}

int find(int x, int *par){
    return x==par[x]? x : par[x]=find(par[x],par);
}

void unite(int x, int y, int * par){
    x= find(x,par);
    y = find(y,par);
    if(x!=y){
        par[x]=y;
    }
}


int main(){

    scanf("%d%d%d",&n,&k,&l);
    init();
    for(int i=0;i<k;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        unite(x,y, par1);
    }
    for(int i=0;i<l;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        unite(x,y, par2);
    }
    map<pair<int,int>, int> mp;
    for(int i=1;i<=n;i++){
        find(i,par1);
        find(i,par2);
    }
    for(int i=1;i<=n;i++){
        mp[make_pair(par1[i],par2[i])]++;
    }
    for(int i=1;i<=n;i++){
        cout<<mp[make_pair(par1[i],par2[i])]<<" ";
    }
    // getchar();
    // getchar();

    return 0;
}

Measured memory_bytes: 13568
// date: June 20 2020
// author: Tibbarnit

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
int n,a[200020],b[200020];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i]>>b[i];
    sort(a+1,a+n+1);sort(b+1,b+n+1);
    if (n&1) cout<<(b[(n+1)/2]-a[(n+1)/2])+1;
    else cout<<b[(n+1)/2+1]+b[(n+1)/2]-a[(n+1)/2]-a[(n+1)/2+1]+1;
    return 0;
}


Measured memory_bytes: 5184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;


struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
};

int main() {
  int N; cin >> N;
  constexpr int offset = 1e5 + 1;
  UnionFindTree tree((offset + 1)*2);
  for (int i = 0; i < N; ++i) {
    int x, y; cin >> x >> y;
    tree.Unite(x, y + offset);
  }

  map<int, LL> mx, my;
  for (int i = 1; i <= offset; ++i) {
    mx[tree.Root(i)]++;
    my[tree.Root(i + offset)]++;
  }

  LL total = 0;
  for (int i = 1; i <= offset; ++i) {
    total += mx[i] * my[i];
  }
  cout << max(0LL, total - N) << endl;
}


Measured memory_bytes: 22724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int k,a,b;
    cin>>k>>a>>b;

    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    
    return 0;
}

Measured memory_bytes: 3648
import copy
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p,r): 
        if a[j][1] <= x[1]:
            i += 1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    return(i+1)

def quickSort(a, p, r):
    if p<r:
        q = partition(a, p, r)
        quickSort(a, p, q - 1)
        quickSort(a, q+1, r)  



n = int(input())
a = []
for i in range(n):
    a.append(list(input().split()))
    a[i][1]=int(a[i][1])
b = copy.deepcopy(a)

quickSort(a, 0, n-1)

for i in range(n-1):
    if a[i][1] == a[i+1][1]:
        if b.index(a[i]) > b.index(a[i+1]):
            print("Not stable")
            break
else:
    print("Stable")

for i in a:
    print(" ".join(map(str,i)))



Measured memory_bytes: 41800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    scanf("%lld",&n);
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
        {
            ll tot=0;
            while(n%i==0) n/=i,tot++;
            ll t=1;
            while(tot>=t)
                tot-=t,t++,ans++;
        }
    if(n>1) ans++;
    printf("%lld\n",ans);
}


Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	int n;
	while (cin >> n, n) {
		int s[1001];
		double alpha=0, ave = 0;
		FOR(i, 1, n) {
			cin >> s[i];
			ave += s[i];
		}
		ave /= n;
		FOR(i, 1, n) {
			alpha += (s[i] - ave)*(s[i] - ave);
		}
		alpha /= n;
		alpha = sqrt(alpha);
		printf("%.10lf\n", alpha);
	}
	return 0;
}


Measured memory_bytes: 3144
#include <stdio.h>

int main(){
    
    char number[1001];
    int i,sum=0,c;
   
    while (1)
    {
        scanf("%s",number);
        if (number[0]=='0')
        {
            break;
        }
        sum=0;
        for (i=0; number[i]!='\0'; i++)
        {
            c=number[i]-'0';
            sum+=c;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 536
import sys

if(__name__ == "__main__"):

    N, K = map( int, input().strip().split() )
    divisor = 10**9+7
    list_a = list( map( int, input().strip().split() ) )
    multiplies = 1
    if(N==K):
        for i in range(N):
            multiplies = multiplies * list_a[i] % divisor
    else:
        list_a.sort()
        """
        解が負になるのはN>Kの時には
        正の項が1つもなく、Kが奇数の時
        """
        if(list_a[-1] < 0 and K % 2 != 0):
            """
            全て負の項
            list_a = [-5, -3, -1]のようにソートされている
            末尾の項から選んでいく
            """
            for i in range(K):
                multiplies = multiplies * list_a[N-1-i] % divisor
        elif(K==1):
            multiplies = list_a[N-1]
        else:
            left = 0
            right = N-1
            if(K%2!=0):
                multiplies = multiplies * list_a[right] % divisor
                right -= 1
            multiply_left = list_a[left] * list_a[left+1]
            multiply_right = list_a[right] * list_a[right-1]
            """
            注意:
                for文を単にK//2回ループ回すと問題が起こりうる。
                multiply_left > multiply_rightがK//2回続いた場合を考える。この時最後のループでleft = K

                Nが奇数かつN = K+1のケースではK//2回目の
                multiply_left = list_a[left] * list_a[left+1]の計算で、
                left+1 = Nとなりリストの領域範囲を超えているためREとなる。

                Nが偶数でかつN=K+1ならばleft+1が領域範囲を超えることがない。

            """

            """
            for s in range(K//2-1):
                if(multiply_left < multiply_right):
                    multiply_right %= divisor
                    multiplies = multiplies * multiply_right % divisor
                    right -= 2
                    multiply_right = list_a[right] * list_a[right-1]

                else:
                    multiply_left%=divisor
                    multiplies = multiplies * multiply_left % divisor
                    left += 2
                    multiply_left = list_a[left] * list_a[left+1]

            if(multiply_left < multiply_right):
                multiply_right %= divisor
                multiplies = multiplies * multiply_right % divisor

            else:
                multiply_left%=divisor
                multiplies = multiplies * multiply_left % divisor
            """

            flag_left = True
            for s in range(K//2):
                if(flag_left==True):
                    multiply_left = list_a[left] * list_a[left+1]
                else:
                    multiply_right = list_a[right] * list_a[right-1]
                if(multiply_left < multiply_right):
                    multiply_right %= divisor
                    multiplies = multiplies * multiply_right % divisor
                    right -= 2
                    flag_left=False


                else:
                    multiply_left%=divisor
                    multiplies = multiplies * multiply_left % divisor
                    left += 2
                    flag_left=True



    print(multiplies)


Measured memory_bytes: 30852
#include<stdio.h>
int sosu(int);
#define true 1
#define false -1
int main(){
  int n,i,count=0,num;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num);
    if(sosu(num)==true){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

int sosu(int a){
  int i;
  if(a==2){
    return true;
  }
  if(a%2==0){
   return false;
 }
   for(i=3;i*i<=a;i+=2){
     if(a%i==0){
       return false;
     }
   }
 return true;
}



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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,k,c;
    cin>>n>>k>>c;
    c++;
    string s;
    cin>>s;
    ll maxx[n+1]={0};
    rep(i,0,n-1){
        if(i) maxx[i]=maxx[i-1];
        if(i<c){
            if(s[i]=='o') maxx[i]=max(maxx[i],1ll);
        }
        else{
            if(s[i]=='o') maxx[i]=max(maxx[i-c]+1,maxx[i]); 
        }
    }
    ll revmaxx[n+1]={0};
    rrep(i,n-1,0){
        if(i!=n-1) revmaxx[i]=revmaxx[i+1];
        if((n-i-1)<c){
            if(s[i]=='o') revmaxx[i]=max(revmaxx[i],1ll);
        }
        else{
            if(s[i]=='o') revmaxx[i]=max(revmaxx[i+c]+1,revmaxx[i]); 
        }
    }
    // rep(i,0,n-1) cout<<maxx[i]<<" ";
    // cout<<endl;
    // rep(i,0,n-1) cout<<revmaxx[i]<<" ";
    // cout<<endl;
    // ll ans=0;
    rep(i,0,n-1){
        if(s[i]=='o'){
            ll curr=0;
            if(i>0) curr+=maxx[i-1];
            if(i<n-1) curr+=revmaxx[i+1];
            if(curr<k) cout<<i+1<<endl;
        }
    }
    // cout<<ans;/
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 5012
#include <stdio.h>
int main(void){
    int x,y,z,pass;

    	 scanf("%d",&x);
	 scanf("%d",&y);

	 if(x<y){
	  pass=x;
	  x=y;
	  y=pass;
	  }

	 z=x%y;
	 while(z!=0){
	  x=y;
	  y=z;
	  z=x%y;
	 }
	 
	printf("%d\n",y);
	  
	 
	 
}



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

#define x first
#define y second

using namespace std;

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

ll ccw(pll a, pll b, pll c) {return a.x*b.y+b.x*c.y+c.x*a.y-a.y*b.x-b.y*c.x-c.y*a.x;}
pll operator * (pll a, pll b) {
	if (a.first<b.first) return pll(a.second-b.second,b.first-a.first);
	return pll(b.second-a.second,a.first-b.first);
}
bool operator <= (pll a, pll b) {
	return a.first*b.second<=b.first*a.second;
}
int n, m;
ll ans[300100];
struct CHT {
	vector<pll> vec;
	void init() {vec.clear();}
	void add(pll a) {
		while(vec.size()>=2&&ccw(vec[vec.size()-2],vec.back(),a)>=0) vec.pop_back();
		vec.push_back(a);
	}
	ll f(pll a, ll b) {return a.first*b+a.second;}
	void getvr(ll s, ll e) {
		ll i, j = 0;
		for (i=s;i<=e;i++) {
			while(j+1<vec.size()&&f(vec[j],i)<=f(vec[j+1],i)) j++;
			ans[i] = f(vec[j],i);
		}
	}
	ll getv(ll x) {
		ll s = 0, e = (int)vec.size()-2;
		while(s<=e) {
			ll m = (s+e)>>1;
			if(f(vec[m],x)<=f(vec[m+1],x)) s = m+1;
			else e = m-1;
		}
		return f(vec[s],x);
	}
} cht;
ll L[300100], R[300100], D[300100];
ll P[300100], Q[300100], T[300100], INF = 1LL<<50;

void dnc(int s, int e) {
	if (s==e) {
		D[s] = max(D[s],(s==1?0:L[s-2])+R[s+2]+1-T[s]);
		return;
	}
	int m = (s+e)>>1, i; ll res = -INF;
	cht.init();
    cht.add(pll(-1LL*(e+1),R[e+2]+Q[e+1]+1LL*(e+1)*(e+2)/2));
	for (i=e;i>m;i--) cht.add(pll(-i,R[i+1]+Q[i]+1LL*i*(i+1)/2));
	cht.getvr(s,m);
	for (i=s;i<=m;i++) {
		res = max(res,ans[i]+1LL*i*(i-1)/2-Q[i]+(i==1?0:L[i-2]));
		D[i] = max(D[i],res);
	}
	cht.init();
    cht.add(pll(-1LL*(n+1-s+1),(s==1?0:L[s-2])+P[s-1]+1LL*(n+1-s+1)*(n+2-s+1)/2));
    for (i=s;i<=m;i++) cht.add(pll(-(n+1-i),L[i-1]+P[i]+1LL*(n+1-i)*(n+2-i)/2));
    cht.getvr(n+1-e,n-m); res = -INF;
    for (i=e;i>m;i--) {
		res = max(res,ans[n+1-i]+1LL*(n+1-i)*(n-i)/2-P[i]+R[i+2]);
		D[i] = max(D[i],res);
    }
    dnc(s,m); dnc(m+1,e);
}

int main() {
    int i;

    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%lld",&T[i]);
    for (i=1;i<=n;i++) P[i] = P[i-1]+T[i];
    for (i=n;i>=1;i--) Q[i] = Q[i+1]+T[i];
    for (i=1;i<=n;i++) D[i] = -INF;
    cht.init();
    cht.add(pll(-1LL*(n+1),1LL*(n+1)*(n+2)/2));
    for (i=n;i>=1;i--) {
		R[i] = max(cht.getv(i)+1LL*i*(i-1)/2-Q[i],R[i+1]);
		cht.add(pll(-i,R[i+1]+Q[i]+1LL*i*(i+1)/2));
    }
    cht.init();
    cht.add(pll(-1LL*(n+1),1LL*(n+1)*(n+2)/2));
    for (i=1;i<=n;i++) {
		L[i] = max(cht.getv(n+1-i)+1LL*(n+1-i)*(n-i)/2-P[i],L[i-1]);
		cht.add(pll(-(n+1-i),L[i-1]+P[i]+1LL*(n+1-i)*(n+2-i)/2));
    }

    dnc(1,n);
/*
    for (i=1;i<=n;i++) printf("%lld ",L[i]);
    printf("\n");
    for (i=1;i<=n;i++) printf("%lld ",R[i]);
    printf("\n");
    for (i=1;i<=n;i++) printf("%lld ",D[i]);
    printf("\n");
*/
    scanf("%d",&m);
    for (i=0;i<m;i++) {
		int a; ll b;
		scanf("%d%lld",&a,&b);
		printf("%lld\n",max(L[a-1]+R[a+1],D[a]-b+T[a]));
    }

    return 0;
}


Measured memory_bytes: 18944
N, M = map(int, input().split())

imos = [0] * (10 ** 5 + 2)

for _ in range(M) :
    L, R = map(int, input().split())
    imos[L] += 1
    imos[R+1] -= 1

for i in range(10 ** 5 + 1) :
    imos[i+1] += imos[i]

print(imos.count(M))

Measured memory_bytes: 44888
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> t3;

bool IsPrime(ll x){
    if(x == 2) return true;
    if(x % 2 == 0)return false;
    for(ll i = 3;i <= sqrt(x);i+=2){
        if(x % i == 0) return false;
    }
    return true;
}

int main(void) {
    ll x;
    cin >> x;
    while(true){
        if(IsPrime(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

#define ycomb [](auto f){ return [=](auto&&... args){ return f(f, std::forward<decltype(args)>(args)...); }; }

int app() {
  int n,m;
  cin>>n>>m;

  vector<int> uf(n,-1);

  auto root = ycomb([&](auto root, int i){
    if(uf[i]<0) return i;
    return uf[i]=root(root,uf[i]);
  });

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b) swap(a,b);
    if(root(a)!=root(b)){
      uf[root(a)]+=uf[root(b)];
      uf[root(b)]=root(a);
    }
  }

  int ans=0;
  rep(i,n){
    chmin(ans,uf[i]);
  }
  return -ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 4036
public class Main{
	public static void main(String[] args){
		
		String value;		//????????????????????????????????\?????????
		int input;			//??\????????????????????????
		int output;			//???????????????
		
		value = new java.util.Scanner(System.in).nextLine();	//???????????????????????????????????\???
		
		
		input=Integer.parseInt(value);				//??\??????????????????String??????int????????????
		output=(int)(Math.pow((double)input,3));	//??\??????????????????3????????????Math.pow???double???????????°?????¨?????????????????£??????????????£????????????
		System.out.println(output);					//????????¨???	
		
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);

    rep(i,n){
        cin>>v[i];
    }
    ll ans=0;
    rep(i,n){
        if(i>0&&i<n-1){
            if(v[i]!=min(v[i-1],min(v[i],v[i+1]))&&v[i]!=max(v[i-1],max(v[i],v[i+1]))){
                ans ++;
            }
        }
    }
    cout<<ans<<endl;
    return  0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

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

void Main(){
    const int INF = 1e9;
    int n, m; cin >> n >> m;
    vi num = {2,5,5,4,5,6,3,7,6};
    vi a(m); 
    rep(i, m) {
        cin >> a[i]; a[i]--;
    }
    // dp[s] = s 本のマッチを使うときの実現可能な最大桁数
    vi dp(n+5, -INF);
    dp[0] = 0;
    rep(i, m) dp[num[a[i]]] = 1; 
    rep(s, n+5){
        rep(i, m) {
            if(s + num[a[i]] <= n+2) chmax(dp[s + num[a[i]]], dp[s] + 1);
        }
    }
    
    int keta = dp[n];
    // cout << keta << endl; 

    rep(k, keta){
        int tmp = -1; 
        rep(i, m){
            if(n - num[a[i]] < 0) continue;
            if(dp[n - num[a[i]]] == dp[n] - 1){
                chmax(tmp, a[i]);
            }
        }
        n -= num[tmp];
        cout << tmp+1;
        // cout << "debug: " << n << " " << tmp+1 << " " << num[tmp] << endl;
    }
    cout << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main() {
    int n ,k;
    cin >> n >> k;
    int h;
    int ans=0;
    rep(i,n){
        cin >> h;
        if (h>=k)
            ans++;
    }
    cout<<ans;
    return 0;
}


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const ll INF = 1LL << 60;

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


Measured memory_bytes: 256
trial = int(input())
while True:
    targ = []
    for t in range(trial):
        targ.append(int(input()))
    targ.remove(max(targ))
    targ.remove(min(targ))
    print(sum(targ) // len(targ))
    trial = int(input())
    if trial ==0:
        break

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin >> N >> T >> A;
  int H[1010];
  for(int i = 0; i < N; i++)cin >> H[i];

  vector<double> h(N);
  for(int i = 0; i < N; i++){
    h.at(i) = abs(A - T + H[i] * 0.006);
  }
double m = h.at(0);
int ans = 0;
  for(int i = 0; i < N; i++){
    if(m >h.at(i)){
      ans = i;
      m = h.at(i);
    }
  }
  cout << ans+1 <<endl;
}



Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))

ki = li[::2]
gu = li[1::2]

ki.sort()
gu.sort()

from itertools import groupby

ki_li = []
gu_li = []

for key, value in groupby(ki):
    ki_li.append((key,len(list(value))))

for key, value in groupby(gu):
    gu_li.append((key,len(list(value))))

ki_li.sort(key=lambda x:(x[1]*(-1)))
gu_li.sort(key=lambda x:(x[1]*(-1)))

if ki_li[0][0] == gu_li[0][0]:
    if ki_li[0][1] > gu_li[0][1]:
        if len(gu_li) >= 2:
            ans = n-ki_li[0][1]-gu_li[1][1]
        else:
            ans = n-ki_li[0][1]
    elif ki_li[0][1] == gu_li[0][1]:
        if len(ki_li) >= 2:
            if ki_li[1][1] >= gu_li[1][1]:
                ans = n-gu_li[0][1]-ki_li[1][1]
            else:
                ans = n-ki_li[0][1]-gu_li[1][1]
        else:
            ans = n-ki_li[0][1]
    else:
        if len(ki_li) >= 2:
            ans = n-gu_li[0][1]-ki_li[1][1]
        else:
            ans = n-gu_li[0][1]
else:
    ans = n-gu_li[0][1]-ki_li[0][1]

print(ans)

Measured memory_bytes: 15772
using System.Linq;
using System.Collections.Generic;
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, int.Parse);
        var an = new List<int>();
        var pre1 = false; var count = 1;
        if (a[0] == 1) pre1 = true;
        for (int i = 1; i < n; i++)
        {
            if (pre1 && a[i] == 0) { count++; pre1 = false; }
            else if (!pre1 && a[i] == 1) { count++; pre1 = true; }
            else { an.Add(count); count = 1; }
        }
        an.Add(count);
        Console.WriteLine(getMax(an));
    }
    public static int getMax(List<int> an)
    {
        if (an.Count() == 1) return an[0];
        if (an.Count() == 2) return an.Sum();
        var a = an.ToArray();
        var n = a.Length;
        var s3 = a[0] + a[1] + a[2];
        var smax = s3;
        for (int i = 3; i < n; i++)
        {
            s3 = s3 + a[i] - a[i - 3];
            smax = Math.Max(smax, s3);
        }
        return smax;
    }
}

Measured memory_bytes: 15032
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = Long.parseLong(sc.nextLine());
        String[] arr = sc.nextLine().split(" ");
        Long[] numArray = Arrays.stream(arr).map(Long::parseLong).toArray(Long[]::new);
        sc.close();

        long min = Long.MAX_VALUE;

        for (int i = 1; i <= 100; i++) {
            long value = 0L;
            for (int l = 0; l < N; l++) {
                long x = numArray[l];
                long val = (long) Math.pow((x - i), 2);
                value += val;
            }
            if (value < min) {
                min = value;
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 27220
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	int t;
	cin>>t;
	int homes[100001];
	int hn=0;
	//int roads[100001];
	int rn=0;
	for(int l = 0; l < t; l++){
		rn=hn=0;
		int n,k;
		cin>>n>>k;
		for(int i = 0; i < n; i++){
			int p;
			cin>>p;
			homes[hn]=(p);
			hn++;
		}
		if(hn<=k){
			cout<<0<<endl;
			continue;
		}
		int sumL=0;
		priority_queue<int> pq;
		for(int i = 1; i < hn; i++){
			int length=homes[i]-homes[i-1];
			//roads[rn]=(length);
			//rn++;
			pq.push(length);
			sumL+=length;
		}
		//sort(roads,roads+rn,greater<int>());
		int rid=0;
		for(int i = 0; i < k-1; i++){
			//rid+=roads[i];
			rid+=pq.top();
			pq.pop();
		}
		cout<<sumL-rid<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {

	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vll A(X), B(Y), C(Z);
	rep(i, X) cin >> A[i];
	rep(i, Y) cin >> B[i];
	rep(i, Z) cin >> C[i];

	vll po, po1;
	rep(i, X) po.push_back(A[i]);
	po1;
	rep(i, Y) {
		for (auto p : po) {
			po1.push_back(p + B[i]);
		}
	}
	sort(all(po1), greater<ll>());
	po1.resize(min(3000, (int)po1.size()));
	po = po1;
	po1.resize(0);
	rep(i, Z) {
		for (auto p : po) {
			po1.push_back(p + C[i]);
		}
	}
	sort(all(po1), greater<ll>());
	po = po1;

	rep(i, K) cout << po[i] << endl;
}

Measured memory_bytes: 49260
#include<stdio.h>

int main(){
	int H=0;
	int W=0;

	do{
		scanf("%d %d",&H,&W);
		if(H*W==0)break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i%(H-1)!=0)&&(j%(W-1)!=0)){
					printf(".");
				}
				else{
					printf("#");
				}
			}
			puts("");
		}
		puts("");
	}while(H*W!=0);

	return 0;
}



Measured memory_bytes: 2052
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn dfs(
    cur: usize,
    n: usize,
    m: usize,
    v: &mut Vec<usize>,
    c: &Vec<(usize, usize, usize, usize)>,
) -> usize {
    if v.len() == n {
        let mut s = 0;
        for i in 0..c.len() {
            if v[c[i].1] - v[c[i].0] == c[i].2 {
                s += c[i].3;
            }
        }
        s
    } else {
        let mut s = 0;
        for i in cur..m + 1 {
            v.push(i);
            s = max(s, dfs(i, n, m, v, c));
            v.pop();
        }
        s
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        c: [(usize1, usize1, usize, usize); q],
    }

    let mut v = vec![];
    println!("{}", dfs(1, n, m, &mut v, &c));
}


Measured memory_bytes: 2140
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let mut ans = 0;

    for i in 0..n {
        let mut h1 = HashSet::new();
        let mut h2 = HashSet::new();
        for &c in &s[0..i] {
            h1.insert(c);
        }
        for &c in &s[i..n] {
            h2.insert(c);
        }
        let h3: HashSet<_> = h1.intersection(&h2).collect();
        ans = max(ans, h3.len());
    }

    println!("{}", ans);
}


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

#define f first
#define s second
#define ins insert
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int,int>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (int) (c).size()
#define trav(x,c) for (auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define db(x) cout << #x << ": " << x << endl;
#define _db(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios_base::sync_with_stdio(0); cin.tie(0);

int main() { 
	godspeed;
	
	ll n; cin >> n;
	vector<char> v;
	while (n--) {
		char c = 'a' + n%26;
		v.pb(c);
		n /= 26;
	}
	reverse(all(v));
	for (int i = 0 ; i < sz(v) ; ++i) cout << v[i];

}

Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;

inline long long up_divisor(long long n, long long d) { return (n + d - 1) / d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << up_divisor(n, min<long long>({a, b, c, d, e})) + 4 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    string ans;
    rep(i,3) {
        string s; cin >> s;
        ans += s[i];
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
	int a[100005];
	int b[100005];
	int cnt = 0;

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

	for (int i = 0; i < n - k + 1; i++)
	{
		b[cnt++] = a[i + k - 1] - a[i];
	}

	int ans = *min_element(b, b + cnt);
	
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n, y, i;
	int a, b, c, d, e, f, g;
	
	while (scanf("%d", &n), n != 0){
		a = b = c = d = e = f = g = 0;
		for (i = 0; i < n; i++){
			scanf("%d", &y);
			if (y <= 9){
				a++;
			}
			else if (10 <= y && y <= 19){
				b++;
			}
			else if (20 <= y && y <= 29){
				c++;
			}
			else if (30 <= y && y <= 39){
				d++;
			}
			else if (40 <= y && y <= 49){
				e++;
			}
			else if (50 <= y && y <= 59){
				f++;
			}
			else if (60 <= y){
				g++;
			}
		}
		printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n", a, b, c, d, e, f, g);
	}
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
long long a[maxn];
int main(){
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    rep(i,1,n){
        cin>>a[i];
    }
    double ans=0,cur=0;;
    rep(i,1,k)cur+=a[i]+1;ans=cur;
    rep(i,k+1,n){
        
        cur+=a[i]+1;
        cur-=(a[i-k]+1);
        ans=max(ans,cur);
    }
    printf("%.3lf",ans/2);
    //cout<<ans/2<<endl;
}
/* 
5 3
1 2 2 4 5

10 4
17 13 13 12 15 20 10 13 17 11

 */

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

vector<vector<int>> G;
int cost[100][100];
bool memo[100][100];

void solve(long long N, long long M, vector<long long> a, vector<long long> b, vector<long long> c){
    for(int i=0; i<N; i++) {
        vector<int> tmp;
        G.push_back(tmp);
        for(int j=0; j<N; j++){
            cost[i][j] = 2100000000;
            memo[i][j] = false;
        }
    }

    for(int i=0; i<M; i++){
        G[a[i] - 1].push_back(b[i] - 1);
        G[b[i] - 1].push_back(a[i] - 1);

        cost[a[i] - 1][b[i] - 1] = c[i];
        cost[b[i] - 1][a[i] - 1] = c[i];

        memo[a[i] - 1][b[i] - 1] = true;
        memo[b[i] - 1][a[i] - 1] = true;
    }

    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que;
    
    for(int i=0; i<N; i++){
        int check[N];
        for(int j=0; j<N; j++){
            check[j] = 100000000;
        }
        check[i] = 0;
        for(int j=0; j<G[i].size(); j++){
            que.push(make_pair(cost[i][G[i][j]], make_pair(G[i][j], i)));
        }

        while (!que.empty()) {
            pair<int, pair<int, int>> now = que.top();
            que.pop();
            int new_pos = now.second.first;
            int prev_pos = now.second.second;
            int mv_cost = now.first;

            if (mv_cost < check[new_pos]) {
                check[new_pos] = mv_cost;
                for(int j=0; j<G[new_pos].size(); j++){
                    que.push(make_pair(cost[new_pos][G[new_pos][j]] + mv_cost, make_pair(G[new_pos][j], new_pos)));
                }
                memo[new_pos][prev_pos] = false;
                memo[prev_pos][new_pos] = false;
            } else if(mv_cost == check[new_pos]) {
                memo[new_pos][prev_pos] = false;
                memo[prev_pos][new_pos] = false;
            }
        }
    }

    int cnt = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cnt += memo[i][j];
        }
    }
    cout << cnt / 2 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    vector<long long> a(M);
    vector<long long> b(M);
    vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, a, b, c);
    return 0;
}


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

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

  for (int i = N; i <= 999; i++) {
    if (i % 10 == i / 10 % 10 && i % 10 == i / 100 % 10) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256