akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#pragma GCC optimize ("O3")

inline static long gl(void){
    long x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[10];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    str[pos] = '\n';
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    write(1, str+pos, 10-pos);
}

inline static int sp(unsigned char* str, unsigned short i){
    if(i>99){
        str[2] = i%10+48; i/=10;
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 3;
    }else if(i>9){
        str[1] = i%10+48;
        str[0] = i/10+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

unsigned char a[1000];
unsigned char buffer[8*1024*1024];

int main(void){
    const unsigned long h=gl(), w=gl();
    unsigned long p=0, pos=0;
    {
        bool haveCoin = false;
        unsigned short old_y, old_x;
        for(unsigned long i=1; i<=h; i++){
            fread(a, 1, 2*w, stdin);
            if(i%2==1){
                for(unsigned long j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = a[2*(j-1)]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(long j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin = a[2*(j-1)]&1 ? !haveCoin : haveCoin;
                    old_y = i;
                    old_x = j;
                }
            }
        }
    }
    pl(pos);
    write(1, buffer, p);
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    
    double ans = 0;
    
    for (int i = 1; i <= n; i++){
        double p = 1;
        int score = i;
        
        while (score < k){
            p *= 0.5;
            score *= 2;
        }
        
        ans += p / n;
    }
    cout  << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int d=scan.nextInt();
		int t=scan.nextInt();
		int s=scan.nextInt();
		if(d<=(t*s)) System.out.println("Yes");
		else System.out.println("No");
		scan.close();
	}

}


Measured memory_bytes: 26848
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-8;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    int a = 0, b = 0, c = 0, d = 0;
    rep(i, n) {
        if (s[i] == "AC")
            ++a;
        else if (s[i] == "WA")
            ++b;
        else if (s[i] == "TLE")
            ++c;
        else
            ++d;
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 6348
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

ll xs[60];
ll ys[60];

int main(void) {
  int n;
  cin >> n;
  REP(i, n) {
    cin >> xs[i] >> ys[i];
  }
  int mini = n;
  REP(i1, n) REP(i2, n) {
    ll p = xs[i1] - xs[i2];
    ll q = ys[i1] - ys[i2];
    if(p == 0 && q == 0) {
      continue;
    }
    int score = 0;
    set<pair<ll,ll> > ss;
    REP(i, n) {
      ss.insert(make_pair(xs[i], ys[i]));
    }
    while(!ss.empty()) {
      pair<ll,ll> pp = *ss.begin();
      ss.erase(pp);
      ++score;
      for(pair<ll,ll> cur(pp); ; ) {
        pair<ll, ll> next(cur.first + p, cur.second + q);
        if(ss.count(next) == 0) {
          break;
        }
        ss.erase(next);
        cur = next;
      }
      for(pair<ll,ll> cur(pp); ; ) {
        pair<ll, ll> next(cur.first - p, cur.second - q);
        if(ss.count(next) == 0) {
          break;
        }
        ss.erase(next);
        cur = next;
      }
    }
    mini = min(mini, score);
  }
  cout << mini << endl;
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod  10000007
int main()
{
 ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> v[n];
    for(int i=0;i<n;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        v[i].pb(x);
        v[i].pb(y);
        v[i].pb(z);
    }
    int dp[n+1][3];
    dp[1][0]=v[0][0];
    dp[1][1]=v[0][1];
    dp[1][2]=v[0][2];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=0;
            for(int k=0;k<3;k++)
            {
                if(j==k) continue;
                dp[i][j]=max(dp[i-1][k]+v[i-1][j],dp[i][j]);
            }
        }
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

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

ll a[4002];

int main(){
    ll N,x;
    cin>>N>>x;
    rep(i,N) cin>>a[i];
    rep(i,N) a[i+N]=a[i];

    vector<vector<ll>> mini(2*N,vector<ll>(2*N,LINF));
    for(int i=0;i<2*N;i++){
        mini[i][i]=a[i];
    }
    for(int i=0;i<2*N;i++){
        for(int j=i+1;j<N*2;j++){
            mini[i][j] = min(mini[i][j-1],a[j]);
        }
    }

    ll ans=LINF;
    for(int counter=0;counter<N;counter++){
        // 魔法をcounter回使用する
        //debug(counter);
        ll sum=counter*x;
        for(int i=0;i<N;i++){
            // 色iをゲットする
            // i-counter ... i
            ll l = i-counter;
            ll t=LINF;
            if(l<0){
                l = 2*N+(i-counter);
            //    debug2(i,l);
            //    debug2(mini[0][i],mini[l][2*N-1]);
                t=min(t,mini[0][i]);
                t=min(t,mini[l][2*N-1]);

            }else{
                t=min(t,mini[i-counter][i]);
            }
            sum += t;
            if(sum>ans) goto F;
        }
F:
        ans=min(ans,sum);
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  
  int n = N%10;
  if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  }
  else  if(n == 3){
    cout << "bon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
def main():
    a = int(input())
    b = int(input())
    if a == 1 and b == 2 or a == 2 and b == 1:
        print(3)
    elif a == 2 and b == 3 or a == 3 and b == 2:
        print(1)
    elif a == 3 and b == 1 or a == 1 and b == 3:
        print(2)
         
if __name__ == '__main__':
    main()

Measured memory_bytes: 9080
n, m = list(map(int, input().split()))
ans = 1
mod = 10**9+7
def a(x, y):
    return x*y%mod

if n==m:
    for i in range(1, n+1):
        ans = a(ans, i)
    print((ans**2*2)%(mod))
elif abs(n-m)==1:
    for i in range(1, n+1):
        ans = a(ans, i)
    for i in range(1, m+1):
        ans = a(ans, i)
    print(ans)
else:
    print(0)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M,X;
  cin>>N>>M>>X;
  vector<vector<ll>>A(N,vector<ll>(M));
  vector<ll> C(N);
  REP(i,N){
    cin>>C[i];
    REP(j,M){
      cin>>A[i][j];
    }
  }
  ll ans=INFLL;
  REP(bit,(1<<N)){
    vector<ll>tmp(M);
    ll cost=0;
    REP(i,N){
      if(bit&(1<<i)){
        REP(j,M){
          tmp[j]+=A[i][j];
        }
        cost+=C[i];
      }
    }
    bool flag=true;
    REP(j,M){
      if(tmp[j]<X)flag=false;
    }
    if(flag)chmin(ans,cost);
  }

  cout<<(ans==INFLL?-1:ans)<<endl;
}


Measured memory_bytes: 3668
#!python3

# input
N = input()


def main():
    s = 0
    for x in N:
        s += int(x)
    if int(N) % s == 0:
        ans = 'Yes'
    else:
        ans = 'No'    
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    string S, T;
    cin >> S >> T;

    bool can = false;
    for (int i = S.size() - T.size(); i >= 0; --i) {
        string X = S.substr(i, T.size());
        bool can2 = true;
        for (int j = 0; j < T.size(); ++j) {
            if ((X[j] != T[j]) && (X[j] != '?')) {
                can2 = false;
                break;
            }
        }
        if (can2) {
            for (int j = 0; j < T.size(); ++j) {
                S[i + j] = T[j];
            }
            can = true;
        }
        if (can) break;
    }
    
    if (can) {
        for (int i = 0; i < S.size(); ++i) {
            if (S[i] =='?') S[i] = 'a';
        }
        cout << S << endl;
    }
    else cout << "UNRESTORABLE" << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

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

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

type runes []rune

func (a runes) Len() int           { return len(a) }
func (a runes) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a runes) Less(i, j int) bool { return a[i] < a[j] }

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	s := make([]string, n)

	for i := 0; i < n; i++ {
		in := runes(scanText())
		sort.Sort(in)
		s[i] = string(in)
	}

	sort.Strings(s)

	ans,c := int64(0), int64(0)
	for i := 0; i < n; i++ {
		if i == n-1 {
			ans+=(c+1)*c/2
			break
		}
		if s[i] == s[i+1] {
			c++
		} else {
			ans+=(c+1)*c/2
			c=0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5760
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)              cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)              cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)          cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}



int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll k,s;
    cin >> k >> s;
    ll ans=0;
    for(ll i=0; i<=k; i++){
        for(ll j=0; j<=k; j++){
            ll x=s-i-j;
            if(x>=0 && x<=k) ans++;
         }
    }
    cout << ans;
    return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
b = [0] * n
for i in range(n):
    b[a[i] - 1] = i + 1
b = [str(x) for x in b]
b = ' '.join(b)
print(b)


Measured memory_bytes: 61740
using System;
using System.Text;

class Program
{
	static void Main()
	{
		var hw = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var h = hw[0];
		var w = hw[1];
		var count = h * 2;
		Console.ReadLine();
		var colors = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var answer = new int[w + 2, h + 2];
		for (var y = 0; y < h; ++y) {
			for (var x = 0; x < w; ++x) {
				answer[x + 1, y + 1] = -1;
			}
		}

		var vectorX = 1;
		var vectorY = 0;
		var currentX = 1;
		var currentY = 1;
		for(var i = 0; i < colors.Length; ++i) {
			for (var j = 0; j < colors[i]; ++j) {
				answer[currentX, currentY] = i + 1;

				if (answer[currentX + vectorX, currentY + vectorY] != -1) {
					var newVectorX = vectorY * -1;
					vectorY = vectorX;
					vectorX = newVectorX;
				}

				currentX += vectorX;
				currentY += vectorY;
			}
		}

		for (var y = 0; y < h; ++y) {
			var line = new StringBuilder();
			for (var x = 0; x < w; ++x) {
				line.Append($"{answer[x + 1, y + 1]} ");
			}

			Console.WriteLine(line.ToString().Trim());
		}

		Console.ReadKey();
	}
}


Measured memory_bytes: 13280
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(D)]
#t = [int(input()) for i in range(D)]
tmp = 0
last = [0]*(26)
tmp_list = [0]*(26)
day = 0
v = [0]*(D+1) #満足度これだけi=日付他のはi-1=日付
v_num = [0]*(D+1)
for day in range(D):
	for i in range(26):#今day+1日目
		tmp_list[i] = v[day]+ s[day][i]
		for j in range(26):
			if j != i:
				tmp_list[i] -= c[j] * (day+1 - last[j]) 
	v[day+1] = max(tmp_list)
	last[tmp_list.index(max(tmp_list))] = day + 1 
	v_num[day+1] = tmp_list.index(max(tmp_list)) +1
	


for i in range(1,D+1):
	print(v_num[i])

Measured memory_bytes: 9376
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = ("0 " + StdIn.readLine() + " 0 0").split(' ').map(_.toInt)
  // println(a.mkString(" "))

  val alls = (0 to n by 2).foldLeft(0) { (acc, idx) =>
    acc + math.abs(a(idx + 1) - a(idx)) + math.abs(a(idx + 2) - a(idx + 1))
  }
  //println(alls)

  (1 to n).foreach { i =>
    println(alls - math.abs(a(i) - a(i - 1)) - math.abs(a(i + 1) - a(i)) + math.abs(a(i + 1) - a(i - 1)))
  }

}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;

 
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vec<int> c(n);
  int a[n][m];
  rep(i, n){
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  int ans = INF;
  for (int tmp = 0; tmp < (1 << 12); tmp++){ 
    bitset<12> s(tmp);
    vec<int> comp(m, 0);
    int money = 0;
    rep(i, n){
      if(s.test(i)){
        money += c[i];
        rep(j, m) comp[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(i, m){
      if(comp[i] < x) ok = false;
    }
    if(ok) ans = min(ans, money);
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

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

long long solve(long long n) {
    long long m = n - 1;
    if (n & 1) {
        for (long long i = 3; i * i <= n; i += 2) {
            if (n % i == 0) {
                m = min(i + (n / i) - 2, m);
            }
        }
    } else {
        for (long long i = 2; i * i <= n; ++i) {
            if (n % i == 0) {
                m = min(i + (n / i) - 2, m);
            }
        }
    }
    return m;
}

int main() {
    long long n;
    cin >> n;
    cout << solve(n) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <unordered_map>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T 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<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_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);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int collatz(int n) {
	static unordered_map<int, int> m;
	if (m.count(n))
		return m[n];
	return m[n] = n == 1 ? 0 : (n % 2 ? collatz(n * 3 + 1) : collatz(n / 2)) + 1;
}

int main() {
	for (int n; (n = in());)
		outl(collatz(n));
}


Measured memory_bytes: 2472
#include <stdio.h>
#include <string.h>
int main() {
	char s[101], key[8] = "keyence";
	scanf("%s", s);
	int cnt = 0, len = strlen(s);
	for (int i = 0; i <= 7; i++) {
		if (s[i] != key[i]) {
			cnt = 7 - i;
			break;
		}
	}
	for (int i = 0; i < cnt; i++) {
		if (s[len - i - 1] != key[6 - i]) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
A.sort()
min=A[0]
A[-1]%=min
if A[-1]!=0:
    min=A[-1]
for i in range(N-1):
    A[-i-2]%=min
    if A[-i-2]!=0:
        min=A[-i-2]
while A.count(0)!=N:
    for i in range(N):
        A[-i-1]%=min
        if A[-i-1]!=0:
            min=A[-i-1]
print(min)



Measured memory_bytes: 14224
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    #divisors.sort(reverse=True)
    return divisors

a, b, k = MAP()
c = make_divisors(a)
d = make_divisors(b)
e = list(set(c) & set(d))
e.sort(reverse=True)
print(e[k - 1])

Measured memory_bytes: 60140
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
string s;
int n;
int dp[maxn][2];
int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	n=s.length();
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	dp[0][0]=1;
	dp[1][1]=1;
	if(s[0]!=s[1])dp[1][0]=2;
	for(int i=2;i<n;i++)
	{
		if(s[i]!=s[i-1])dp[i][0]=max(dp[i][0],dp[i-1][0]+1);
		dp[i][0]=max(dp[i][0],dp[i-1][1]+1);
		dp[i][1]=max(dp[i][1],dp[i-2][0]+1);
		if(i-3>=0)dp[i][1]=max(dp[i][1],dp[i-2][1]+1);
	}
	
	cout<<max(dp[n-1][0],dp[n-1][1]);
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

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

    cout << 3 * n * n << '\n';
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include<cstring> 
#include<cstdlib> 



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
string s, t;
cin >> s >> t;
int n = s.length();
int m = t.length();
ll dp[n+1][m+1];
for(int i=0; i<=n; i++){

	dp[i][0]=0;
}
for(int j=0; j<=m; j++){
	dp[0][j]=0;
}

for(int i=1;i<=n;i++){
	for(int j=1; j<=m; j++){

		if(s[i-1]==t[j-1]){
			dp[i][j] = 1+dp[i-1][j-1];
		}
		else
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

	}
}

int index = dp[n][m];

char lcs[index+1];
lcs[index]='\0';

int i = n;
int j = m;
while(i>0 && j>0){

	if(s[i-1]==t[j-1]){
		lcs[index-1] = s[i-1];
		i--;
		j--;
		index--;
	}

	else if(dp[i-1][j]>dp[i][j-1]){
		i--;
	}
	else
		j--;
}

cout << lcs;
return 0;
}



Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; ++i)

int main(){
int n,ptr,res;
cin>>n;
int a[100000];
rep(i,0,n) cin>>a[i];
sort(a,a+n);
while(ptr<n){
    int x=a[ptr],cnt=0;
    while(ptr<n && a[ptr]==x)cnt++,ptr++;
    res+=cnt%2;
}
cout<<res<<endl;
return 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

btc = 380000

n = ni()

ans = 0
for _ in range(n):
    s = ls()
    num = float(s[0])
    typ = s[1]
    
    if typ == "JPY":
        ans += num
    else:
        ans += num * btc
        
print(ans)

Measured memory_bytes: 3064
n,a,b,k=map(int,input().split())
mod=998244353
s=0
fact=[1]*(n+1)
rev=[1]*(n+1)

for i in range(1,n+1):
    fact[i]=i*fact[i-1]%mod
    rev[i]=pow(fact[i],mod-2,mod)
fx=lambda a,b:(fact[a]*rev[a-b]*rev[b])%mod

for i in range(n+1):
    j,r=divmod((k-a*i),b)
    if r==0 and 0<=j<=n:
      s+=(fx(n,i)*fx(n,j))%mod

print(s%mod)


Measured memory_bytes: 46060
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024;

int n, m, len, a, b;
string s[2];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n >> m >> len >> a >> b >> s[0] >> s[1];
	int u = 0, d = 0, r = 0, l = 0;
	FORD(i, len - 1, 0)
	{
		if (s[1][i] == 'U')
		{
			d = max(0, d - 1);
		}
		if (s[1][i] == 'D')
		{
			u = max(0, u - 1);
		}
		if (s[1][i] == 'R')
		{
			l = max(0, l - 1);
		}
		if (s[1][i] == 'L')
		{
			r = max(0, r - 1);
		}
		if (s[0][i] == 'U')
		{
			u++;
		}
		if (s[0][i] == 'D')
		{
			d++;
		}
		if (s[0][i] == 'R')
		{
			r++;
		}
		if (s[0][i] == 'L')
		{
			l++;
		}
		if (u + d >= n || r + l >= m)
		{
			cout << "NO\n";
			return 0;
		}
	}
	debug(u, d, l, r);
	if (a <= u || a + d > n || b <= l || b + r > m)
	{
		cout << "NO\n";
	}
	else
	{
		cout << "YES\n";
	}
	return 0;
}

Measured memory_bytes: 920
///   Journey to the End of earth   ///
/// Gunjan Kumar ///
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// using namespace __gnu_pbds; 
using namespace std;
#define ll  long long
#define s(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define p(n) printf("%d",n)
// #define ln() printf("\n")
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          LONG_MAX
#define ninf         LONG_MIN
#define fast         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const   ll mod=1e9+7;
const ll N=3e2+5;



int main()
{

       
        int n,k;
        cin >>  n >> k;
        std::vector<bool> dp(k+1);
        std::vector<int> arr(n);
        for(int& x:arr)
        cin >> x;
        for(int i=0;i<=k;i++)
        {
           for(int x: arr)
           {
              if(i>=x && dp[i-x]==0)
                dp[i]=1;
           }
        }
        if(dp[k])
          cout<<"First"<<endl;
        else cout<<"Second"<<endl;

     return 0;
}



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

int main(){
  int n,i,j,k;
  cin >> n >> k;
  long long x[n],ret=1e16;
  for(i=0;i<n;i++)cin >> x[i];
  for(i=0;i<n-k+1;i++){
    ret=min(ret, abs(x[i+k-1]-x[i]) + abs(x[i+k-1]));
    ret=min(ret, abs(x[i+k-1]-x[i]) + abs(x[i]));
  }
  //if(ret==1e16)ret=x[0];
  cout << ret << endl;
}


Measured memory_bytes: 1024
from collections import Counter

def count_tree(d):
    n = max(int(i) for i in d)
    cnt = 1
    if d[0] != "0":
        return 0
    dd = Counter(d)
    if dd["0"] != 1:
        return 0
    for i in range(1, n):
        if dd[str(i + 1)] > 0 and dd[str(i)] < 1:
            return 0
        else:
            cnt *= pow(dd[str(i)], dd[str(i + 1)], 998244353)
    return cnt % 998244353

input()
print(count_tree(input().split()))

Measured memory_bytes: 19820
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int N, d[105], count = 1;

	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> d[i];

	}
	sort(d, d + N);

	for (int i = 1; i < N; i++) {

		if (d[i] != d[i - 1])count++;

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for h in range(3):
        for w in range(3):
            if A[h][w]==b:
                A[h][w]=0
ans = "No"
for h in range(3):
    cnt = 0
    for w in range(3):
        if A[h][w]==0:cnt+=1
    if cnt==3:ans="Yes"
for w in range(3):
    cnt = 0
    for h in range(3):
        if A[h][w]==0:cnt+=1
    if cnt==3:ans="Yes"
if A[0][0]+A[1][1]+A[2][2]==0:ans="Yes"
if A[2][0]+A[1][1]+A[0][2]==0:ans="Yes"
print(ans)

Measured memory_bytes: 3064
// #include <boost/multiprecision/cpp_int.hpp>
// using boost::multiprecision::cpp_int;
#include <bits/stdc++.h>
using namespace std;
// ¯\_(ツ)_/¯
#define f first
#define s second
#define p push
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define foi(i, a, n) for (i = (a); i < (n); ++i)
#define foii(i, a, n) for (i = (a); i <= (n); ++i)
#define fod(i, a, n) for (i = (a); i > (n); --i)
#define fodd(i, a, n) for (i = (a); i >= (n); --i)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define endl " \n"
#define newl cout<<"\n"
#define MAXN 100005
#define MOD 1000000007LL
#define EPS 1e-13
#define INFI 1000000000             // 10^9
#define INFLL 1000000000000000000ll //10^18
// ¯\_(ツ)_/¯
//#define l long int
//#define d double
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define vvll vector<vll>
#define vvld vector<vector<ld>>

//vector<vector<int>> v(10, vector<int>(20,500)); 2d vector initialization. of 10 rows and 20 columns, with value 500.
#define mii map<int, int>
#define mll map<long long, long long>
#define pii pair<int, int>
#define pll pair<long long, long long>

#define fast_io()                   \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);

ll tc, n, m, k;
// ll ans = 0, c = 0;
// ll i, j;
// ll a, b;
// ll x, y;

int main()
{
    fast_io();
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif

//    cin>>tc;
//    while(tc--) {
        cin>>k>>n;
        vll arr(n, 0);
        rep(i, 0, n) cin>>arr[i];
        ll sum = accumulate(all(arr), 0LL);
        if(sum <= k) cout<<k-sum;
        else cout<<-1;

//    }


    return 0;
}

/*
2
4
0 1 0 1
5
0 0 1 0 0
*/

Measured memory_bytes: 3728
#line 1 "test/aoj/DSL2D.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D"
#include <iostream>
#line 1 "segment_tree/dual_segment_tree.hpp"



#include <vector>
#include <cstdint>

//===
template<class Monoid>
struct DualSegmentTree {
    using T = typename Monoid::value_type;
    std::vector<T> lazy;

    DualSegmentTree() = default;
    explicit DualSegmentTree(uint32_t n):
        lazy(n << 1, Monoid::identity()) {};

    inline int size() {
        return (int)(lazy.size() >> 1);
    };
    
    inline void propagate(uint32_t k) {
        if (k >= size()) return;
        lazy[(k << 1) | 0] = Monoid::operation(lazy[(k << 1) | 0], lazy[k]);
        lazy[(k << 1) | 1] = Monoid::operation(lazy[(k << 1) | 1], lazy[k]);
        lazy[k] = Monoid::identity();
    };
    inline void push_down(uint32_t k) {
        for (uint32_t i = 31; i > 0; i--) propagate(k >> i);
    };
 
    // [l, r)
    void update(uint32_t l, uint32_t r, T op) {
        l += size();
        r += size();
        push_down(l);
        push_down(r);
         
        while (l < r) {
            if (l & 1) lazy[l] = Monoid::operation(lazy[l], op), l++;
            if (r & 1) --r, lazy[r] = Monoid::operation(lazy[r], op);
 
            l >>= 1;
            r >>= 1;
        }
    };
 
    T operator [] (uint32_t k) {
        k += size();
        push_down(k);
        return lazy[k];
    };
};
//===


#line 4 "test/aoj/DSL2D.test.cpp"
using namespace std;
using llong = long long;

struct RUQ {
    using value_type = long long;
    using T = value_type;

    inline static T identity() {
        return (1ll << 31) - 1;
    };
    inline static T operation(T a, T b) {
        if (a == identity()) return b;
        else if (b == identity()) return a;
        else return b;
    };
};

int main() {
    llong n, q;
    llong com;
    llong s, t, x;
    llong idx;

    cin >> n >> q;
    DualSegmentTree<RUQ> seg(n);
    for (int i = 0; i < q; i++) {
        cin >> com;

        if (com == 0) {
            cin >> s >> t >> x;
            seg.update(s, t + 1, x);
        }
        else if (com == 1) {
            cin >> idx;
            cout << seg[idx] << '\n';
        }
    }
};



Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[3];
int main() {
	ll a,b;
	cin>>a>>b;
	a--;b--;
	ch[a]=true;ch[b]=true;
	for(ll i=0;i<3;i++){
		if(ch[i]==false){
			cout <<i+1;
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main () {
  int N;
  std::cin >> N;
  
  int A[N];
  int sum = 0;
  for (int i = 0; i < N; i++) {
    std::cin >> A[i];
    sum = sum + A[i];    
  }  
  std::cout << sum - N << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r, d;
    vector<int> x(11);
    cin >> r >> d >> x[0];
    for(int i = 1; i <= 10; i++)
    {
        x[i] = r * x[i - 1] - d;
        cout << x[i] << endl;
    }

    return 0;
}


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

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

    for (int a = 1; a < INT64_MAX; ++a)
        for (int b = -100; b < a; ++b)
        {
            int64_t A = a * a;
            A = A * A;
            A = A * a;
            int64_t B = b * b;
            B = B * B;
            B = B * b;

            if(A-B==X)
            {
                cout << a << " " << b << endl;
                exit(0);
            }
        }
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> vec1;
  vector<ll> vec2;
  for(ll i = 1; i <= n; i++) {
    if(i%k==0) vec1.push_back(i);
    else if(2*i%k==0) vec2.push_back(i);
  }
  ll a = vec1.size();
  ll b = vec2.size();
  ll ans = 0;
  ans += a*(a-1)*(a-2);
  ans += a*(a-1)*3;
  ans += a;
  ans += b*(b-1)*(b-2);
  ans += b*(b-1)*3;
  ans += b;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N, Sum=0;
  cin >> N;
  int A=N;
  while(A>0){
    Sum=Sum+A%10;
    A=A/10;
  }
  if(N%Sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
XY_set = set(tuple(map(int, input().split())) for _ in range(N))
N = len(XY_set)

XY45 = [(x + y, x - y) for x, y in XY_set]
ans = max(max(x for x, _ in XY45) - min(x for x, _ in XY45),
          max(y for _, y in XY45) - min(y for _, y in XY45))
print(ans)

Measured memory_bytes: 69904
def slide(c,n)
	if (c==" "||c==".") then c
	else((c.ord-"a".ord+n)%26+"a".ord).chr
	end
end

while input=gets
	input=input.chomp
	ans=""
	26.times{|i|
		dec=""
		for ch in input.split("")
			dec+=slide(ch,i+1)
		end
		if(dec.include?("the")||dec.include?("this")||dec.include?("that")) then
			ans=dec
			break
		end
	}
	puts ans
end


Measured memory_bytes: 6872
N = int(input())
A = list(map(int, input().split()))

tmp = 0
sum = [0 for i in range(N)]

for a, b in enumerate(A):
    tmp += b
    sum[a] = tmp


def search(l, r):
    mid = lower_bound(l, r + 1, get_sum(l, r) / 2 + (0 if l == 0 else sum[l-1]))
    for i in range(mid - 2, mid + 3):
        if l <= i and i + 1 <= r:
            yield get_sum(l, i), get_sum(i + 1, r)


#
# 10
# 10 71 84 33 6 47 23 25 52 64
## 81 84 86 164
## 81 84 134 116
## 81 123 95 116
## (81, 117, 101, 116)

def lower_bound(l, r, val):
    while r-l > 1:
        mid = (r + l) // 2
        if sum[mid] <= val:
            l = mid
        else:
            r = mid
    return l


def get_sum(l, r):
    return sum[r] - (0 if l == 0 else sum[l - 1])


ans = tmp

for ind in range(1, N - 2):
    for l1, r1 in search(0, ind):
        for l2, r2 in search(ind + 1, N - 1):
            # print(ind)
            # print(l1, r1, l2, r2)
            t = l1, r1, l2, r2
            # print(t)
            ans = min(ans, max(t) - min(t))
            # if ans == 36:
            #     print("ans   ", t)

print(ans)


Measured memory_bytes: 90232
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>


using namespace std;

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

int main(){
    int N,K;
    cin >> N >> K;
    int R,S,P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    ll ans=0;
    for(int i=0; i<K; i++){
        char pre='o';
        for(int j=i; j<N; j+=K){
            if(T[j]=='s'){
                if(pre=='r'){
                    pre='o';
                    continue;
                }
                ans+=R;
                pre='r';
            }else if(T[j]=='p'){
                if(pre=='s'){
                    pre='o';
                    continue;
                }
                ans+=S;
                pre='s';
            }else{
                if(pre=='p'){
                    pre='o';
                    continue;
                }
                ans+=P;
                pre='p';
            }
        }
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int Q, q, a, b;
	cin>>Q;
	priority_queue<ll> pq1;
	priority_queue<ll, vl, greater<ll>> pq2;
	cin>>q>>a>>b;
	pq1.push(a);
	ll sum=b-a;
	REP(i, Q-1){
		cin>>q;
		if(q==1){
			cin>>a>>b;
			sum+=b;
			if(pq1.size()==pq2.size()){
				if(a<=pq2.top()){
					pq1.push(a);
					sum-=a;
				}
				else{
					ll tmp=pq2.top();
					pq2.pop();
					pq1.push(tmp);
					pq2.push(a);
					sum=sum-tmp*2+a;
				}
			}
			else{
				if(a>=pq1.top()){
					pq2.push(a);
					sum+=a;
				}
				else{
					ll tmp=pq1.top();
					pq1.pop();
					pq2.push(tmp);
					pq1.push(a);
					sum=sum+tmp*2-a;
				}
			}
		}
		else{
			ll tmp=pq1.top();
			cout<<tmp<<' ';
			cout<<(ll)pq1.size()*tmp-(ll)pq2.size()*tmp+sum<<'\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3828
N,K=map(int,input().split())
a=-1
b=-1
c=-1
for i in range(N+1):
  for k in range(N-i+1):
    if 10000*(i)+5000*(k)+1000*(N-i-k)==K:
      a=i
      b=k
      c=N-k-i
print(a,b,c)
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> edge[maxn];
int n,m,h[maxn],ans;
int main() {
	scanf("%d%d",&n,&m); ans = n;
	for (int i = 1;i <= n;i++) scanf("%d",&h[i]);
	for (int i = 1,u,v;i <= m;i++) {
		scanf("%d%d",&u,&v);
		edge[u].push_back(h[v]);
		edge[v].push_back(h[u]);
	}
	for (int i = 1;i <= n;i++)
		for (size_t j = 0;j < edge[i].size();j++)
			if (h[i] <= edge[i][j]) { ans--; break; }
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 9336