akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!


int imos[1000000];

signed main() {
	int A, P;
	cin >> A >> P;
	int kakera = A * 3 + P;
	cout << kakera / 2 << "\n";




	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

    vector<int> d = {1, 2, 4, 8};
    vector<int> v(4);
    for (auto &t : v) {
        cin >> t;
    }
    for (int i = 0; i < 3; i++) {
        v[i + 1] = min(v[i + 1], v[i] * (d[i + 1] / d[i]));
    }
    // for (int i = 0; i < 4; i++) {
    //     cerr << v[i] << ' ';
    // }
    // cerr << endl;
    int n;
    cin >> n;
    n *= 4;
    int ans = 0;
    for (int i = 3; i >= 0; i--) {
        ans += v[i] * (n / d[i]);
        n %= d[i];
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    ulong mod = 1000000009;
    static void Main(string[] args)
    {
        ulong n = ulong.Parse(Read.Str());
        List<char> cap = new List<char> { };
        HashSet<char> kab = new HashSet<char> { };
        ulong[] a = new ulong[5];
        for (ulong i = 0; i < n; i++)
        {
            char Jksd = Console.ReadLine()[0];

            if (Jksd == 'M') { a[0]++; }
            else if (Jksd == 'A') { a[1]++; }
            else if (Jksd == 'R') { a[2]++; }
            else if (Jksd == 'C') { a[3]++; }
            else if (Jksd == 'H') { a[4]++; }
        }
        Array.Sort(a);

        ulong ans = 0;
        for (int i = 0; i < 5; i++)
        {
            for (int j = i + 1; j < 5; j++)
            {
                for (int k = j + 1; k < 5; k++)
                {
                    ans += a[i] * a[j] * a[k];
                }
            }
        }
        Console.WriteLine(ans);


        Console.ReadLine();
    } public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

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

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class FAbsoluteMinima {
public:
    void solve(std::istream& in, std::ostream& out) {
        priority_queue<int> small;
        priority_queue<int, vector<int>, greater<int>> large;
        int Q;
        in >> Q;
        ll answer = 0;
        REP(i,0,Q) {
            int type;
            in >> type;
            if (type == 1) {
                int a, b;
                in >> a >> b;

                const int oldMedian = small.empty() ? 0 : small.top();
                const int sizeDiff = small.size() - large.size();
                if (small.empty() || small.top() > a) {
                    small.push(a);
                } else {
                    large.push(a);
                }
                while (small.size() > large.size() + 1) {
                    int tmp = small.top();
                    large.push(tmp);
                    small.pop();
                }
                while (small.size() < large.size()) {
                    int tmp = large.top();
                    small.push(tmp);
                    large.pop();
                }
                const int newMedian = small.top();
                answer += b + abs(newMedian - a) + sizeDiff * abs(newMedian - oldMedian);
            } else {
                out << small.top() << " " << answer << "\n";
            }
        }
    }
};


signed main() {
    FAbsoluteMinima solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
	string S;
	cin >> S;
	int ans = 0, flg=1;
	for(int i=0; i<3; i++){
		if(S.at(i)=='R' && flg==0){
			ans++;
		}else if(S.at(i)=='R' && flg==1){
			ans=1;
			flg=0;
		}else if(S.at(i)=='S'){
			flg=1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
  int n,flag,flag2;
  int d1[100],d2[100];
  flag = 0;
  flag2 = 0;
  scanf("%d", &n);
  for(int i = 0; i < n;i++){
    scanf("%d %d", &d1[i], &d2[i]);
    if(d1[i] == d2[i]){
      flag++;
    }
    else{
      flag = 0;
    }
    if(flag == 3){
      flag2 = 1;
    }
  }
  if(flag2 == 1)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    
    int n;
    cin >> n;
    
    int d[n][n];
    rep(i, n) rep(j, n) cin >> d[i][j];
    
    rep(k, n) rep(i, n) rep(j, n) {
        if (d[i][k] + d[k][j] < d[i][j]) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    ll ans = 0;
    rep(i, n) rep3(j, i + 1, n) {
        ans += d[i][j];
    }
    
    rep(i, n) rep3(j, i + 1, n) {
        rep(k, n) {
            if (k == i || k == j) continue;
            if (d[i][k] + d[k][j] == d[i][j]) {
                ans -= d[i][j];
                break;
            }
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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





///////////////////////////


int main() {
	char c[3][3];
	rep(i, 3)rep(j, 3) cin >> c[i][j];
	rep(i, 3) cout << c[i][i];

	system("PAUSE");

}


Measured memory_bytes: 504
# -*- coding: utf-8 -*-

# 整数の入力
a = int(input())

flag = 0
for i in range(1, 10):
  if (a % i == 0 and a / i < 10 and a / i >= 1):
    print('Yes')
    flag = 1
    break

if (flag == 0):
  print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int V, E, r;
int dist[1005];
vector<vector<pii>> g;

int main() {
    cin >> V >> E >> r;
    g.resize(V);
    rep(i, E) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].pb(make_pair(d, t));
    }

    rep(i, V) dist[i] = INF;
    dist[r] = 0;

    rep(i, V) {
        rep(u, V) {
            for (pii edge: g[u]) {
                int cost = edge.first;
                int v = edge.second;
                if (dist[u] != INF && dist[v] > dist[u] + cost) {
                    dist[v] = dist[u] + cost;

                    if (i == V - 1) {
                        cout << "NEGATIVE CYCLE" << endl;
                        return 0;
                    }
                }
            }
        }
    }

    rep(i, V) {
        if (dist[i] == INF) cout << "INF" << endl;
        else cout << dist[i] << endl;
    }
}



Measured memory_bytes: 3172
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    s = args[1]

    ret = 0
    for l in range(n-2):
        r = l+ret+1
        while r < n-ret:
            if s[l:r] in s[r:]:
                ret = max(ret, r-l)
            else:
                break
            r += 1

    return str(ret)


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))


Measured memory_bytes: 41916
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q;

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

  cin >> n;
  rep(i, n) cin >> a[i], sum[i] = a[i];
  rrep(i, 1, n) sum[i] += sum[i - 1];

  ans = LINF;
  rrep(i, 1, n - 2) {
    ll peace1, peace2, peace3, peace4, dis;

    ll le = 0, ri = i - 1, mid;
    while (ri - le > 1) {
      mid = (le + ri) / 2;
      if (sum[mid] >= sum[i] - sum[mid])
        ri = mid;
      else
        le = mid;
    }

    dis = LINF;
    rrep(j, le, ri + 1) {
      if (dis >= abs(sum[j] - (sum[i] - sum[j]))) {
        dis = abs(sum[j] - (sum[i] - sum[j]));
        peace1 = sum[j];
        peace2 = sum[i] - sum[j];
      }
    }

    le = i + 1, ri = n - 2, mid;
    while (ri - le > 1) {
      mid = (le + ri) / 2;
      if (sum[mid] - sum[i] >= sum[n - 1] - sum[mid])
        ri = mid;
      else
        le = mid;
    }

    dis = LINF;
    rrep(j, le, ri + 1) {
      if (dis >= abs((sum[j] - sum[i]) - (sum[n - 1] - sum[j]))) {
        dis = abs((sum[j] - sum[i]) - (sum[n - 1] - sum[j]));
        peace3 = sum[j] - sum[i];
        peace4 = sum[n - 1] - sum[j];
      }
    }

    ans = min(ans, max({peace1, peace2, peace3, peace4}) -
                       min({peace1, peace2, peace3, peace4}));
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n; cin >> n;
  vector<int> d(n); REP(i,n) cin >> d[i];
  if (n%2) { COUT(0); return 0;}
  sort(ALL(d));
  int med = n/2-1;
  COUT(d[med+1]-d[med]);
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

		for(int i = (X-K+1); i<(X+K); i++) {
			System.out.print(i);
			if(i+1 < (X+K)) System.out.print(" ");
		}

		sc.close();
	}
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max({a, b, c}) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int Search(vector<int> &d, int data, int st, int ed) {
	int v = (st + ed) / 2;
	if (d[v] == data)
		return v + 1;
	else if (d[v] > data)
		return Search(d, data, st, v);
	else
		return Search(d, data, v + 1, ed);
}

int main(void) {
	int pnum, num, i = 0, pp, yy;
	cin >> pnum >> num;
	vector<int> p(num), y(num);
	vector<vector<int>> d(pnum, vector<int>());
	for (i = 0; i < num; i++) {
		scanf("%d%d", &p[i], &y[i]);
		d[p[i] - 1].push_back(y[i]);
	}
	for (i = 0; i < pnum; i++)
			sort(d[i].begin(), d[i].end());
	for (i = 0; i < num; i++) {
		printf("%06d%06d\n", p[i], Search(d[p[i] - 1], y[i], 0, d[p[i] - 1].size() - 1));
	}
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int N,K,x[100000];
  cin>>N>>K;
  for (int i(0);i<N;i++) cin>>x[i];
  ll ans(1e18);
  for (int i(0);i<=N-K;i++){
    ll left(x[i]),right(x[i+K-1]);
    ans=min(ans,right-left+min(abs(left),abs(right)));
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int n,k,p,x,i;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&p);
		if(k%p==0){
			printf("%d\n",p);
		}
		else{
			x=k%p;
			printf("%d\n",x);
		}
	}
	
	return 0;
}



Measured memory_bytes: 2764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int m, k;
  cin >> m >> k;
  if (pow(2, m) <= k) {
    cout << -1 << endl;
    return 0;
  }
  if (m == 0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  if (m == 1) {
    if (k == 0) {
      cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
      return 0;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  std::vector<int> result;
  for (int i = 0; i < std::pow(2, m); i++) {
    if (i != k) {
      result.push_back(i);
    }
  }

  result.push_back(k);

  for (int i = std::pow(2, m) - 1; i >= 0; i--) {
    if (i != k) {
      result.push_back(i);
    }
  }
  result.push_back(k);

  for (int i = 0; i < std::pow(2, m + 1) - 1; i++) {
    cout << result[i] << " ";
  }
  cout << result.back() << endl;

  return 0;
}


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int a[200001];

int main(void) {
	int n, x;
	int p;

	cin >> n >> x;

	if (x ==1||x==2*n-1) {
		cout << "No" << endl;
	}
	else {
		p = 1;
		cout << "Yes" << endl;
		if (n == 2) {
			cout << 1 << endl;
			cout << 2 << endl;
			cout << 3 << endl;
		}
		else {
			if (x == 2 * n - 2) {
				FOR(i, 1, n - 2) {
					if (p != x - 1 && p != x&&p != x + 1 && p != x - 2) {
						cout << p << endl;
						p++;
					}
					else {
						p = x + 3;
						cout << p << endl;
						p++;
					}
				}
				cout << x - 1 << endl;
				cout << x << endl;
				cout << x + 1 << endl;
				cout << x - 2 << endl;
				FOR(i, n + 3, 2 * n - 1) {
					if (p != x - 1 && p != x&&p != x + 1 && p != x - 2) {
						cout << p << endl;
						p++;
					}
					else {
						p = x + 3;
						cout << p << endl;
						p++;
					}
				}
			}
			else {
				FOR(i, 1, n - 2) {
					if (p != x - 1 && p != x&&p != x + 1 && p != x + 2) {
						cout << p << endl;
						p++;
					}
					else {
						p = x + 3;
						cout << p << endl;
						p++;
					}
				}
				cout << x + 1 << endl;
				cout << x << endl;
				cout << x - 1 << endl;
				cout << x + 2 << endl;
				FOR(i, n + 3, 2 * n - 1) {
					if (p != x - 1 && p != x&&p != x + 1 && p != x + 2) {
						cout << p << endl;
						p++;
					}
					else {
						p = x + 3;
						cout << p << endl;
						p++;
					}
				}
			}
			
		}
	}


	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
 
int main(){
  int cou,i,j,k,l,val;
 
  while((scanf("%d",&val)) != EOF){
    cou=0;
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
    for(k=0;k<10;k++){
      for(l=0;l<10;l++){
        if(i+j+k+l == val)cou++;
      }
    }
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}


Measured memory_bytes: 1972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c;
  cin >> a >> b >>c;
  if( a.at(a.size()-1) == b.at(0) && b.at(b.size()-1)== c.at(0)){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    X,Y,A,B,C=map(int,input().split())
    p=list(map(int,input().split()))
    q=list(map(int,input().split()))
    r=list(map(int,input().split()))
    p.sort(reverse=1)
    q.sort(reverse=1)
    l=p[:X]+q[:Y]+r
    l.sort(reverse=1)
    print(sum(l[:X+Y]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 100264
import java.io.*;

class Main
{
	public static void main(String[] args) throws IOException
	{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str1 = br.readLine();
		String str2[] = str1.split(" ");
		int a = Integer.parseInt(str2[0]);
		int b = Integer.parseInt(str2[1]);
		int c = a*b;
		int d = 2*(a+b);
		System.out.println( c + " " + d);
	}
}



Measured memory_bytes: 24092
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	string s,t;
	scan(s>>t);
	int flag=1;
	int N=s.size();
	rep(i,N){
		if(s[i]!=t[i]) flag=0;
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 3624
n = int(input())
xys = {}
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xys[(x,y)] = True
  xy.append((x,y))

scores = []

if n == 1:
  print(1)
  exit(0)
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    xi, yi = xy[i]
    xj, yj = xy[j]
    p = xj-xi
    q = yj-yi
    score = n
    for k in range(n):
      xk, yk = xy[k]
      if (xk+p, yk+q) in xys:
        score -= 1
    scores.append(score)

print(min(scores))


Measured memory_bytes: 3064
def main():
    N = int(input())
    S = input()

    east = [0] * (N + 1)
    west = east[:]
    for i, s in enumerate(S, start=1):
        if s == 'E':
            east[i] += east[i-1] + 1
            west[i] += west[i-1]
        else:
            east[i] += east[i-1]
            west[i] += west[i-1] + 1

    people = float('inf')
    for i in range(1, N + 1):
        people = min(people, west[i-1] + east[-1] - east[i])
    print(people)

main()


Measured memory_bytes: 27040
#include<iostream>
using namespace std;
int main(){
  int num;
  cin>>num;
  int a[num-1];
  for(int i=0;i<num-1;i++){
    cin>>a[i];
  }
	int b[num]={};
  for(int i=0;i<num-1;i++){
    int x=a[i];
    b[x-1]=b[x-1]+1;
  }
  for(int i=0;i<num;i++){
    cout<<b[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5204
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

class Balloon
{
public:
	int p, t;
	Balloon(int pp = 0, int tt = 0)
		:p(pp), t(tt) {}
};

class State
{
public:
	int p, k, d, t, a;
	State(int pp, int kk, int dd, int tt, int aa)
		:p(pp), k(kk), d(dd), t(tt), a(aa) {}
	bool operator < (const State& st) const
	{
		return this->d > st.d;
	}
};

int main()
{
	const int INF = 1 << 30;

	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0)
			break;

		vector<Balloon> b(n+1);
		for (int i = 0; i < n; ++i)
			scanf("%d %d", &b[i+1].p, &b[i+1].t);

		int achive = 0;
		priority_queue<State> que;
		que.push(State(0, 0, 0, 0, 0));
		vector<vector<vector<int> > > cost(5, vector<vector<int> >(n+1, vector<int>(n+1, INF)));

		while (!que.empty()) {
			State st = que.top();
			que.pop();

			achive = max(achive, st.a);
			if (st.p == 0 && st.a == n) {
				printf("OK %d\n", st.d);
				break;
			}

			if (cost[st.k][st.p][st.a] < st.d)
				continue;

			if (st.k != 0) {
				int d = st.d + b[st.p].p;
				if (cost[st.k][0][st.a] > d) {
					cost[st.k][0][st.a] = d;
					que.push(State(0, 0, d, st.t+b[st.p].p*(st.k+1), st.a));
				}
			}

			if (st.k < 3 && st.a+1 <= n) {
				st.t += abs(b[st.p].p - b[st.a+1].p)*(st.k+1);
				if (st.t > b[st.a+1].t)
					continue;

				// update
				++st.a;
				++st.k;
				st.t += (b[st.a].t - st.t);
				st.d += abs(b[st.p].p - b[st.a].p);
				st.p = st.a;

				if (cost[st.k][st.p][st.a] > st.d) {
					cost[st.k][st.p][st.a] = st.d;
					que.push(st);
				}
			}
		}

		if (achive != n)
			printf("NG %d\n", achive+1);
	}
	return 0;
}

Measured memory_bytes: 0
#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>;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int dx = tx - sx;
  int dy = ty - sy;

  string s1 = string(dy, 'U') + string(dx, 'R');
  string s2 = string(dy, 'D') + string(dx, 'L');
  string s3 = 'L' + string(dy + 1, 'U') + string(dx + 1, 'R') + 'D';
  string s4 = 'R' + string(dy + 1, 'D') + string(dx + 1, 'L') + 'U';

  cout << s1 + s2 + s3 + s4 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    long sum = 0;
    for (int i = 0; i < n - 1; i++) {
      if(a[i] > a[i + 1]) {
        long dai = a[i] - a[i + 1];
        sum = sum + dai;
        a[i + 1] = a[i];
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 60560
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s,t=input().split()
print(t+s)

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

int main(){
	int yama[10];
	for(int i=0;i<10;i++){
		cin>>yama[i];
	}
	for(int i=0;i<9;i++){
      for(int j=9;j>i;j--){
		  if(yama[j]>yama[j-1]){
			  int t=yama[j];
			  yama[j]=yama[j-1];
			  yama[j-1]=t;
		  }
	  }
	}
	for(int i=0;i<3;i++){
		cout<<yama[i]<<endl;
	}
    return 0;
}

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

typedef pair<int,int>   ii;
typedef pair<int,ii>   pii;
typedef vector< ii >   vii;
typedef vector< ii >   vpii;
typedef vector<int>     vi;
typedef vector< vi > 	vvi;
typedef long long int 	ll;
typedef unsigned long long int ull;

#define pb push_back

#define Add1(a,b) ady[a].pb(b)
#define Add1c(a,b,c) ady[a].pb({b,c})
#define AddS1(a,b) ady[a].insert(b)
#define AddS1c(a,b,c) ady[a].insert({b,c})

#define Add2(a,b) ady[a].pb(b), ady[b].pb(a)
#define Add2c(a,b,c) ady[a].pb({b,c}), ady[b].pb({a,c})
#define AddS2(a,b) ady[a].insert(b), ady[b].insert(a)
#define AddS2c(a,b,c) ady[a].insert({b,c}), ady[b].insert({a,c})

#define f first
#define s second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define DRT() int t; si(t); while(t--)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define TRACE

#ifdef TRACE
#define trace                    cerr << "Hola mundo" << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int maxn = 1e5+1;
const int maxe = 20;
const int oo = 1 << 30;

int main(){
    int n;
    cin>>n;
    
    for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
    if(i*j==n){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int r = 0; r <= N/R; r++) {
        for (int g = 0; g <= N/G; g++) {
            int t = N - R*r - G*g;
            if (t < 0) continue;
            if (t % B == 0) ans++;
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    int pos = 0,count = 0;
    string s;
    cin >> s;
    
    pos = s.find("hi");

    while(pos != std::string::npos){
        pos = s.find("hi",pos+2);
        count++;

    }

    if(s.size() == 2*count) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
//atcoder 002 E Candy Piles 博弈论 
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);//逆转元素，从大到小
	bool flag = 0; 
	for (int i = 1; i <= n; i++) 
	if (i+1 > a[i+1]) {
		for (int j = i+1; a[j] == i; j++) flag ^= 1;
		flag |= (a[i]-i) & 1;
		if (flag) printf("First\n");else printf("Second\n");
		return 0;
	} 
}

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

int main(){
    int e,y;
    cin >> e >> y;
    if(e==0){
        if(y<=1911){
            cout << "M" << y-1867 << endl;
        }else if(y<=1925){
            cout << "T" << y-1911 << endl;
        }else if(y<=1988){
            cout << "S" << y-1925 << endl;
        }else{
            cout << "H" << y-1988 << endl;
        }
    }else if(e==1){
        cout << 1867+y << endl;
    }else if(e==2){
        cout << 1911+y << endl;
    }else if(e==3){
        cout << 1925+y << endl;
    }else{
        cout << 1988+y << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
	       return a.second>b.second;
}

ll gcd(ll big, ll small){
    ll tmp = big%small;

    if(tmp == 0) return small;
    return gcd(small,tmp);
}

int n;
string u[100];
double x[100];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> u[i];
    }

    double ans = 0.0;
    for(int i = 0; i < n; i++){
        if(u[i] == "JPY"){
            ans += x[i];
        }
        else{
            ans += x[i]* 380000.0;
        }
    }
    cout << fixed;
    cout << setprecision(6) << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  ll ans = 0;
  FOR(i,1,n+1) {
    if (i%3 == 0) continue;
    if (i%5 == 0) continue;
    ans += i;
  }
  cout<<ans<<endl;
  return 0;
}


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

int n, k, sz, cnt, a[25];
int main()
{
	int i, j;
	cin >> n;
	for (k = 1, sz = 0; k <= n; k *= 2, sz++);
	k /= 2;
	sz--;
	i = 1;
	cnt = sz * 2;
	while (n > 1) {
		if (n % 2) {a[i] = 1; cnt++;}
		i++;
		n /= 2;
	}
	cout << sz + 1 << " " << cnt << endl;
	for (i = 1, j = 1; i <= sz; i++, j *= 2) {
		printf("%d %d 0\n", i, i + 1);
		printf("%d %d %d\n", i, i + 1, j);
		if (a[i] == 1) {
			printf("%d %d %d\n", i, sz + 1, k);
			k += j;
		}
	}
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
m=0
count=0
a=[]
for i in range(n-1):
    a.append(l[i]-l[i+1])
for i in a:
    if i>=0:
        count+=1
    else:
        m=max(m,count)
        count=0
    m=max(m,count)
#print(a)
print(m)

Measured memory_bytes: 14224
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int p = 0;
		while(a > 0 && c > 0){
			if(p == 0)
				c -= b;
			else
				a -= d;
			p = 1 - p;
		}
		System.out.println((a > 0)?"Yes":"No");
		
		sc.close();
    }
}

Measured memory_bytes: 35840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {  
    ll inf = 1e18; 
    int n; cin >> n;
    ll res = 1;
    bool zero = false;
    vector<ll> A(n);
    rep(i, n){
        cin >> A[i];
        if(A[i] == 0) zero = true;
    }
    rep(i, n){
        if(res >= LONG_LONG_MAX/A[i]){res = -1; break;}
        res *= A[i];
        if(res > inf){res = -1; break;}
    }
    if(zero) res = 0;
    cout << res << ln;
}



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

int main(){
  int n;cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin >> d[i];
  sort(d.begin(),d.end());
  cout << d[n/2]-d[n/2-1];
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  if(k <= a) {printf("%lld %lld\n",a-k, b);}
  else {
    k = k - a;
    if(k <= b) {printf("%lld %lld\n",0, b-k);}
    else {printf("%d %d\n",0,0);}
  }
}

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

constexpr int height = 100;
constexpr int width = 100;
array<array<bool, width>, height> solve(int a, int b) {
    array<array<bool, width>, height> f = {};
    REP (y, height / 2) {
        REP (x, width) {
            f[y][x] = true;
        }
    }
    for (int y = 0; y < height / 2; y += 2) {
        for (int x = 0; x < width; x += 2) {
            if (a >= 2) {
                a -= 1;
                f[y][x] = false;
            }
        }
    }
    for (int y = height - 1; y >= height / 2; y -= 2) {
        for (int x = 0; x < width; x += 2) {
            if (b >= 2) {
                b -= 1;
                f[y][x] = true;
            }
        }
    }
    return f;
}

int main() {
    int a, b; scanf("%d%d", &a, &b);
    array<array<bool, width>, height> f = solve(a, b);
    printf("%d %d\n", height, width);
    REP (y, height) {
        REP (x, width) {
            printf("%c", f[y][x] ? '#' : '.');
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;

long long int N,M,L,R,K,H,W;

int main(){
	cin>>W>>H>>N;
	vector<vector<int>>box(H,vector<int>(W,INT_MIN));
	vector<int>x(N);
	vector<int>y(N);
	vector<int>d(N);
	for(int i=0;i<N;i++){
		cin>>x[i]>>y[i]>>d[i];
		x[i]--,y[i]--;
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int k=0;k<N;k++){
				box[i][j]=max(box[i][j],d[k]-abs(i-y[k])-abs(j-x[k]));
			}
		}
	}
	for(int i=0;i<N;i++){
		if(box[y[i]][x[i]]!=d[i]){
			cout<<"No\n";
			return 0;
		}
	}
	int ans=0;
	for(auto i:box)for(auto j:i)ans+=j;
	cout<<ans<<endl;
}



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

int main() {
    int n,x;
    cin >> n >> x;
    vector<int>a(n);
    a[0]=0;
    int ans=n+1;
    rep2(i,1,n+1){
        int t;
        cin >> t;
        a[i]=t+a[i-1];
        if(a[i]>x){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
 int main() {
  int a, b;
  std::string op;
  while (1) {
   std::cin >> a >> op >> b;
   if (op == "?") break;
    if (op == "+") {
   std::cout << a + b <<std::endl;
  } else if (op == "-") {
   std::cout << a - b <<std::endl;
  } else if (op == "*") {
   std::cout << a * b <<std::endl;
  } else if (op == "/") {
   std::cout << a / b <<std::endl;
  } 
  }



 return 0;


}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
  map<int, int> m;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
	int a;
	cin >> a;
	m[a] = m[a] + 1;
  }
  int count = 0;
  for (auto v : m)
  {
	if (v.first <= v.second)
	{
	  count += (v.second - v.first);
	}
	else
	{
	  count += v.second;
	}
  }
  cout << count << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

    int a;
    cin>>a;
    REP(i,10){
        if(111*i>=a){
            cout<<111*i<<endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[] a=new int[n];
		Arrays.setAll(a,i->s.nextInt());

		int[]c=new int[100000];
		long r=1;
		for(int i=0;i<n;++i) {
			++c[a[i]];
			if(a[i]>0) {
				r*=c[a[i]-1]-c[a[i]]+1;
			}else {
				r*=4-c[a[i]];
			}
			r%=1000000007;
			//System.err.println(Arrays.toString(c));
			//System.err.println(r);
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 51420
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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 decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll c=a-b;
    vll h(n);rep(i,n)cin>>h[i];
    ll l=-1;ll r=1e9;ll m,sum;
    while(r-l>1){
        m=(l+r)/2;
        sum=0;
        rep(i,n){
            if(h[i]>=b*m)sum+=(h[i]-b*m+c-1)/c;
        }
        if(sum>m)l=m;
        else  r=m;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
#define INF (lo)(1e9 + 7)
#define MOD (lo)(1e9 + 7)
#define mp make_pair
#define pb push_back
#define pp pop_back
using namespace std;
typedef long long int lo;
typedef pair<lo,lo> pii;
lo a,b,c;
map<lo,lo> mep;

int main(){
    cin >> a >> b >>c;
    mep[a]++;
    mep[b]++;
    mep[c]++;
    if(mep[a] == 2 or mep[b] == 2 or mep[c] == 2) cout << "Yes";
    else cout << "No";
}




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

int main(){
      int minn = INT_MAX;
      int n;cin >> n;
      int x;cin >> x;
      int all = 0;
      for(int i = 0;i < n;i++){
            int t;cin >> t;
            if(t < minn)minn = t;
            all += t;
      }
      cout << (x - all) / minn + n;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

void prime_factor(int n, map<int, int> &mp)
{
    for (int i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1)
        mp[n]++;
    return;
}

int main()
{
    int n;
    cin >> n;
    map<int, int> primes;
    repi(i, n + 1, 2)
    {
        prime_factor(i, primes);
    }
    ll ans = 1;
    for (auto itr = primes.begin(); itr != primes.end(); itr++)
    {
        ans *= itr->second + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD 1000000007LL

int main(){
    string s;
    cin >> s;
    ll a = 0;
    ll ab = 0;
    ll abc = 0;
    ll num = 1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            a += num;
        }else if(s[i] == 'B'){
            ab += a;
        }else if(s[i] == 'C'){
            abc += ab;
        }else if(s[i] == '?'){
            ll olda = a;
            ll oldab = ab;
            a *= 3;
            ab *= 3;
            abc *= 3;
            abc += oldab;
            ab += olda;
            a += num;
            num *= 3;
        }
        a %= MOD;
        ab %= MOD;
        abc %= MOD;
        num %= MOD;
    }
    cout << abc << endl;
}


Measured memory_bytes: 512