akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

struct DIJK_LINK
{
	int from;
	int to;
	ll cost;
};

// リンクのリストから隣接リストをつくる
void dijkstra_make_G(vector< vector< pair<int, ll> > >& G, const vector < DIJK_LINK >& links, int N)
{
	G.clear();
	G.resize(N);

	for (int i = 0; i<SZ(links); i++)
	{
		G[links[i].from].push_back(make_pair(links[i].to, links[i].cost));
	}
}


void dijkstra(vector <ll>& D, const int start, const int N, const vector< vector< pair<int, ll> > >& G)
{
	D.clear();
	for (int i = 0; i<N; i++)
	{
		D.push_back(BIGLL);
	}
	priority_queue<pair<ll, int>, vector< pair<ll, int> >, greater< pair<ll, int> > > Q;
	D[start] = 0;
	Q.push(pair<ll, int>(0, start));

	while (!Q.empty()) {

		pair<ll, int> top = Q.top();
		Q.pop();

		int v = top.second;
		ll d = top.first;
		if (d <= D[v]) {
			for (int di = 0; di<SZ(G[v]); di++)
			{
				int v2 = G[v][di].first;
				ll cost = G[v][di].second;
				if (D[v2] > D[v] + cost) {
					D[v2] = D[v] + cost;
					Q.push(pair<ll, int>(D[v2], v2));
				}
			}
		}
	}
}

int main(void) 
{
	int n, m, s, t;
	cin >> n >> m >> s >> t;


	vector< vector< pair<int, ll> > > G[2];
	vector < DIJK_LINK > links[2];

	for (int i=0;i<m;++i)
	{
		int u, v;
		ll a, b;

		cin >> u >> v >> a >> b;

		{
			DIJK_LINK tmp;
			tmp.from = u - 1;
			tmp.to = v - 1;
			tmp.cost = a;
			links[0].push_back(tmp);
			swap(tmp.from, tmp.to);
			links[0].push_back(tmp);
		}

		{
			DIJK_LINK tmp;
			tmp.from = u - 1;
			tmp.to = v - 1;
			tmp.cost = b;
			links[1].push_back(tmp);
			swap(tmp.from, tmp.to);
			links[1].push_back(tmp);
		}
	}

	dijkstra_make_G(G[0], links[0], n);
	dijkstra_make_G(G[1], links[1], n);

	vector <ll> D[2];
	dijkstra(D[0], s - 1, n, G[0]);
	dijkstra(D[1], t - 1, n, G[1]);

	vector <ll> cost;
	for (int i = 0; i < n; ++i)
	{
		cost.push_back(D[0][i] + D[1][i]);
	}

	vector <ll> mincost(n);
	mincost[n - 1] = cost[n - 1];
	for (int i = n-2; i >=0; --i)
	{
		mincost[i] = min(mincost[i+1], cost[i]);
	}

	for (int i = 0; i < n; ++i)
	{
		printf("%lld\n", 1000000000000000LL-mincost[i]);
	}

	return 0;
}


Measured memory_bytes: 26716
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=100007;
int a[maxn],n,m,f[maxn],vis[maxn],sum[maxn],b[maxn],c[maxn],p[maxn],fa[maxn];
vector<int>v[maxn];
int find(int x){return fa[x]==x?fa[x]:fa[x]=find(fa[x]);}
inline bool cmp(int x,int y){return c[x]<c[y];}
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)cin>>a[i]>>b[i],p[i]=fa[i]=i,c[i]=max(a[i]-b[i],0ll);
	sort(p+1,p+1+n,cmp);
	for(int i=1,x,y;i<=m;++i){
		cin>>x>>y;v[x].push_back(y);v[y].push_back(x);
	}
	for(int i=1;i<=n;++i){
		int x=p[i];vis[x]=1;
		sum[x]=b[x];vector<int>son;
		for(auto y:v[x])if(find(y)^find(x)&&vis[y])sum[x]+=sum[find(y)],son.push_back(find(y)),fa[find(y)]=find(x);
		f[x]=sum[x]-b[x]+max(a[x],b[x]);
		for(auto y:son)f[x]=min(f[x],sum[x]-b[x]-sum[y]+max(max(a[x],b[x]),f[y]+b[x]));
	}
	cout<<f[p[n]];
}

Measured memory_bytes: 13304
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
#include <cmath>
#include <stack>
#include <bitset>

