akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll IF=1e18;
static const ll MX=101010;
static const ll MD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll N;

ll f(ll k) {
  return 26*((ll)pow(26, k)-1)/25;
}

int main(void) {
  ll i, j, k;
  
  cin >> N;
  
  k=1;
  while(f(k)<N) k++;
  N-=f(k-1);
  N--;
  
  string ans="";
  while(N) {
    ans=(char)(N%26+'a')+ans;
    N/=26;
  }
  
  
  pt(string(k-ans.size(), 'a')+ans);
}


Measured memory_bytes: 4088
#include <iostream>
#include<algorithm>
#include<utility>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;

int main() {
    int l, r;
    cin>>l>>r;
    int mx = min(2018,r-l);
    int ans = 9999;
    for(int i = l+mx; i > l; i--){
        for(int j = l; j < i; j++){
            ans = min(ans,((i%2019)*(j%2019))%2019);
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll n,m;
    cin>>n>>m;
    ll ans = n*(n-1)/2 + m*(m-1)/2;
    cout<<ans<<endl;
}

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

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

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


int main(){
  ll n,m,p[1010];
  while(cin >> n >> m){
    if(n==0 && m==0)break;

    rep(i,n)cin >> p[i];
    vector<ll> sum;

    sum.push_back(0);
    rep(i,n){
      sum.push_back(p[i]);
      Rep(j,i,n)sum.push_back(p[i]+p[j]);
    }
    sort(all(sum));
    sum.erase(unique(all(sum)),sum.end());

    ll res = 0;
    rep(i,sum.size()){
      if(m<sum[i])break;
      int pos = upper_bound(all(sum),m-sum[i]) - sum.begin();
      if(pos>0)res = max(res, sum[pos-1] + sum[i]);
    }
    cout << res << endl;
  }
}

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

int A[400005];

int prev1[400005];
int next1[400005];

bool present[200005];

vector<int> stack1;

int main(){
    int N; long long K;
    scanf("%lld%lld", &N, &K);

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
        A[N+i] = A[i];
    }
    A[2*N] = A[0];

    memset(prev1, -1, sizeof(prev1));

    for(int i = 0; i <= 2*N; i ++){
        if(prev1[A[i]] == -1){
            prev1[A[i]] = i;
        }else{
            next1[prev1[A[i]]] = i;
            prev1[A[i]] = i;
        }
    }

    long long cur_pos = 0;
    long long P = N+1;
    while(true){
        long long temp = cur_pos/N * N;
        long long next1_pos = temp + next1[cur_pos%N] + 1;
        if(next1_pos % N == 0){
            P = next1_pos/N;
            break;
        }else{
            cur_pos = next1_pos;
        }
    }

    K %= P;

    cur_pos = 0;
    while(true){
        long long temp = cur_pos/N * N;
        long long next1_pos = temp + next1[cur_pos%N] + 1;
        if(next1_pos >= N*K){
            break;
        }else{
            cur_pos = next1_pos;
        }
    }

    cur_pos %= N;
    memset(present, 0, sizeof(present));
    for(int i = cur_pos; i < N; i ++){
        if(!present[A[i]]){
            stack1.push_back(A[i]);
            present[A[i]] = true;
        }else{
            while(!stack1.empty()){
                int k = stack1.back(); stack1.pop_back();
                present[k] = false;
                if(!present[A[i]]){break;}
            }
        }
    }

    for(int i = 0; i < (int)stack1.size(); i ++){
        printf("%d", stack1[i]);
        if(i != stack1.size()-1){
            printf(" ");
        }
    }

    return 0;
}


Measured memory_bytes: 6516
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[30];
int main(void)
{
    int i,ch,len=0;
    long long ans;
    while((ch=getchar())>='a'&&ch<='z')++a[ch-'a'],++len;
    ans=1LL*len*(len-1)/2;
    for(i=0;i<26;++i)ans-=1LL*a[i]*(a[i]-1)/2;
    printf("%lld\n",ans+1);
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans_list=list(input().split())[1:]
for i in range(n-1):
  l=len(ans_list)
  ans_list2=ans_list
  ans_list=[]
  keep=input().split()[1:]
  for j in range(l):
    if ans_list2[j] in keep:
      ans_list.append(ans_list2[j])
print(len(ans_list))

Measured memory_bytes: 3060
import java.io.*;
// import java.math.*;
import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

@SuppressWarnings ("unchecked")
public class Main {
    public static <T> List<List<T>> zip (List<T>... lists) {
        List<List<T>> zipped = new ArrayList<List<T>>();
        for (List<T> list : lists) {
            for (int i = 0, listSize = list.size(); i < listSize; i++) {
                List<T> list2;
                if (i >= zipped.size())
                    zipped.add (list2 = new ArrayList<T>());
                else
                    list2 = zipped.get (i);
                list2.add (list.get (i));
            }
        }
        return zipped;
    }
    static List<Character> toCharacterList (String s) {
        if (s == null) {
            return null;
        }
        int len = s.length();
        List<Character> lst = new ArrayList<Character>();
        for (int i = 0; i < len; i++) {
            lst.add (Character.valueOf (s.charAt (i)));
        }
        return lst;
    }
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        List<Character> S = toCharacterList (reader.readLine());
        List<Character> T = toCharacterList (reader.readLine());
        List<List<Character>> z = zip (S, T);
        int ans = 0;
        for (List<Character> v : z) {
            if (v.get (0) != v.get (1))
                ans++;
        }
        System.out.println (ans);
        return;
    }
}

Measured memory_bytes: 60804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  
  int x = 0;
    
  for (int i = A; i <= B; i++){
    if (i % K == 0){
      x++;
      cout << "OK" << endl;
      break;
    }
  }
  
  if (x == 0){
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans = INFLL;
	cin >>n;
	V a(n);
	cin>>a;
	V sum(n + 1, 0LL);
	rep(i, n) { sum[i + 1] += a[i];
		sum[i + 1] += sum[i];
	}
	//clog << sum << endl;
	for (int i = 1; i < n;i++){
		chmin(ans, abs(sum[i] - (sum.back() - sum[i])));
	} cout << ans << endl;
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
using namespace std;
int A,B,M;
int ai[100005],bi[100005];
int x,y,z,a,b;

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

int main(){
	A=read(),B=read(),M=read();
	a=b=1e9;
	for(int i=1;i<=A;i++) a=min(a,ai[i]=read());
	for(int i=1;i<=B;i++) b=min(b,bi[i]=read());
	int ans=a+b;
	for(int i=1;i<=M;i++){
		x=read(),y=read(),z=read();
		ans=min(ans,ai[x]+bi[y]-z);
	}
	cout<<ans<<endl;

	return 0;
}

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

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

    int n, m;
    while (cin >> n >> m) {
        if (n == 0) break;
        vector<vector<int>> as(m + 1);
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b;
            as[a].push_back(b);
        }
        for (int i = 1; i <= m; i++) {
            sort(as[i].rbegin(), as[i].rend());
        }
        long long ans = 0;
        for (int i = 1; i <= m; i++) {
            ans += as[i][0];
        }
        cout << ans << '\n';
    }
}



