akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[705][2005];

int main() {
    ll S;
    cin >> S;

    dp[0][0] = 1;
    vl T(S + 1, 1);

    ll ans = 0;
    rep(i, S / 3){
        repe(j, 3, S + 1){
            (dp[i + 1][j] += T[j - 3]) %= MOD;
        }
        (ans += dp[i + 1][S]) %= MOD;
        // verr(dp[i + 1], S + 1);

        // verr(T, S + 1);
        T[0] = 0;
        repe(j, 1, S) T[j] = (T[j - 1] + dp[i + 1][j]) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 13900
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
int main (){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for (ll i = k; i <= n + 1; i++){
        ll Min = (i - 1) * i / 2, Max = (2 * n - i + 1) * i / 2;
        (ans += Max - Min + 1) %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
x1,y1,x2,y2 = map(int, raw_input().split())
lenx = x2-x1
leny = y2-y1
x3 = x2 - leny
y3 = y2 + lenx
x4 = x3 - lenx
y4 = y3 - leny
print x3,
print y3,
print x4,
print y4

Measured memory_bytes: 2568
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll =  long long;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll s=0;
    for(ll i=0;i<m;i++){
        ll t;
        cin>>t;
        s+=t;

    }
    if(s>n){
        cout<<-1;
    }
    else{
        cout<<n-s;
    }


    return 0;
}


Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
q=int(input())
l=[list(map(int,input().split())) for i in range(q)]
ct=[0]*(10**5+1)
for i in range(n):
  ct[a[i]]+=1
s=sum(a)
for i in range(q):
  s+=ct[l[i][0]]*(l[i][1]-l[i][0])
  print(s)
  ct[l[i][1]]+=ct[l[i][0]]
  ct[l[i][0]]=0

Measured memory_bytes: 92728
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

int main(){
  int n,m;
  cin >> n >> m;
  if(n<m)cout << 0 << endl;
  else cout << 10 << endl;
return 0;}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
char c;
int main(){
	putchar('A');
	scanf("%*c%c",&c);
	if(c=='B')putchar('R');
	else putchar('B');
	putchar('C');
    return 0;
}

Measured memory_bytes: 1540
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func main() {
	io := NewIo()
	defer io.Flush()
	a := io.NextInt()
	b := io.NextInt()
	k := io.NextInt()
	i := 1
	j := a+1
	for i <= k {
		j--
		if (a%j==0)&&(b%j==0){
			i++
		}
	}
	io.PrintLn(j)
}

Measured memory_bytes: 640
import java.util.Scanner;

/**
 * A - Don't be late
 * 高橋君は青木君と待ち合わせをしています。
 * 待ち合わせ場所は高橋君の家から D メートル離れた地点であり、待ち合わせの時刻は T 分後です。
 * 高橋君は今から家を出発し、分速 S メートルで待ち合わせ場所までまっすぐ移動します。
 * 待ち合わせに間に合うでしょうか？
 */
public class Main {

    public static void main( String[] args ) {

        // 入力値
        Scanner sc = new Scanner( System.in );
        int d = sc.nextInt();   // 高橋くんの家から待ち合わせまでの距離（m）
        int t = sc.nextInt();   // 今から待ち合わせまでの時間（分）
        int s = sc.nextInt();   // 高橋くんが待ち合わせに向かう速度

        System.out.println( t >= ( double ) d / s ? "Yes" : "No" );

        sc.close();
    }
}


Measured memory_bytes: 35720
n = gets.to_i
array = gets.chomp.split.map(&:to_i)

even = array.select(&:even?)

ans = 'APPROVED'

for i in 0..(even.length - 1)
  if !(even[i] % 3 == 0 || even[i] % 5 == 0)
    ans = 'DENIED'
  end
end

puts ans


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, t[50];
    cin >> n;
    string s[50], x;
    for (int i = 0; i < n; ++i) {
        cin >> s[i] >> t[i];
    }
    cin >> x;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == x) {
            for (int j = i + 1; j < n; ++j) ans += t[j];
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
// #include<map>
#include<cmath>
#include<list>
#define ll long long
#define N 150005
#define pb push_back
#define Sca(a) scanf("%d",&a)
#define Scs(a) scanf("%s",&a)
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define Scal(a) scanf("%ld",&a)
#define Scall(a) scanf("%lld",&a)
#define Pri(a) printf("%d",a)
#define Prs(a) printf("%s",a)
#define Pril(a) printf("%ld",a)
#define Prill(a) printf("%lld",a)
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double pi = 3.141592653;
using namespace std;
template <class T>void tomax(T&a, T b) {
	a = max(a, b);
}
template <class T>void tomin(T&a, T b) {
	a = min(a, b);
}
int main(){
	int ans=0,n,a[1005],b[1005];
	cin>>n;
	for(int i=0;i<n-1;i++)
		cin>>b[i];
	for(int i=1;i<n-1;i++){
		a[i]=min(b[i],b[i-1]);
	}
	a[0]=max(b[0],a[1]);
	a[n-1]=max(b[n-2],a[n-2]);
	for(int i=0;i<n;i++) ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
        int n,q,i,b,c,tmp;
        long long sum=0,t;
        cin >> n;
        vector<int> a(n);
        vector<int> cnt(1000000);
        vector<long long> ans;
        for(i=0;i<n;++i){
                cin >> tmp;
                ++cnt.at(tmp);
                a.at(i) = tmp;
                sum += tmp;
        }
        cin >> q;
        for(i=0;i<q;++i){
                cin >> b >> c;
                t = (c-b)*cnt.at(b);
                cnt.at(c) += cnt.at(b);
                cnt.at(b) = 0;
                sum += t;
                ans.push_back(sum);
        }
        i = 0;
        while(true){
                cout << ans.at(i) << endl;
                ++i;
                if(i==q) break;
        }
        return 0;
}

Measured memory_bytes: 8620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    ll ans =0;
    int n;cin>>n;
    int b[n];
    rep(i, n-1){
        cin>>b[i];
    }
    b[n-1]=100000;
    rep(i,n){
        if(i==0){ans+=b[i];continue;}
        ans+=min(b[i-1], b[i]);
    }
    co(ans);

}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<double> A(N);
    double sum = 0;
    rep(i,N) {
        double a;
        cin >> a;
        sum += 1/a;
    }
    cout << fixed << setprecision(14);
    cout << 1/sum << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

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

        int n = sc.nextInt();
        int w = sc.nextInt();
        int[] Weight = new int[n];
        int[] Value = new int[n];
        for (int i = 0; i < n; i++) {
            Weight[i] = sc.nextInt();
            Value[i] = sc.nextInt();
        }
        long[][] dp = new long[n][w+1]; //i madede w ika no value no max
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                for (int j = 0; j <= w; j++) {
                    if (j >= Weight[0]) {
                        dp[i][j] = Value[0];
                    } else {
                        dp[i][j] = 0;
                    }
                }
            } else {
                for (int j = 0; j <= w; j++) {
                    if (j >= Weight[i]) {
                        dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-Weight[i]] + Value[i]);
                    } else {
                        dp[i][j] = dp[i-1][j];
                    }
                }
            }
        }

        System.out.println(dp[n-1][w]);

        sc.close();
    }
}


