akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func reverseString(s string) string {
	n := len(s)
	bytes := []byte(s)
	for i := 0; i < n/2; i++ {
		bytes[i], bytes[n-1-i] = bytes[n-1-i], bytes[i]
	}
	return string(bytes)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	ans := ""
	for n != 0 {
		r := n % 2
		if r < 0 {
			r += 2
		}
		ans += string('0' + r)
		n = (n - r) / (-2)
	}

	if len(ans) == 0 {
		ans = "0"
	}
	puts(reverseString(ans))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll X){
    X--;
    next_int:
    while (X++) {
        rep2(i, 2, floor(sqrt(X))) if (X % i == 0) goto next_int;
        cout << X << "\n";
        return;
    }
}

int main() {
    ll X;
    ignore_ret(scanf("%lld",&X));
    solve(X);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SS=SZB,*TT=SZB;
    inline char gc(){   if (SS==TT){  TT=(SS=SZB)+fread(SZB,1,GYN,stdin); if (SS==TT) return '\n';  }   return *SS++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
ll ans=1e9,n;
ll calc(ll x){ll sum=0;for(;x;x/=10)sum+=x%10;return sum;}
int main(){
	n=read();
	For(i,1,n/2)Min(ans,calc(i)+calc(n-i));
	writeln(ans);
}

Measured memory_bytes: 256
def main():

    S = input()
    S_1 = S[:int((len(S)-1)/2)]
    S_2 = S[int((len(S)+3)/2)-1:]

    if S == S[::-1] and S_1 == S_1[::-1] and S_1 == S_1[::-1]:
        print("Yes")
    
    else:
        print("No")

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
struct node{
	string name;
	int length;
} song[1010];
int n,fl=0,ans=0;
string s;

int main()
{	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>song[i].name>>song[i].length;
	cin>>s;
	for(int i=1;i<=n;++i)
		if(fl)
			ans+=song[i].length;
		else if(song[i].name==s)
			fl=1;
	cout<<ans<<endl;
	return 0;
} 

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

int main(){
  int A,B,K;
  cin >>A>>B>>K;
  
  vector<int> C(max(A,B),0);
  rep(i,1,min(A,B)){
    if(A%i==0 and B%i==0){
      C[i-1] = i;
    }
  }  
  
  sort(C.begin(),C.end(),greater<int>());
  int ans = C[K-1];
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;
    bool flag = false;

    cin >> N;

    if (N > 81){
        flag = false;
    }

    else{
        FOR(i, 1, 9){
            FOR(j, 1, 9){
                if (i*j == N){
                    flag = true;
                    break;
                }
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> vecX(N);
  for(int i=0; i<N; i++){
    cin >> vecX.at(i);
  }
  vector<int> vecY(M);
  for(int j=0; j<M; j++){
    cin >> vecY.at(j);
  }
  string ans = "No War";
  sort(vecX.begin(), vecX.end());
  sort(vecY.begin(), vecY.end());
  
  if(vecY.at(0) - vecX.at(N-1) <= 0){
    ans = "War";
  }
  if(vecY.at(0) <= X){
    ans = "War";
  }
  if(vecX.at(N-1) >= Y){
    ans = "War";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//2018.09.15 9.5min

#include <iostream>
using namespace std;

int main() {

    string s;
    cin >> s;

    int i;
    bool ans = false;
    for(i=2;i<4;i++){
        if(s[i]==s[i-1] && s[i]==s[i-2]) ans = true;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include<map>
#include <utility>
#include <math.h>
#include <queue>
# define INF 1000000000
using namespace std;
int  a = 0, b = 0, c = 0, d = 0, e[100009] = {}, f[100010],g=0, ans = 0;
double syo = 0, su = 0;
long long   mur = 0, kmr = 0, yju = 0, counto[5003], counto1[5003];
char fir, sec = 'z', mado[1010][1010], homu[52][52];
string rik, mrsm[500], tok[25003];
bool mazi[110], gi[110], zi, manji;
pair<int, int>n;
vector<int> aa[100], cc;
vector<char> bb[100], dd;
map<char, int>zis, uuu;
int gcd(int a, int b) {
	int d;
	if (a > b) {
		int t = b;
		b = a;
		a = t;
	}
	while ((d = b % a) != 0) {
		b = a;
		a = d;
	}
	return a;
}
int dp[100100];
int main(){
	cin >> a;
	e[0] = 0;
	dp[0] = 0;
	for (int i = 1; i <= a; i++) {
		cin >> e[i];
		dp[i] = INF;
	}
	dp[1] = 0;
	for (int i = 2; i <= a; i++) {
		if (i >= 2) {
			dp[i] = min(dp[i], dp[i - 1] + abs(e[i - 1] - e[i]));
		}
		if (i >= 3) {
			dp[i] = min(dp[i], dp[i - 2] + abs(e[i - 2] - e[i]));
		}
	}
	cout << dp[a] << endl;
	return 0;
}

	



Measured memory_bytes: 1280
s = list(input())
t = list(input())
length = len(s)-len(t) + 1
max = 0
for i in range(length):
    count = 0
    for j in range(len(t)):
        if t[j] == s[i+j]:
            count += 1
        if j == len(t)-1 and max < count:
            max = count
print(len(t) - max)

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
	ll x,n;
	cin>>x>>n;
	ll arr[n];
	for(ll i=0;i<=n-1;i++){
		cin>>arr[i];
	}

	unordered_set<ll> us1;

	for(ll i=0;i<=n-1;i++){
		us1.insert(arr[i]);
	}

	ll ans = x;
	ll dif = INT_MAX;
	for(ll i = x;i>=x-1-n;i--){
		if(us1.find(i)==us1.end()){
			dif = abs(i-x);
			ans  = i;
			break;
		}
	}

	for(ll i = x;i<=x+1+n;i++){
		if(us1.find(i)==us1.end()){
			if(abs(i-x) < dif){
				ans = i;
				break;
			}
			break;
		}
	}
	cout<<ans;

}

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

int main() {
int a,b;
  cin>>a>>b;
  int n=b-a;
  int h=0;
  for(int i=1;i<=n;i++){
    h+=i;}
  cout<<h-b<<endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            ans++;
        }
    }
    cout << 700 + ans * 100 << endl;

    return 0;
}

Measured memory_bytes: 256
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 4e5 + 5;

int a[N];
 
inline void solve() {
   int n, x;
   vector < P > v;
   cin >> n;
   for (int i = 1; i <= n; ++i) {
    cin >> x;
    v.push_back({x, i});
   }
   sort(all(v));
   for (auto i : v) {
    cout << i.second << ' ';
   }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t; while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef string st;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef vector<string>si;
typedef list<int>li;
typedef multiset<int>msi;
typedef map<int,int>ma;
#define dd(x) cout<<#x<<"="<<x<<",";
#define de(x) cout<<#x<<"="<<x<<endl;
#define df(x) cout<<x<<endl;
#define dg(x) cout<<x<<" ";
#define rep(i,a,b) for(i=a;i<b;++i)
#define per(i,a,b) for(i=b-1;i>=a;--i)
#define rpp(i,a,b) for(i=a;i<2*b-1;i+=2)
#define all(x) (x).begin() (x).end()
#define sz(x) (x).size()
#define mp make_pair
#define pb push_back
#define po2 pop_back
#define po1 front_back
#define fi first
#define se second
#define Nmax 200005
//erase  merge
const int N=575757;
ll top,S[1000];
void push(int x){
	S[++top]=x;
}
int pop(){
	top--;
	return S[top+1];
}
int main()
{
	ll a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}	
		else if(s[0] == '-'){
		b=pop();
		a=pop();
		push(a-b);
	}
	else if(s[0]=='*'){
		a=pop();
		b=pop();
		push(a*b);
	}
	else
	push(atoi(s));
	}
	df(pop());
	return 0;
}



Measured memory_bytes: 3240
n = int(input())
a = list(map(int,input().split()))

p = {}
q = {}
for i in range(n):
  pp = a[i]+i+1
  if pp in p:
    p[pp] += 1
  else:
    p[pp] = 1
  qq = -(a[i]-(i+1))
  if qq in q:
    q[qq] += 1
  else:
    q[qq] = 1
ans = 0
for kp,vp in p.items():
  if kp in q:
    vq = q[kp]
    ans += vp*vq
print(ans)

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

int main(void){
    int a = 0, b = 0; 

    scanf("%d%d", &a, &b);

    if(a >= b){
        for(int i = 0; i < a; i++){
            printf("%d", b);
        }
    }else{
        for(int i = 0; i < b; i++){
            printf("%d", a);
        }
    }

    printf("\n");
    return 0;

} 


Measured memory_bytes: 256
# E - Strings of Impurity  maspyさん
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from bisect import bisect_left

S = input().rstrip()
T = input().rstrip()

LS = len(S)

index = defaultdict(list)

for i,s in enumerate(S):
    index[s].append(i)

x = -1 #今みたところ　次はx+1から
for t in T:
    arr = index[t]
    if len(arr) == 0:
        print(-1)
        exit()
    y = (x+1)%LS
    i = bisect_left(arr,y)
    if i < len(arr):
        next_x = (x+1) + arr[i] - y
    else:
        next_x = (x+1) + arr[0] + LS - y
    x = next_x

ans = x + 1
print(ans)
    
    



Measured memory_bytes: 8052
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const mod = 998244353
const facNum = 300001
const INF = 2 << 31

func main() {
	sc := newScanner(os.Stdin)
	a := sc.s()
	if a[0] >= 'a' {
		fmt.Println("a")
	} else {
		fmt.Println("A")
	}
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n;
    cin >> n;
    VI a(n);
    VI b(n);
    VI c(n-1);

    rep(i,n) {
        cin >> a[i];
    }

    rep(i,n) {
        cin >> b[i];
    }

    rep(i,n-1) {
        cin >> c[i];
    }

    int count = 0;

    rep(i,n) {
        count += b[i];
    }

    rep(i,n) {
        if(a[i] + 1 == a[i+1]) {
            count += c[a[i]-1];
        }
    }

    cout << count;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,ans;
int main(){
	n=read();
	for(int i=1;i<n;i++) ans+=(n-1)/i;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int w,a,b;cin>>w>>a>>b;
    int ans;
    if(a>b)ans=a-b;
    else ans = b-a;
    cout<<max(0,ans-w)<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <array>

using namespace std;

const int MaxObservatoryNum = 100000;
// const int MaxObservatoryNum = 100;
// 負けがない展望台を出力

int main() {
  int observatory_num;
  int road_num;
  array<int, MaxObservatoryNum + 1> observatory_height_list;
  array<bool, MaxObservatoryNum + 1> is_good_observatory_list;

  cin >> observatory_num >> road_num;

  // init
  for(int i = 1; i <= observatory_num; i++)  {
    is_good_observatory_list[i] = true;
  }

  for(int i = 1; i <= observatory_num; i++) {
    cin >> observatory_height_list[i];
  }

  for(int i = 0; i < road_num; i++) {
    int label1, label2;
    cin >> label1 >> label2;

    if (observatory_height_list[label1] == observatory_height_list[label2]) {
      is_good_observatory_list[label1] = false;
      is_good_observatory_list[label2] = false;
      continue;
    }

    if(observatory_height_list[label1] > observatory_height_list[label2]) {
      is_good_observatory_list[label2] = false;
    } else {
      is_good_observatory_list[label1] = false;
    }
  }


  int is_good_observatory_num = 0;
  for(int i = 1; i <= observatory_num; i++ ) {
    if(is_good_observatory_list[i]) {
      is_good_observatory_num++;
    }
  }

  cout << is_good_observatory_num << endl;
  return 0;
}


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


int main() {
  int sx,sy,tx,ty;
  cin >>sx>>sy>>tx>>ty;
  int ans=0;
  rep(i,ty-sy){
    cout<<'U';
  }
  rep(i,tx-sx){
    cout<<'R';
  }
  rep(i,ty-sy){
    cout<<'D';
  }
  rep(i,tx-sx){
    cout<<'L';
  }
  cout<<'L';
  rep(i,ty-sy+1){
    cout<<'U';
  }
  rep(i,tx-sx+1){
    cout<<'R';
  }
  cout<<'D'<<'R';
  rep(i,ty-sy+1){
    cout<<'D';
  }
  rep(i,tx-sx+1){
    cout<<'L';
  }
  cout<<'U';
}





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

max = 0
count = 0
for x in range(N-1):
  if H[x]>=H[x+1]:
    count += 1
  else:
    if max < count:
      max = count
    count=0
if max < count:
  max = count
print(max)

Measured memory_bytes: 14252
n, m = map(int, input().split())
ls = [[int(i) for i in input().split()] for _ in range(m)]

se1 = set()
se2 = set()

for a, b in ls:
    if a == 1:
        se1.add(b)
    if b == n:
        se2.add(a)

se = se1 & se2

print('POSSIBLE' if se else 'IMPOSSIBLE')


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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N, M; cin >> N >> M;
    vector<P> day_bns;
    int a, b;
    rep(i, N) {
        cin >> a >> b;
        day_bns.emplace_back(a, b);
    }
    sort(day_bns.begin(), day_bns.end());

    ll ans = 0;
    int di = 0;
    priority_queue<int> que;
    for (int i = 1; i <= M; ++i) {
        // cout << "day: " << i << endl;
        while(day_bns[di].first <= i && di<N) {
            // 日付がi日以内であれば、priority_queueにpush
            que.push(day_bns[di].second);
            di++;
        }
        int bonus = 0;
        if (!que.empty()) {
            bonus = que.top();
            que.pop();
            // cout << "key:  " << i << "value: " << bonus << endl;
            ans += bonus;
        }
    }

    cout << ans << endl;
    return 0;
}

/*
7 3
1 2
1 3
1 4
3 2
5 1
2 1
2 3
*/

Measured memory_bytes: 1908
#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>
using namespace std;

int main() {
	int x;
	cin >> x;
	if (x == 25) cout << "Christmas" << endl;
	else if (x == 24) cout << "Christmas Eve" << endl;
	else if (x == 23) cout << "Christmas Eve Eve" << endl;
	else if (x == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl;
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

int main(){
    ll n,m;
    cin >> n >>m;
    ll a[n];
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    sort(a,a+n,greater<ll>());
    bool can=true;
    rep(i,m){
        if(sum>4*m*a[i]){
            can=false;
            break;
        }
    }
    if(can){
        cout << "Yes" << endl;
    }
    else{
        cout <<"No" << endl;
    }
}



Measured memory_bytes: 256
class uf():
    def __init__(self,n):
        self.n=n
        self.pa=[-1]*n
    def find(self,x):
        if self.pa[x]<0:
            return x
        else:
            self.pa[x]=self.find(self.pa[x])
            return self.pa[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
        	return True
        else:
            if self.pa[x]>self.pa[y]:
                x,y=y,x
            self.pa[x]+=self.pa[y]
            self.pa[y]=x
            return True
    def same(self,x,y):
        return self.find[x]==find.pa[y]
    def size(self,x):
        return -self.pa[self.find(x)] 
n,m=map(int,input().split())
import sys
input=sys.stdin.readline
l=list(map(int,input().split()))
uf=uf(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.unite(a-1,b-1)
d=dict()
for i in range(n):
    if uf.find(i) in d:
        d[uf.find(i)].add(i)
    else:
        d[uf.find(i)]=set([i])
for x in d:
  for y in d[x]:
    if l[y]-1 in d[x]:
      pass
    else:
      n-=1
print(n)

Measured memory_bytes: 40992
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    string S[N];
    for (int i = 0; i < N; i++) {
        cin >> S[i];
        for (int j = 0; j < 10; j++) {
            for (int k = j + 1; k < 10; k++) {
                if (S[i][j] < S[i][k]) {
                    char t = S[i][j];
                    S[i][j] = S[i][k];
                    S[i][k] = t;
                }
            }
        }
    }
    sort(S, S + N);
    long long ans = 0;
    long long count = 1;
    string _S = S[0];
    for (int i = 1; i < N; i++) {
        if (S[i] == _S) {
            count++;
            if (i == N - 1) {
                ans += count * (count - 1) / 2;
            }
        }
        else {
            ans += count * (count - 1) / 2;
            count = 1;
            _S = S[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8576
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

main(){
	int n,m;cin>>n>>m;
	UnionFind uf(n);
	
	rep(i,m){
		int x,y,z;cin>>x>>y>>z;
		x--,y--;
		uf.unite(x,y);
	}
	int ans=0;
	rep(i,n){
		if(uf.data[i]<0)ans++;
	}
	dans;
}





Measured memory_bytes: 1024
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "deque"
#include "cmath"
using namespace std;
typedef long long ll;

int main() {
	int n, d;
	cin >> n >> d;
	d = 2 * d + 1;
	if (n%d == 0) {
		cout << n / d;
	}
	else {
		cout << n / d + 1;
	}
	cout << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<int, int> ans;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int i = -1; i <= 1; i++) {
      if (!ans.count(a+i)) {
        ans[a+i] = 1;
      }
      else {
        ans[a+i]++;
      }
    }
  }
  int answer = 0;
  for (auto p : ans) {
    int value = p.second;
    if (answer < value) {
      answer = value;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vl A(N);
	priority_queue<ll> que;
	REP(i,N) {
		cin >> A[i];
		que.push(A[i]);
	}
	ll res = 0;
	int cnt = 1;
	REP(i,N - 1) {
		ll tmp = que.top();
		res += tmp;
		--cnt;
		if (cnt == 0) {
			que.pop();
			cnt = 2;
		}
	}
	cout << res << endl;
}

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


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

int main()
{
    int64_t x; cin >> x;

    int ans_500 = (x/500)*1000;
    int ans_5 = ((x%500)/5)*5;
    int ans = ans_500 + ans_5;

    cout << ans << endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod> struct modulo {
	int w;
	operator int&() { return w; }
	operator int() const { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { this->w = w; if (f) fix(); }
	void inline fix() { if (w >= mod || w < -mod) w %= mod; if (w < 0) w += mod; }
	
	inline modulo  operator -  () { w = -w + mod; return *this; }
	inline modulo  operator +  (const modulo &b) { modulo r = *this; return r += b; }
	inline modulo  operator -  (const modulo &b) { modulo r = *this; return r -= b; }
	inline modulo  operator *  (const modulo &b) { return (num) w * b.w % mod; }
	inline modulo  operator /  (const modulo &b) { return *this * inv(b); }
	inline modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline modulo& operator *= (const modulo &b) { return *this = *this * b; }
	inline modulo& operator /= (const modulo &b) { return *this /= inv(b); }
	
	friend inline modulo inv(const modulo &w) {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return modulo(u, 1);
	}
	
	friend inline modulo pow(const modulo &w, int p) {
		if (!w)  return 0;
		modulo a = w, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9) + 7;
typedef modulo<mod> rem;

const int nsz = int(5e3);
char s[nsz + 5];
int n, m;
rem dp[2][nsz + 5], ans;

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	m = strlen(s);
	
	int o = 0, x = 1;
	dp[o][0] = 1;
	loop (i, n) {
		circ (j, 0, i) {
			rem val = dp[o][j];
			dp[x][max(0, j - 1)] += val;
			dp[x][j + 1] += val + val;
		}
		swap(o, x);
		memset(dp[x], 0, sizeof(dp[x]));
	}
	ans = dp[o][m] / pow(rem(2), m);
	printf("%d\n", ans.w);
}

Measured memory_bytes: 3860
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	int d;ll g; cin >> d >> g;
	ll p[10], c[10];
	rep(i, d) {
		cin >> p[i] >> c[i];
	}
	ll mi = INF;
	rep(i, (1 << d)) {
		ll sum = 0; ll cnt = 0;
		rep(j, d) {
			if (i&(1 << j)) {
				sum += (ll)(j + 1)*100*p[j] + c[j];
				cnt += p[j];
			}
		}
		per(j, d) {
			if (i&(1 << j))continue;
			if (sum >= g)continue;
			ll key = (j + 1) * 100;
			ll nex = min(p[j],((g - sum) + key - 1) / key);
			cnt += nex; sum += nex * key;
		}
		if (sum >= g) {
			mi = min(mi, cnt);
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for(auto&&x:a) std::cin >> x;
	const int INF = 1e18;
	// dp[l][r] min cost it takes to get this slime
	// use recursion
	std::vector<int> ac(n+1,0);
	rep(i,n) ac[i+1] = ac[i] + a[i];
	std::vector<std::vector<int> > dp(n,std::vector<int>(n,0));
	std::function<int(int,int)> f = [&] (int l, int r) -> int {
		if(dp[l][r]!=0) return dp[l][r];
		if(l==r) return 0;
		int min = INF;
		for(int x = l;x<r;x++) {
			min = std::min(min, f(l,x)+f(x+1,r)+ac[r+1]-ac[l]);
		}
		return dp[l][r] = min;
	};
	print(f(0,n-1));
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll N; cin >> N;
    auto A = multivector(10,10,0LL);
    for(int i = 1; i <= N; ++i){
        string S = to_string(i);
        A[S.front()-'0'][S.back()-'0']++;
    }
    ll ans = 0;
    for(int i = 1; i <= 9; ++i){
        for(int j = 1; j <= 9; ++j){
            ans += A[i][j]*A[j][i];
        }
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
def enum_divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res


N, M = map(int, input().split())
divs = filter(lambda x: x <= M // N, enum_divisors(M))
print(max(divs))


Measured memory_bytes: 9436
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1LL << 40;
int main() {
	long long N, K;
	cin >> N >> K;
	vector<vector<long long>>S(N);
	for (int i = 0;i<N;++i) {
		long long T, D;
		cin >> T >> D;
		--T;
		S[T].push_back(D);
	}
	vector<long long>maxlist;
	for (int i = 0;i<N;++i) {
		sort(S[i].begin(), S[i].end(), greater<long long>());
		if (0 != S[i].size()) {
			maxlist.push_back(S[i][0]);
		}
		else {
			maxlist.push_back(-INF);
		}
	}
	sort(maxlist.begin(), maxlist.end(), greater<long long>());

	//K種類選ぶ
	long long ans0 = 0;
	priority_queue<long long> que;
	for (int i = 0; i < K; ++i) {
		ans0 += maxlist[i];
	}	
	for (int i = K; i < N; ++i) {
		que.push(maxlist[i]);
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j < S[i].size(); ++j) {
			que.push(S[i][j]);
		}
	}

	long long ans = ans0 + K*K;

	for (long long k = K - 1;k>=1;--k) {
		long long tmp = maxlist[k];
		long long tmp1 = que.top();
		if (tmp <tmp1) {
			que.pop();
			ans0 -= tmp;
			ans0 += tmp1;
			que.push(tmp);
		}
		ans = max(ans, ans0 + k * k);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10236
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, m, x = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()]for j in range(n)]    # nは行数

tmp = 0
res = inf

for i in range(2 ** n):
    s = f"{i:0{n}b}"
    tmp = [0 for i in range(m + 1)]
    for j in range(n):
        if s[j] == "1":
            for k in range(m + 1):
                tmp[k] += A[j][k]
    flg = True
    for k in range(1, m + 1):
        if tmp[k] < x:
            flg = False
    if flg:
        res = min(res, tmp[0])
if res == inf:
    res = -1

print(res)


Measured memory_bytes: 30896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
//再帰関数
string f(ll n){
  if(n == 0)return "";
  n--;
  return f(n/26) + string(1,'a'+n%26);
}

int main(){
  ll n;
  cin >> n;
  cout << f(n) << endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int used[SIZE];
int main(void)
{
	int n,i,res=0,s,a;
	scanf("%d",&n);
	FOR(i,0,n){
		scanf("%d",&a);
		used[a]++;
	}
	FOR(i,0,100000){
		s=used[i];
		if(i>0) s+=used[i-1];
		if(i<100000) s+=used[i+1];
		res=MAX(res,s);
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int x = a+b;
    if(x<10){
      System.out.println(x);
    }else{
      System.out.println("error");
    }
  }
}


Measured memory_bytes: 21716
import java.util.Scanner;


import java.util.Comparator;
import java.util.Arrays;
import java.util.ArrayList;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int [] d = new int[n];
		for(int i = 0; i<n ;i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		if(n%2 == 1) {
			System.out.println(0);
		}
		else {
			int half = n/2;
			System.out.println(d[half] - d[half-1] );
		}
	}
}


Measured memory_bytes: 53144
#include<bits/stdc++.h>
int INF = (1<<20);
using namespace std;

struct edge{
    int to,pnt,cost,rev;
    edge(int to,int pnt,int cost,int rev)
        :to(to),pnt(pnt),cost(cost),rev(rev){}
};

int MAX_V=222;
int S=MAX_V-2,T=MAX_V-1; 
int N,M,B;
int ax[111],ay[111];
int bx[5],by[5];
int c[5],f[5];
vector<edge> G[222];
int dist[222];
int prevv[222],preve[222];

int min_cost_flow(int f){
  int ret = 0;
  while(f > 0){
    fill_n(dist,MAX_V,INF);
    dist[S] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0; v < MAX_V;v++){
    if(dist[v] == INF) continue;
    for(int i=0;i<G[v].size();i++){
      edge &e = G[v][i];
      if(e.pnt > 0 && dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        prevv[e.to] = v;
        preve[e.to] = i;
        update = true;
      }
    }
      }
    }
    if(dist[T] == INF) return -1;
    int d = f;
    for(int v=T;v!=S;v=prevv[v]){
      d = min(d,G[prevv[v]][preve[v]].pnt);
    }
    f -= d;
    ret += d * dist[T];
    for(int v=T;v!=S;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.pnt -= d;
      G[v][e.rev].pnt += d;
    }
  }
  return ret;
}

void add_edge(int from,int to,int pnt,int cost){
  G[from].push_back(edge(to,pnt,cost,G[to].size()));
  G[to].push_back(edge(from,0,-cost,G[from].size()-1));
}

void make_edge(int bit,int mid){
  fill_n(G,MAX_V,vector<edge>());
  for(int i=0;i<N;i++){
    add_edge(S,i,1,0);
    for(int j=0;j<M;j++){
      if((bit>>j&1)==0)continue;
      int d = abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
      add_edge(i,N+j,1,max(0,d-mid));
    }
  }
  for(int i=0;i<M;i++){
    if((bit>i&1)==0)continue;
    add_edge(N+i,T,c[i],0);
  }
}

int search(int bit){
  int ret=0,cnt=0;
  for(int i=0;i<M;i++){
    if(bit&(1<<i)){
      ret += f[i];
      cnt++;
    }
  }
  int left=0,right=100000;
  while(right-left > 1){
    int mid = (left+right)/2;
    make_edge(bit,mid);
    int tmp1 = min_cost_flow(N)+mid*B*cnt;
    make_edge(bit,mid-1);
    int tmp2 = min_cost_flow(N)+(mid-1)*B*cnt;
    if(tmp1 == -1 || tmp2 == -1) return INF;
    if(tmp1 < tmp2) left = mid;
    else right = mid;
  }
  make_edge(bit,left);
  return ret+min_cost_flow(N)+left*B*cnt;
}

int main(){
  while(cin >> N >> M >> B, N) {
    for(int i=0;i<N;i++) cin >> ax[i] >> ay[i];
    for(int i=0;i<M;i++) cin >> bx[i] >> by[i] >> c[i] >> f[i];
    int ans = INF;
    for(int i=1;i<(1<<M);i++){
      ans = min(ans,search(i));
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int main(){
  int N;
  int K;
  cin >> N >> K;

  if(K == 0){
    cout << (long long) N * (long long) N << endl;
    return 0;
  }
  long long ans = 0;
  for(int i = K + 1; i <= N; i++){
    ans += (long long) (N / i) * (long long) (i - K);
    if(N % i >= K){
      ans += (long long) (N % i - K + 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
using ll = long long;
using namespace std;

int main() {
 ll n; cin >> n; ll sum=0;
  for(ll i=0; i<=n; i++){
    if(i%3 !=0 && i%5 !=0)
      sum += i;
    else continue;
  }
  cout << sum<< endl;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    string A; cin >> A;
    ll n[26]; CLR(n); for(char c : A) n[c-'a']++;
    ll rmv = A.size(); REP(i,26) rmv += n[i]*(n[i]-1)/2;
    ll ans = A.size()*(A.size()+1)/2 - rmv + 1;
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 640