Measured memory_bytes: 3152
N, H = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
  A[i],B[i] = map(int, input().split())

a = max(A)
B.sort()
cnt = 0
for b in B[::-1]:
  if b>a:
    H -= b
    cnt += 1
    if H<=0:
      break
if H>0:
  cnt += (H+a-1)//a
    

print(cnt)

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long M) {
  if(N==M){ cout << "Yes" << endl; }
  else cout <<"No"<<endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  long long N;
  std::cin >> N;
  long long M;
  std::cin >> M;
  solve(N, M);
  return 0;
}


Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int cnt = parseNum();

		for (int i = 0; i < cnt; i++) {
			int	num = parseNum();
			System.out.println("Case "+(i+1)+":");
			for (int k = 0; k < 10; k++) {
				num = (num > 10) ? ((num*num)/100)%10000 : 0;
				System.out.println(num);
			}
		}
	}
 
	private static int parseNum() {
		int     num = 0;
		String  str = null;

		if ((str = parseStdin()) != null) {
			num = Integer.parseInt(str);
		}

		return num;
	}
 
	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) stdin = tmp;
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 15044
#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char **argv)
{
  int n, a, b, c, x, s[10001], t, p;

  while(1){
    cin >> n >> a >> b >> c >> x;
    if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0){
      break;
    }

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

    for(int i = 0; i < n && t < 10001; i++){
      while(t < 10001 && s[i] != x){
	x = (a*x+b)%c;
	t++;
      }
      if(i < n-1){
	x = (a*x+b)%c;
	t++;
      }
    }
    
    if(t < 10001){
      cout << t << endl;
    } else {
      cout << "-1" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


vector<int> M(13);
vector<int> T(24);

int solve(){
    if(M[0]>=1) return 0;
    if(M[12]>=2) return 0;
    
    vector<int> b;
    for(int i=0; i<13; i++){
        if(M[i]==1) b.push_back(i);
        if(M[i]==2){
            T[i]++;
            T[24-i]++;
        }
        if(M[i]>=3) return 0;
    }
    
    
    int len = (int)b.size();
    int mx = 0;
    T[0] = 1;
    for(int i=0; i<1<<len; i++){
        for(int j=0; j<len; j++){
            if((i>>j)&1){
                T[24-b[j]] = 0;
                T[b[j]] = 1;
            }else{
                T[b[j]] = 0;
                T[24-b[j]] = 1;
            }
        }
        
        vector<int> C = T;
        for(int &t:T) C.push_back(t);
        int mn = INF;
        int cnt = 0;
        for(int i=1; i<48; i++){
            cnt++;
            if(C[i]){
                mn = min(mn, cnt);
                cnt = 0;
            }
        }
        
        mx = max(mx, mn);
    }

    return mx;
}


int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++){
        int d; cin >> d;
        M[d]++;
    }
    cout << solve() << endl;
    
    return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(lo i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 200005; 
const lo mod = 1000000007; 

lo n,m,b,a[li],k,flag,cev,say=1,yes,dp[55][2505][55];
string s;
vector<lo> v;

lo f(lo sira,lo sum,lo kac){
	if(~dp[sira][sum][kac]) return dp[sira][sum][kac];
	lo cevv=0;
	if(sira>n){
		if((double)sum/kac==m) return 1;
		return 0;
	}
	cevv+=f(sira+1,sum+a[sira],kac+1);
	cevv+=f(sira+1,sum,kac);
	return dp[sira][sum][kac]=cevv;
}

int main(void){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld",&a[i]);
	}
	printf("%lld\n",f(1,0,0));
	return 0;
}


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

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (b); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a, p;
    cin >> a >> p;
    cout << (int)(3 * a + p) / 2 << ln;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,bool>have;
int ans=0;
int main(){
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        if(have[s]==0){
            have[s]=1;
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

typedef long long ll;

int main() {
    int N, A, B;  cin >> N >> A >> B;
    int m, M;
    
    M = min(A,B);
    m = A+B-N;
    
    cout << M <<" "<< max(m,0) << endl;
    
}


Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return map(int, sys.stdin.readline().split())
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())


def FLIST(n):
    res = [1]
    for i in range(1, n+1):
        res.append(res[i-1]*i % DVSR)
    return res


N = II()
ST = input()
ST = ST[::-1]

# NUM1 =
# NUM2 =
popcnt = 0

for i in range(N):
    popcnt += ST[i] == '1'

NUM1 = 0
NUM2 = 0
pop_1 = popcnt-1
pop_2 = popcnt+1
for i in range(N):
    if ST[i] == '1':
        if pop_1 > 0:
            NUM1 += pow(2, i, pop_1)
            NUM1 %= pop_1
        if pop_2 <= N:
            NUM2 += pow(2, i, pop_2)
            NUM2 %= pop_2

# print(pop_1, pop_2)
# print(NUM1, NUM2)

for i in range(N):
    cnt = 1
    i = N-i-1
    if ST[i] == '1':
        # print("A")
        if pop_1 != 0:
            value = NUM1 - pow(2, i, pop_1)
            value %= pop_1
            while value:
                value %= bin(value).count("1")
                cnt += 1
            print(cnt)
        else:
            print(0)
    else:
        # print("B")
        value = NUM2 + pow(2, i, pop_2)
        value %= pop_2
        while value:
            value %= bin(value).count("1")
            cnt += 1
        print(cnt)


Measured memory_bytes: 9644
// inputに入力データ全体が入る
function Main(input) {
	input = input.split('\n');
	var num = input[0];
	var character = input[1];
	var max = 0;
	var x = 0;
	for(var i = 0; i < character.length; i++){
	    if(character[i] === 'I'){
	        x++;
	    } else {
	        x--;
	    }
	    if(max < x){
	        max = x;
	    }
	}
	console.log(max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

void solve(void)
{
	int n, k;
	cin >> n >> k;
	vector<long> vs(n);
	for (long&x : vs)
		cin >> x;

	long ans = 0;

	for (int border = 0; border <= n; border++)
	{
		vector<long> ls(k + 1, -1e15), rs(k + 1, -1e15);
		ls[0] = rs[0] = 0;
		for (int l = 1; l <= k; l++)
		{
			for (int d = 0; d <= min(l, border); d++)
			{
				long res = 0;
				priority_queue<long> pq;
				for (int i = 0; i <= d - 1; i++)
				{
					pq.push(-vs[i]);
					res += vs[i];
				}
				ls[l] = max(ls[l], res);
				for (int i = 0; i < (l - d) && !pq.empty(); i++)
				{
					res += pq.top();
					ls[l] = max(ls[l], res);
					pq.pop();
				}
			}
		}
		for (int r = 1; r <= k; r++)
		{
			for (int d = 0; d <= min(r, n-border); d++)
			{
				long res = 0;
				priority_queue<long> pq;
				for (int i = n - 1; i > n - d - 1; i--)
				{
					pq.push(-vs[i]);
					res += vs[i];
				}
				rs[r] = max(rs[r], res);
				for (int i = 0; i < (r - d) && !pq.empty(); i++)
				{
					res += pq.top();
					rs[r] = max(rs[r], res);
					pq.pop();
				}
			}
		}

		for (int i = 0; i < k; i++)
		{
			ls[i + 1] = max(ls[i + 1], ls[i]);
			rs[i + 1] = max(rs[i + 1], rs[i]);
		}
		for (int i = 0; i <= k; i++)
		{
			//cout << ls[i] << ' ' << rs[k - i] << endl;
			ans = max(ans, ls[i] + rs[k - i]);
		}
	}

	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int vis[200010];
pair<int,int>p[200010],a[200010];
vector<pair<int,int> >e[200010];
vector<int>ans;
int dfs(int u)
{
	vis[u]=1;
	for(int i=0;i<e[u].size();i++)
	{
		int to=e[u][i].first;
		if(vis[to]==0)
		{
			int tmp=dfs(to);
			if(tmp)
				ans.push_back(e[u][i].second);
			a[u].second^=tmp;
		}
	}
	return a[u].second;
}
signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].first,&a[i].second);
	sort(a+1,a+n+1);
	a[0].second=a[1].second;
	for(int i=1;i<=n;i++)
		a[i].second^=a[i+1].second;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&p[i].first,&p[i].second);
		p[i].first=lower_bound(a+1,a+n+1,make_pair(p[i].first,0))-a-1;
		p[i].second=upper_bound(a+1,a+n+1,make_pair(p[i].second,1))-a-1;
		e[p[i].first].push_back(make_pair(p[i].second,i));
		e[p[i].second].push_back(make_pair(p[i].first,i));
	}
	for(int i=0;i<=n;i++)
		if(!vis[i])
		{
			if(dfs(i))
			{
				printf("-1");
				return 0;
			}
		}
	printf("%d\n",ans.size());
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++)
		printf("%d ",ans[i]);
	return 0;
}
/*
4 6
-1 0 1 2
*/