Measured memory_bytes: 128976
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/6/2018
 
 16:05-16:27 analysis
 16:27-16:28 implement and got AC
 
 Editorials:
  - https://atcoder.jp/img/arc067/editorial.pdf
  - https://youtu.be/28IanD3lXGg?t=1886
   - proof by connected component is very cool
   - visit all the "nodes" -> graph theorem -> visting all the components is necessary and sufficient
  - https://kimiyuki.net/writeup/algo/atcoder/arc-067-d/
  - http://seica-at.hatenablog.com/entry/2017/12/29/171258
  - http://nafmo.hatenablog.jp/entry/2017/03/09/231235#D%E5%95%8F%E9%A1%8CWalk-and-Teleport
 
 Summary:
  - Actually "order doesn't matter" is typical pattern.
 
 */

// 16:05-16:27 analysis
// 16:28 AC

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e5+1;
int N;
LL X[MAX_N];
LL A,B;
void solve() {
  LL res=0;
  REP(i,N-1) res+=min(A*(X[i+1]-X[i]), B);
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>A>>B;
  REP(i,N) cin>>X[i];
  solve();
  return 0;
}

Measured memory_bytes: 1024
n, x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
for i in range(n):
  if a[i] <= x:
    ans += 1
    x -= a[i]
  else:
    break
