akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORX(i, a, b, x) for (int i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use for debugging
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 5] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
 
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<int,int>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).size())
#define cut(x) {cout<<x<<"\n"; return;}
#define setprec(x) cout << fixed << showpoint << setprecision(8)<<x<<endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n"
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order() ->returns an iterator to the k-th largest element (counting from zero);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
//sort(a+1,a+n+1,[](ll x,ll y){return abs(x)>abs(y);});
//sort(v.begin(), v.end(), greater<int>()); 
const int N=1e5+5;

void solve()
{

}
int main()
{
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  readb(k,x);
  if(k*500>=x) cout<<"Yes";
  else cout<<"No";
}

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

using namespace std;

#define ll long long

#define all(x) x.begin(), x.end()

const int mod = 998244353;


bool solve2(int n, int m, int k){

	for(int i = 0; i <= n; ++i){
		for(int j = 0; j <= m; ++j){
			int res = i * (m - j) + j * (n - i);
			if(res == k){
				return true;
			}
		}
	}
	return false;
}

int main(){

	cin.tie(0);
	cin.sync_with_stdio(0);

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

	int n, m, k;
	cin >> n >> m >> k;
	puts(solve2(n, m, k) ? "Yes" : "No");
}

Measured memory_bytes: 256
program main
implicit none
integer :: i, j, k
integer :: a(3)

read(*,*) a
k = 0
do i = 1, 2
   do j = i+1, 3
      if( a(i) /= a(j) ) then
         k = k + 1
      end if
   end do
end do
write(*,'(i0)') max(k,1)


end program main