Measured memory_bytes: 19836
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

template<class t>
vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
  sort(line.begin(),line.end(),comp);
  return line;
}

template<class t>
vector<t> reversed(vector<t> line){
  reverse(line.begin(),line.end());
  return line;
}

int main(){
  ll n = in();
  if(n==2){
    cout << 1 << endl;
    return 0;
  }
  ll ans = 2;
  set<ll> s;
  {
    for(ll i=2;i*i<=n;++i){
      if(n%i==0){
        s.insert(i);
        s.insert(n/i);
      }
    }
    foreach(i,s){
      ll d = n;
      while(d>=i){
        if(d%i==0)d/=i;
        else d%=i;
      }
      if(d==1)++ans;
    }
  }

  for(ll i=2;i*i<=n;++i){
    if((n-1)%i==0){
      if(!s.count(i)){
        ++ans;
        s.insert(i);
      }
      if(!s.count((n-1)/i)){
        ++ans;
        s.insert((n-1)/i);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char s[15];
  scanf("%s", s);
  s[3] = '8';
  printf("%s\n", s);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
vector<int> graph[2020];
int sub[2020];

int dfs(int p, int rt)
{
	sub[p] = 1;
	for (int q : graph[p]) if (q != rt) sub[p] += dfs(q, p);
	return sub[p];
}

int ultimate = 23486932;

vector<int> solve(int p, int rt)
{
	vector<vector<int> > tmp;
	vector<int> ch;
	for (int q : graph[p]) if (q != rt) {
		ch.push_back(q);
		tmp.push_back(solve(q, p));
	}

	vector<int> ret;
	ret.push_back(sub[p]);
	for (int i = 0; i <= K; ++i) {
		int j = K - i;
		if (i <= j) {
			int sco = 0;
			for (auto &a : tmp) sco += a[i];
			sco = min(sco, ret[ret.size() - 1]);
			ret.push_back(sco);
		} else {
			int ans = 202020, pres = 0;
			for (auto &a : tmp) pres += a[j];
			for (auto &a : tmp) {
				ans = min(ans, pres - a[j] + a[i]);
			}
			if (ch.size() == 0) ans = 0;
			ans = min(ans, ret[ret.size() - 1]);
			ret.push_back(ans);
		}
	}
	ultimate = min(ultimate, (sub[0] - sub[p]) + ret[ret.size() - 1]);
	return ret;
}

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	dfs(0, -1);
	solve(0, -1);
	printf("%d\n", ultimate);
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 bubblesort(vector<int> &a){
    bool flag = 1;
    int n = a.size();
    int cnt = 0;
    while(flag){
        flag = 0;
        for(int i = n-1;i>=0;i--){
            if(a[i] < a[i-1]){
                swap(a[i],a[i-1]);
                cnt++;
                flag = 1;
            }
        }   
    }
    return cnt;
}

//ミョ(-ω- ?)
int main() {
    int n;
    cin >> n;
    vector<int> a(n,0);
    rep(i,n)cin >> a.at(i);
    int res = bubblesort(a);
    rep(i,n) cout << (i ? " " : "") << a[i];
    cout << "\n" << res << endl;
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(100100);
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  int ans = 0;
  rep(i, n) {
    bool ok = true;
    for (int v : to[i]) {
      if (h[i] <= h[v]) {
        ok = false;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8804
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long int ll;

bool mysort(const vector<ll> &a, const vector<ll> &b) {
  return (a[0] > b[0]);
}

int main() {
  ll N;
  cin >> N;
  vector< vector<ll> > ABs;
  rep(i, N) {
    ll A, B;
    cin >> A >> B;
    ll sum = A + B;
    vector<ll> AB;
    AB.pb(sum);
    AB.pb(A);
    AB.pb(B);
    ABs.pb(AB);
  }

  sort(all(ABs), mysort);
  ll ans = 0;
  rep (i, N) {
    if (i % 2 == 0) {
      ans += ABs[i][1];
    }
    else {
      ans -= ABs[i][2];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6324
#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>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
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-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
const int MAX_N = 500000;
int n,m;
map<P,vector<P>> G;
deque<P> S={};
map<P,bool> visited;
map<P,ll> d;

void bfs(int s){
    S.push_back(P(s,0));
    d[P(s,0)]=0;
    while (!S.empty()){
        P p=S[0];
        S.pop_front();
        if (visited[p]) continue;
        visited[p]=true;
        rep(i,G[p].size()){
            P q=G[p][i];
            if (visited[q]) continue;
            d[q]=d[p]+1;
            S.push_back(q);
        }
    }
}

void solve(){
    cin >> n >> m;
    rep(i,n){
        rep(r,3){
            visited[P(i,r)]=false;
            d[P(i,r)]=INF;
            G[P(i,r)]={};
        }
    }

    int u,v;
    rep(i,m){
        cin >> u >> v;u--,v--;
        rep(r,3){
            G[P(u,r)].push_back(P(v,(r+1)%3));
        }
    }

    int s,t;
    cin >> s >> t;
    
    bfs(s-1);
   

    // rep(i,n){
    //     rep(r,3){
    //         cout << i << " " << r << endl;
    //         cout << d[P(i,r)] << endl;
    //     }
    // }
    if (d[P(t-1,0)]==INF) cout << -1 << endl;
    else cout << d[P(t-1,0)]/3 << endl;
}

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

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

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

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

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

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


	ll n;
	cin>>n;
	if(n%1000==0)cout<<0;
	else cout<<1000-n%1000;

    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;


int main()
{
    Go_
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

    cin>>n>>m;
    ll ara[n+4];
    
    ll sum[n+4];
    sum[0]=ara[0]=0;
    for(i=1;i<=n;i++){
        cin>>ara[i];
        sum[i]=sum[i-1]+ara[i];
    }

    ll ans=0;
    map<ll,ll> mp;
    for(i=0;i<min(m,n);i++) {
        p=(((sum[i]-i)%m)+m)%m;
        ans+=mp[p];
        mp[p]+=1;
    }

    for(i=min(n,m),j=0;i<=n;i++){
        if(i-m>=j) {
            --mp[(((sum[j]-j)%m)+m)%m];
            ++j;
        }
        p=(((sum[i]-i)%m)+m)%m;
        ans+=mp[p];
        mp[p]+=1;
    }

    cout<<ans<<endl;

    

}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main()
{
uint64_t a,b,c,d,k=0;
cin>>a>>b;
for(int i=0;i<a;i++){
    cin>>c>>d;
    if((d*d*0.1+c*c*0.1)<=b*b*0.1)
    { k++;
    //cout<<i<<endl;
    }
}
cout<<k;
}


Measured memory_bytes: 3640
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,m,x;
    cin>>n>>m>>x;
    ll C[n], A[n][m];
    rep(i,0,n){
        cin>>C[i];
        rep(j,0,m)  cin>>A[i][j];
    }
    ll mask = (1<<n);
    ll ans=-1;
    rep(i,0,mask){
        ll B[m] = {0};
        ll cnt=0;
        rep(j,0,n){
            if(i&(1<<j)){
                rep(k,0,m)  B[k] += A[j][k];
                cnt += C[j];
            }
        }
        bool f=0;
        rep(j,0,m)  if(B[j]<x)  f=1;
        if(!f){
            if(ans == -1 or ans > cnt){
                ans = cnt;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
// https://atcoder.jp/contests/abc076/tasks/abc076_c

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

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

	bool hint_fit = false;
	for (int i = partial_key.size() - hint.size(); i >= 0; i--) {
		bool found = true;
		for (int j = 0; j < hint.size(); j++) {
			int key_j = i + j;
			if (partial_key[key_j] == '?') continue;
			if (partial_key[key_j] != hint[j]) {
				found = false;
				break;
			}
		}
		if (found) {
			for (int j = 0; j < hint.size(); j++) {
				partial_key[i + j] = hint[j];
			}
			hint_fit = true;
			break;
		}
	}

	if (!hint_fit) {
		cout << "UNRESTORABLE" << endl;
	} else {
		replace(partial_key.begin(), partial_key.end(), '?', 'a');
		cout << partial_key << endl;
	}
}


Measured memory_bytes: 256
root = None

class Node:
    def __init__(self, key, left, right):
        self.parent = -1
        self.key = key
        self.left = left
        self.right = right

def preorder(T):
    if T is None:
        return
    print(' ' + str(T.key), end='')
    preorder(T.left)
    preorder(T.right)

def inorder(T):
    if T is None:
        return
    inorder(T.left)
    print(' ' + str(T.key), end='')
    inorder(T.right)

def find(T, z):
    if T is None:
        return False
    if T.key == z:
        return True

    if z < T.key and T.left is not None:
        return find(T.left, z)
    elif z > T.key and T.right is not None:
        return find(T.right, z)
    else:
        return False

def insert(T, z):
    global root
    if T is None:
        root = Node(z, None, None)
        return

    # print("\n# Insert: " + str(z))
    # print("# T: " + str(T.key))

    parent = T
    while True:
        if parent.left is None and parent.right is None:
            break
        elif parent.left is None and z < parent.key:
            break
        elif parent.right is None and z > parent.key:
            break

        # print("# left: " + str(parent.left.key))
        # print("# right: " + str(parent.right.key))

        if z < parent.key:
            parent = parent.left
#            print("# Slide parent to left: " + str(parent.key))
        else:
            parent = parent.right
#            print("# Slide parent to right: " + str(parent.key))

    if z < parent.key:
        node = Node(z, None, None)
        parent.left = node
    elif z > parent.key:
        node = Node(z, None, None)
        parent.right = node

n = int(input())

for i in range(n):
    s = input().split()
    if s[0] == 'insert':
        insert(root, int(s[1]))
    elif s[0] == 'find':
        if find(root, int(s[1])):
            print('yes')
        else:
            print('no')
    else:
        inorder(root)
        print('')
        preorder(root)
        print('')



Measured memory_bytes: 85224
#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 pii = pair<int, int>;

void Main(){
	int S;
	cin >> S;
	int h, m;
	h = S/3600;
	S %= 3600;
	m = S/60;
	S %= 60;
	cout << h << ":" << m << ":" << S << endl;
	return;
}

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



Measured memory_bytes: 3148
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var r = Enumerable.Range(1, 1009).FirstOrDefault(x => (int)(0.08 * x) == h[0] && (int)(0.1 * x) == h[1]);
		Console.WriteLine(r > 0 ? r : -1);
	}
}


Measured memory_bytes: 28336
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;



int main(){
    ll n,k;
    cin >> n >> k;
    if (n*500>=k)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}





Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define MN 200005
using namespace std;
inline int in(){
    int x=0;bool f=0;char c;
    for (;(c=getchar())<'0'||c>'9';f=c=='-');
    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');
    return f?-x:x;
}
ll sum[MN],ans,mn,mx;
int a[MN],n,hd,tl,pl,pr;
int main()
{
	n=in();ans=inf;
	for (int i=1;i<=n;++i)
	a[i]=in(),sum[i]=sum[i-1]+1ll*a[i];
	hd=0;tl=2;
	for (int i=2;i<n-1;++i){
		while (hd<i&&sum[i]-(sum[hd+1]<<1ll)>=0) ++hd;tl=max(tl,i+1);
		while (tl<n&&sum[n]+sum[i]-(sum[tl+1]<<1ll)>=0) ++tl;
		pl=(abs(sum[i]-(sum[hd]<<1ll))<=abs(sum[i]-(sum[hd+1]<<1ll)))?hd:hd+1;
		pr=(abs(sum[n]+sum[i]-(sum[tl]<<1ll))<=abs(sum[n]+sum[i]-(sum[tl+1]<<1ll)))?tl:tl+1;
		mn=min(min(sum[pl],sum[i]-sum[pl]),min(sum[pr]-sum[i],sum[n]-sum[pr]));
		mx=max(max(sum[pl],sum[i]-sum[pl]),max(sum[pr]-sum[i],sum[n]-sum[pr]));
		ans=min(ans,abs(mx-mn));
	}printf("%lld",ans);return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N;cin>>N;
    
	// 解法
    ll ans = 0;
    REP(i,N){
        if (i+1<10) ans++;
        else if (100<=i+1 and i+1<1000) ans++;
        else if (10000<=i+1 and i+1<100000) ans++;
    }
    
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

ll gcd(ll a, ll b){
  return b ? gcd(b, a%b) : a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin>>k;
    ll ans = 0;
    for(int a=1;a<=k;a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += gcd(gcd(a,b),c);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define go(i,a,b) for(int i=(a);i<=(b);++(i))
#define com(i,a,b) for(int i=(a);i>=(b);--(i))
#define mem(a,b) memset((a),(b),sizeof(a))
#define inf 0x3f3f3f3f
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
typedef long long ll;
int n,A,B,x,p[5005];
ll f[5005][5005],pre[5005][5005];

void gmin(ll &a,ll b){if(a>b) a=b;}

int main()
{
	//fin;
	scanf("%d%d%d",&n,&A,&B);
	go(i,1,n) scanf("%d",&x),p[x]=i;
	mem(f,0x3f),mem(pre,0x3f);
	go(i,1,n) pre[0][i]=0;
	go(i,1,n)
	go(j,1,n){
		if(p[i]>j) gmin(f[i][j],pre[i-1][j]+B);
		else if(p[i]==j) gmin(f[i][j],pre[i-1][j]);//允许i-1在自己左边的空格或者和自己一个空格
		//保证了对于任意数比它小一的的数都在它左边，即升序排列 
		else gmin(f[i][j],pre[i-1][j]+A);
		pre[i][j]=pre[i][j-1];
		gmin(pre[i][j],f[i][j]); 
	}
	ll ans=1e18;
	go(i,1,n) ans=min(ans,f[n][i]);
	printf("%lld",ans);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a.at(i);
  
  map<long long, long long> dis;
  for(int i = 0; i < n; ++i){
    dis[i+1-a.at(i)]++;
  }
  
  long long ans = 0;
  for(int i = 0; i < n; ++i){
    int k = i + 1 + a.at(i);
    ans += dis[k];
  }
  
  cout << ans << endl;  
}


Measured memory_bytes: 26624
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;

int main()
{
	int n;
	double ans = 0.0;
	cin >> n;
	vector<double> a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < n; i++) {
		ans += 1 / a.at(i);
	}
	cout << 1.0 / ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main() {
        int i;
    //??????????????????????????則vector????????????????????測??????vector???????????????????????????????????即????即??????????????????????
    double n, m, s[1000], v;
    
    while(1){
        cin >> n;
        //exit condition
        if(n==0) break;
        
        m=0;
        for(i=0; i<n; i++){
            cin >> s[i];
            m+=s[i];
        }
        m/=n;
        v=0;
        for(i=0; i<n; i++){
            v+=pow(s[i]-m, 2.0);
        }
        
        cout.precision(4); // ????????? 4????????????????????????
        cout.setf(ios::fixed); // ?属???属??即?????????????????即?????????
    
        cout << sqrt(v/n) << endl;
    }
        return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3704