akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
int n;
int main()
{
	geti(n);
	int mn=Imx,mx=0,ans=1;
	bool f=0;
	for(int i=1;i<=n;i++)
	{
		int x;
		geti(x);
		if(mx==0)mn=mx=x;
		else if(mn==mx)
		{
			if(x<mn)mn=x,f=0;
			else mx=x,f=1;
		}
		else
		{
			if(f)
			{
				if(x<mx)mn=mx=x,ans++;
				mx=max(mx,x);
			}
			else
			{
				if(x>mn)mn=mx=x,ans++;
				mn=min(mn,x);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct Sieve {
    int N;
    vector<int> min_factor;
    Sieve(int _N):N(_N) {
        min_factor.assign(N + 1,-1);
        int i = 2;
        for (; i*i <= N; ++i) {
            if (min_factor[i] < 0) {
                min_factor[i] = i;
                for (int p = i*i; p <= N; p += i) {
                    if (min_factor[p] < 0) min_factor[p] = i;
                }
            }
        }
        for (int j = i; j <= N; ++j) {
            if (min_factor[j] < 0) min_factor[j] = j;
        }
    }
    // M > 1 
    vector<pair<int,int>> factorization(int M) {
        vector<pair<int,int>> ret;
        while (M > 1) {
            int p = min_factor[M],e = 1;
            M /= p;
            while (p == min_factor[M]) {
                ++e;
                M /= p;
            }
            ret.emplace_back(p,e);
        }
        return ret;
    }
    int count_factor(int M) {
        int ans = 1;
        while (M > 1) {
            int p = min_factor[M],e = 1;
            M /= p;
            while (p == min_factor[M]) {
                ++e;
                M /= p;
            }
            ans *= (e + 1);
        }
        return ans;
    }
};

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

    int N; cin >> N;
    Sieve si(N);
    ll ans = 0;
    for (int c = 1; c < N;++c) {
        ans += (ll)si.count_factor(N - c);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 7060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K;
  cin>>N>>K;
  ll P[N], C[N];
  for(int i=0;i<N;++i) {
    cin>>P[i];
    P[i]--;
  }
  for(int i=0;i<N;++i) cin>>C[i];
  ll ans=-big;
  ll cycle[N], now;
  ll tmpans;
  ll get1[N];
  for(int i=0;i<N;++i) {
    now = i;
    get1[i] = 0;
    cycle[i] = -1;
    for(ll j=0;j<K;++j) {
      now = P[now];
      get1[i] += C[now];
      ans = max(ans, get1[i]);
      if(now==i) {
        cycle[i] = j+1;
        break;
      }
    }
  }
  ll num;
  for(int i=0;i<N;++i) {
    if(cycle[i]==-1 || get1[i]<=0) continue;
    get1[i] = (K/cycle[i]-1)*get1[i];
    now = i;
    num = K/cycle[i]-1;
    for(int j=0;j<K-num*cycle[i];++j) {
      now = P[now];
      get1[i] += C[now];
      ans = max(ans, get1[i]);
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3792
N = gets.to_i
As = gets.split.map(&:to_i)

# $stdout = File.open(File::NULL, "w")
MOD = 10 ** 9 + 7

def main
  as = As.reverse
  base = as.shift
  result = 0
  loop do
    n = as.shift
    return result if n.nil?
    result += base * n
    result %= MOD
    base += n
  end
end

STDOUT.puts main


Measured memory_bytes: 35364
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n, x, t;
	cin >> n >> x >> t;

	int ans = ((n - 1) / x + 1) * t;

	cout << ans << '\n';
	return 0;
}


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

int main() {
    vector<int> vec(5);
    for (int i = 0; i < 5; ++i) {
        cin >> vec[i];
    }

    for (int i = 0; i < 5; ++i) {
        if (vec[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  char c;
  int a, b; scanf("%d %c %d", &a, &c, &b);
  if(c=='+')  cout << a+b << endl;
  else  cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 256
Code = {" " => "101", "'" => "000000", "," => "000011", "-" => "10010001", "." => "010001", "?" => "000001", "A" => "100101", "B" => "10011010",
  "C" => "0101", "D" => "0001", "E" => "110", "F" => "01001", "G" => "10011011", "H" => "010000", "I" => "0111", "J" => "10011000",
  "K" => "0110", "L" => "00100", "M" => "10011001", "N" => "10011110", "O" => "00101", "P" => "111", "Q" => "10011111", "R" => "1000",
  "S" => "00110", "T" => "00111", "U" => "10011100", "V" => "10011101", "W" => "000010", "X" => "10010010", "Y" => "10010011", "Z" => "10010000"
}
Codew = (("A".."Z").to_a + [" ", ".", ",", "-", "'", "?"]).map.with_index{|v,i|[v, i.to_s(2).rjust(5, "0")]}.to_h
class BinTree
  def self.root=(val)
    @@root = val
  end
  @@root
  attr_accessor :root
  def initialize
    @value = nil
    @children = nil
  end

  def search(bin)
    if bin == ""
      return @value
    else
      return @children[bin[0].to_i].search(bin[1..-1])
    end
  end

  def insert(bin, v)
    if bin == ""
      @value = v
    elsif @children
      @children[bin[0].to_i].insert(bin[1..-1], v)
    else
      @children = [BinTree.new, BinTree.new]
      insert(bin, v)
    end
  end

  def decode(str)
    if @value
      return @value + @@root.decode(str)
    elsif str == "" or !@children
      return ""
    else
      return @children[str[0].to_i].decode(str[1..-1])
    end
  end
end
root = BinTree.new
BinTree.root = root
Code.each {|(key,value)|root.insert(value, key)}
while (str = gets)
  puts root.decode(str.chomp.split(//).map{|i|Codew[i]}.join)
end

Measured memory_bytes: 8836
// #pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 2e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;
    char ls;
    ls = getchar();
    while (!isdigit(ls))
    {
        if (!(ls ^ 45))
            kr = -1;
        ls = getchar();
    }
    while (isdigit(ls))
    {
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);
        ls = getchar();
    }
    return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;
    char ls;
    ls = getchar();
    while (!isdigit(ls))
        ls = getchar();
    while (isdigit(ls))
    {
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);
        ls = getchar();
    }
    return xs;
}
inline void writeull(ull x)
{
    if (x < 0)
    {
        x *= -1;
        putchar('-');
    }
    if (x >= 10)
        writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0)
    {
        x *= -1;
        putchar('-');
    }
    if (x >= 10)
        write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
ll a[MAXN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // t = read();
    while (t--)
    {
        int n = read();
        for (int i = 1; i <= n; i++)
        {
            a[i] = read();
        }
        ll ans = 0;
        for (int i = 2; i <= n; i++)
        {
            if (a[i] < a[i - 1])
            {
                ans += (a[i - 1] - a[i]);
                a[i] = a[i - 1];
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    char c[100][100];
    rep(i,100){
        rep(j,100){
            if(i <= 49) c[i][j] = '.';
            else c[i][j] = '#'; 
        }
    }
    int wh = 1, bl = 1;    
    rep(i,100){
        rep(j,100){
            if(i < 49){
                if(bl < b && i-1 >= 0 && i+1 <= 49 && j-1 >= 0 && j + 1 < 100 && c[i-1][j] == '.' && c[i+1][j] == '.' && c[i][j+1] == '.' && c[i][j-1] == '.' && c[i+1][j+1] == '.' && c[i+1][j-1] == '.' && c[i-1][j-1] == '.' && c[i-1][j+1] == '.'){
                    c[i][j] = '#';
                    bl++;
                }
            } 
            if(i > 50){
                if(wh < a && i-1 >= 50 && i+1 <= 99 && j-1 >= 0 && j + 1 < 100 && c[i-1][j] == '#' && c[i+1][j] == '#' && c[i][j+1] == '#' && c[i][j-1] == '#' && c[i+1][j+1] == '#' && c[i+1][j-1] == '#' && c[i-1][j-1] == '#' && c[i-1][j+1] == '#'){
                    c[i][j] = '.';
                    wh++;
                }
            }
        }
    }
    cout << "100" << " " << "100" << endl;
    rep(i,100){
        rep(j,100){
            cout << c[i][j];
        }
        cout << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
import math
S = int(input())

x,y = 1,S
ret = int(math.sqrt(S))
if(ret**2 == S):
    print("{} {} {} {} {} {}".format(0,0,0,ret,ret,ret))
else:
    print("{} {} {} {} {} {}".format(0,0,ret+1,(ret+1)**2-S,1,ret+1))



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

ll mod = 1e9+7;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}



int N;
vector<vector<int>> edge;
vector<vector<int>> child;
vector<int> ts;
vector<int> rs;

int calcrs(int now, int par = -1){
    ts.push_back(now);
    rs[now] = 1;
    for (int c : edge[now]) {
        if (c == par) continue;
        child[now].push_back(c);
        rs[now] += calcrs(c, now);
    }
    return rs[now];
}

int main(){
    cin >> N;
    edge.resize(N+1);
    child.resize(N+1);
    rs.resize(N+1);
    for (int i = 0; i < N-1; i++) {
        int A, B;
        cin >> A >> B;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    calcrs(1, 0);
    
    vector<ll> pow(N+1, 1);
    for (int i = 1; i <= N; i++) pow[i] = pow[i-1]*2%mod;
    
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll t = pow[N-1]-1;
        t += mod-(pow[N-rs[i]]-1);
        for (int c : child[i]) {
            t += mod-(pow[rs[c]]-1);
        }
        ans += t;
        ans %= mod;
    }
    cout << ans*modinv(pow[N])%mod << endl;
    return 0;
}


Measured memory_bytes: 33524
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n, m, k;
    cin >> n >> m >> k;
    VL a(n), b(m), sa(n + 1), sb(m + 1);
    REP(i,n){
        a[i] = in();
        sa[i + 1] = sa[i] + a[i];
    }
    REP(i,m){
        b[i] = in();
        sb[i + 1] = sb[i] + b[i];
    }
    sb.push_back(1e18);
    int ans = 0;
    REP(i,n+1){
        if (sa[i] > k) break;
        int x = i;
        int y = upper_bound(ALL(sb), k - sa[i]) - sb.begin() - 1;
        chmax(ans, x + y);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11244
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <set>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 100;
int N;
string W[MAX_N];

bool solve() {
    set<string> sets;
    REP(i,0,N) sets.insert(W[i]);
    if (N != sets.size()) return false;

    REP(i,1,N) {
        if (W[i-1].back() != W[i].front()) return false;
    }
    return true;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;
    REP(i,0,N) cin >> W[i];
    cout << (solve() ? "Yes" : "No") << "\n";
    return 0;
}



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

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

	for(int i=0; i<s.length(); i++) {
		int temp = s[i] - 'A';
		temp += n;
		temp %= 26;
		s[i] = 'A' + temp;
	}

	cout<<s;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string A, B, C; cin >> A >> B >> C;
    int x = 0, y = -1, z = -1, n = 1;
    while(1) {
        char t;
        if(x == A.length()) {
            cout << "A" << endl;
            break;
        }
        else if(y == B.length()) {
            cout << "B" << endl;
            break;
        }
        else if(z == C.length()){
            cout << "C" << endl;
            break;
        }

        if(n == 1) t = A[x];
        else if(n == 2) t = B[y];
        else if(n == 3) t = C[z];

        if(t == 'a') {
            x++; n = 1;
        }
        else if(t == 'b') {
            y++; n = 2;
        }
        else if(t == 'c') {
            z++; n = 3;
        }

        // printf("%d %d %d\n",x, y, z);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cn count;
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
    string s;
    cin>>s;
    forni(i,s.len()){
        if(s[i-1]==s[i]){cout<<"Bad\n";return 0;}
    }
    cout<<"Good\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 3632
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]


ans = float('inf')
for i in range(2 ** n):
    cost = 0
    skills = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            cost += ca[j][0]

            for k in range(m):
                skills[k] += ca[j][k + 1]

    f = True
    for k in range(m):
        if skills[k] < x:
            f = False

    if f:
        ans = min(ans, cost)

if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 73988
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll used[MAX];
vector<int>adj[MAX];
int loop;
void dfs(int src)
{
    used[src]=1;
    for(auto i:adj[src])
    {
        if(!used[i])
            dfs(i);
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    int sum=0;
    while(m--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].push_back(b);
        adj[b].push_back(a);

        //adj[b].push_back(c);
       // adj[c].push_back(b);
    }
    for(int i=1; i<=n; i++)
    {
        if(used[i])
            continue;
        dfs(i);
        sum++;
    }
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 33996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

    ll cnt = 0;
    rep(i,Q){
        int T;
        scanf("%d", &T);
        if(T==1){
            cnt++;
        }else{
            int F;
            string C;
            cin >> F >> C;
            if((F+cnt)%2==1){
                S.insert(0, C);
            }else{
                S += C;
            }
        }
    }
    if(cnt%2==1) reverse(all(S));

    cout << S;
    return 0;
}


Measured memory_bytes: 900
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        s:[String;n],
    }
    let mut gacha_kind_set = HashSet::new();
    for si in s.iter() {
        gacha_kind_set.insert(si);
    }
    gacha_kind_set.len().to_string()
}
test! {
    include_str!("c1_in.txt") => "2",
    include_str!("c2_in.txt") => "1",
    include_str!("c3_in.txt") => "4",
}


Measured memory_bytes: 18548
s = input()
c = ["A","C","G","T"]
ans = 0
count = 0
f = False
for i,ss in enumerate(s):
    if i == 0 and s[i] in c:
        count = 1
        f = True
        continue
    if f:
        if s[i] in c:
            count += 1
        else:
            ans = max(count,ans)
            count = 0
            f = False
    else:
        if s[i] in c:
            count += 1
            f = True
ans = max(count,ans)
print(ans)








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

int main()
{
  int a,b,c;

  scanf("%d%d%d",&a,&b,&c);
  if (a%2==0||b%2==0||c%2==0)printf("0\n");
  else if (a>=b&&a>=c)
  printf("%lld\n",(long long)b*c);
  else if (b>=a&&b>=c)
  printf("%lld\n",(long long)a*c);
  else if (c>=a&&c>=b)
  printf("%lld\n",(long long)a*b);
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  if(n % 10 == 9 || n/10 == 9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

import math
def get_pairs(N, M):
    sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)
    M2_ceil = math.ceil(M/2.0)
    M2_flor = math.floor(M/2.0)
    pairs = []
    for i in range(M2_ceil):
        pairs.append([1+i, 1+i+sizes_even[i]+1])
    half = 2+sizes_even[0]
    for i in range(M2_flor):
        pairs.append([half+i+1, half+i+1+sizes_odd[i]+1])
    return pairs
pairs = get_pairs(N, M)
for pair in pairs:
    print(pair[0], pair[1])

Measured memory_bytes: 26968
import math
N,A,B,C,D=(int(x) for x in input().split())
if 1<=N<=1000 and 1<=A<=1000 and 1<=B<=1000 and 1<=C<=1000 and 1<=D<=1000:
   if math.ceil(N/A)*B<math.ceil(N/C)*D:
      print(math.ceil(N/A)*B)
   else:
      print(math.ceil(N/C)*D)
else:
   pass


Measured memory_bytes: 5672
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll dp[105][105];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (auto &e : s)
        cin >> e;
    dp[0][0] = s[0][0] == '#';
    for (ll i = 0; i < h; i++)
        for (ll j = !i; j < w; j++)
            if (s[i][j] == '.')
                dp[i][j] = min((j > 0 ? dp[i][j - 1] : M), (i > 0 ? dp[i - 1][j] : M));
            else
                dp[i][j] = min((j > 0 ? dp[i][j - 1] + (s[i][j - 1] == '.') : M), (i > 0 ? dp[i - 1][j] + (s[i - 1][j] == '.') : M));
    cout << dp[h - 1][w - 1];
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int p, q, r;
	cin >> p >> q >> r;
	cout << min({ p + q,q + r,p + r }) << endl;
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>

using namespace std;

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

int solve()
{
	int N = 0;
	vector<int> s(100);

	scanf("%d", &N);

	int sum = 0;

	rep(i, N)
	{
		scanf("%d", &s[i]);
		sum += s[i];
	}

	if (sum % 10 != 0)
	{
		printf("%d", sum);
		return 0;
	}

	sort(s.begin(), s.begin() + N);

	rep(i, N)
	{
		if (s[i] % 10 == 0)
		{
		}
		else
		{
			sum -= s[i];
			printf("%d", sum);
			return 0;
		}
	}

	printf("%d", 0);
	return 0;
}

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        if (m==-1&&f==-1&&r==-1) break;
        else if (m==-1||f==-1) cout<<"F"<<endl;
        else if (m+f>=80) cout<<"A"<<endl;
        else if (m+f>=65) cout<<"B"<<endl;
        else if (m+f>=50) cout<<"C"<<endl;
        else if (m+f>=30){
            if (r>=50) cout<<"C"<<endl;
            else cout<<"D"<<endl;
        }
        else cout<<"F"<<endl;
    }
}


Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Min_Ma_and_Sum
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            String[] str = Console.ReadLine().Split(' ');
            long[] ngo = new long[n];
            for (int i = 0; i < n; ++i) ngo[i] = long.Parse(str[i]);


            Console.WriteLine("{0} {1} {2}", ngo.Min(), ngo.Max(), ngo.Sum());

        }
    }
}


Measured memory_bytes: 10292
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[str]"):
    ABC = [A, B, C]
    ans = []
    d = {"AB": (0, 1), "BC": (1, 2), "AC": (0, 2)}
    # print(ABC)
    for i in range(N):
        j, k = d[s[i]]
        if ABC[j] == ABC[k] == 0:
            no()
            return
        if ABC[j] == ABC[k] == 1:
            if i != N-1 and (j not in d[s[i+1]]):
                j, k = k, j
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])
        elif ABC[j] > ABC[k]:
            ABC[j] -= 1
            ABC[k] += 1
            ans.append("ABC"[k])
        else:
            ABC[j] += 1
            ABC[k] -= 1
            ans.append("ABC"[j])

    yes()
    for a in ans:
        print(a)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, A, B, C, s)


if __name__ == '__main__':
    main()


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

const int maxn=1e5+5;

int a[maxn];

int main(){
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;){
		int flg=0;
		int j=i;
		int posr=0;int posl=0;
		int cr=0,cl=0;
		for(;j<n;j++){
			if(!flg&&s[j]=='R'){
				cr++;
			}
			if(!flg&&s[j]=='L'){
				flg=1;
				posr=j-1;
				posl=j;
			}
			if(flg&&s[j]=='L'){
				cl++;
			}
			if(flg&&s[j]=='R') break;
		}
		i=j;
//		printf("%d %d\n",cr,cl);
		int num=max(cl,cr);
		if(num%2==0){
			a[posr]=a[posl]=(cl+cr)/2;
			if((cl+cr)%2==1&&cr>cl){
				a[posr]++;
			}
			if((cl+cr)%2==1&&cl>cr){
				a[posl]++;
			}
			swap(a[posr],a[posl]);
		}
		else{
			a[posr]=a[posl]=(cl+cr)/2;
			if((cl+cr)%2==1&&cr>cl){
				a[posr]++;
			}
			if((cl+cr)%2==1&&cl>cr){
				a[posl]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
MOD = 10**9+7
N = 200000
p = [1] * (N+1)
q = [1] * (N+1)
for i in range(1, N+1):
    p[i] = (p[i-1]*(i)%MOD)
q[0] = pow(p[-1], MOD-2, MOD)
for i in range(1, N+1):
    q[i] = (N-i+1)*q[i-1]%MOD
q.reverse()

def nCk(n,k):
    if k > n or (k != 0 and n == 0):
        return 0
    elif k == 0:
        return 1
    else:
        return p[n]*q[k]%MOD*q[n-k]%MOD

h,w,a,b = map(int, input().split())

ans = 0
for i in range(b, w):
    ans += nCk(h-a+i-1, i)*nCk(w-i-2+a, w-i-1)%MOD
print(ans%MOD)


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

int main(){
    int n;
    cin >> n;
    long long a[n];
    long long sum = 0; 
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    long long dp[n];
    dp[0] = a[0];
    double hanbun = (sum+1) / 2;
    long long mintemp = abs(hanbun - a[0]);
    long long ans = dp[0];
    for(int i = 1; i < n; i++){
        dp[i] = dp[i-1] + a[i];
        if(mintemp > abs(hanbun - dp[i])){
            mintemp = abs(hanbun - dp[i]);
            ans = dp[i];
        }
    }
    long long anotherhen = sum - ans;
    cout << abs(anotherhen - ans) << endl;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		double x,y;
		x = 0;
		y = 0;
		int deg = 90;
		for(;;){
			String str = sc.next();
			if(str.equals("0,0"))break;
			str = str.replace(',', ' ');
			Scanner buf = new Scanner(str);
			int d = buf.nextInt();
			
			x += d*Math.cos(deg*Math.PI/180);
			y += d*Math.sin(deg*Math.PI/180);
			
			int t = buf.nextInt();			
			deg += t;
		}
		System.out.println((int)-x );
		System.out.println((int)y );
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string in;
	while(cin>>in)
	{
		if(in[0]==in[4]&&in[4]==in[8])
		{
			if(in[0]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[0]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[2]==in[4]&&in[4]==in[6])
		{
			if(in[2]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[2]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[0]==in[1]&&in[1]==in[2])
		{
			if(in[0]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[0]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[3]==in[4]&&in[4]==in[5])
		{
			if(in[3]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[3]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[6]==in[7]&&in[7]==in[8])
		{
			if(in[6]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[6]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[0]==in[3]&&in[3]==in[6])
		{
			if(in[0]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[0]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[1]==in[4]&&in[4]==in[7])
		{
			if(in[1]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[1]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		if(in[2]==in[5]&&in[5]==in[8])
		{
			if(in[2]=='o')
			{
				cout<<"o"<<endl;
				continue;
			}
			else if(in[2]=='x')
			{
				cout<<"x"<<endl;
				continue;
			}
		}
		cout<<"d"<<endl;
	}
  return 0;
}

Measured memory_bytes: 1180
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
double PI = acos(-1);
using namespace std;
class point{
public:
	double x, y;
	point(){ x = 0, y = 0; }
	point(double a, double b){ x = a, y = b; }
	friend point operator+(point a, point b){
		return point(a.x + b.x, a.y + b.y);
	}
	friend point operator/(point a, double b){
		return point(a.x / b, a.y / b);
	}
	friend point operator*(point a, double b){
		return point(a.x * b, a.y * b);
	}
};
void koch(int m, point p1, point p2){
	if (m == 0) return;
	point s, t, u;
	s = (p1 * 2.0 + p2) / 3.0;
	t = (p1 + p2 * 2.0) / 3.0;
	u.x = (t.x - s.x)*cos(PI / 3) - (t.y - s.y)*sin(PI / 3)+s.x;
	u.y = (t.x - s.x)*sin(PI / 3) + (t.y - s.y)*cos(PI / 3) + s.y;
	koch(m - 1, p1, s);
	cout << s.x << ' ' << s.y << '\n';
	koch(m - 1, s, u);
	cout << u.x << ' ' << u.y << '\n';
	koch(m - 1, u, t);
	cout << t.x << ' ' << t.y << '\n';
	koch(m - 1, t, p2);
}
int main(){
	int n; cin >> n;
	point P1, P2;
	P1.x = P1.y = 0;
	P2.x = 100; P2.y = 0;
	cout << fixed << setprecision(8);
	cout << P1.x << ' ' << P1.y << '\n';
	koch(n, P1, P2);
	cout << P2.x << ' ' << P2.y << '\n';
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
double dp[501][501];

double recursive(int num_of_rest_type,int know_num){
	if(dp[num_of_rest_type][know_num] != -1.0)return dp[num_of_rest_type][know_num];

	if(num_of_rest_type == know_num)return 0.0;

	double ret = 0.0;
	int num_cards = 2*num_of_rest_type-know_num;

	if(know_num > 0){
		ret += (double)know_num/(double)num_cards*(recursive(num_of_rest_type-1,know_num-1));
	}

	double new_p = (double)(num_cards-know_num)/(double)(num_cards);
	ret += new_p*(1.0/(double)(num_cards-1))*recursive(num_of_rest_type-1,know_num);
	ret += new_p*(double(know_num)/(double)(num_cards-1))*(1.0+recursive(num_of_rest_type-1,know_num));
	if((num_cards-1-(know_num+1) > 0)){
		ret += new_p*((double)(num_cards-1-(know_num+1))/(num_cards-1))*(1.0+recursive(num_of_rest_type,know_num+2));
	}
	return dp[num_of_rest_type][know_num] = ret;
}

void func(){

	for(int i = 0; i <= N/2; i++){
		for(int k = 0; k <= N/2; k++)dp[i][k] = -1.0;
	}

	printf("%.10lf\n",recursive(N/2,0));
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 5120
n = int(input())
a = [int(_) for _ in input().split()]
ans = 0
h = a[0]
if n == 1:
    print(0)
else:
    for i in range(1, n):
        if a[i] <= h:
            ans += h - a[i]
        else:
            h = a[i]
    print(ans)

Measured memory_bytes: 32188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll b, w;std::cin >> b >> w;
  init();
  vll sq(300001, 1);rep(i, 1, 300001) sq[i] = (sq[i-1]*inv[2])%P;
  vll B(b+w, 0), W(b+w, 0);
  for(int i=1;i<b+w;i++){
    B[i] = pp(sq[i], comb(i-1, b-1));
    W[i] = pp(sq[i], comb(i-1, w-1));
  }
  for(int i=1;i<b+w;i++){
    B[i] = (B[i] + B[i-1])%P;
    W[i] = (W[i] + W[i-1])%P;
  }
  ll ext = 2*P;
  for(int i=1;i<=b+w;i++){
    ll x = W[i-1];
    ll y = pp(inv[2], (1-W[i-1]-B[i-1]+ext)%P);
    std::cout << (x+y)%P << '\n';
  }
  return 0;
}


Measured memory_bytes: 54528
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define INF 1000000000000

int main()
{
	ll n,k;
	cin>>n>>k;
	ll *dp = new ll[n];
	ll *h = new ll[n];
	rep(i,n){
		cin>>h[i];
	}
	rep(i,n){
		dp[i] = INF;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if( i + j > n) break;
			dp[i+j] = min(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}



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

using namespace std;

typedef long long ll;

const int maxN = 1e7 + 1;
int main(){
	ll n;
	cin >> n;
	ll sol = 1;
	vector<ll> sieve(maxN, 2);
	for(ll i = 2; i <= n; i++){
		sol += i * 1LL * sieve[i];
		for(ll j = i + i; j <= n; j += i){
			sieve[j]++;
		}
	}
	cout << sol << '\n';
}


Measured memory_bytes: 81396
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 60;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  ll a;
  double b;
  cin >> a >> b;
  ll B = b * 100 + 0.5;
  ll ans = a * B / 100;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define mp(a,b) make_pair(a,b)
#define pi acos(-1)
#define pii pair<int,int>
#define pb push_back
#define lowbit(x) ((x)&(-x))
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const ll mod =  998244353;
int a[maxn];
int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
#endif
    int n;
    scanf("%d",&n);
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        int x,y;
        scanf("%d%d",&x,&y);
        a[i] = x + y;
        ans -= y;
    }
    sort(a, a + n);
    int cur = 1;
    for(int i = n - 1; i >= 0; i--) {
        if(cur) ans += a[i];
        cur ^= 1;
    }
    printf("%lld",ans);
    return 0;
}

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

namespace ABC137
{
    class Question_A
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine()
                                .Split(' ')
                                .Select(str => int.Parse(str))
                                .ToArray();

            var results = CreateResults(inputs[0], inputs[1]).OrderBy(x => -x);
            Console.WriteLine(results.First());
        }

        static IEnumerable<int> CreateResults(int x, int y)
        {
            yield return x + y;
            yield return x - y;
            yield return x * y;
        }
    }
}


Measured memory_bytes: 13396