Measured memory_bytes: 896
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const int mod = 1e9+7;
const int dX[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (long long)x.size()
#define all(x) (x).begin(), (x).end()
#define ub upper_bound
#define lb lower_bound
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------
int main(){
    string one, two; cin >> one >> two;
    vector<vector<int>> dp(sz(one)+1, vector<int>(sz(two)+1, 0));
    string ans = "";
    for(int i = 1; i < sz(dp); i++){
        for(int j = 1; j < sz(dp[i]); j++){
            if(one[i-1] == two[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                /* ans += two[j-1]; */ 
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int i = sz(one); int j = sz(two);
    while(i > 0 and j > 0){
        if(one[i-1] == two[j-1]){
            ans += one[i-1];i--; j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        } else {
            j--;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
    // Read notes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 35584
#include<stdio.h>
#include<string.h>

int main(void){
    int n, q, i, j, l, r, a = 0;
    char s[100000];
    int  ans[100000] = {0}, num[100000];
    scanf("%d %d",&n, &q);
    scanf("%s",s);
    num[0] = 0;
    for(i = 1; i < n; i++){
        char c[3] = {s[i-1],s[i]};
        if(strncmp(c, "AC", 2) == 0){
            a++;
        }
        num[i] = a;
    }
    for(i = 0; i < q; i++){
        scanf("%d %d",&l, &r);
        ans[i] = num[r-1] - num [l-1];
    }
    for(i = 0;i < q; i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(){
  int i,n,j,kari,mcount,scount,frag,data[13],ndata[13],fdata[13];

  while(1){
    frag = 0;
    mcount= 0;
    scanf("%d",&n);
    if(n == 0) break;
    for(i = 0; i < n;i++){
      scanf("%d",&data[i]);
    }
    while(1){
      if(frag == 1)break;
      for(i = 0; i < n; i++){
	scount = 0;
	for(j = 0; j < n; j++){
	  if(data[i] == data[j])
	    scount++;
	}
	ndata[i] = scount;
      }
      kari = 0;
      mcount++;
      for(i = 0; i < n; i++){
	fdata[i] = 0;
	if(data[i] == ndata[i])
	  kari += 1;
	data[i] = ndata[i];
      }
      if(kari == n) frag = 1;
    }

    printf("%d\n",mcount-1);
    for(i = 0; i < n; i++){
      if(i == n-1)
	printf("%d",data[i]);
      else
	printf("%d ",data[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    int n;  cin >> n;
    vector<ll> a(n), b(n);

    ll asum=0, bsum=0;
    for(int i=0; i<n; i++){
        cin >> a.at(i);
        asum += a.at(i);
    }
    for(int i=0; i<n; i++){
        cin >> b.at(i);
        bsum += b.at(i);
    }
    string ans="No";
    ll bc=0, ac=0;
    if(asum<=bsum){
        for(int i=0; i<n; i++){
            if(a[i]<b[i]){
                ac += (b[i]-a[i])/2 + (b[i]-a[i])%2;
                bc += (b[i]-a[i])%2;;
            }else{
                bc += (a[i]-b[i]);
            }
        }
        if(bc<=ac)
            ans = "Yes";
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	string S;
	cin >> S;
	int pos = S.size();
	while (pos > 0) {
		if (pos >= 5 && (S.substr(pos - 5, 5) == "dream" || S.substr(pos - 5, 5) == "erase")) pos -= 5;
		else if (pos >= 6 && S.substr(pos - 6, 6) == "eraser") pos -= 6;
		else if (pos >= 7 && S.substr(pos - 7, 7) == "dreamer") pos -= 7;
		else break;
	}
	if (pos == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=998244353;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  int a[n],b[n],c[n];
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,n){
    cin>>c[i];
    c[i]=-c[i];
    }
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  ll ans=0;
  rep(i,n){
    int x=lower_bound(a,a+n,b[i])-a;
    int y=lower_bound(c,c+n,-b[i])-c;
    ans+=(ll)x*y;
    }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int x[100005];
int par1[17][100005], par2[17][100005];
int main(){
    int n, l, q;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &x[i]);
    scanf("%d%d", &l, &q);
    for(int i=1;i<=n-1;i++){
        int lo = i+1, hi = n, ans;
        while(lo <= hi){
            int mid = (lo+hi)/2;
            if(x[mid]-x[i] <= l) ans = mid, lo = mid+1;        
            else hi = mid-1;
        }
        par1[0][i] = ans;
    }
    for(int i=n;i>=2;i--){
        int lo = 1, hi = i-1, ans;
        while(lo <= hi){
            int mid = (lo+hi)/2;
            if(x[i]-x[mid] <= l) ans = mid, hi = mid-1;
            else lo = mid+1;
        }
        par2[0][i] = ans;
    }
    for(int j=1;j<17;j++){
        for(int i=1;i<=n;i++){
            if(par1[j-1][i] != 0) par1[j][i] = par1[j-1][par1[j-1][i]];
            if(par2[j-1][i] != 0) par2[j][i] = par2[j-1][par2[j-1][i]];
        }
    }
    for(int i=1;i<=q;i++){
        int a, b, ans = 0;
        scanf("%d%d", &a, &b);
        if(a < b){
            for(int j=16;j>=0;j--){
                if(par1[j][a] == 0) continue;
                if(par1[j][a] <= b){
                    a = par1[j][a];
                    ans += (1<<j);
                }
            }

            if(a != b) ans++;
        }
        else{
            for(int j=16;j>=0;j--){
                if(par2[j][a] == 0) continue;
                if(par2[j][a] >= b){
                    a = par2[j][a];
                    ans += (1<<j);
                }
            }
            if(a != b) ans++;
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 14336
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

int H, W, S, U[32][32], L;
int sm[64][64], dp[32][32][32][32], memo[32][32][32][32];

inline void cmax(int& a, int b) { if(a<b) a = b; }

inline int sum(int i, int j, int l, int r) {
    return sm[j+1][r+1]-sm[i][r+1]-sm[j+1][l]+sm[i][l];
}

int rec(int i, int j, int l, int r) {
    if(dp[i][j][l][r]==1) return sum(i, j, l, r)-L;
    if(memo[i][j][l][r]!=-1) return memo[i][j][l][r];
    int ans = 0;
    for(int a=l; a<r; a++) if(dp[i][j][l][a] && dp[i][j][a+1][r]) {
        if(dp[i][j][l][r]==dp[i][j][l][a]+dp[i][j][a+1][r]) {
            cmax(ans, min(rec(i, j, l, a), rec(i, j, a+1, r)));
        }
    }
    for(int a=i; a<j; a++) if(dp[i][a][l][r] && dp[a+1][j][l][r]) {
        if(dp[i][j][l][r]==dp[i][a][l][r]+dp[a+1][j][l][r]) {
            cmax(ans, min(rec(i, a, l, r), rec(a+1, j, l, r)));
        }
    }
    return memo[i][j][l][r] = ans;
}

int main() {
    for(;;) {
        scanf("%d%d%d", &H, &W, &S);
        if(H==0 && W==0 && S==0) return 0;
        rep(i, H) rep(j, W) scanf("%d", U[i]+j);
        rep(i, H) rep(j, W) {
            sm[i+1][j+1] = U[i][j]-sm[i][j]+sm[i][j+1]+sm[i+1][j];
        }
        L = sm[H][W]-S;
        rep(h, H) rep(i, H-h) {
            const int j = i+h;
            rep(w, W) rep(l, W-w) {
                const int r = l+w;
                dp[i][j][l][r] = sum(i, j, l, r)>=L;
                for(int a=l; a<r; a++) if(dp[i][j][l][a] && dp[i][j][a+1][r]) {
                    cmax(dp[i][j][l][r], dp[i][j][l][a]+dp[i][j][a+1][r]);
                }
                for(int a=i; a<j; a++) if(dp[i][a][l][r] && dp[a+1][j][l][r]) {
                    cmax(dp[i][j][l][r], dp[i][a][l][r]+dp[a+1][j][l][r]);
                }
            }
        }
        memset(memo, -1, sizeof(memo));
        printf("%d %d\n", dp[0][H-1][0][W-1], rec(0, H-1, 0, W-1));
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i <= X + K - 2; i++) {
	  cout << i << " ";
	}
  cout << X + K - 1 << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
// using System.Globalization;
using System.IO;
using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        FastScanner sc = new FastScanner(Console.OpenStandardInput());
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = sc.intArray(N);
        Console.WriteLine(h.Sum((cur) => K <= cur ? 1 : 0));
        return;
    }
}

// FastScanner start
public class FastScanner
{
    public readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public FastScanner(Stream stream)
    {
        str = stream;
    }
    private T[] enumerate<T>(int n, Func<T> f)
    {
        var a = new T[n];
        for (int i = 0; i < n; ++i) a[i] = f();
        return a;
    }
    public char nextChar()
    {
        byte b = 0;
        do
        {
            b = read();
        }
        while ((b < 33 || 126 < b) && !isEof);
        return (char)b;
    }
    public int nextInt()
    {
        return (isEof) ? int.MinValue : (int)nextLong();
    }
    public long nextLong()
    {
        if (isEof)
        {
            return long.MinValue;
        }
        long ret = 0;
        byte b = 0;
        var ng = false;
        do
        {
            b = read();
        }
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = read();
        }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
            {
                return ng ? -ret : ret;
            }
            else ret = ret * 10 + b - '0';
        }
    }
    public int[] intArray(int n)
    {
        return enumerate(n, nextInt);
    }
    public long[] longArray(int n)
    {
        return enumerate(n, nextLong);
    }
    public char[] charArray(int n)
    {
        return enumerate(n, nextChar);
    }
    private byte read()
    {
        if (isEof)
        {
            return 0;
        }
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
}
// FastScanner end

Measured memory_bytes: 26188
#include<iostream>
using namespace std;
int main(){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<a[k-1]<<endl;
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int r, c, k;
  cin >> r >> c >> k;
  vvi item(3010, vi(3010, -1));
  
  vector<vvl> dp(3010, vvl(3010, vl(4)));
  rep(i, 0, 3010){
    rep(j, 0, 3010){
      item[i][j] = -1;
      rep(d, 0, 4){
        dp[i][j][d] = 0;
      }
    }
  }
  rep(i, 0, k){
    int x, y;
    cin >> x >> y;
    x--;y--;
    cin >> item[x][y];
  }
 
  rep(i, 0, r){
    rep(j, 0, c){
      rep(d, 0, 4){
        llchmax(dp[i][j+1][d], dp[i][j][d]);
        llchmax(dp[i+1][j][0], dp[i][j][d]);
        
        if(item[i][j] == -1 || d == 3){
          continue;
        }
       
        ll v = item[i][j];
        llchmax(dp[i+1][j][0], dp[i][j][d] + v);
        llchmax(dp[i][j+1][d+1], dp[i][j][d] + v);
        
      }
    }
  }
  
  cout << dp[r][c-1][0] << endl;
  
  return 0;
  
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst<<": "; dbg(rst...); }


int main()
{
	const double PI = acos(-1);
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	if(s[0]>='A' && s[0]<='Z') puts("A");
	else puts("a");
	return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    string N; cin >> N;
    int m = 0;
    for(char c : N){
        int x = c-'0';
        (m += x) %= 9;
    }
    cout << (m==0 ? "Yes" : "No") << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    deque<char> q;
    for(auto i:s) q.push_back(i);
    bool flag = false;
    int Q; cin >> Q;
    rep(i,Q){
        int t; cin >> t;
        if(t == 1) flag = !flag;
        else{
            int f;
            char c;
            cin >> f >> c;
            if(flag) f = 3-f;
            if(f == 1) q.push_front(c);
            else q.push_back(c);
        }
    }
    if(flag)REVERSE(q);
    for(auto i:q)cout << i;

    return 0;
}

Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			double pi = Math.PI;
			double r = sc.nextDouble();
			double a;
			double b;

			a = pi * r * r;
			b = 2 * pi * r;
			System.out.printf("%f %f",a ,b);
	}
}

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

typedef long long ll;
const int N = 1e5 + 100;

ll n, q, cnt, l[N], a[N], ans[N];

void input() {
	cin >> n >> q;
	l[cnt++] = n;
	for (int i = 1; i <= q; i++) {
		cin >> l[cnt];
		while (cnt && l[cnt] < l[cnt - 1]) {
			l[cnt - 1] = l[cnt];
			cnt--;
		}
		cnt++;
	}
}

void solve() {
	a[cnt - 1] = 1;
	for (int i = cnt - 1; ~i; i--) {
		ll x = l[i];
		while (x > l[0]) {
			ll y;
			if (x == l[i])
				y = lower_bound(l, l + cnt, x) - l - 1;
			else
				y = upper_bound(l, l + cnt, x) - l - 1;
			a[y] += a[i] * (x / l[y]);
			x %= l[y];
		}
		ans[x] += a[i];
	}
}

void output() {
	for (int i = n; i; i--)
		ans[i] += ans[i + 1];
	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	input();
	solve();
	output();
}


Measured memory_bytes: 4096
import java.io.*;
import java.util.*;

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

        if(N>=400){
            if(N<=599){
                System.out.println(8);
            }
        }
        if(N>=600){
            if(N<=799){
                System.out.println(7);
            }
        }
        if(N>=800){
            if(N<=999){
                System.out.println(6);
            }
        }
        if(N>=1000){
            if(N<=1199){
                System.out.println(5);
            }
        }
        if(N>=1200){
            if(N<=1399){
                System.out.println(4);
            }
        }
        if(N>=1400){
            if(N<=1599){
                System.out.println(3);
            }
        }
        if(N>=1600){
            if(N<=1799){
                System.out.println(2);
            }
        }
        if(N>=1800){
            if(N<=1999){
                System.out.println(1);
            }
        }

    }
}

Measured memory_bytes: 35716
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);
uint64_t silver_fox(vector<vector<int64_t>>& monster_arr, uint64_t range, uint64_t attack, uint64_t count);

int main()
{   
 
    vector<vector<int64_t>> monster_arr(0);
    vector<int64_t> monster(2);
    vector<double> temp_vec(0);
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t range, attack;
    uint64_t num;
    uint64_t result;
    uint64_t sum;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, count, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
 
    cin >> num;

    if (num % 2 == 0) {
        num = num / 2;
    } else {
        num = num / 2 + 1;
    }

    cout << num << endl;
    // range = 2 * range + 1;

    // for (i = 0; i < num; i++) {
    //     cin >> monster[0] >> monster[1];
    //     monster_arr.push_back(monster);
    // }

    // sort(monster_arr.begin(), monster_arr.end(),
    //     [](auto& x, auto& y) {
    //         return x[0] < y[0];
    //     }
    // );

    // result = silver_fox(monster_arr, range, attack, 0);

    // cout << result << endl;

    return 0;
}

uint64_t silver_fox(vector<vector<int64_t>>& monster_arr, uint64_t range, uint64_t attack, uint64_t count) {
    int64_t life, pos, num;
    int64_t i, short_i;

    while (monster_arr.size() != 0) {
        pos = monster_arr[0][0];
        life = monster_arr[0][1];
        count++;
        short_i = 0;

        for (i = 0; i < monster_arr.size(); i++) {
            short_i++;
            if (monster_arr[i][0] < pos + range) {
                monster_arr[i][1] -= attack;
            } else {
                break;
            }
        }

        for (i = short_i - 1; i >= 0; i--) {
            if (monster_arr[i][1] <= 0) {
                monster_arr.erase(monster_arr.begin() + i);
            }
        }
    }

    return count;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int in[100050];
int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);
	sort(in + 1, in + N + 1);

	if (in[N] - in[1] >= 2) return !printf("No\n");

	if (in[N] == in[1]) {
		if (in[1] == N - 1) return !printf("Yes\n");

		int mx = N / 2;
		if (in[1] <= mx) return !printf("Yes\n");
		return !printf("No\n");
	}

	int c1 = 0, c2;
	for (i = 1; i <= N; i++) if (in[i] != in[1]) break;
	c1 = i - 1, c2 = N - c1;

	if (in[N] >= c1 + 1 && in[N] <= c1 + c2 / 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/

int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	ll x,k,d,ans;
	cin>>x>>k>>d;
	x=abs(x);
	ll y=x/d;
	if(y>k){
		cout<<x-k*d<<endl;
	}
	else{
		if((k-y)&1) cout<<d-x%d<<endl;
		else cout<<x%d<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
        l: [i128; n],
    }

    if n < 2 {
        println!("0");
        return;
    }

    let mut count = 0usize;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            if l[i] == l[j] {
                continue;
            }
            for k in (j + 1)..n {
                if l[j] == l[k] || l[i] == l[k] {
                    continue;
                }
                let a = l[i];
                let b = l[j];
                let c = l[k];
                if a + b > c && b + c > a && c + a > b {
                    count += 1;
                }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2200
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let c: usize = s.chars().filter(|&c| c == '1').count();
    println!("{}", c);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using Graph = vector<vector<int>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << N/2 + N%2 << endl;
}

Measured memory_bytes: 256
H=int(input())
W=int(input())
N=int(input())

a=0
count=0
if H>W:
    
    for i in range(W):
        a+=H
        count+=1
        if a>=N:
            break
else:
    for i in range(H):
        a+=W
        count+=1
        if a>=N:
            break
print(count)

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

const int MAXN = 5010;

int n, k, s, a[MAXN];
bitset<MAXN> f;

int main()
{
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		a[i] = min(a[i], k);
		s += a[i];
	}
	sort(a + 1, a + 1 + n);
	int flag = 0; f[0] = 1;
	for(int i = n; i >= 0; --i)
	{
		int l = max(k - s, 0), r = k - 1, flag = 0;
		for(int j = l; j <= r; ++j)
			if(f[j]) flag = 1;
		if(!flag) {printf("%d\n", i); break;}
		f |= f << a[i];
		s -= a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,M; cin >> N >> M;
	int now; cin >> now;
	V<ll> s(M+M+2),t(M+M+2);
	rep(i,N-1){
		int to; cin >> to;
		int c = (to-now+M)%M;
		int x = (M-to)%M, y = x+c, z = x+M;
		s[y]+=c,s[z]-=c;
		t[x]++,t[y]-=c+1,t[y+1]+=c;
		now = to;
	}
	rep(i,M+M+1) s[i+1] += s[i];
	rep(_,2) rep(i,M+M+1) t[i+1] += t[i];
	ll ans = 1e18;
	rep(i,M){
		chmin(ans,s[i]+s[i+M]+t[i]+t[i+M]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3456
#include <stdio.h>
#include <stdlib.h>

int ok(int x) {
  int a, b, c;
  a = x % 10;
  x /= 10;
  b = x % 10;
  x /= 10;
  c = x;
  return a == b && b == c;
}

int main(int argc, char *argv[]) {
  int N, ans;
  scanf("%d", &N);
  for (ans = N; !ok(ans); ans++)
    ;
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    ll a=0;
    ll ans =0;
    REP(i,n-1){
        if(s[i]=='A'){
            a++;
        }else if(s[i]=='B'){
            if(s[i+1]=='C'){
                ans+=a;
            }else if(s[i+1]=='A'){
                a=1;
            }else{
                a=0;
            }
            i++;
        }else{
            a=0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n;
double x[55], y[55], centerX, centerY, maxD, currD;

double dist(double a, double b){
  return a*a + b*b;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
  cin>>n;
  for(int i=0; i<n; ++i){
    cin>>x[i]>>y[i];
    centerX += x[i];
    centerY += y[i];
  }
  centerX /= n;
  centerY /= n;
  double P = 0.1;
  for(int i=0; i<70000; ++i){
    maxD = dist(centerX - x[0], centerY - y[0]);
    int at = 0;
    for(int j=1; j<n; ++j){
      currD = dist(centerX - x[j], centerY - y[j]);
      if( currD > maxD){
        maxD = currD;
        at = j;
      }
    }
    centerX += (x[at]-centerX) * P;
    centerY += (y[at]-centerY) * P;
    P *= 0.998;
  }
  cout.precision(10);
  cout<<fixed<<sqrt(maxD)<<'\n';

	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll n;
string s;
ll dp[101010][4];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  cin>>s;
  s="000"+s+"000";
  n+=6;
  ll l=0,r=0;
  ll res=0;
  while(1){
    while(l<n-1&&s[l]=='0'&&s[l+1]=='0')l++;
    if(l==n-1)break;
    r=l;
    while(r<n-1&&(s[r]!='0'||s[r+1]!='0'))r++;
    if(r-l<=3){
      l=r;
      continue;
    }
    vector<ll> idx;
    idx.push_back(l);
    repl(i,l+1,r-2){
      if(s[i]=='1'&&s[i+1]=='0'&&s[i+2]=='1'){
        idx.push_back(i+1);
      }
    }
    idx.push_back(r);
    ll m=idx.size();
    if(m==2){
      l=r;
      continue;
    }
    rep(i,m)rep(j,4)dp[i][j]=0;
    repl(i,1,m-1){
      { // not move
        rep(j,4)maxch(dp[i+1][0],dp[i][j]);
      }
      { // left
        rep(j,4){
          if(j!=3){
            if(idx[i+1]-idx[i]-1==1){
              if(j==0)maxch(dp[i+1][3],dp[i][j]+(idx[i]-idx[i-1]-1));
              if(j==1)maxch(dp[i+1][3],dp[i][j]+(idx[i]-idx[i-1]-2));
              if(j==2)maxch(dp[i+1][3],dp[i][j]+1);
            }else{
              if(j==0)maxch(dp[i+1][1],dp[i][j]+(idx[i]-idx[i-1]-1));
              if(j==1)maxch(dp[i+1][1],dp[i][j]+(idx[i]-idx[i-1]-2));
              if(j==2)maxch(dp[i+1][1],dp[i][j]+1);
            }
          }
        }
      }
      { // right
        rep(j,4){
          if(j!=3){
            maxch(dp[i+1][2],dp[i][j]+(idx[i+1]-idx[i]-2));
            maxch(dp[i+1][3],dp[i][j]+(idx[i+1]-idx[i]-1));
          }
        }
      }
    }
    ll sum=0;
    rep(j,4)maxch(sum,dp[m-1][j]);
    res+=sum;
    l=r;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1308
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int coin[]={500,100,50,10,5,1};
int p,n[6];

int pay(int a)
{
	int ret=0;
	rep(i,6)
	{
		int t=min(n[i],a/coin[i]);
		a-=coin[i]*t; ret+=t;
	}
	return a?inf:ret;
}
int change(int a)
{
	int ret=0;
	rep(i,6)ret+=a/coin[i],a%=coin[i];
	return ret;
}

int main()
{
	while(cin>>p,p)
	{
		rep(i,6)cin>>n[5-i];
		int ans=inf;
		for(int i=p;i<=p+1000;i++)ans=min(ans,pay(i)+change(i-p));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n, x int

	fmt.Scan(&n)
	for i := 1; i <= n; i++ {
		x = i
		if x%3 == 0 {
			fmt.Printf(" %d", i)
		} else {
			for {
				if x%10 == 3 {
					fmt.Printf(" %d", i)
					break
				}
				x /= 10
				if x != 0 {
					continue
				}
				break
			}
		}
	}
	fmt.Println()
}



Measured memory_bytes: 1124
n = int(input())
ans = [0 for _ in range(10050)]

for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i * i + j * j + k * k + i * j + j * k + k * i
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i + 1])


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

int n, m, q, ans;
int a[55], b[55], c[55], d[55], t[15];

inline int sum() {
    int ans = 0;
    for (int i = 1; i <= q; ++i)
        if (t[b[i]] - t[a[i]] == c[i])
            ans += d[i];
    return ans;
}

void dfs(int x) {
    if (x == n + 1) {
        ans = std::max(ans, sum());
        return;
    }
    for (int i = t[x - 1]; i <= m; ++i) {
        t[x] = i;
        dfs(x + 1);
    }
}

int main() {
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 1; i <= q; ++i) scanf("%d%d%d%d", a + i, b + i, c + i, d + i);
    t[0] = 1;
    dfs(1);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    int n;
    cin >> n;
    int a[100005];
    rep(i, n) {
        cin >> a[i];
    }

    int ans = a[0];
    rep(i, n) {
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n;
double probs[3005];
double dp[3005][3005];

double get(int start, int rem, int tab){
    if(rem > start) return 0;
    if(rem == 0 and start == 0) return 1;
    if(dp[start][rem] == -1){
        if(rem == 0) dp[start][rem] = (1-probs[start])*get(start-1, rem, tab+1);
        else dp[start][rem] = probs[start]*get(start-1, rem-1, tab+1) + (1-probs[start])*get(start-1, rem, tab+1);
    }
    return dp[start][rem];
}

int32_t main(){

    loop(3005) for(int j = 0; j < 3005; j++) dp[i][j] = -1;

    dp[0][0] = 1;

    cout << setprecision(10);
    cin >> n;
    loop(n) cin >> probs[i+1];
    int s = ceil(n/(2.0));
    
    double ans = 0;
    Loop(s, n+1, i){
        double temp = get(n, i, 0);
        ans += temp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 74696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int t0=1,renzoku=0,PRL=0,RorL=0,N;
  cin >>S;
  N=S.size();
  vector<int> S2(N,0);
  for(int i=0;i<N;i++){
      if(S[i]=='R'){
          renzoku++;
          if(RorL==1){
          RorL=0;
          renzoku=1;
          t0=1;
          }
      }
      else if(S[i]=='L'){
          //RLが来た時の処理
          if(RorL==0){
              RorL=1;
              PRL=i-1;
              S2[i-1]+=(int)((renzoku+1)/2);
              S2[i]+=(int)(renzoku/2)+1;
              renzoku=0;
              t0++;
          }
          else{
              S2[PRL+(t0%2)]+=1;
              t0++;
          }

      }
  }
  for(int j=0;j<N;j++)
    cout <<S2[j]<<" ";
    cout<<endl;


}

Measured memory_bytes: 1152
import heapq
N, M = map(int,input().split())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = map(int,input().split())
ptj = {}
for i in range(N):
    if A[i] in ptj:
        ptj[A[i]].append(-B[i])
    else:
        ptj[A[i]] = [-B[i]]
count = 0
s = []
for i in range(1,M+1):
    if i in ptj:
        for j in ptj[i]:
            heapq.heappush(s,j)
    if s != []:
        count -= heapq.heappop(s)
print(count)

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

int main (){
  int n;
  cin >> n;
  vector<int> a(n+2);
  a[0]=0;
  a[n+1]=0;
  long long sum=0;

  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    sum+=abs(a[i]-a[i-1]);
  }
  sum+=abs(a[n]);

  for (int i = 1; i <= n; i++)
  {
    int diff = abs(a[i+1]-a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]);
    cout << sum+diff << endl;
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int v[5001];
int main(){
	int n;
	while(cin >> n,n){
		rep(i,n) cin >> v[i];
		int sum = 0 , mx = *max_element(v,v+n);
		for(int i = 0 ; i < n ; i++){
			if(sum+v[i]<0){
				sum = 0;
			}else{
				sum += v[i];
				mx = max(sum,mx);
			}
		}
		cout << mx << endl;
	}
}

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

using namespace std;

int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = W*H/2;
  int num = (W==x*2 && H==y*2) ? 1 : 0;
  printf("%.10f %d\n",ans,num);
}
  
  


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int curtainA = sc.nextInt();
		int curtainB = sc.nextInt();

		if (curtainA <= (curtainB * 2)) {
			System.out.println("0");
		} else {
			System.out.println(curtainA - (curtainB * 2));
		}
	}

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007;
#define inf (1LL<<60)
using namespace std;

struct flower
{
    ll hi;
    ll bty;
};

ll solve(vector<flower>& v,int n)
{
    vector<ll> dp(n+1);
    map<ll,ll> m;
    dp[1]=v[1].bty;
    m[v[1].hi]=dp[1];
    ll ans=dp[1];
    for(int i=2;i<=n;i++)
    {
        dp[i]=v[i].bty;
        auto it=m.lower_bound(v[i].hi+1);
        if(it!=m.begin())
        {
            it--;
            dp[i]+=it->second;
        }
        m[v[i].hi]=dp[i];
        it=m.upper_bound(v[i].hi);
        while(it!=m.end()&&it->second<=dp[i])
        {
            auto temp =it;
            temp++;
            m.erase(it);
            it=temp;
        }
        ans=max(ans,dp[i]);
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    vector<flower> v(n+1);
    for(int i=1;i<=n;i++)
        cin>>v[i].hi;
    for(int i=1;i<=n;i++)
        cin>>v[i].bty;
    cout<<solve(v,n);
    return 0;
}


Measured memory_bytes: 17408
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];
	
	for(int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}
	
	d[0] = 0;
	
	while(1) {
		minv = INFTY;
		u = -1;
		for(int i = 0; i < n; i++) {
			if(minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
	   if(u == -1) break;
	   color[u] = BLACK;
	   for(int v = 0; v < n; v++) {
           if(color[v] != BLACK && M[u][v] != INFTY){
		   	  if(d[v] > M[u][v]) {
	   		      d[v] = M[u][v];
   		          p[v] = u;
           	   	  color[v] = GRAY;
   	           }
           }
   	   }	
	}
	int sum = 0; 
	for(int i = 0; i < n; i++) {
		if(p[i] != -1) sum += M[i][p[i]];
	}
	return sum;
} 

int main() {
	cin >> n;
	
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++){
			int e;
			cin >> e;
			M[i][j] = (e == -1) ? INFTY :e;
		}
	}
	
	cout << prim() << endl;
	
}

Measured memory_bytes: 3080