akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	A := nextInts(N)
	B := nextInts(N)
	c := make([]int, N)
	sumc := 0
	for i := 0; i < N; i++ {
		c[i] = A[i] - B[i]
		sumc += c[i]
	}
	if sumc < 0 {
		fmt.Println("-1")
		log.Println("sumc<0")
		return
	}
	sort.Ints(c)
	log.Println(c)
	var i = 0
	var j = N - 1
	if c[0] >= 0 {
		fmt.Println("0")
		log.Println("c[0]>=0")
		return
	}
	pool := 0
	for {
		if i == j {
			fmt.Println(N)
			return
		}
		if c[i] >= 0 {
			break
		}
		if pool+c[i] < 0 {
			pool += c[j]
			j--
		} else {
			pool += c[i]
			i++
		}
		if pool < 0 {
			fmt.Println("-1")
			log.Println("pool < 0")
			return
		}
		// log.Println(i, j, pool)
	}
	fmt.Println(N - (j - i) - 1)
}

func intPow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func intMax(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func intMin(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func intSum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func intAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint fact[201010];

modint nCr(int n, int r){
    if(n < r) return 0;
    return fact[n]/fact[r]/fact[n-r];
}

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> used(n+1, -1);
    int idxl = 0, idxr = 0;
    rep(i, n+1){
        cin >> a[i];
        if(used[a[i]] != -1){
            idxl = used[a[i]];
            idxr = i;
        }
        used[a[i]] = i;
    }

    fact[0] = 1;
    rep(i, 200000) fact[i+1] = fact[i] * (i+1);

    rep1(k, n+2){
        modint tmp = nCr(n+1, k);
        tmp -= nCr(idxl+n-idxr, k-1);
        cout << tmp << endl;
    }

}

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

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> nums;
  bool one(true);
  int cnt(0);

  for (int i = 0; i < n; i++) {
    if (s[i] == (one ? '1' : '0')) {
      cnt++;
    } else {
      nums.push_back(cnt);
      one = !one;
      cnt = 1;
    }
  }
  nums.push_back(cnt);
  if (nums.size() % 2 == 0) {
    nums.push_back(0);
  }

  vector<int> sums(nums.size() + 1);
  for (int i = 0; i < nums.size(); i++) {
    sums[i + 1] = sums[i] + nums[i];
  }

  int ans(0);
  for (int i = 0; i < nums.size(); i += 2) {
    int left = i;
    int right = min(left + 2 * k + 1, int(nums.size()));
    ans = max(ans, sums[right] - sums[left]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1272
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    // all black, all white, white...black...
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = INF;
    int black = 0, white = 0;
    {
        FORE(e, S) {
            if (e == '.') white++;
            else black++;
        }
        ans = min(white, black);
    }

    int left_white = 0, right_black = black;
    REP(i, N + 1) {
        if (i > 0) {
            if (S[i - 1] == '#') right_black--;
            else left_white++;
        }
        chmin(ans, N - left_white - right_black);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Solve{
    int N;
    int[] a;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int f = 2;
        int l = 2*N-2;
        while(f != l){
            int c = (f+l+1)/2;
            if(check(c)){
                f = c;
            }
            else{
                l = c-1;
            }
        }
        Console.WriteLine(f);
    }
    bool check(int j){
        if(a[N-1] >= j && (a[N] >= j || a[N-2] >= j)){
            return true;
        }
        if(a[N-1] < j && (a[N] < j || a[N-2] < j)){
            return false;
        }
        bool b = (a[N-1] < j);
        for(int i=1;i<N;i++){
            if(b && (a[N-1-i] < j || a[N-1+i] < j)){
                return false;
            }
            if(!b && (a[N-1-i] >= j || a[N-1+i] >= j)){
                return true;
            }
            b = !b;
        }
        return !b;
    }
    void getinput(){
        N = int.Parse(Console.ReadLine());
        a = new int[2*N-1];
        string[] str = Console.ReadLine().Split(' ');
        for(int i=0;i<2*N-1;i++){
            a[i] = int.Parse(str[i]);
        }
    }    
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll k;
  cin >> k;

  ll n = 50;
  ll div = k / n, mod = k % n;

  // cnt[i]: A_iに対する操作回数
  vector<ll> cnt(n);
  for (ll i = 0; i < n; ++i) {
    cnt[i] = div + (i < mod);
  }

  vector<ll> va(n);
  for (ll i = 0; i < n; ++i) {
    // A_iはいくつ増えるか
    ll sum = 0;
    for (ll j = 0; j < n; ++j) {
      if (i != j) {
        sum += cnt[j];
      }
    }

    va[i] = n * (cnt[i] + 1) - sum - 1;
  }

  cout << va.size() << '\n';
  for (ll i = 0; i < va.size(); ++i) {
    cout << va[i] << (i == va.size() - 1 ? '\n' : ' ');
  }

  return 0;
}

Measured memory_bytes: 256
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

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

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

int main(){
    int n;
    cin >> n;
    if(n % 1000 == 0){
        cout << "0\n";
    }else{
        cout << 1000 - (n % 1000) << endl;
    }
}


Measured memory_bytes: 3632
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}
 long long lcm(int x,int y)
{
     long long mul = x*y;
     long long gd = __gcd(x,y);
    return mul/gd;
}
int lm;
int n,m;
bool chk(int x)
{
   // test1(x);
     long long h = 2*x-1;
     long long g = h*lm;
    if(g<=m)
    return true;

    return false;
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	
    cin>>n>>m;
    int A[n];

    
    bool gret=false;
    int f1=0,f2=0;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
        int temp = A[i]/2;
        if(temp%2)
        f1++;
        else
        {
            f2++;
        }
       
    }
    if(f1&&f2)
    {
        cout<<0;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        if(i==0)
        lm=A[i]/2;
        else
        {
            lm = lcm(lm,A[i]/2);
            
        }
    }
  
    bool ano=true;
    for(int i=0;i<n;i++)
    {
        int div = A[i]/2;
        div = lm/div;
        if(div%2==0)
        ano=false;
    }
    if(!ano)
    {
        cout<<0;
        return 0;
    }
    int cnt=-1;
    for(int z=m+1;z>0;z=z/2)
    {
        while(chk(cnt+z))
        cnt+=z;
    }
    
    cout<<cnt;

    

return 0;
}

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
const int MAX=15,width=100,height=50,depth=30;

int N,M,L;
int B[MAX],F[MAX],P[MAX];
double H[MAX],A[MAX],T[MAX],sum[MAX],ans[MAX];

void f(int id,int l,int r,double &w){
    if (r-l>1){
        int mid=max_element(H+l+1,H+r)-H;
        if (id<mid){
            f(id,l,mid,w);
            f(id,mid,r,w);
        } else {
            f(id,mid,r,w);
            f(id,l,mid,w);
        }
    }
    double wall=min(H[l],H[r]),bottle=B[r]-B[l];
    if (wall<ans[l]) return;
    if (ans[l]+w/bottle<wall){
        for (int i=l;i<r;++i) ans[i]+=w/bottle;
        w=0;
    } else {
        w-=(wall-ans[l])*bottle;
        for (int i=l;i<r;++i) ans[i]=wall;
    }
}

void solve(){
    for (int i=0;i<=N;++i) sum[i]=0;
    for (int i=0;i<M;++i){
        int pos=upper_bound(B,B+N+1,F[i])-B-1;
        sum[pos]+=A[i];
    }
    for (int i=0;i<L;++i){
        for (int j=0;j<=N;++j) ans[j]=0;
        for (int j=0;j<=N;++j){
            double W=sum[j]*T[i]/depth;
            f(j,0,N+1,W);
        }
        int pos=upper_bound(B,B+N+1,P[i])-B-1;
        cout << ans[pos] << '\n';
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int D; cin >> D;
    for (;D--;){
        cin >> N;
        B[0]=0,B[N+1]=width; H[0]=H[N+1]=height;
        for (int i=1;i<=N;++i) cin >> B[i] >> H[i];
        cin >> M;
        for (int i=0;i<M;++i) cin >> F[i] >> A[i];
        cin >> L;
        for (int i=0;i<L;++i) cin >> P[i] >> T[i];
        solve();
    }
}


Measured memory_bytes: 3252
#include <bits/stdc++.h>
 
using namespace std;
 
int n,a[100001],b[100001],mmax;
 
int main()
{
	ios::sync_with_stdio(false);
 	cin.tie(0);cout.tie(0);
 	cin>>n;
 	for (int i=1;i<=n;i++)
    {
      	cin>>a[i];
    }
 	for (int i=n-1;i>=1;i--)
    {
		if(a[i]>=a[i+1]) b[i]=b[i+1]+1;
     	mmax=max(mmax,b[i]);
    }
  cout<<mmax;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main(){
	


	ll n; cin>>n; ll a;

 cout<<(-n%1000+1000)%1000;
	
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

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

ll n, x, a[100100];

int main(){
	ll ans = 0;
	cin >> n >> x;
	REP(i, n)cin >> a[i];
	REP(i, n - 1){
		if (a[i] + a[i + 1] > x){
			ll num = a[i] + a[i + 1] - x;
			ans += num;
			a[i + 1] -= num;
			if (a[i + 1] < 0)a[i + 1] = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
		
		int n = sn.nextInt();
		int k = sn.nextInt();
		int cnt = 0,cur = 1;
		while(cur <= n )
		{
			cur += 2;
			++cnt;
		}
		if( cnt >= k )
			System.out.println("YES");
		else
			System.out.println("NO");
		sn.close();
	}
}


Measured memory_bytes: 22740
#include <map>
#include <queue>
#include <cstdio>
using namespace std;
#define N 2005
#define V 40005
#define Inf (1<<30)
int lastNotCoprime[N];
int minOnSuff[N];
int a[N]; 
int ans[N];
bool b[N][N];
int comp[V];
int C;
int bestForCol[N];
map<int,int> primeId;
vector<int> g[V];
int n,m;
bool inAns[N];
int ansSz;
int gcd(int a,int b){
	if(b==0){
		return a;
	}
	return gcd(b,a%b);
}
int getId(int p){
	if(primeId.count(p)>0){
		return primeId[p];
	}
	primeId[p]=m;
	return m++;
}
void dfs(int v){
	comp[v]=C;
	int u;
	for(int i=0;i<(int)g[v].size();i++){
		u=g[v][i];
		if(comp[u]!=-1){
			continue;
		}
		if(u<n&&inAns[u]){
			continue;
		}
		dfs(u);
	}
}
void colors(){
	for(int i=0;i<m;i++){
		comp[i]=-1;
	}
	C=0;
	for(int i=0;i<n;i++){
		if(inAns[i]){
			continue;
		}
		if(comp[i]!=-1){
			continue;
		}
		dfs(i);
		C++;
	}
}
int mn(int a,int b){
	return a<b?a:b;
}
int main(){
	scanf("%d",&n);
	m=n;
	int x,id;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		x=a[i];
		for(int j=2;j*j<=x;j++){
			if(x%j!=0){
				continue;
			}
			id=getId(j);
			g[i].push_back(id);
			g[id].push_back(i);
			while(x%j==0){
				x/=j;
			}
		}
		if(x>1){
			id=getId(x);
			g[i].push_back(id);
			g[id].push_back(i);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(gcd(a[i],a[j])>1){
				b[i][j]=b[j][i]=1;
			}
		}
	}
	for(int i=0;i<n;i++){
		lastNotCoprime[i]=-1;
	}
	for(int i=0;i<n;i++){
		minOnSuff[i]=Inf;
	}
	while(ansSz<n){
		colors();
		for(int i=0;i<C;i++){
			bestForCol[i]=-1;
		}
		for(int i=0;i<n;i++){
			if(inAns[i]){
				continue;
			}
			if(minOnSuff[lastNotCoprime[i]+1]<a[i]){
				continue;
			}
			if(bestForCol[comp[i]]==-1||a[bestForCol[comp[i]]]>a[i]){
				bestForCol[comp[i]]=i;
			}
		}
		id=-1;
		for(int i=0;i<C;i++){
			if(bestForCol[i]==-1){
				continue;
			}
			if(id==-1||a[bestForCol[i]]>a[id]){
				id=bestForCol[i];
			}
		}
		ans[ansSz++]=a[id];
		inAns[id]=1;
		for(int i=0;i<ansSz;i++){
			minOnSuff[i]=mn(minOnSuff[i],a[id]);
		}
		for(int i=0;i<n;i++){
			if(b[id][i]){
				lastNotCoprime[i]=ansSz-1;
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("%d ",ans[i]);
	}
	puts("");
	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
int a[N];

void solve() {
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
    }
    sort(a, a+n);
    int m = a[n-1];
    printf("%d ", m);
    auto p = equal_range(a, a+n-1, m/2);
    if (*(p.first) != m/2) --p.first;
    if (p.second == a+n-1 || abs(*(p.first)-m/2) < abs(*(p.second)-m/2)) {
        printf("%d", *(p.first));
    } else {
        printf("%d", *(p.second));
    }
}

int main() {
    init();
    int t = 1; //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

int main() {
    string s;
    string t;
    int i, j;
    int temp, max;
    max = 0;
    cin >> s >> t;
    for(i = 0; i <= s.size() - t.size(); i ++){
        temp = 0;
        for(j = 0; j < t.size(); j ++){
            if(s[i + j] == t[j]){
                temp ++;
            }
        }
        if(max<temp){
            max = temp;
        }
    }
    cout << t.size() - max << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
typedef long long ll;
typedef pair<ll, ll> P;
map<long long, long long> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
signed main() {
    ll n;
    cin >> n;
    ll ini = n;
    ll length = 0;
    REP(i, 30) {
        n = n - modpow(26, i + 1);
        if (n <= 0) {
            length = i + 1;
            n = n + modpow(26, i + 1);
            break;
        }
    }
    // cout << length << endl;
    REP(i, length) {
        ll digit = 0;
        ll z = 0;
        REP(j, 27) {
            n = n - modpow(26, length - i - 1);
            digit++;
            if (n <= 0) {
                n += modpow(26, length - i - 1);
                z++;
                break;
            }
        }
        // cout << digit << endl;
        char ans = 'a' + digit - 1;
        if (z == 0) {
            cout << 'z';
            continue;
        }
        cout << ans;
    }
}

Measured memory_bytes: 3656
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,P = ilint()
ans = 0

def swap(i):
    global ans
    P[i],P[i+1] = P[i+1],P[i]
    ans += 1

for i in range(N-1):
    if P[i]==i+1:
        swap(i)
if P[-1]==N:
    swap(N-2)
print(ans)

Measured memory_bytes: 85496
a,b,m = map(int,input().split())
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
s = min(la) + min(lb)

for i in range (m):
    x,y,c = map(int,input().split())
    t = la[x-1]+lb[y-1]-c
    if t < s:
        s = t
    else:
        s = s

print (s)


Measured memory_bytes: 18612
//https://atcoder.jp/contests/abc148/tasks/abc148_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a;
	cin>>a;
	ll b;
	cin>>b;
	if((a==1)&&(b==2))
	{
		cout<<"3"<<"\n";
	}
	else if((a==2)&&(b==1))
	{
		cout<<"3"<<"\n";
	}
	else if((a==2)&&(b==3))
	{
		cout<<"1"<<"\n";
	}
	else if((a==3)&&(b==2))
	{
		cout<<"1"<<"\n";
	}
	else if((a==1)&&(b==3))
	{
		cout<<"2"<<"\n";
	}
	else
	{
		cout<<"2"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;

int n;
char s[21][1000000];

int main(){
	int i,j,len;
	char bef,now;
	int cnt,cor;
	
	while(1){
		cin >> n >> s[0];
		if( !n )break;
		
		for( i = 0; i < n; i++ ){
			len = strlen(s[i]);
			cnt = 1;
			cor = 0;
			bef = s[i][0];
			for( j = 1; j < len; j++ ){
				now = s[i][j];
				if( bef == now ){
					cnt++;
				}
				else{
					cor += sprintf(s[i+1]+cor,"%d%c",cnt,bef);
					cnt = 1;	//すでに新しい文字を1文字読み込んでいる
				}
				bef = now;
			}
			cor += sprintf(s[i+1]+cor,"%d%c",cnt,bef);
			//s[i+1]を何回でも使えるようにする工夫
			s[i+1][cor] = '\0';
		}
		cout << s[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 19644
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<iomanip>

using namespace std;

#define INF 999999999

int main(){
	int ans, i, j, k, e;
	while(1){
		cin >> e;
		if(!e)break;
		ans=INF;
		for(i=0;i*i*i<=e;i++){
			for(j=0;i*i*i+j*j<=e;j++){
				if(i+j+(e-i*i*i-j*j) < ans){
					ans = i+j+(e-i*i*i-j*j);
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxn = 305;

int n, k, m;
int f[maxn][maxn], g[maxn][maxn], C[maxn][maxn];

inline int add(int x, int y){ return (x + y) % m; }
inline int mul(int x, int y){ return 1ll * x * y % m; }
inline void uadd(int &x, int y){ (x += y) %= m; }

int main(){
	scanf("%d%d%d", &n, &k, &m);

	REP(i, 0, n + 1){
		C[i][0] = 1;
		REP(j, 1, i)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
	}

	REP(i, 1, n + 1) for(int u = k; u >= 0; --u){
		if(i == 1)
			f[i][u] = 1;
		else{
			FOR(j, 0, i)
				uadd(f[i][u], mul(mul(f[i - j][u], C[i - 2][j - 1]), g[j][u + 1]));
		}
		g[i][u] = add(g[i][u + 1], f[i][u]);
	}

	printf("%d\n", f[n + 1][0]);
	return 0;
}


Measured memory_bytes: 4828
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a[150][150],n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	LL sum;
	sum=ans=0;
	LL t=1;
	for(int  i=1;i<=n;i++){
		sum=0;
		for(int k=1;k<=n;k++){
			if(k<t)
				sum+=a[1][k];
			else{
				sum+=a[2][k];
			}
		}
		sum+=a[1][t];
		ans=max(sum,ans);
		t++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
 
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
using namespace std;
 
const int MX = 100 * 1000 + 7;
const int MOD = 1000 * 1000 * 1000 + 7;
 
vector<int> g[MX];
int f[MX][2];
 
void dfs(int v, int p) {
    f[v][0] = f[v][1] = 1;
    for (int to : g[v]) {
        if (to != p) {
            dfs(to, v);
            f[v][0] = (1ll * f[v][0] * (f[to][0] + f[to][1])) % MOD;
            f[v][1] = (1ll * f[v][1] * f[to][0]) % MOD;
        }
    }
}
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
 
    dfs(1, -1);
 
    cout << (f[1][0] + f[1][1]) % MOD << "\n";
    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
 
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
typedef long long LL;
 
using namespace std;

static const int NMAX = 50000;
static const int MMAX = 20;
static const int INFITY = 1 << 29;

int main(){
	int n, m, C[MMAX+1], T[NMAX+1];
	cin >> n >> m;
	FOR(i,0,m){
		cin >> C[i];
	}

	FOR(j,0,NMAX){
		T[j] = INFITY;
	}

	T[0] = 0;
	//cout << C[0];
	FOR(i,0,m){
		FOR(j,C[i],n+1){
			T[j] = min(T[j], T[j-C[i]] + 1);
		}
	}

	cout << T[n] << endl;

	return 0;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MaxN = 302;
const double eps = 1e-9;
double dp[MaxN][MaxN][MaxN];
int N;

double rec(int one ,int two , int three){

    if(one<0 || two<0 || three<0) return 0;
    if(!one  && !two && !three) return 0;
    auto &ret = dp[one][two][three];
    if( ret+1.0 > eps ) return ret;
    int cur =  one+two+three;
    ret = N + one * rec(one-1,two,three) + two * rec(one+1,two-1,three) + three * rec(one,two+1, three-1);
    return ret = (ret*1.0) / cur;

}

void solve(){

    cin>>N;
    memset(dp,-1,sizeof dp);
    int one = 0, two = 0 , three = 0;
    for(int i=0; i<N; i++){
        int val;
        cin>>val;
        if(val==1) one++;
        else if(val==2) two++;
        else three++;
    }

    cout<<fixed<<setprecision(15)<< rec(one, two, three) <<"\n";
}


int main(){

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();

    return 0;
}


Measured memory_bytes: 219032
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var C = new int[100];
		string s;
		int max = 0;
		
		while( null != ( s = Console.ReadLine()) ) {
			var n = int.Parse(s);
			C[n - 1]++;
			max = Math.Max(max, C[n-1]);
		}
		
		for(int i = 0; i < 100; i++) {
			if(C[i] == max)	Console.WriteLine(i+1);
		}
	}

}

public struct Vector
{
	public double X,Y;
}

Measured memory_bytes: 9020
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   string s;
   cin >> s;
   vector< vector<int> > v(26);
   int N = s.size();
   for (int i = 0; i < N; i++) {
      int id = s[i] - 'a';
      v[id].push_back(i);
   }
   int ans = N;
   for (int i = 0; i < 26; i++) {
      int M = v[i].size();
      if (M == 0) continue;
      int MAX = v[i][0];
      for (int j = 1; j < M; j++) {
         int cur = v[i][j] - v[i][j - 1] - 1;
         chmax(MAX, cur);
      }
      int cur = N - v[i][M - 1] - 1;
      chmax(MAX, cur);
      chmin(ans, MAX);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        static void Main(){
            long n = ILongs()[0];
            long[] a = ILongs();
            long[] b = ILongs();
            long[] c = ILongs();

            long ans = 0;

            for(int i=0;i<n;i++){
                ans += b[i];
            }

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

            WriteLine(ans);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main()
{
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll cnt=0;
    while(n>0){
        n=n/k;
        cnt++;
    }
    cout<<cnt<<endl;
}





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

int main(){
    int H, W, K; cin >> H >> W >> K;
    vector<vector<int>> c(H, vector<int>(W));
    rep(i, H) rep(j, W){
        char tmp; cin >> tmp;
        if(tmp == '.'){
            c[i][j] = 0;
        }
        else{
            c[i][j] = 1;
        }
    }
    int ans = 0;
    rep(i, pow(2, H)){
        vector<vector<int>> c_tmp = c;
        rep(j, H){
            if(i >> j & 1){
                rep(k, W){
                    c_tmp[j][k] = 3;
                }
            }
        }
        rep(a, pow(2, W)){
            vector<vector<int>> c_tmp2 = c_tmp;
            rep(b, W){
                if(a >> b & 1){
                    rep(c, H){
                        c_tmp2[c][b] = 3;
                    }
                }
            }
            int blk_cnt = 0;
            rep(x, H){
                rep(y, W){
                    if(c_tmp2[x][y] == 1){
                        blk_cnt++;
                    }
                }
            }
            if(blk_cnt == K){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    reverse(whole(s));
    while (s.size()<3) {
        s += '0';
    }
    s += "CBA";
    reverse(whole(s));
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long INF=pow(2,31)-1;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long P_SIZE=301;
const long MAX_N=100004;
long packet[401];
long arr[MAX_N];

long find(long x,long y){
	long res=INF;
	if(floor(x/P_SIZE)==floor(y/P_SIZE)){//1???????????±??????????????¨??§?????????
		FOR(i,x,y+1){
			res=min(res,arr[i]);
		}
		return res;
	}
	long pb=x/P_SIZE+1;//???????????????????????±??????????¬?????????±????????????
	long pd=y/P_SIZE-1;//??????????????¨?????????????????????????????±??????
	FOR(i,x,min(pb*P_SIZE,y+1)){
		res=min(res,arr[i]);//????????????
	}
	if(pb<=pd)FOR(i,pb,pd+1){
		//cout<<"!2"<<endl;
		res=min(res,packet[i]);//?????±????????????????????????
	}
	FOR(i,max(pd*P_SIZE,x),y+1){
		//cout<<"!3"<<endl;
		res=min(res,arr[i]);//????????????
	}
	return res;
}

void update(long x,long y){
	arr[x]=y;
	long pb=floor(x/P_SIZE);//?????????????±????????????±??????
	packet[pb]=INF;
	FOR(i,pb*P_SIZE,(pb+1)*P_SIZE){
		packet[pb]=min(packet[pb],arr[i]);
	}

}

int main(){
	int N,Q;
	cin>>N>>Q;
	fill(packet,packet+401,INF);
	fill(arr,arr+MAX_N,INF);
	
	REP(i,Q){
		long c,x,y;
		cin>>c>>x>>y;
		if(c==0){
			update(x,y);
		}else{
			cout<<find(x,y)<<endl;
		}
	}
	//REP(i,SZ(res))cout<<res[i]<<endl;
	return 0;
}

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

using namespace std;

int main(void)
{
    int num;

    cin >> num;

    long long odd_count = 0;
    int up_border = 10;
    int bottom_border = 1;

    while(bottom_border <= num){
        if(up_border > num){
            odd_count += num - bottom_border + 1;
        }else{
            odd_count += up_border - bottom_border;
        }

        up_border *= 100;
        bottom_border *= 100;
    }

    cout << odd_count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(stoi(s.substr(5,2))>=5){
        cout << "TBD";
    }
    else{
        cout << "Heisei";
    }


    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
txys = [[0, 0, 0], *n.times.map { gets.split.map(&:to_i) }]

ans = "Yes"
n.times do |i|
  rt, rx, ry = txys[i + 1]
  lt, lx, ly = txys[i]

  t = rt - lt
  x = (rx - lx).abs
  y = (ry - ly).abs

  if x + y > t
    ans = "No"
    break
  end

  t -= (x + y)
  if t.odd?
    ans = "No"
    break
  end
end

puts ans


Measured memory_bytes: 10364
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  copy_n(istream_iterator<string>(cin), H, C.begin());
  for (auto& s : C) {
    cout << s << endl;
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        x: i64,
        y: i64,
    }

    let mut f = false;
    for i in 0..x+1 {
        if y == 2*i+4*(x-i) {
            f = true;
            break;
        }
    }

    if f {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
const double EPS = 1e-8;
typedef vector<Point> Polygon; // 反時計回りを仮定
double cross(Point a, Point b){
    return imag(conj(a) * b);
}
Point curr(const Polygon& a, int x){ return a[x]; }
Point next(const Polygon& a, int x){ return a[(x + 1) % a.size()]; }
double area(const Polygon& P) {
    double A = 0;
    for(int i = 0; i < P.size(); i++){
        A += cross(curr(P, i), next(P, i));
    }
    return abs(A) / 2.0;
}


int main(){
    int n;
    int casenum = 0;
    while(cin >> n && n){
        vector<Point> ps(n);
        REP(i, n){
            double x, y;
            cin >> x >> y;
            ps[i] = Point(x, y);
        }
        printf("%d %.1f\n", ++casenum, area(ps));
    }
    return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,f[MAX];
int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
vector<int> E[MAX];
int U[MAX],V[MAX],a[MAX];
void dfs(int u,int ff){for(int v:E[u])if(v!=ff)dfs(v,u),a[u]^=a[v];}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=m;++i)
	{
		int u=read(),v=read();
		if(getf(u)!=getf(v))
			E[u].push_back(v),E[v].push_back(u),f[getf(u)]=getf(v);
		U[i]=u;V[i]=v;
	}
	for(int i=1;i<=n;++i)
		if(getf(i)!=getf(1))E[1].push_back(i),E[i].push_back(1),f[getf(i)]=getf(1);
	for(int i=1;i<=m;++i)
	{
		int u=U[i],v=V[i];
		a[u]^=1;a[v]^=1;
	}
	dfs(1,0);
	for(int i=1;i<=n;++i)if(a[i]){puts("NO");return 0;}
	puts("YES");
	return 0;
}


Measured memory_bytes: 7548
/*
 * Copyright (c) 2019 ... All rights reserved.
 * ...
 */
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {

    // source code
    int N = inputValue();
    int Y = inputValue();

    bool flag = false;
    rep(i, N+1){
        rep(j, N+1){
            int senen = N - i - j;
            if(senen < 0) break;
            if(10000*i + 5000*j + 1000*senen == Y){
                cout << i << ' ' << j << ' ' << senen << endl;
                flag = true;
                break;
            }
        }
        if(flag){
            break;
        }
    }

    if(!flag) cout << -1 << ' ' << -1 << ' ' << -1 << endl;


    return 0;
}

Measured memory_bytes: 256