akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int c = 1;
  FOR(i, 0, n){
    int a;
    cin >> a;
    if(c==a) c++;
  }
  cout << (c==1 ? -1 : n-c+1) << endl;
}

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

#define ri register int
#define sid 200050

char s[sid];
int nxt[sid][26], f[sid];

int main() {

    scanf("%s", s + 1);
    int n = strlen(s + 1);

    for(ri i = 0; i < 26; i ++) nxt[n][i] = n + 1;
    for(ri i = n - 1; i >= 0; i --) {
        for(ri j = 0; j < 26; j ++) nxt[i][j] = nxt[i + 1][j];
        nxt[i][s[i + 1] - 'a'] = i + 1;
    }

    for(ri i = n; i >= 0; i --) {
        f[i] = 1e9;
        for(ri j = 0; j < 26; j ++)
        f[i] = min(f[i], 1 + f[nxt[i][j]]);
    }

    int o = 0;
    while(o != n + 1) {
        for(ri j = 0; j < 26; j ++)
        if(f[o] == f[nxt[o][j]] + 1) {
            o = nxt[o][j]; 
            printf("%c", j + 'a'); break;
        }
    } 
    return 0;
}

Measured memory_bytes: 21504
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

ll a;
ld b;

void input() {
  cin >> a >> b;
}

void solve() {
  cout << (a * (ll)round(b * 100)) / 100ll << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


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



int main() {
  int H,W,N,p;
  cin>>H>>W>>N;
  p=max(H,W);
  cout<<(N-1)/p+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    int left = a + b, right = c + d;

    if (left < right) {
        cout << "Right" << endl;
    } else if (left > right) {
        cout << "Left" << endl;
    } else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	public static void Main()
	{
		var valueList = ReadLines();
		
		//
		var intList = new List<int>();
		var count = 0;
		var result = 0;
		foreach(var val in valueList){
			count++;
			if(count == 2){				
				foreach(var s in  val.Trim().Split(' ')){
						intList.Add(Convert.ToInt32(s));
				}
				result = intList.Max() - intList.Min();
			}			
		}
		Console.WriteLine(result);
	}
	
	
	static List <string> ReadLines(){
		var list = new List<string>();
		while (true)
		{
			string line = Console.ReadLine();
			if (string.IsNullOrEmpty(line)){
				break;
			}
			
			list.Add(line);
		}
		return list;
	}
	
}


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

int main()
{
    int K;
    string S;
    cin >> K;
    cin >> S;
    string R;
    if(S.size() <= K){
        R = S;
    }
    else{
        R = S.substr(0,K)+"...";
    }
    cout << R << endl;
}

Measured memory_bytes: 3600
package main

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

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

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

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

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

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

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

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

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

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

type Card struct {
	pattern string
	num     int
	count   int
}

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	cards := make([]Card, N)
	found := make(map[string]int)
	for i := 0; i < N; i++ {
		p, n := sc.nextStr(), sc.nextInt()
		str := strconv.Itoa(n)
		found[str]++
		cards[i] = Card{p, n, found[str]}
	}
	quickSort(cards, 0, N-1)

	ok := true
	found = make(map[string]int)
	for _, c := range cards {
		str := strconv.Itoa(c.num)
		found[str]++
		if c.count != found[str] {
			ok = false
		}
	}
	if ok {
		fmt.Fprintln(wtr, "Stable")
	} else {
		fmt.Fprintln(wtr, "Not stable")
	}
	for _, c := range cards {
		fmt.Fprintln(wtr, c.pattern, c.num)
	}
	wtr.Flush()
}

func quickSort(A []Card, p, r int) {
	if p < r {
		q := partition(A, p, r)
		quickSort(A, p, q-1)
		quickSort(A, q+1, r)
	}
}