using namespace std;

#define int long long
#define MAX 1e18

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while(true) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        } 
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,g,b,n;
  cin >> r >> g >> b >> n;
  int ans=0;
  for(int i=0;i<=3000;i++){
    for(int j=0;j<=3000;j++){
      if(n-i*r-j*g>=0&&(n-i*r-j*g)%b==0){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

int main()
{
    int n, a[110], cnt=0;
    bool ok;
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];
    for (int i=100; i>=1; i--)
    {
        cnt=0;
        ok=true;
        for (int j=1; j<=n; j++)
        {
            cnt+=a[j];
            cnt-=i;
            if (cnt<0) ok=false;
            if (!ok) break;
        }
        if (ok)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    vector<double> x(3),y(3);
    REP(i,3){
        cin >> x[i] >> y[i];
    }
    x[0] -= x[2];
    y[0] -= y[2];
    x[1] -= x[2];
    y[1] -= y[2];
    x[2] = 0;
    y[2] = 0;
    double area = 0.5 * fabs(x[0]*y[1] - y[0]*x[1]);

    double mdist = 0;
    double sumdist = 0;
    REP(i,3){
        int j = (i+1)%3;
        double dist = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        sumdist += dist;
        mdist = max(mdist, dist);
    }
    double r = area * 2.0 / sumdist;
    double ans = mdist * r / (2*r+mdist);
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int dis[10000][10000];
int main() {
  int n,x,y;
  cin >> n >> x >> y;
  int a=y-x-1,c=(x+y)/2;
  vector<int> b(n+1,0);
  r2(i,n){
    for(int j=i+1; j<=n; j++) {
      if(i<=x) {
        if(j<=c) dis[i][j]=j-i;
        else if(j>=y) dis[i][j]=j-i-a;
        else dis[i][j]=y-i-a-j+y;
      }
      else if(i<=y) {
        dis[i][j]=min(j-i,i-x+dis[x][j]);
      }
      else dis[i][j]=j-i;
      b.at(dis[i][j])++;
    }
  }
  r2(i, n) cout << b.at(i) << endl;
}

Measured memory_bytes: 78720
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++){
        if(i%2==0&&s[i]=='L'){
            ans++;
        }
        if(i%2==1&&s[i]=='R'){
            ans++;
        }
    }
    if(ans!=0){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long a = in.nextLong(), b = in.nextLong(), x = in.nextLong();
			long c1 = (a-1)/x;
			long c2 = b/x;
			out.println(a == 0 && (a-1) % x != 0 ? c2-c1+1 : c2-c1);
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(ll i=0; i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);



















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h, n;
  cin >> h >> n;
  ll ans =0;
  loop(n){
    int x;
    cin >> x;
    ans+=x;
  }
  if(ans >= h) cout << "Yes\n";
  else cout << "No\n";
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 256
N, M = gets.split.map{|i|i.to_i}
m = Array.new(N){Array.new(N){false}}
M.times{
    a, b = gets.split.map{|i|i.to_i - 1}
    m[a][b] = true
    m[b][a] = true
}

q = []
q << [0]
count = 0
until q.empty?
    o = q.shift
    if o.size == N
        count += 1
        next
    end
    n = o[-1]
    N.times{|i|
        next unless m[n][i]
        next if o.include?(i)
        q << (o + [i])
    }
end
puts count


Measured memory_bytes: 4348
N = int(input())
a = list(map(int, input().split()))
cnt=0
for i in range(N):
    if a[i] == i+1:
        if i+1 == N:
            inter=a[i]
            a[i]=a[i-1]
            a[i-1]=inter
        else:
            inter=a[i]
            a[i]=a[i+1]
            a[i+1]=inter
        cnt +=1
print(cnt)

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

using namespace std;

int main(){
    queue<pair<string, int>> q;
    int n, m, t=0, temp_time;
    string temp_name;
    pair<string, int> temp_pair;
    cin >> n >> m;
    for(int i=0; i<n; i++) {
        cin >> temp_name >> temp_time;
        q.push(pair<string, int>{temp_name, temp_time});
    }
    while(!q.empty()){
        temp_pair = q.front();
        if(temp_pair.second>m){
            q.push(pair<string, int>{temp_pair.first, temp_pair.second-m});
            t = t + m;
        }else{
            t = t + temp_pair.second;
            cout << temp_pair.first << " " << t << endl;
            
        }
        q.pop();
    }
    
    return 0;
}


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


int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n)
    cin >> h[i];
  h[0]--;
  for (int i=1; i<n; i++)
  {
    if (h[i] < h[i-1])
    {
      cout << "No\n";
      return 0;
    }
    if (h[i] > h[i-1])
      h[i]--;
  }
  cout << "Yes\n";
  return 0;
}

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

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

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

int main(void) {
    long long n, p[6], sum = 0;
    cin >> n;
    for (int i = 0; i < 5; i++) {
        cin >> p[i];
    }
    sort(p, p + 5);
    if (p[0] >= n) {
        sum = 5;
    } else {
        sum = 4 + n / p[0];
        sum += (n % p[0] > 0) ? 1 : 0;
    }
    cout << sum << "\n";
}


Measured memory_bytes: 256
S = input()
a = S[0:2]
b = S[2:4]
tuki = ['01','02','03','04','05','06','07','08','09','10','11','12']
if a in tuki and b in tuki:
    print('AMBIGUOUS')
if a in tuki and b not in tuki:
    print('MMYY')
if a not in tuki and b in tuki:
    print('YYMM')
if a not in tuki and b not in tuki:
    print('NA')

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 1000005;
const int K = 25;
int t[N], a[4][N], b[2];
vector < int > v[2];
int sum (int r)
{
	int result = 0;
	for (; r >= 0; r = (r & (r+1)) - 1)
		result += t[r];
	return result;
}

void inc (int i, int delta)
{
	for (; i < N; i = (i | (i+1)))
		t[i] += delta;
}
int invc(vector < int > v){
    int res = 0;
    for (int i = 0; i < N; i++) t[i] = 0;
    for (auto i: v){
        inc(i, 1);
        res += sum(N - 1) - sum(i);
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int r = 0;
    for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= n; j++) cin >> a[i][j];
    for (int j = 1; j <= n; j++){
        if (a[2][j] % 2 == j % 2){
            cout << "No";
            return 0;
        }
        if (a[1][j] > a[3][j]){
            b[j % 2]++;
        }
        v[j % 2].pb(a[2][j]);
        if (a[1][j] != a[2][j] - 1){
            if (a[1][j] != a[2][j] + 1 || a[3][j] != a[2][j] - 1){
                cout << "No";
                return 0;
            }
        } else{
            if (a[3][j] != a[2][j] + 1){
                cout << "No";
                return 0;
            }
        }
    }
    b[1] += invc(v[0]);
    b[0] += invc(v[1]);
    if (b[0] % 2 || b[1] % 2){
        cout << "No";
        return 0;
    }
    cout << "Yes";
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<ll,ll>;

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

int N, A, B;
ll vs[100];
P dp[100][100];

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

    std::cin >> N >> A >> B;

    for(int i=0;i<N;++i){
        std::cin >> vs[i];
    }

    dp[0][0] = std::make_tuple(0, 1);
    for(int i=0;i<N;++i){
        for(int j=0;j<=N;++j){
            if(fst(dp[i][j]) > fst(dp[i+1][j])){
                dp[i+1][j] = dp[i][j];
            }else if(fst(dp[i][j]) == fst(dp[i+1][j])){
                snd(dp[i+1][j]) += snd(dp[i][j]);
            }

            if(j + 1 <= N){
                if(fst(dp[i][j]) + vs[i] > fst(dp[i+1][j+1])){
                    dp[i+1][j+1] = std::make_tuple(fst(dp[i][j]) + vs[i], snd(dp[i][j]));
                }else if(fst(dp[i][j]) + vs[i] == fst(dp[i+1][j+1])){
                    snd(dp[i+1][j+1]) += snd(dp[i][j]);
                }
            }
        }
    }

    ll mx = 0, mx_n = 1;
    for(int i=A;i<=B;++i){
        if(fst(dp[N][i]) * mx_n > mx * i){
            mx = fst(dp[N][i]);
            mx_n = i;
        }
    }

    ll cnt = 0;
    for(int i=A;i<=B;++i){
        if(fst(dp[N][i]) * mx_n == mx * i){
            cnt += snd(dp[N][i]);
        }        
    }

    printf("%.10f\n", 1. * mx / mx_n);
    printf("%lld\n", cnt);
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    String str = sc.next();
    for (int i = 0; i < str.length() - 2; ++i) {
      int[] cnt = new int[256];
      for (int j = 0; j < 3; ++j) {
        cnt[str.charAt(i + j)]++;
      }
      for (int j = 0; j < 256; ++j) {
        if (cnt[j] >= 2) {
          ++i;
          System.out.println(i + " " + (i + 2));
          return;
        }
      }
    }
    for (int i = 0; i < str.length() - 1; ++i) {
      int[] cnt = new int[256];
      for (int j = 0; j < 2; ++j) {
        cnt[str.charAt(i + j)]++;
      }
      for (int j = 0; j < 256; ++j) {
        if (cnt[j] == 2) {
          ++i;
          System.out.println(i + " " + (i + 1));
          return;
        }
      }
    }
    System.out.println(-1 + " " + -1);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> town(n+1,0),hero(n,0);
	for(int &i:town){
		scanf("%d",&i);
	}	
	for(int &i:hero){
		scanf("%d",&i);
	}
	long long int ans=0ll;
	if(hero[0]>=town[0]){
		ans+=town[0]+0ll;
		hero[0]-=town[0];
		town[0]=0;
	}
	else{
		ans+=hero[0]+0ll;
		hero[0]=0;
		town[0]-=hero[0];
	}
	for(int i=1;i<n+1;i++){
		if(hero[i-1]>=town[i]){
			ans+=town[i]+0ll;
			hero[i-1]-=town[i];
			town[i]=0;
		}
		else{
			ans+=hero[i-1]+0ll;
			town[i]-=hero[i-1];
			hero[i-1]=0;
		}
		if(hero[i]>=town[i]){
			ans+=town[i]+0ll;
			hero[i]-=town[i];
			town[i]=0;
		}
		else{
			ans+=hero[i]+0ll;
			town[i]-=hero[i];
			hero[i]=0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
h, w = map(int, input().split())
M = [list(input()) for _ in range(h)]
M = [[1 if M[i][j]=='.' else 0 for j in range(w)] for i in range(h)]

sy, sx = 0, 0
gy, gx = h-1, w-1

from collections import deque

d = deque()
d.append((sy, sx))

goal = 0
V = [[0]*w for i in range(h)]
V[sy][sx] = 1
D = [[-1]*w for i in range(h)]
D[sy][sx] = 1
while len(d):
  y_cur, x_cur = d.popleft()
  #print(y_cur, x_cur)
  if y_cur == gy and x_cur == gx:
    goal = 1
    break
  for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
    y_nxt = y_cur + dy
    x_nxt = x_cur + dx
    if y_nxt>=0 and y_nxt<h and x_nxt>=0 and x_nxt<w:
      if M[y_nxt][x_nxt] == 1 and V[y_nxt][x_nxt]==0:
        V[y_nxt][x_nxt] = 1
        D[y_nxt][x_nxt] = D[y_cur][x_cur] + 1
        d.append((y_nxt, x_nxt))

if goal:
  black = h*w - sum([sum(M[i]) for i in range(h)])
  white = h*w - black
  ans = white - D[gy][gx]
  #print(black, white, D[gy][gx])
  print(ans)
else:
  print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

int main()
{
	string s;
	cin>>s;
	if(s[1]=='B')
		cout<<"ARC"<<endl;
	else
		cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define _GLIBCXX_DEBUG
const int MOD = 1000000007;

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if (op=='+') cout << A+B << endl;
  else cout << A-B << endl;
}

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;

}


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

char chess(int h, int w) {
    if((h+w)%2==0) {
        return '#';
    }
    return '.';
}

int main(void){
    int H,W;
    while(true){
        cin >> H >> W;
        if(H==0&&W==0){
            break;
        }
    for(int i = 0; i< H; i++) {
        for(int j=0; j< W; j++) {
            cout << chess(i,j);
        }
        cout << endl;
    }
    cout << endl;
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  rep(i, H){
    cin >> S.at(i);
  }
  ll ans = INF;
  bool flag = false;
  bool flag2 = false;
  for (int tmp = 0; tmp < (1 << H-1); tmp++) {
    bitset<9> s(tmp);
    ll g = 0;
    vector<ll> id(H, 0);
    rep(i, H){
      id.at(i) = g;
      if(tmp >> i & 1){
        g++;
      }
    }
    g++;
    vector<ll> now(g, 0);
    ll b = 0;
    ll cut = 0;
    rep(i, W){
      b++;
      rep(j, H){
        now.at(id.at(j)) += S.at(j).at(i) - '0';
      }
      rep(j, g){
        if(now.at(j) > K){
          if(b == 1){
            flag = true;
            break;
          }
          cut++;
          flag2 = true;
          break;
        }
      }
      if(flag){
        break;
      }
      if(flag2){
        rep(j, g){
          now.at(j) = 0;
        }
        i--;
        b = 0;
        flag2 = false;
      }
    }
    if(flag){
      flag = false;
      continue;
    }
    chmin(ans, g-1+cut);
  }
  cout << ans << endl;
}

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

#define Type int
const Type MOD = 1000000007;
namespace ModOp {
    inline Type mo(Type x) {
        if(x >= MOD) x -= MOD;
        if(x < 0) x += MOD;
        return x;
    }
    struct MF {
        Type v;
        MF(Type x = 0): v(mo(x)) { }
        operator Type() { return v; }
        MF operator + (const MF& f) const { return mo(v + f.v); }
        MF operator - (const MF& f) const { return mo(v - f.v); }
        MF operator * (const MF& f) const { return 1LL * v * f.v % MOD; }
        MF operator / (const MF& f) const { return v / f.v; }
        MF operator - () const { return MOD - v; }
        MF operator >> (int idx) const { return v >> idx; }
        MF operator << (int idx) const { return v << idx; }
        bool operator == (const MF& f) const { return v == f.v; }
        bool operator != (const MF& f) const { return v != f.v; }
        bool operator > (const MF& f) const { return v > f.v; }
        bool operator < (const MF& f) const { return v < f.v; }
        bool operator >= (const MF& f) const { return v >= f.v; }
        bool operator <= (const MF& f) const { return v <= f.v; }
        friend ostream& operator << (ostream& out, MF f) { return out << f.v; }
        friend istream& operator >> (istream& in, MF f) { return in >> f.v; }
        bool scan() { return scanf("%d", &v) != -1; }
        void print() { printf("%d", v); }
    };
}
#undef Type

template<typename T> T qpow(T x, int y) {
    T ret = T(1);
    for(; y; y >>= 1, x = x * x)
        if(y & 1) ret = ret * x;
    return ret;
}
using ModOp::MF;

const int maxn = 200200, N = 200000;
MF fac[maxn], ifac[maxn], onlyb[maxn], onlyw[maxn];
MF C(int x, int y) {
    if(x < y) return MF(0);
    return fac[x] * ifac[y] * ifac[x - y];
}

int b, w;
int main() {
    #ifdef FREOPEN
        freopen("in.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    fac[0] = ifac[0] = MF(1);
    for(int i = 1; i <= N; ++i) {
        fac[i] = fac[i - 1] * MF(i);
        ifac[i] = qpow(fac[i], MOD - 2);
    }

    scanf("%d%d", &b, &w);
    for(int i = 1; i <= b + w; ++i) {
        onlyb[i] = onlyb[i - 1] + C(i-1, w-1) * qpow(MF(2), MOD-1-i);
        onlyw[i] = onlyw[i - 1] + C(i-1, b-1) * qpow(MF(2), MOD-1-i);
    }
    
    for(int i = 0; i < b + w; ++i) {
        cout << (MF(1) + onlyb[i] - onlyw[i]) * qpow(MF(2), MOD - 2) << '\n';
    }
 
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
long long dp[100005],a,b;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a,&b);
		for(int j=m-a;j>-1;j--)
		{
			dp[j+a]=max(dp[j+a],dp[j]+b);
		}
	}
	long long ans=0;
	for(int i=1;i<=m;i++)ans=max(ans,dp[i]);
	printf("%lld",ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

int[] mon=new int[46298];
int i=0;
for(i=0;i<46298;i++){
mon[i]=(int)(((double)i)*1.08);
}

i=0;
int dif=0;
for(i=0;i<46298;i++){
    if(num==mon[i]){
    System.out.println(i);
    break;
    }else{
    dif=dif+1;
    }
}
if(dif==46298){
System.out.println(":(");
}
  
  
}
}

Measured memory_bytes: 23252
import sys
input = sys.stdin.readline
a=list(input().strip())
b=list(input().strip())
c=list(input().strip())
x=a
while True:
    #print(x,a,b,c)
    t=x.pop(0)
    if t=="a":
        x=a
        if len(x)==0:
            print("A")
            exit()
    elif t=="b":
        x=b
        if len(x)==0:
            print("B")
            exit()
    elif t=="c":
        x=c
        if len(x)==0:
            print("C")
            exit()


Measured memory_bytes: 38256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K=map(int,input().split())
    H=sorted(list(map(int,input().split())),reverse=True)

    if K>=N:
        print(0)
    else:
        cnt=0


        H=H[K:]

        cnt+=sum(H)

        print(cnt)


resolve()

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

const int MAX_Q = 100000;
bool isPrime[MAX_Q + 1];
bool isLike_2017[MAX_Q + 1];
int like_2017s[MAX_Q + 1];

void init() {
  for (int i=0; i<=MAX_Q; i++) {
    isPrime[i] = true;
    isLike_2017[i] = false;
    like_2017s[i] = 0;
  }
  isPrime[0] = isPrime[1] = false;
  for (int i=2; i<=MAX_Q; i++) {
    if (!isPrime[i]) continue;
    isPrime[i] = true;
    for (int j=2*i; j<=MAX_Q; j+=i) {
      isPrime[j] = false;
    }
  }
  for (int i=1; i<=MAX_Q; i+=2) {
    isLike_2017[i] = (isPrime[i] && isPrime[(i+2)/2]) ? true : false;
  }
  for (int i=3; i<=MAX_Q; i+=2) {
    like_2017s[i] = like_2017s[i-2];
    if (isLike_2017[i]) like_2017s[i]++;
  }
}

int solve(int l, int r) {
  int res = like_2017s[r];
  if (l != 1) res -= like_2017s[l-2];
  return res;
}

int main() {
  int Q, l, r;
  init();
  cin >> Q;
  for (int i=0; i<Q; i++) {
    scanf("%d %d", &l, &r);
    printf("%d\n", solve(l, r));
  }
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,l,a[N],st[N],top=0;
bool check() {
    for(int i=1;i<n;i++) if(a[i]+a[i+1]>=l) return 1;
    return 0;
}
int main() {
    cin>>n>>l;
    for(int i=1;i<=n;i++) a[i]=gi();
    if(!check()) return puts("Impossible"),0;
    puts("Possible");
    int p=0;
    for(int i=1;i<n;i++) if(a[i]+a[i+1]>=l) { p=i;break; }
    st[++top]=p;
    for(int i=p-1;i;i--) st[++top]=i;
    for(int i=p+1;i<n;i++) st[++top]=i;
    for(int i=top;i;i--) printf("%d\n",st[i]);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9')
	{
		k=k*10+(s-'0');
		s=getchar();
	}
	return k*base;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		write(-x);
	}
	else
	{
		if(x/10)write(x/10);
		putchar(x%10+'0');
	}
}
int n,ans;
int i,s;
int a[1001000];
int main()
{
	n=read();
	while (n--)
	{
		i++;
		a[i]=read();
		if (a[i]==i) 
		{
			s++;a[i]=-233;
			if (a[i-1]==-233) 
			{
				s--;
				a[i]=-2333333;
			}
		}
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 640
n, l = map(int, input().split())
ll = []

for i in range(1, n+1):
    ll.append(i + l - 1)

if ll[0]>= 0:
    ans = sum(ll) - ll[0]
elif ll[n-1]<=0:
    ans = sum(ll) - ll[n-1]
else:
    ans = sum(ll)

print(ans)

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll K;

void init()
{
	cin >> K;
}

void print(ll x, int y)
{
	cout << 50 << endl;
	vector<ll> v(50, x - y);
	rep(i, y) {
		v[i] += 51;
	}
	cout << v[0];
	reps(i, 1, 50) {
		cout << " " << v[i];
	}
	cout << endl;

}

void solve()
{
	ll x = 49 + K / 50;
	K %= 50;
	print(x, (int) K);
}




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

int main() {
  int N;
  cin >>N;
  double x[N];
  string u[N];
  for(int i=0;i<N;i++){
    cin >>x[i]>>u[i];
  }
  double ans=0;
  for(int i=0;i<N;i++){
    if(u[i]=="JPY"){
      ans+=x[i];
    }
    else{
      ans+=x[i]*380000.0;
    }   
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define fo(i,k,n) for(i=k;i<=n;i++)
#define endl '\n'
ll arr[100001][3];
ll dp[100001][3];
ll f(ll n,ll i,ll last){
	if(dp[i][last]>-1) return dp[i][last];
	if(i==n) return 0;
	ll j,ans = LLONG_MIN;
	fo(j,0,2){
		if(j==last) continue;
		ans  = max(ans,arr[i][j] + f(n,i+1,j));
	}
	return dp[i][last]=ans;
}
void solve(){
	ll n,a,b,c,i,j,ans=LLONG_MIN;
	cin>>n;
	fo(i,0,n-1){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	memset(dp,-1,sizeof(dp));
	fo(j,0,2){
		ans = max(ans,arr[0][j] + f(n,1,j));
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	t=1;//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 12800
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())
    h = sorted([int(input()) for i in range(N)], reverse=True)

    MAX = (h[0] // B) + 1

    l, r = 0, MAX
    while True:
        # print(l, r)
        if l + 1 >= r:
            print(r)
            break
        t = (l + r) // 2
        Bt = B * t
        a = 0
        i = 0
        while i < N and h[i] > Bt:
            tmp = h[i] - Bt
            if tmp % (A-B) == 0:
                a += tmp // (A-B)
            else:
                a += tmp // (A-B) + 1
            i += 1
        # print(t, a)
        if a <= t:# t回で倒しきれる
            l, r = l, t
        else:
            l, r = t, r

if __name__ == "__main__":
    main()

Measured memory_bytes: 8276
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int sum = 0;
    for(int i=0; i<5; ++i)
        sum += (v[i] + 9) / 10 * 10;

    int ans = INT_MAX;
    for(int i=0; i<5; ++i){
        int tmp = sum - (v[i] + 9) / 10 * 10 + v[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==0&&b==100){
    cout<<101<<endl;
  }
  else if(a==0&&b<100){
    cout<<b<<endl;
  }
  else if(a==1&&b==100){
    cout<<10100<<endl;
  }
  else if(a==1&&b<100){
    cout<<100*b<<endl;
  }
  else if(a==2&&b==100){
    cout<<1010000<<endl;
  }
  else{
    cout<<10000*b<<endl;
  }
  return 0;
}

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

using namespace std;

const int N = 100005; 
const int L = 18; 
int toR[L][N];
int toL[L][N];

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    int D; cin >> D;
    for (int i = 0; i < n; i++) {
        int j = upper_bound(a.begin(), a.end(), a[i]+D) - a.begin();
        toR[0][i] = j - 1;
    }
    for (int j = 1; j < L; j++) {
        for (int i = 0; i < n; i++) {
            toR[j][i] = toR[j-1][toR[j-1][i]];
        }
    }
    for (int i = 0; i < n; i++) {
        int j = lower_bound(a.begin(), a.end(), a[i]-D) - a.begin();
        toL[0][i] = j;
    }
    for (int j = 1; j < L; j++) {
        for (int i = 0; i < n; i++) {
            toL[j][i] = toL[j-1][toL[j-1][i]];
        }
    }
    int q; cin >> q;
    while (q--) {
        int i,k;
        cin >> i >> k;
        i--; k--;
        if (i < k) {
            int res = 0;
            for (int j = L-1; j >= 0; j--) {
                if (toR[j][i] >= k) continue;
                res |= 1<<j;
                i = toR[j][i];
            }if (i<k) res++;
            cout << res << "\n";
        } else {
            int res = 0;
            for (int j = L-1; j >= 0; j--) {
                if (toL[j][i] <= k) continue;
                res |= 1<<j;
                i = toL[j][i];
            }if (i>k) res++;
            cout << res << "\n";
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#include <atcoder/fenwicktree>
using namespace atcoder;

int main() {
    ll N, Q;
    cin >> N >> Q;

    fenwick_tree<ll> ft(N);
    rep(i, N) {
        ll a;
        cin >> a;
        ft.add(i, a);
    }

    rep(i,Q) {
        ll t, x, y;
        cin >> t >> x >> y;
        if (t == 0) {
            ft.add(x, y);
        } else {
            cout << ft.sum(x, y) << endl;
        }
    }
    return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    list<char> ls;
    string s;
    cin >> s;

    for(auto ch : s) {
        ls.push_back(ch);
    }

    int q;
    cin >> q;

    int hd = 1; /** hd = 0 Norm **/

    while(q--) {
        int t;
        cin >> t;

        if(t == 1) hd ^= 1;
        else {
            int f;
            char c;

            cin >> f >> c;

            if(f == 1) {
                if(hd) {
                    ls.push_front(c);
                }else {
                    ls.push_back(c);
                }
            }else {
                if(hd) {
                    ls.push_back(c);
                }else {
                    ls.push_front(c);
                }
            }
        }
    }

    string ans;
    for(auto el : ls) {
        ans += el;
    }

    if(!hd) reverse(all(ans));

    cout << ans;
}











Measured memory_bytes: 10452
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int dp[111][4][4];
int C[111];
int N, K;

int const MOD = 10000;

int solve(int idx = 0, int p = 0, int pp = 0) {
  int& ret = dp[idx][p][pp];
  if(ret + 1) return ret;
  if(C[idx] && (C[idx] != p || C[idx] != pp)) return ret = solve(idx + 1, C[idx], p);
  if(C[idx]) return ret = 0;
  if(idx == N) return ret = 1;
  ret = 0;
  REP(i, 1, 4) {
    if(i == p && i == pp) continue;
    ret += solve(idx + 1, i, p);
    ret %= MOD;
  }
  return ret % MOD;
}

int main() {

  cin >> N >> K;
  rep(i, K) {
    int A, B; cin >> A >> B;
    C[A-1] = B;
  }

  minus(dp);
  cout << solve() << endl;
  
  return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();

		if(A==1)
			A+=100;
		if(B==1)
			B+=100;
		String ans ;
		if(A<B){
			ans="Bob";
		}else if(A>B){
			ans="Alice";
			
		}else{
			ans="Draw";
		}

		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

ll K;

bool prime_factorize(long long N)
{
    vector<ll> res;
    for (long long a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back(N);
        if(K == N){
            return true;
        }
    }
 
    return false;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(15);
    ll K;
    cin >> K;
    ll x = 7%K;
    ll ans = 0;
    ll i = 1;
    set<int> s;
    while (s.count(x) == 0)
    {
        if(x == 0){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % K;
        i++;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 50440
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int INF = -1;
		int l = 1<<16;
		long[] sat = new long[100];
		int[] time = new int[100];
		long[][] dp = new long[101][l];
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = 0; i < n; i++) {
				sat[i] = time[i] = 0;
				Arrays.fill(dp[i], INF);
			}
			Arrays.fill(dp[n], INF);
			
			for (int i = 0; i < n; i++) {
				int m = sc.nextInt();
				sat[i] = sc.nextInt();
				for (int j = 0; j < m; j++) {
					int s = sc.nextInt()-6, e = sc.nextInt()-6;
					for (int k = s; k < e; k++) {
						time[i] += (1 << k);
					}
				}
			}
			
			dp[0][0] = 0;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					if (dp[i][j] != INF) {
						dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j]);
						if ((j & time[i]) == 0) {
							dp[i+1][j|time[i]] = Math.max(dp[i+1][j|time[i]], dp[i][j]+sat[i]);
						}
					}
				}
			}
			long res = 0;
			for (int i = 0; i < l; i++)
				res = Math.max(res, dp[n][i]);
			
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 119320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, A, B, R, ans = 0;
  cin >> N >> A >> B;
  ans = (N / (A + B)) * A;
  R = N % (A + B);
  ans += min(A, R);
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    
    
    int N;
    cin >> N;
    int K;
    cin >> K;
    
    if(N%K==0){
        cout << 0 <<endl;
    }
    else{
        cout << 1 << endl;
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int v[2];
    cin >> v[0] >> v[1];
    ll sum = 0;
    rep(i, n)
    {
        if (v[0] > v[1])
        {
            sum += v[0] - v[1];
            v[1] = v[0];
        }

        v[0] = v[1];
        cin >> v[1];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
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 n, a[100000], ta, mu, rin;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 4 == 0)ta++;
		else if (a[i] % 2 == 0)mu++;
		else rin++;
	}
	if ((mu == 0 && rin <= ta + 1) || (mu != 0 && rin <= ta))cout << "Yes" << endl;
	else cout << "No" << endl;
	getchar(); getchar();
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();

    long d = 100;
    int count = 0;

    while (true) {
      if (d >= x) {
        System.out.println(count);
        break;
      }
      d += d*0.01;
      count++;
    }

  }

}


Measured memory_bytes: 35728