if ans == n and x > 0:
  ans -= 1
print(ans)

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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;
    ll a[n+2];
    for(int i=1; i<=n; i++)
        cin >> a[i];

    ll ans=0;
    for(int i=1; i<n; i++)
    {
        if (a[i+1] < a[i]) ans += (a[i+1]-a[i]) , a[i+1] = a[i];
    }

    cout << ans*-1 << '\n';

    return 0;
}



Measured memory_bytes: 5172
// 問題の URL を書いておく
// https://atcoder.jp/contests/arc067/tasks/arc067_b

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = int64_t;

int main(int, const char**)
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    ll walkLimit = b / a;
    rep(i, n)
    {
        cin >> x[i];
    }
    ll ans = 0;
    rep(i, n - 1)
    {
        auto d = x[i + 1] - x[i];
        ans += d > walkLimit ? b : a * d;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
n,m,c = map(int,input().split())
b_L = list(map(int,input().split()))

ans = 0
for i in range(n):
    counter = 0
    a_L = list(map(int,input().split()))

    for j in range(m):
        counter += a_L[j] * b_L[j]
    counter += c

    if counter > 0:
        ans += 1

print(ans)


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

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0; i < a + b + 1; ++i) {
        if (i == a && s[i] != '-') {
            cout << "No" << endl;
            return 0;
        }
        if (i != a && (s[i] < '0' || s[i] > '9')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

ll gcd(ll x, ll y){
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y){
  return x / gcd(x, y) * y;
}

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

  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  ll l = lcm(n, m);
  if(s.length() > t.length()){
    ll tmpi = n;
    n = m;
    m = tmpi;
    string tmps = s;
    s = t;
    t = tmps;
  }

  bool able = true;
  for(ll i = 0; i < l; i += l / n){
    if(i % (l / m) == 0){
      if(t[i / (l / m)] != s[i / (l / n)]){
        able = false;
        break;
      }
    }
  }

  if(able) cout << l << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int n, A[2000];

bool solve(int i, int m){
    bool res;
    if (m == 0){
        return true; 
    }
    if (i >= n){
        return false; 
    }
    res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main(void){
    int q,mi;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    cin >> q;
    for (int j = 0; j < q; j++){
        cin >> mi;
        for (int i = 0; i <= n; i++){
            if (i == n){
                cout << "no" << endl;
                break;
            }
            if (solve(i,mi)){
                cout << "yes" << endl;
                break;
            }
        }
    }
}


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

int main() {
  int n, a, b, P_a, P_b;
  cin >> n >> a >> b;
  P_a = n * a;
  P_b = b;
  
  if (P_a < P_b) {
    cout << P_a << endl;
  }
  
  else if (P_a > P_b) {
    cout << P_b << endl;
  }
  
  else 
    cout << P_a << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		long N = Long.parseLong(tokens[0]);
		if (N % conv(tokens[0]) == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	static int conv(String s) {
		int result = 0;
		for (int i = 0; i < s.length(); ++i) {
			result += Integer.parseInt(s.substring(i, i + 1));
		}
		return result;
	}
}

Measured memory_bytes: 22484
#include <iostream>
using namespace std;
int T, A, B, N,zost,i,j,pud,ilezw,ilenor;
 
int main()
{
    T=1;
    while(T)
    {
        cin >> N >> A >> B;
        if ((long long)A*B<(long long)N || A + B - 1>N)
        {
            cout << -1<<endl;
            T--;
            continue;
        }
        if (B == 1)
        {
            for (i = 1; i <= N; i++)
                cout << i << " ";
            cout << endl;
            T--;
            continue;
        }
        for (i = 1; i <= A; i++)
            cout << N - A + i << " ";
        zost = N - A;
        pud = zost / (B - 1);//ile w pudelku
        ilezw = zost % (B - 1);//ile zwiekszonych pudelek o jeden
        for (i = 1; i <= ilezw; i++)
        {
            for (j = 1; j <= pud + 1; j++)
                cout << zost - (pud + 1) + j << " ";
            zost -= (pud + 1);
        }
            
                
        ilenor = B - 1 - ilezw;
        
        for (i = 1; i <= ilenor; i++)
        {
            for (j = 1; j<=pud; j++)
                cout << zost - pud + j << " ";
            zost -= pud;
        }
        cout << endl;
        pud = zost = ilezw = ilenor = 0;
        T--;
    }
    return 0;
}
 

Measured memory_bytes: 2176
N,K = map(int,input().split())
p = list(map(int,input().split()))

ave = [(p[i]+1)/2 for i in range(N)]

ans = 0
cumlative = []
for i in range(N):
	if i == 0:
		cumlative.append(ave[i])
	else:
		cumlative.append(cumlative[i-1]+ave[i])
	#print(ave[i:K+i])
if N == K:
	ans = cumlative[N-1]
else:
	for i in range(N-K):
		ans = max(cumlative[i+K] - cumlative[i],ans)

print(ans)



Measured memory_bytes: 25060
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    cs <- getLine
    print $ solve n cs

solve :: Int -> String ->  Int
solve _ cs = go maxBound e0 0 cs
  where
    !e0 = length $ filter (== 'E') cs
    go !res !e !w ('E':cs) = go (min res $ e - 1 + w) (e - 1) w cs
    go !res !e !w ('W':cs) = go (min res $ e + w) e (w + 1) cs
    go res _ _ _           = res


Measured memory_bytes: 16764
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

typedef long long int LLI;
using namespace std;

//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}


void func() {
    long double a, b, c;
    cin >> a >> b >> c;
    if ( a + b + 2.0 * sqrtl(a * b) < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 9999999;
    for(ll i = a[0]; i <= a[n-1]; ++i){
        ll m = 0;
        rep(j, n){
            m += pow(a[j] - i, 2);
        }
        ans = min(ans, m);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np


A = list(map(int, input().split()))
N = A[0]
Y = A[1]
Y = Y/1000
Ans = [-1,-1,-1]
for i in range(N+1):
	for j in range(N+1):
		okane = i + 5* j
		if okane + 10*(N-i-j) == Y and 0 <= N-i-j:
			Ans[0]=(N-i-j)
			Ans[1]=(j)
			Ans[2]=(i)
print(' '.join(map(str, Ans)))

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 103;
const int mod = 1e9 + 7;

int dp[2][100001];

void add(int &a, int b){
	if(b < 0){b += mod;}
	a += b;
	if(a > mod){a-=mod;}
}

int main(){
	int n,k,i,j;
	int a[maxn];
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<=k;i++){
		if(a[0] >= i){dp[0][i] = 1;}
	}
	// printf("n: %d\n",n);
	int pref[100001];
	for(i=1;i<n;i++){
		int idx = i%2;

		if(idx == 1){
			memset(dp[1], 0, sizeof dp[1]);
			for(j=0;j<=k;j++){
				pref[j] = dp[0][j];
				if(j){add(pref[j], pref[j-1]);}
			}
		}else{
			memset(dp[0], 0, sizeof dp[0]);
			for(j=0;j<=k;j++){
				pref[j] = dp[1][j];
				if(j){add(pref[j], pref[j-1]);}
			}
		}

		for(j=0;j<=k;j++){
			int maks = j, minim = max(0, j-a[i]);
			int tambah = pref[maks] - (minim ? pref[minim-1]: 0);

			add(dp[idx][j], tambah);
			// printf("dp[%d][%d]: %d\n",i,j,dp[idx][j]);
		}
	}
	int idx = (n-1) % 2;
	printf("%d\n",dp[idx][k]);
	return 0;
};

Measured memory_bytes: 1408
A,B,C,K=map(int,input().strip().split())
if K-A>0:
  K=K-A
  Sum=A
  K=K-B
  if K>0:
    if K>C:
      print(Sum-C)
    else:
      print(Sum-K)
    #if K>C:
  else:
    print(Sum)
else:
	print(K)

Measured memory_bytes: 9060
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    string S;
    int i, j;
    ll r=0, g=0, b=0;
    ll all = 0;

    cin >> N >> S;

    for(i=0; i<N; i++) {
        if(S[i] == 'R') {
            r++;
        } else if(S[i] == 'G') {
            g++;
        } else if(S[i] == 'B') {
            b++;
        }
    }

    all = r*g*b;

    for(i=0; i<N-2; i++) {
        for(j=i; 2*j-i<N; j++) {
            if(S[i]!=S[j] && S[i]!=S[2*j-i] && S[j]!=S[2*j-i]) {
                all--;
            }
        }
    }

    cout << all << endl;

    return 0;

}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>

using namespace std;

long long int x, y;
long long int anscnt;

int main(){
	scanf("%lld %lld", &x, &y);
	if (y < x){
		if (y > 0){
			anscnt = (x - y) + 2;
		}
		else if (x < 0){
			anscnt = (x - y) + 2;
		}
		else{
			if (x > (y * -1)){
				anscnt = (y - x * -1) + 1;
			}
			else{
				anscnt = (y * -1 - x) + 1;
			}
		}
	}
	else if (x == y){
		anscnt = 0;
	}
	else if (x < y){
		if (x >= 0){
			anscnt = y - x;
		}
		else if (y <= 0){
			anscnt = y - x;
		}
		else{
			if (x > (y * -1)){
				anscnt = (y - x * -1) + 1;
			}
			else{
				anscnt = (y * -1 - x) + 1;
			}
		}
	}
	printf("%lld\n", anscnt);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  ppp();
  int n,k;
  scanf("%d %d",&n,&k);
  ll a[n],ans=0;
  FOR(n)scanf("%lld",&a[i]);
  qsort(a,n,sizeof(ll),usort);
  FOR(n-k+1){
    ans=(ans+(a[n-i-1]-a[i])*nCr(n-i-1,k-1)%mod)%mod;
    if(ans<0)ans-=(ans/mod-1)*mod;
  }
  PRL(ans);
  return 0;
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

ll d;
string s;

ll dp[MAXN][2][105];

ll solve(ll ind, ll smaller, ll rem){
  if(ind == s.size()){
    if(rem == 0) return 1;
    return 0;
  }

  if(dp[ind][smaller][rem] != -1){
    return dp[ind][smaller][rem];
  }

  ll ans = 0;
  if(smaller){
    for(int i = 0; i < 10; i++){
      ans = (ans + solve(ind + 1, 1, (rem + i) % d)) % mod;
    }
  }else{
    ll limit = s[ind] - '0';
    for(int i = 0; i <= limit; i++){
      ans = (ans + solve(ind + 1, i == limit ? 0 : 1, (rem + i) % d)) % mod;
    }
  }

  dp[ind][smaller][rem] = ans;
  return ans;
}

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

  cin >> s;
  cin >> d;

  for(int i = 0; i < MAXN; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 105; k++) dp[i][j][k] = -1;
    }
  }

  ll ans = (solve(0, 0, 0) - 1 + mod) % mod;
  cout << ans << endl;
}


Measured memory_bytes: 165120
N = int(input())

target = dict()
max_count = 0
max_key = list()
for i in range(N):
	S = str(input())
	if S in target:
		count = target[S] +1
		target[S] = count	
	else:
		target[S] = 1
		count = 1

	if max_count < count:
		max_count = count
		max_key = [S]
	elif max_count == count:
		max_key.append(S)

max_key.sort()
for i in max_key:
	print(i)

Measured memory_bytes: 33416
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output
set<ll> Divisors(ll n){
    set<ll> s1;
    for (int i = 1; i*i<=n; ++i)
    {
        if(n%i==0){
            s1.insert(i);
            s1.insert(n/i);
        }
    }
    return s1;
}

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

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

    for (int i = n; i>=1; i--)
    {
        ll sum=0;
        for (int j = i; j<=n; j+=i)
        {
            sum+=b[j];
        }
        if((sum%2)!=(a[i]%2)){
            b[i]=1;
        }
        else{
            b[i]=0;
        }
    }

    vector<ll> v;
    for (int i = 1; i < n+1; ++i)
    {
        if(b[i]==1){
            v.push_back(i);
        }
    }

    cout<<v.size()<<endl;
    for (int i = 0; i < v.size(); ++i)
    {
        cout<<v[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 7268
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// i日目に買った株はi+1日目に全部売って良い グラフを考えればわかる
int n, d, x, p[11][11], dp[200200];

signed main() {
	cin >> n >> d >> x;
	rep(i,d) rep(j,n) cin >> p[i][j];
	rep(k,d-1) {
		memset(dp, -1, sizeof(dp));
		dp[0] = 0;
		rep(i,n) rep(j,100100) if (dp[j]!=-1)
			chmax(dp[j+p[k][i]], dp[j] + p[k+1][i]);
		int t = 0;
		rep(i,x+1) chmax(t, dp[i] + x-i);
		x = t;
	}
	cout << x << endl;
}


Measured memory_bytes: 3996
n = int(input())
a = list(map(int, input().split()))
flag = False
for i in range(n):
    if (a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0)):
        print("DENIED")
        exit()
else:
    print("APPROVED")


Measured memory_bytes: 3060
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	vector<pair<int, int>> v(in());
	for (auto &p: v)
		p = {in(), in()};
	sort(v.begin(), v.end());
	for (auto p: v)
		outl(p.first, ' ', p.second);
}


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

DP = [0]*N
DP[1] = abs(H[1]-H[0])

for i in range(2, N):
    two = abs(H[i]-H[i-2])
    one = abs(H[i]-H[i-1])
    if DP[i-2]+two <= DP[i-1]+one:
        DP[i] = DP[i-2]+two
    else:
        DP[i] = DP[i-1]+one

print(DP[-1])

Measured memory_bytes: 13900
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
ans = [k-q]*n

for j in range(q):
  ans[(a[j])-1] += 1
  
for k in range(n):
  if ans[k] > 0:
    ans[k] = "Yes"
  else:
    ans[k] = "No"
  print(ans[k])
  

Measured memory_bytes: 15328
import math

def resolve():
    A, B = map(int, input().split())

    answer = least_common_multiple(A, B)    
    print(answer)

def least_common_multiple(a, b):
    if b > a:
        a, b = b, a
    
    ab = a*b

    while (a%b) != 0:
        a, b = b, a%b

    return int(ab/b)

if __name__ == "__main__":
    resolve()

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

using namespace std;
using ll = long long;

#define SIZE 2010
bool A[SIZE][SIZE];
bitset<SIZE> l[SIZE];
bitset<SIZE> r[SIZE];


int main() {
  ll N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      char a;
      cin >> a;
      A[i][j] = a == '1';
      A[j][i] = !A[i][j];
    }
  }

  for (int i = N - 1; i >= 0; --i) {
    l[i][i] = true;
    r[i][i + 1] = true;
    bitset<SIZE> X;
    for (int j = i + 1; j < N; ++j) {
      if ((l[j] & r[i]).any()) {
        if (A[i][j])
          r[i] |= r[j];
        else {
          l[j][i] = true;
          X[j] = true;
        }
      }
      if ((X & l[j]).any()) {
        l[j][i] = true;
        X[j] = true;
      }
    }
  }

  ll ret=0;
  for(int i=0;i<N;i++)
  {
    if(l[i][0]&&r[i][N])
    {
      ret++;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<long long> a(n + 1);
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		a[i] = a[i - 1] + x;
		a[i] %= m;
	}
	long long ans = 0;
	map<int, long long> mp;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) ans++;
		ans += mp[a[i]];
		mp[a[i]]++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if (a + b + c == 17) {
		if ((a == b&&a == 5) || (a == c&&a == 5) || (b == c&&b == 5))
			cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int tri[1111];

int main(){
  int i,j,num,max,ans;
  for(i=0;i<1111;i++) tri[i]=(i+1)*(i+1)*(i+1);
  do{
    scanf("%d",&num);
    if(!num) break;
    for(j=num-1,ans=tri[num-1];j>-1;j--){
      max=tri[num-1]-tri[j-1];
      for(i=0;max-tri[i]>0;i++);
      max-=tri[i-1];
      if(max<ans) ans=max;
    }
    printf("%d\n",ans);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int d[505050];
int occ[505050];
#define SIZE 524288
class BIT
{
public:
	int bit[SIZE + 1];
	void add(int a, int b)
	{
		a++;
		for (;;)
		{
			bit[a] += b;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	int get(int a)
	{
		a++;
		int ret = 0;
		for (;;)
		{
			ret += bit[a];
			a -= a&-a;
			if (a == 0)return ret;
		}
	}
};
BIT bi;
ll po(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = po(a, b / 2);
	z = z*z%mod;
	if (b & 1)z = z*a%mod;
	return z;
}
ll inv(ll a)
{
	return po(a, mod - 2);
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]), occ[d[i]] = 1;
	vector<int>v;
	for (int i = 1; i <= num; i++)if (occ[i] == 0)v.push_back(i);
	ll kai = 1;
	for (int i = 1; i < v.size(); i++)kai = kai*i%mod;
	ll k2 = 1;
	for (int i = 1; i <= v.size(); i++)k2 = k2*i%mod;
	ll tim = 1;
	ll sum = 0;
	ll ans = 0;
	ll dd = 0;
	for (int i = num - 1; i >= 0; i--)
	{
		if (d[i] == 0)
		{
			ans += (sum + v.size()*dd%mod*inv(2) % mod)*tim%mod*kai;
			ans %= mod;
			dd++;
		}
		else
		{
			int low = lower_bound(v.begin(), v.end(), d[i]) - v.begin();
			ll ko = (bi.get(d[i]) + dd*low%mod*inv(v.size())) % mod;
			ans += ko*tim%mod*k2;
			ans %= mod;
			sum += v.size() - low;
			sum %= mod;
			bi.add(d[i], 1);
		}
		tim *= num - i;
		tim %= mod;
	}
	printf("%lld\n", (ans + k2) % mod);
}

Measured memory_bytes: 8048
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    
    if(10%p==0){
        ll ans = 0;
        rep(i,n){
            if( (s[i]-'0') % p == 0 ){
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    vector<int> d(n+1);
    map<int,ll> mp;
    mp[0]++;
    int ten = 1;
    for(int i=n-1;i>=0;i--){
        int a = (s[i] - '0') * ten % p;
        d[i] = (d[i+1]+a)%p;
        ten *= 10; ten %= p;
        mp[d[i]]++;
    }
    ll ans = 0;
    for(auto x:mp)ans += x.second * (x.second-1) / 2LL;
    cout << ans << endl;
}


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

int N;
int balls[15];

int solve() {
    vector<int> A, B;
    for(int i = 0; i < 10; i++) {
        if(i == 0) {
            A.push_back(balls[i]);
        } else {
            if(B.size() == 0) {
                if(A[A.size()-1] > balls[i]) {
                    B.push_back(balls[i]);
                } else {
                    A.push_back(balls[i]);
                }
            } else {
                if(A[A.size()-1] < balls[i] && B[B.size()-1] < balls[i]) {
                    if(A[A.size()-1] > B[B.size()-1]) {
                        A.push_back(balls[i]);
                    } else {
                        B.push_back(balls[i]);
                    }
                } else if(A[A.size()-1] < balls[i] && B[B.size()-1] > balls[i]) {
                    A.push_back(balls[i]);
                } else if(A[A.size()-1] > balls[i] && B[B.size()-1] < balls[i]) {
                    B.push_back(balls[i]);
                } else {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "YES" << endl;
    return 0;
}


int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> balls[j];
        }
        solve();
    }

    return 0;
}

Measured memory_bytes: 1204
import queue

K = int(input())
A = queue.Queue()

for i in range(1, 10):
        A.put(i)

num = 0
while num < K:
        emp = A.get()
        var = emp % 10
        if var != 0:
                A.put(emp*10+var-1)
        A.put(10*emp+var)
        if var != 9:
                A.put(emp*10+var+1)
        num += 1

print(emp)

Measured memory_bytes: 12480
#include <bits/stdc++.h>
using namespace std;
#define FOR for(int i=1;i<=n*2;i++)
#define lo long long
#define inf 100005
#define in -999999999
#define IN 999999999
#define FOr for(int i=n;i>=1;i--)
#define mpp make_pair
#define pb push_back
#define se second
#define fi first
int n,m,cev,dal[100005];
pair<int,int> a;
vector< pair<int,int> > v;
int main(){
	scanf("%d %d",&n,&m);
	printf("%d",n-m+1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    auto check = [&](int types) {
        map<int, int> count;
        for (int i = 1; i < N; i++) {
            if (A[i - 1] < A[i]) continue;
            int idx = A[i];
            if (types == 1) return false;
            while (true) {
                count[idx]++;
                if (count[idx] >= types) {
                    count.erase(idx);
                    idx--;
                } else break;
            }
            auto itr = next(count.find(idx), 1);
            while (itr != count.end()) itr = count.erase(itr);
        }
        bool ok = count[0] == 0;
        return ok;
    };
    int left = 0, right = 1e9 + 100;
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (check(mid)) right = mid;
        else left = mid;
    }
    cout << right << endl;
}


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

using namespace std;

long long tab[100020];
long long wynik[100020];
long long roz(long long x,long long y)
{
   return max(x,y)-min(x,y);

}

int main()
{
    long long n,k;
    cin >> n >> k;
  cin >> tab[1];
  tab[0]=tab[1];


  for (long long i=2;i<=n;i++)
  {
      cin>> tab[i];
      long long minim=1000000000;

      for(long long a=i-1;a>=i-k;a--)
      {
          long long act=roz(tab[i],tab[a])+wynik[a];
          minim=min(act,minim);
          if(a==0)
            break;
      }
      wynik[i]=minim;

       ///cout << "pos:" << i << " roz1: " << wylicz1 << " roz2: " << wylicz2 << " wynik: " << wynik[i] << "\n";
  }
cout << wynik[n];
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B;
	cin >> A >> B;
	set<int> ans;
	ans.insert(1);
	ans.insert(2);
	ans.insert(3);
	ans.erase(A);
	ans.erase(B);
	cout << *ans.begin() << endl;

	return 0;
}

Measured memory_bytes: 256