func partition(A []Card, p, r int) int {
	x := A[r].num
	i := p - 1
	for j := p; j < r; j++ {
		if A[j].num <= x {
			i = i + 1
			A[i], A[j] = A[j], A[i]
		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}



Measured memory_bytes: 11168
#include <bits/stdc++.h>
using namespace std; 
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	a=a+b+c;
	if(a>=22)cout<<"bust"<<endl;
	else cout<<"win"<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 256
#include<cstdio>
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0;bool f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
ll a,b,c;
int main()
{
    a=read(),b=read(),c=read();
    if(a+b>=c) puts("No");
    else
    {
        ll d=(c-a-b)*(c-a-b);
        puts(4*a*b<d?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 128
<?php
  $a = trim(fgets(STDIN));
  $i = 3;
  while ($i <= $a) {
    if (($i % 3) == 0) {
      print (" " . $i);
    } else if (($i % 10) == 3) {
      print (" " . $i);
    } else if (strstr($i, '3')) {
      print (" " . $i);
    }
    $i++;
  }
?>

Measured memory_bytes: 6548
n,m = map(int, input().split())
ans = n*m
n,m = min(n,m), max(n,m)

if n == 1:
    if m == 1:
        print(1)
    else:
        print(m-2)
    exit()

tmp = n + m - 2
print(ans - tmp * 2)


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

int main()
{
    int x = 0, ans = 0, n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I') x++;
        else x--;
        ans = max(x, ans);
    }
    cout << ans << endl;
}

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

int main() {
	int n;
	int a[200000];
	cin >> n;
	int ans = 0;
	int max = 0;
	int max2 = 0;
	int b = 0;
	for (int i = 0; i != n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			max = a[i];
			b = i;
		}
	}
	for (int i = 0; i != n; i++) {
		if (a[i] > max2) {
			if (a[i] == max) {
				if (b != i) {
					max2 = a[i];
				}
			}
			else {
				max2 = a[i];
			}
		}

	}
	for (int i = 0; i != n; i++) {
		if (b == i) {
			cout << max2 << '\n';
			continue;
		}
		cout << max << "\n";
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,X;
  while(cin >> N >> X){
    vector<int> L(N); cin >> L;

    int ans = 0;

    vector<bool> b(100000);

    b[0] = true;
    int t = 0;
    REP(i,N){
      t += L[i];
      b[t] = true;
    }

    FORE(i,0,X) if(b[i]) ++ans;
    

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,k;
    cin >> n >> k;
    vi l(n);
    rep(i,n) cin >> l.at(i);
    sort(l.begin(), l.end(), greater<>());
    int64_t res = 0;
    rep(i,k){
        res += l.at(i);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
def p_facto(n):
    ret = []
    nc = n
    for i in range(2, nc):
        if i*i > nc:
            break
        if n % i == 0:
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            ret.append([i, ex])
    if n != 1:
        ret.append([n, 1])
    return ret


def main(N):
    ans = 0
    for p, e in pf:
        ex = 1
        while True:
            z = p**ex
            if N % z == 0:
                ans += 1
                N //= z
            else:
                break
            ex += 1
    print(ans)


if __name__ == "__main__":
    N = int(input())
    pf = p_facto(N)
    main(N)



Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  
  vector<int> v;

  for(int i=1;i*i<=n;i++){
    if(n%i==0){
      v.pb(i);
      if(i!=n/i) v.pb(n/i); 
    }
  }

  sort(all(v));

  int ans = 1e18;

  for(int i=0;i<v.size();i++){
    int x = v[i];
    int y = n/v[i];
    int dis = x-1+y-1;
    ans = min(ans,dis);
  }
  
  cout << ans;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &) { ris; }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;
int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = {-1, 1, 0, 0, 1, -1, -1, 1};
void solve();
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.setf(ios::fixed);
    cout.precision(20);
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}

const int mxn = 2e5+10;
int parent[mxn];
int siz1[mxn];
int n, q;

int find(int x) {
	if(parent[x] == x)
	return x;
	return parent[x] = find(parent[x]);
}

void union1(int x, int y) {
	x=find(x), y=find(y);
	if(parent[x] == parent[y])
	return;
	parent[x]=y;
}

void solve() {
    cin >> n >> q;
    for(int i=0; i<n; ++i) parent[i]=i;
    for(int i=0; i<q; ++i) {
    	int a, x, y;
    	cin >> a >> x >> y;
    	if(a == 0) {
    		union1(x, y);
    	}else{
    		if(parent[find(x)] == parent[find(y)]) {
    			cout << 1 << "\n";
    		}else{
    			cout << 0 << "\n";
    		}
    	}
    }
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template <typename T,bool isMin>
struct ConvexHullTrick {
  #define F first
  #define S second
  using P = pair<T, T>;
  deque<P> H;
  bool empty()const{return H.empty();}
  void clear(){H.clear();}

  inline Int sgn(T x){return x==0?0:(x<0?-1:1);}
  
  using D = long double;
  inline bool check(const P &a,const P &b,const P &c){
    if(b.S==a.S||c.S==b.S)
      return sgn(b.F-a.F)*sgn(c.S-b.S) >= sgn(c.F-b.F)*sgn(b.S-a.S);
    
    //return (b.F-a.F)*(c.S-b.S) >= (b.S-a.S)*(c.F-b.F);
    return
      D(b.F-a.F)*sgn(c.S-b.S)/D(abs(b.S-a.S)) >=
      D(c.F-b.F)*sgn(b.S-a.S)/D(abs(c.S-b.S));
  }  
  
  void addLine(T m,T b){
    if(!isMin) m*=-1,b*=-1;
    P line(m,b);
    if(empty()||H.front().F<=m){
      while(H.size()>=2&&check(line,H.front(),H[1])) H.pop_front();
      H.emplace_front(line);
    }else{
      assert(m<=H.back().F);      
      while(H.size()>=2&&check(H[H.size()-2],H.back(),line)) H.pop_back();
      H.emplace_back(line);
    } 
  }
  
  inline T getY(const P &a,const T &x){
    return a.F*x+a.S; 
  }

  T query(T x){
    assert(!empty());
    Int l=-1,r=H.size()-1;
    while(l+1<r){
      Int m=(l+r)>>1;
      if(getY(H[m],x)>=getY(H[m+1],x)) l=m;
      else r=m;
    }
    if(!isMin) return -getY(H[r],x);
    return getY(H[r],x);
  }

  T queryMonotoneFromLeft(T x){
    assert(!empty()); 
    while(H.size()>=2&&getY(H.front(),x)>=getY(H[1],x)) H.pop_front();
    if(!isMin) return -getY(H.front(),x);
    return getY(H.front(),x);
  }
  
  T queryMonotoneFromRight(T x){
    assert(!empty());
    while(H.size()>=2&&getY(H.back(),x)>=getY(H[H.size()-2],x)) H.pop_back();
    if(!isMin) return -getY(H.back(),x);
    return getY(H.back(),x);
  }
  
  T queryMonotoneInc(T x){
    if(!isMin) return queryMonotoneFromRight(x);
    return queryMonotoneFromLeft(x);
  }
  
  T queryMonotoneDec(T x){    
    if(!isMin) return queryMonotoneFromLeft(x);
    return queryMonotoneFromRight(x);
  }
  #undef F
  #undef S
};

//INSERT ABOVE HERE
signed main(){
  using CHT = ConvexHullTrick<Int, true>;
  Int s,n,m;
  cin>>s>>n>>m;
  vector<Int> x(s);
  for(Int i=0;i<s;i++) cin>>x[i];

  const Int MAX = 1e4+10;
  vector<Int> t(n),p(n);  
  for(Int i=0;i<n;i++) cin>>t[i]>>p[i],t[i]+=MAX,p[i]--;

  const Int INF = 1e15;
  vector<Int> dp(MAX*2,0),cnt(MAX*2,0);
  for(Int i=0;i<MAX*2;i++){
    for(Int j=0;j<n;j++){
      if(i+x[p[j]]<t[j]) dp[i]=INF;
      else dp[i]+=i+x[p[j]]-t[j],cnt[i]++;
    }
  }
  for(Int j=1;j<m;j++){
    vector<Int> nx(MAX*2,INF);
    CHT cht;
    for(Int i=MAX*2-1;i>=0;i--){
      cht.addLine(-i,dp[i]);
      nx[i]=cht.queryMonotoneDec(cnt[i])+i*cnt[i];
    }
    swap(dp,nx);
  }
  cout<<*min_element(dp.begin(),dp.end())<<endl;
  return 0;
}



Measured memory_bytes: 3372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll dp1[12][1<<21];//前半
ll dp2[12][1<<21];//後半

int a[21][21];
int main()
{
	fill(dp1[0],dp1[11],0);
	fill(dp2[0],dp2[11],0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	}
	if(n==1)
	{
		if(a[0][0]==1)
			cout<<1<<endl;
		else
			cout<<0<<endl;
		return 0;
	}
	//dp1,dp2の初期化
	for(int i=0;i<n;i++)
	{
		if(a[0][i]==1)
			dp1[0][1<<i]=1;
	}
	for(int i=0;i<n;i++)
	{
		if(a[n/2][i]==1)
			dp2[0][1<<i]=1;
	}
	//dp1
	for(int i=1;i<n/2;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[i][j]==1)
			{
				for(int k=0;k<(1<<n);k++)
				{
					if(k&(1<<j))
						continue;
					dp1[i][k|(1<<j)]+=dp1[i-1][k];
				}
			}
		}
	}
	//dp2
	for(int i=n/2+1;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[i][j]==1)
			{
				for(int k=0;k<(1<<n);k++)
				{
					if(k&(1<<j))
						continue;
					dp2[i-n/2][k|(1<<j)]+=dp2[i-n/2-1][k];
				}
			}
		}
	}
	//merge
	ll ans=0;
	for(int k=0;k<(1<<n);k++)
	{
		ans+=dp1[n/2-1][k]*dp2[n-1-n/2][((1<<n)-1)^k];
		ans%=MOD;
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 364928
import java.util.Scanner;
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); boolean ans = false;
        for (int i = 0; i <= 100; i++) {
            if (a - d * i > 0 && c - b * (i + 1) <= 0) ans = true;
        }
        System.out.println(ans ? "Yes" : "No");
    }




}

Measured memory_bytes: 35768
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int x = abs(a-b);
  int y = abs(b-c);
  int z = abs(c-a);

  cout << min({ x+y, x+z, y+z }) << LF;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

  int x = tx-sx, y = ty-sy;
  
  rep(i, 0, x) cout << 'R';
  rep(i, 0, y) cout << 'U';
  rep(i, 0, x) cout << 'L';
  rep(i, 0, y) cout << 'D';
  cout << 'D';
  rep(i, 0, x+1) cout << 'R';
  rep(i, 0, y+1) cout << 'U';
  cout << "LU";
  rep(i, 0, x+1) cout << 'L';
  rep(i, 0, y+1) cout << 'D';
  cout << 'R' << endl;
  
}

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

int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++)
  {
    if (i % 3 == 0)
      continue;
    if (i % 5 == 0)
      continue;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.*;
public class Main{
 	public static void main(String[] args) {
 	    
		Scanner sc = new Scanner(System.in);
      	
      	int A = sc.nextInt();
      	int V = sc.nextInt();
      	int B = sc.nextInt();
      	int W = sc.nextInt();
      	int T = sc.nextInt();
      	
      	
      	double tt = 0;
      	
      	if(B>A){
      	    tt = (double)(B-A)/(V-W);
      	}else if(A>B){
      	    tt = (double)(A-B)/(V-W);
      	}
        if(T<tt){
            System.out.println("NO");
            return;
        }else if(W>V){
            System.out.println("NO");
            return;
        }
        
        System.out.println("YES");
      	
 	}
}


Measured memory_bytes: 35724
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000

using namespace std;
typedef long long ll;

char change(char c){
	if(c>='D')return (char)(c-3);
	else return 'Z'+(c-'C');
}

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		s[i]=change(s[i]);
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1180
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  string s;
  cin >> s;
  n = s.size();
  int t = 0;
  int l = n, r = 0;
  for(int i = 0; i < n; i++) {
    if(t == 0) {
      if(s[i] == 'A') {
        l = i;
        t = 1;
      }
    } else if(t == 1) {
      if(s[i] == 'Z') {
        r = i;
      }
    }
  }
  cout << max(r - l + 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

using namespace std;

int p[21];
int q[21];

int main(){
  for(int cc = 1; ; cc++){
    int n = getInt();
    int m = getInt();

    if(n + m == 0) break;

    REP(i,21) p[i] = q[i] = 0;
    p[0] = n;

    int *buff = p;
    int *next = q;

    for(int turn = 1; ; turn++){
      REP(i,m) next[i] = 0;
      REP(i,m){
	next[i + 1] += buff[i] / 2;
	next[0]     += buff[i] / 2;
	next[i]     += buff[i] % 2;
      }
      
      if(next[m]){
	printf("Case %d: %d\n", cc, turn);
	break;
      }

      swap(buff, next);
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int main()
{
	int a,b;
	ll ans=0;
	cin>>a>>b;
	if(a==1)
		ans+=3e5;
	else if(a==2)
		ans+=2e5;
	else if(a==3)
		ans+=1e5;
	if(b==1)
		ans+=3e5;
	else if(b==2)
		ans+=2e5;
	else if(b==3)
		ans+=1e5;
	if(a==1&&b==1)
		ans+=4e5;
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
"""inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]"""
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

def main():
    mod = 10 ** 9 + 7
    h, w = wi()
    a = grid(h)
    dp = [[0 for _ in range(w + 1)] for _ in range(h + 1)]
    dp[1][1] = 1
    # (H,W)へ行く場合の数は、(H−1,W),(H,W−1)へ行く場合の数の和
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if not (i == 1 and j == 1):
                if a[i - 1][j - 1] == '#':
                    dp[i][j] = 0
                else:
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod
    ans = dp[h][w]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 54900
# import sys
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(min(A+1, 1+X//500)):
    for k in range(min(B+1, 1+X//100)):
        for j in range(min(C+1, 1+X//50)):
            if X == 500*i+100*k+50*j:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
import math
a,b,h,m=map(int,input().split())
 
dh=30*h+m/2
dm=6*m
 
if dm==dh:
    rad=0
else:
    rad=abs(dm-dh)
    
if rad>180:
    rad=360-rad
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif 0<rad and rad<180:
    length=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad)))
 
elif rad==180:
    length=a+b
    
else:
    length=abs(a-b)
    
print(length)

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    int a, b;
    cin >> a >> b;

    if (a > 0) cout << "Positive" << endl;
    else if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else {
        a *= -1;
        b *= -1;
        if ((a - b) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define rep(i, n) for (int i = 0; i < (int)n; i++)
typedef long long ll;
const ll MOD = 1e9+7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e9;
const ll mlnf = -1e9;

void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();
int main(void){

    solve();
    return 0;
}

void solve(){
    // 入力

    int H, N;
    cin >> H >> N;

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    
    // dp[i][d]:= i 番目の魔法で d ダメージ与える時の使う魔力の最小値
    // ans = dp[N][D]
    vector<vector<ll>> dp(N+10, vector<ll>(H+10, lnf));
    dp[0][0] = 0;

    for (int i = 0; i < N; i++){
        for (int d = 0; d <= H; d++){
            chmin(dp[i+1][d], dp[i][d]);
            chmin(dp[i+1][min(A[i]+d, H)], dp[i+1][d] + B[i]);
        }
    }
    cout << dp[N][H] << endl;

}


Measured memory_bytes: 79360
#include <cstdio>
#include <iostream>
#include <string>

int main() {
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    if (b - a <= 0) {
        puts("delicious");
    }
    else if (b - a <= x) {
        puts("safe");
    }
    else if (b - a > x) {
        puts("dangerous");
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for k in range(a+1):
  for j in range(b+1):
    for i in range(c+1):
      if 50*i+100*j+500*k==x:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#pragma comment(linker,"/STACK:1024000000,1024000000")
using namespace std;
#define PB pop_back
#define PF pop_front
#define np next_permutation
#define eb emplace_back
#define pb push_back
#define bf push_front
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define Forn(i, a) for(int i=1; i<=a; i++)
#define INF 1e9
#define memINF 127
#define inf 1e18
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 

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

using namespace std;

inline int in() 
{
    int x=0, c;
    for(; (uint)((c=getchar())-'0')>=10;) 
	{ 
		if(c=='-') 
			return -in(); 
		if(!~c)
			throw ~0; 
	}
    do 
	{ 
		x=(x<<3)+(x<<1)+(c-'0'); 
	} 
	while((uint)((c=getchar())-'0')<10);
    return x;
}
inline int gcd(int a, int b){if(a>b) swap(a, b); return a==0?b:gcd(b%a, a);}
inline int lcm(int a, int b){return a*b/gcd(a, b);}

int N, M, T, sum[2005][2005], ud[2005][2005], lr[2005][2005], x, y, xx, yy, res;
char grid[2005][2005];

int main()
{
	N=in(), M=in(), T=in();
	Forn(i, N)
		Forn(j, M)
		{
			grid[i][j]=getchar();
			while(grid[i][j]!='0'&&grid[i][j]!='1')
				grid[i][j]=getchar();
			sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+(grid[i][j]=='1');
			lr[i][j]=lr[i-1][j]+lr[i][j-1]-lr[i-1][j-1]+(grid[i][j]=='1'&&grid[i][j-1]=='1');
			ud[i][j]=ud[i-1][j]+ud[i][j-1]-ud[i-1][j-1]+(grid[i][j]=='1'&&grid[i-1][j]=='1');
		}
	while(T--)
	{
		x=in(), y=in(), xx=in(), yy=in();
		res=sum[xx][yy]-sum[xx][y-1]-sum[x-1][yy]+sum[x-1][y-1];
		res-=lr[xx][yy]-lr[xx][y]-lr[x-1][yy]+lr[x-1][y];
		res-=ud[xx][yy]-ud[xx][y-1]-ud[x][yy]+ud[x][y-1];
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 52864
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  int x,t;
  cin >> x >> t;
  if ((x-t)>0)
  {
      cout << x-t << endl;
  }else{
      cout << '0' << endl;
  }
  
  
  
    


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	q := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&q[i])
	}
	ans := order(p) - order(q)
	if ans < 0 {
		ans *= -1
	}
	fmt.Println(ans)
}

func order(nums []int) int {
	result := 0
	n := len(nums)
	isUsed := make([]bool, n)
	for i, num := range nums {
		if sort.IsSorted(sort.IntSlice(nums[i:])) {
			return result + 1
		}
		result += (numUsed(isUsed, num) - 1) * factorial(n-i-1)
		isUsed[num-1] = true
	}
	return -1
}

func factorial(i int) int {
	if i == 0 {
		return 1
	}
	return i * factorial(i-1)
}

func numUsed(list []bool, i int) int {
	count := 0
	for j := i - 1; j > -1; j-- {
		if !list[j] {
			count++
		}
	}
	return count
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define mod 1000000007
#define MAXN 200001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


void solve()
{
    int n,m;
    cin>>n>>m;
    v<float> a(n,0);
    float sum = 0.0;
    for(int i = 0 ; i < n ; i++)
    {
        cin>>a[i];
        sum += 1.0*a[i];    
    }
    sort(a.rbegin(),a.rend());
    bool flag = false;
    float temp = (sum*0.25)/m;
    for(int i = 0 ; i < m ; i++)
    {
        if(a[i] >= temp)
        continue;
        else
        {
            flag = true;
            break;
        }
    }
    if(flag)
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }
}

int main()
{
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


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

  vector<vector<ll>> v(3, vector<ll>(n));
  REP(i,n)cin >> v[0][i] >> v[1][i] >> v[2][i];

  ll ans=-1;
  REP(i,8){
    vector<pair<ll, int>> arr;
    REP(j,n){
      ll tmp=0;
      REP(k,3){
        if(i>>k & 1){
          tmp += v[k][j];
        }else{
          tmp -= v[k][j];
        }
      }
      arr.push_back(make_pair(tmp, j));
    }
    sort(ALL(arr));
    reverse(ALL(arr));

    ll x=0;
    ll y=0;
    ll z=0;

    REP(j,m){
      x+= v[0][arr[j].second];
      y+= v[1][arr[j].second];
      z+= v[2][arr[j].second];
    }
    ans=max(ans,abs(x)+abs(y)+abs(z));
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{
    ll n , m ;
    scanf ("%lld%lld" , &n ,&m );
    ll ans = n * m ;
    if (min(n , m) > 1 )
    {
        ans = ans - (  2*m + 2*n - 4  );
    }else if (n != m && min (m,n) == 1 )
    ans-=2 ;
    printf ("%lld\n" ,ans );


}


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

int main(){
    int n, m;
    cin >> n >> m;
    int road[60] = {};
    
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        road[a]++;
        road[b]++;
    }
    
    for(int i = 1; i <= n; i++){
        cout << road[i] << endl;
    }
    
    return 0;
}
    

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d,g; cin>>d>>g;
    vi p(d),c(d);
    rep(i,d) cin>>p[i]>>c[i];
    int ans=INT_MAX;
    rep(s,1<<d){
        int cnt=0;
        ll score=0;
        rep(i,d)if(s>>i&1){
            cnt+=p[i];
            score+=(ll)(i+1)*100*p[i];
            score+=c[i];
        }
        if (score<g){
            RFOR(i,d-1,0){
                if (s>>i&1) continue;
                ll diff = g-score;
                ll need = (diff+(i+1)*100-1)/((i+1)*100);
                if (need<=p[i]){
                    cnt+=need;
                    break;
                }else{
                    cnt+=p[i];
                    score+=(ll)(i+1)*100*p[i];
                }
            }
        }
        chmin(ans,cnt);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
//typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
//#define int long long

#define INF 1000000000000000000

int main() {
	lint V, E;
	cin >> V >> E;
	vector<vector<lint>>G(V, vector<lint>(V));
	rep(i, V) {
		rep(j, V) {
			if (i != j) {
				G[i][j] = INF;
			}
		}
	}
	rep(i, E) {
		lint s, t, d;
		cin >> s >> t >> d;
		G[s][t] = d;
	}
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	rep(i, V) {
		if (G[i][i] != 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
	}
	rep(i, V) {
		rep(j, V) {
			if (G[i][j] >= INF/100) {
				cout << "INF";
			}
			else {
				cout << G[i][j];
			}
			if (j == V - 1) {
				cout << endl;
			}
			else {
				cout << ' ';
			}
		}
	}
}


Measured memory_bytes: 3248
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, K;
const int MAX_N = 2010;
vector<int> edges[MAX_N];
int M;
int res;
void dfs(int pos, int pre, int len)
{
    // cerr << pos << " "<< pre << " " << len << endl;
    if (len > M)
    {
        res++;
    }

    for (auto &val : edges[pos])
    {
        if (val == pre)
        {
            continue;
        }
        dfs(val, pos, len + 1);
    }
}
int main()
{
    cin >> N >> K;
    M = K / 2;
    rep(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    int result = INF;
    for (int i = 0; i < N; i++)
    {
        if (K % 2 == 0)
        {
            res = 0;
            dfs(i, -1, 0);
            result = min(result, res);
        }
        else
        {
            for (int p : edges[i])
            {
                
                int res1,res2;
                
                res = 0;
                dfs(i, p, 0);
                res1 = res;

                res = 0;
                dfs(p, i, 0);
                res2 = res;
                result = min(result, res1 + res2);
            }
            
        }
        // cerr << "i = " << i << " res = " << res << endl;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> buka(n);
  int ai;
  int i;
  for (i = 1; i <n; i++) {
    cin >> ai;
    buka[ai - 1]++;
  }
  for (i = 0; i <n; i++) {
    cout << buka[i] << endl;
  }

  return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  string ans = "Balanced";

  if((a+b) > (c + d)) ans = "Left";
  else if((a+b) != (c+d)) ans = "Right";

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<char> x(s.size());
    /*
    rep(i, s.size()) {
        x[i] = s[i];
    }
    */
    int rev = 0;
    vector<char> sa;
    vector<char> sb;
    rep(i, q) {
        int t;
        cin >> t;
        if (t==1) {
            rev += 1;
        }
        if (t==2) {
            int f;
            char c;
            cin >> f >> c;
            if (f==1) {
                if (rev%2) sb.push_back(c);
                else sa.push_back(c);
            }
            if (f==2) {
                if (rev%2) sa.push_back(c);
                else sb.push_back(c);
            }
        }
    }
    //cout << " a " << rev << endl;
    
    if (rev%2) {
        //cout << "bbb" << endl;
        rep(i, sb.size()) {
            cout << sb[sb.size()-1-i];
        }
        rep(i, s.size()) {
            cout << s[s.size()-1-i];
        }
        rep(i, sa.size()) {
            cout << sa[i];
        }
        cout << endl;
        return 0;
    }
    
    rep(i, sa.size()) {
        cout << sa[sa.size()-1-i];
    }
    cout << s;
    rep(i, sb.size()) {
        cout << sb[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 1148
N,M=gets.split.map &:to_i
a=gets.split.map(&:to_i).sort.reverse
border=a.inject(:+).to_f/(4*M)
b=a.first(M)
flg=true
b.each do |i|
  flg=false if i<border
end
puts flg ? 'Yes' : 'No'


Measured memory_bytes: 1788
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rept(i,s,n) for (int i = (s); i < (n); ++i)

#include <iostream>
#include <cmath>
#include <bitset>
#include <algorithm>
using namespace std;

int main(){
    
    string s;
    int k;
    cin >> k >> s;
    if(s.length()<= k){
    }else{
        int i;
        for(i=0;i<s.length()-k;++i){
            s.replace(k,s.length(),"");
            s += "...";
        }
    }
    cout << s << endl;


    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	set<ll>st;
 	for(ll i=0;i<n;i++)
 	{
 		ll x;
 		cin>>x;
 		st.insert(x);
 	}
 	if(st.size()==n)
 	{
 		cout<<"YES"<<endl;
 	}
 	else
 	{
 		cout<<"NO"<<endl;
 	}
    return 0;
}

Measured memory_bytes: 9600