akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int L, R; cin >> L >> R;
	int D; cin >> D;
	cout << R/D - (L-1)/D << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a[100010];
priority_queue<int,vector<int>,greater<int> > q;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>a[i];
	    q.push(a[i]);
	}
	while(q.size()>1){
		int ruo=q.top();q.pop();
		int ciruo=q.top();q.pop();
		if(ciruo%ruo!=0){
			q.push(ruo);
			q.push(ciruo%ruo);
		}
		else
		   q.push(ruo);
	}
	cout<<q.top()<<endl;
	return 0;
}


Measured memory_bytes: 1148
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;

struct Edge {
	int to, a, b;//行き先,コスト,時間
	Edge(int to, int a, int b) :to(to), a(a), b(b) {}
};
struct Data {
	int v, s;
	LL x;
	Data(int v, int s, LL x) :v(v), s(s), x(x) {}
	bool operator<(const Data& a) const {
		return a.x < x;
	}
};

vector<Edge> g[MAX_V];
LL dist[MAX_V][MAX_S + 5];

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

	R(i, m) {//グラフの構築Edgeの隣接
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u; --v;
		g[u].emplace_back(v, a, b);
		g[v].emplace_back(u, a, b);
	}
	R(i, n)R(j, MAX_S + 5)dist[i][j] = LINF;
	s = min(s, MAX_S);//所持金MAX_Sを超えた場合の処理

	priority_queue<Data> que;
	
	auto push = [&](int v, int s, LL x) {
		if (s < 0)return;//所持金不足で、移動できない。
		if (dist[v][s] <= x)return;//すでに最短を通っている。
		dist[v][s] = x;
		que.emplace(v, s, x);
	};

	vector<int> c(n), d(n);
	R(i, n)cin >> c[i] >> d[i];
	push(0, s, 0);//初期位置、初期金、初期総時間
	while (!que.empty()) {
		Data now = que.top(); que.pop();//
		int v = now.v;//頂点
		int s = now.s;//所持金
		LL x = now.x;//経過時間

		//今、最短の値でなければスキップ
		if (dist[v][s] != x) continue;

		{
			//現在の頂点で換金
			int ns = min(s + c[v], MAX_S);
			push(v, ns, x + d[v]);
		}

		//移動
		for (Edge e : g[v]) {
			push(e.to, s - e.a, x + e.b);
		}
	}
	
	//答えの出力
	for (int i = 1; i < n; ++i) {
		LL ans = LINF;
		R(j, MAX_S + 5) {//到達時の所持金を総なめ
			chmin(ans, dist[i][j]);
		}
		cout << ans << endl;
	}

	
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

struct Edge
{
  int to, cost;
};
bool operator<(const Edge& lht, const Edge& rht)
{
  return lht.cost > rht.cost;
}

#define MN 100

int N, M;
bool done[MN];

int main()
{
loop:
  fill(done, done + MN, false);
  vector<Edge> edges[MN];
  cin >> N >> M;
  if(!N)
    return 0;
  for(int i = 0; i < M; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    edges[a].push_back({b, c});
    edges[b].push_back({a, c});
  }

  priority_queue<Edge> q;
  q.push({0, 0});
  int cost = 0;
  while(!q.empty())
  {
    auto e = q.top(); q.pop();
    if(done[e.to])
      continue;
    cost += e.cost;
    done[e.to] = true;
    for(auto ee: edges[e.to])
      q.push(ee);
  }
  cout << cost << endl;
  goto loop;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int x[5];
  cin >> x[0] >>x[1] >> x[2] >> x[3] >> x[4];
  rep(i,5)if(x[i] == 0){
    cout<<i+1<<endl;
    return 0;
  }
  return 0;
}

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

ll lcm(ll c, ll d) {
    if (c>d) swap(c,d);
    ll cc=c,dd=d;
    ll g=d%c;
    while (g!=0) {
        d=c;
        c=g;
        g=d%c;
    }
    return (cc*dd)/c;
}

int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll a1ans = (a-1)/c+(a-1)/d-(a-1)/lcm(c,d);
    ll bans = b/c+b/d-b/lcm(c,d);

    cout << b-a+1-(bans-a1ans) << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W, K; 
	char S[310][310] = {}; 
	cin >> H >> W >> K; 
	int cnt[310] = {}; 
	vector<int> B[310] = {}; 
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> S[i][j]; 
			if(S[i][j] == '#') B[i].push_back(j);
		}
	}
	int now = 1; 
	int A[310][310] = {}; 
	for(int i = 0; i < H; i++){
		if(B[i].size() == 0) continue; 
		for(int j = 0; j < B[i].size(); j++){
			A[i][B[i].at(j)] = now; 
			now ++; 
		}
		for(int j = 1; j < W; j++){
			if(A[i][j] == 0) A[i][j] = A[i][j-1]; 
		}
		for(int j = W-2; j >= 0; j--){
			if(A[i][j] == 0) A[i][j] = A[i][j+1]; 
		}
	}
	for(int j = 0; j < W; j++){
		for(int i = 1; i < H; i++){
			if(A[i][j] == 0) A[i][j] = A[i-1][j]; 
		}
	}
	for(int j = 0; j < W; j++){
		for(int i = H-2; i >= 0; i--){
			if(A[i][j] == 0) A[i][j] = A[i+1][j]; 
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cout << A[i][j] << " "; 
		}
		cout << endl; 
	}
}

Measured memory_bytes: 1792
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String str = sc.next();
            if("AAA".equals(str) || "BBB".equals(str)){
              System.out.println("No");
            } else {
              System.out.println("Yes");
            }
          }
}

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

int x;

int Gcd(int a , int b){
	return b ? Gcd(b , a % b) : a;
}

int main(){
	scanf("%d" , &x);
	printf("%d" , 360 / Gcd(x , 360));
	return 0;
} 

Measured memory_bytes: 3820
#include<bits/stdc++.h>
    #include<algorithm>
    using namespace std;
    #define mod 1e9+7
    #define FOR(a,c)   for ( int (a)=0; (a)<(c); (a)++)
    #define FORL(a,b,c)  for ( int (a)=(b); (a)<=(c); (a)++)
    #define FORR(a,b,c)  for (  int (a)=(b); (a)>=(c); (a)--)
    #define INF 1000000000000000003
    typedef long long int ll;
    typedef vector<long long int> vi;
    typedef pair<long long int,long long int> pi;
    typedef priority_queue<long long int> max_pq;
    typedef priority_queue<long long int, vector<long long int>, greater<long long int>> min_pq;
    #define F first
    #define S second
    #define PB push_back
    #define POB pop_back
    #define MP make_pair
    #define pi 3.1415926535
    #define buff cin.ignore(numeric_limits<streamsize>::max(),'\n')

    // Use inbuilt function  __gcd(a,b), __builtin_popcount(n), Use (x&-x) for last set Bit;
    
    int main()
    {
        ios::sync_with_stdio(NULL);
        cin.tie(NULL);
        cout.tie(NULL);

        ll n=0;
        cin>>n;
        ll mat[n][3],dp[n][3];
        memset(mat,0,sizeof(mat));
        memset(dp,0,sizeof(dp));
        ll mx=LLONG_MIN;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<3;j++)
                cin>>mat[i][j];
        }

        for(ll i=0;i<3;i++)
            dp[0][i]=mat[0][i];

        for(ll i=1;i<n;i++)
        {
            for(ll j=0;j<3;j++)
            {
                for(ll k=0;k<3;k++)
                {
                    if(k!=j)
                    {
                        mx=max(dp[i-1][k],mx);
                    }
                }
                dp[i][j]=mat[i][j]+mx;
                mx=LLONG_MIN;
            }
        }
       mx=0;
        for(ll i=0;i<3;i++)
            mx=max(mx,dp[n-1][i]);
        cout<<mx<<endl;
        // for(int i=0;i<n;i++)
        // {
        //     for(int j=0;j<3;j++)
        //         cout<<dp[i][j]<<" ";
        //     cout<<endl;
        // }
        return 0;
    }

Measured memory_bytes: 4992
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

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

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if (N < A + B - 1 || A * B < N) {
        cout << -1 << endl;
        return 0;
    }

    ll arr[A];
    fill(arr, arr + A, 1);
    arr[0] = B;
    N -= A + B - 1;

    for (ll i = 1; i < A; ++i) {
        arr[i] += min(N, B - 1);
        N -= min(N, B - 1);
    }

    ll used = 0;
    for (ll i = 0; i < A; ++i) {
        used += arr[i];
        for (ll j = 0; j < arr[i]; ++j) {
            cout << used - j << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	for (string s; getline(cin, s) && s != ".";) {
		stack<char> st;
		rep(i, 0, s.size()) {
			if (s[i] == '(') {
				st.emplace('(');
			}
			if (s[i] == '[') {
				st.emplace('[');
			}
			if (s[i] == ')') {
				if (st.empty() || st.top() == '[') {
					cout << "no" << endl;
					break;
				}
				st.pop();
			}
			if (s[i] == ']') {
				if (st.empty() || st.top() == '(') {
					cout << "no" << endl;
					break;
				}
				st.pop();
			}
			if (s[i] == '.') {
				if (st.size()) {
					cout << "no" << endl;
					break;
				}
				cout << "yes" << endl;
			}
		}
	}
	return 0;
}

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

int main(){

  int n,count;

  while(cin >> n, n){

    count = 0;
    n = 1000 - n;

    if(n >= 500){
      count++;
      n -= 500;
    }

    while(n >= 100){
      count++;
      n -= 100;
    }

    while(n >= 50){
      count++;
      n -= 50;
    }

    while(n >= 10){
      count++;
      n -= 10;
    }

    while(n >= 5){
      count++;
      n -= 5;
    }

    cout << n+count << endl;

  }
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int n = sc.nextInt();
			if(n == -1) break;
			double x = 1;
			double y = 0;
			double ang = Math.PI;
			
			for(int i = 0; i < n-1; i++) {
				ang -= Math.PI/2;
				y += Math.sin(ang);
				x += Math.cos(ang);
				ang = Math.atan2(-y, -x);
			}
			out.println(x);
			out.println(y);
		}
		out.flush();

	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

int m;
using ld = long double;

int divide(ld target, int original){
	return ceil(original / target)-1;
}

bool isok(ld v, vector<int> a, int k){
	for(int t: a){
		k -= divide(v, t);
		if(k < 0) return false;
	}
	return true;
}

void Main(){
	int n; int k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	m = max(a);
	ld ok = m;
	ld ng = 0;
	while(ok-ng > 1e-10){
		ld mid = (ok + ng) / 2;
		if(isok(mid, a, k)) ok = mid;
		else ng = mid;
	}
	cout << (int)ceil(ok) << endl;
}


Measured memory_bytes: 4776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <cassert>
using namespace std;


main(){
	int n;

	int last_A=0;
	int head_B=0;
	int last_A_head_B=0;

	int ans=0;
	
	cin >> n;
	string s[n];
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<s[i].length()-2;j++){
			if(s[i][j]=='A' && s[i][j+1]=='B'){
				ans++;
			}
		}
		if(s[i][0]=='B' && s[i][s[i].length()-1]=='A'){
			last_A_head_B++;
		}else if(s[i][0]=='B'){
			head_B++;
		}else if(s[i][s[i].length()-1]=='A'){
			last_A++;
		}
	}

	if(last_A_head_B>0){
		ans+=(last_A_head_B-1);
		if(last_A>0){
			last_A--;
			ans++;
		}
		if(head_B>0){
			head_B--;
			ans++;
		}
	}

	ans+=min(last_A,head_B);

	cout << ans << endl;

}


Measured memory_bytes: 768
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

H = iin()

a = int(math.log(H,2))+1
print(2**a-1)

Measured memory_bytes: 5552
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
// typedef long long ll;
int main()
{
  int n, k;
  cin >> n>> k;
  vector<int > h(n);
  REP(i,n)cin >> h[i];
  int num = 0;
  REP(i, n){
    if(h[i] >= k ){
      num ++;
    }

  }
  cout << num << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		
		if(a==b){
			System.out.println("a == b");
		}else if(a<b){
			System.out.println("a < b");
		}else{
			System.out.println("a > b");
		}
	}
}


Measured memory_bytes: 26204
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>

using namespace std;

#define sz			size()
#define lgt			length()
#define rep(i,n)	for (int i = 0; i < n; i++)
#define ALL(X)		(X).begin(),(X).end()
#define RALL(X)		(X).rbegin(),(X).rend()
#define pb			push_back
#define SORT(a)		sort(ALL(a));
#define RSORT(a)	sort(RALL(a));
#define mp			make_pair
#define dump(x)		cerr<<#x<<" = "<<(x)<<endl;
#define fir			first
#define sec			second

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<string> vs;

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();}
vs form(string a,char s){vs v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(b);b="";}else b+=a[i];}v.pb(b);return v;}
vi formint(string a,char s){vi v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(toInt(b));b="";}else b+=a[i];}v.pb(toInt(b));return v;}

const double EPS=1e-10,PI=acos(-1.0);
const int INF=2100000000;

vi v;

int main(void)
{
	int n, a, b, c, tmp;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++){
		cin >> tmp;
		v.pb(tmp);
	}
	RSORT(v);
	int cal = c;
	int tnum = 0;
	double res = (double)cal / a;
	for (int i = 0; i < n; i++){
		cal += v[i];
		tnum++;
		if (res < ((double)cal / (a + tnum * b))){
			res = (double)cal / (a + tnum * b);
		}
		else break;
	}
	cout << (int)floor(res) << endl;
	
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static long n = long.Parse(Console.ReadLine());
static long[,] trees = new long[n,3];//親、左、右。左が存在しなければ葉である。
static long[] depthes = new long[n];
static long leftNum = 0;
static long rightNum = 0;
static List<long>[] childrenList = new List<long>[n];//直接の子のリスト

	static void Main()
	{
    for(long i = 0; i < n; i++)
    {
      trees[i,0] = -1;
      trees[i,1] = -1;
      trees[i,2] = -1;
      childrenList[i] = new List<long>();//リストの宣言
    }

    for(int i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      for(long j = 0; j < nums[1]; j++)
      {
        if(j == 0) trees[nums[0],1] = nums[j+2];
        else trees[leftNum,2] = nums[j+2];
        leftNum = nums[j+2];
        trees[nums[j+2],0] = nums[0];//親を自分と仮定
        childrenList[nums[0]].Add(nums[j+2]);
      }
    }

    for(long i = 0; i < n; i++)
    {
      if(trees[i,0] == -1) rightNum = i;
    }

    SetDepth(rightNum, 0);

    for(long i = 0; i < n; i++)
    {
      string memo = "internal node";
      if(trees[i,0] == -1) memo = "root";
      else if(trees[i,1] == -1) memo = "leaf";
      long[] memoc = new long[childrenList[i].Count()];
      for(int j = 0; j < childrenList[i].Count(); j++)
      {
        memoc[j] = childrenList[i][j];
      }
      string memoChildren = string.Join(", ", childrenList[i]);
      Console.WriteLine("node " + i + ": parent = " + trees[i,0] + ", depth = " + depthes[i]+
        ", " + memo + ", [" + memoChildren +"]");
    }
	}

  static void SetDepth(long u, long p)//再帰的に深さを求める
  {
    depthes[u] = p;
    if(trees[u,2] != -1) SetDepth(trees[u,2], p);//右にも同じ深さを設定
    if(trees[u,1] != -1) SetDepth(trees[u,1], p+1);//子のうち最も左は1大きい深さにする
  }
}


Measured memory_bytes: 41680
from sys import stdin

def main():
    N, M, C = map(int, input().split())
    B = tuple(map(int, input().split()))
    A = [tuple(map(int, input().split())) for _ in [0] * N]

    ans = 0
    for a in A:
        total = C
        for i, j in zip(a, B):
            total += i * j
        if total > 0:
            ans += 1
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect, heapq
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

n,m,s0 = map(int,input().split())
s0 = min(2500,s0)
G = [[] for i in range(n)]
for i in range(m):
  u,v,a,b = map(int,input().split())
  u-=1;v-=1
  G[u].append((v,-a,b))
  G[v].append((u,-a,b))
for i in range(n):
  c,d = map(int,input().split())
  G[i].append((i,c,d))

def dijktra(g,s):
    n=len(g)
    dist = [[inf]*2501 for i in range(n)]
    dist[s][s0] = 0
    hq=[]
    heapq.heappush(hq,(0,s0,s))
    while hq:
        time,money,u = heapq.heappop(hq)
        if dist[u][money] < time: continue
        for v,money1,time1 in g[u]:
          M = min(2500,money+money1)
          if not M >= 0: continue
          if dist[v][M] > time + time1:
            dist[v][M] = (time + time1)
            heapq.heappush(hq,(time + time1, M,v))
    return dist

dist = dijktra(G,0)
for i in range(1,n):
  print(min(dist[i]))

Measured memory_bytes: 97080
N = int(input())
p = []
for _ in range(N):
    x, y = map(int, input().split())
    p.append((x, y))
p = sorted(p, key=lambda i: i[0] + i[1])
x1, y1 = p[0]
x2, y2 = p[-1]
res = abs((x1 + y1) - (x2 + y2))
p = sorted(p, key=lambda i: i[0] - i[1])
x1, y1 = p[0]
x2, y2 = p[-1]
res = max(abs((x1 - y1) - (x2 - y2)), res)
print(res)


Measured memory_bytes: 47004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int n;
ll cnt=0;
ll ans=0,c1=0,c2=0;
ll f[200001];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	string s;cin >> s;
	for(int i=1; i<n ;i++){
		if(n%i==0 && n/i%2==1) f[i]=2*i-2*n;
	}
	for(int i=n-1; i>=1 ;i--){
		if(f[i]==0) continue;
		for(int j=2*i; j<n ;j+=i){
			f[i]=(f[i]+mod-f[j])%mod;
		}
	}
	for(int i=1; i<n ;i++){
		if(f[i]!=0){
			string t="";
			for(int j=0; j<n ;j++){
				char c=((j/i%2)^s[j%i]);
				if(j==n-1 && c==s[j]) ans+=f[i];
				if(c==s[j]) continue;
				if(c<s[j]) ans+=f[i];
				break;
			}
			c1=c2=0;
			for(int j=0; j<i ;j++){
				c1=c1*2+s[j]-48;
				c1%=mod;
			}
			ans=(ans+c1*f[i])%mod;
			ans=(ans+mod)%mod;
		}
	}
	c1=s[n-1]-48+1;
	c2=2;
	for(int i=n-2; i>=0 ;i--){
		if(s[i]=='1') c1=(c1+c2)%mod;
		c2=(c2+c2)%mod;
	}
	c1=c1*2*n%mod;
	ans=(ans+c1)%mod;
	ans=(ans+mod)%mod;
	cout << ans << endl;
}

Measured memory_bytes: 720
import itertools
import math
N=int(input())
z=[]
for _ in range(N):
    z.append(list(map(int,input().split())))
sum=0
for per in itertools.permutations(list(range(N))):
    for i in range(N-1):
        sum+=math.sqrt((z[per[i]][0]-z[per[i+1]][0])**2+(z[per[i]][1]-z[per[i+1]][1])**2)
ans=sum/math.factorial(N)
print(ans)

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

int main()
{
    int r, d, x;
    cin >> r >> d >> x;
    int ans[11] = {0};
    ans[0] = x;
    for (int i = 1; i <= 10; i++)
    {
        ans[i] = r * ans[i - 1] - d;
    }
    for (int i = 1; i <= 10; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;

ll A[200000];
ll B[200000];
ll C[200000];
ll D[400000];
ll T[200000];

int main() {
    ll N;
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) {
        C[i] = A[i] ^ A[(i+1)%N];
        D[i] = B[i] ^ B[(i+1)%N];
        D[i+N] = D[i];
    }
    vector<int> T(N+1);
    T[0] = -1;
    int j = -1;
    for (int i = 0; i < N; i++) {
        while (j >= 0 && C[i] != C[j]) j = T[j];
        T[i+1] = ++j;
    }
    vector<int> Ks;
    int m = 0, i = 0;
    while (m+i < 2*N-1) {
        if (C[i] == D[m+i]) {
            if (++i == N) {
                Ks.push_back((N-m)%N);
                m = m+i-T[i];
                i = T[i];
            }
        } else {
            m = m+i-T[i];
            if (i > 0) i = T[i];
        }
    }
    sort(Ks.begin(), Ks.end());
    for(auto k : Ks) {
        ll x = A[k] ^ B[0];
        cout << k << " " << x << endl;
    }

    return 0;
}

Measured memory_bytes: 12916
#include<stdio.h>
int main(){
  int a[4], b[4], i, j,  x=0, y=0;

  while( scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF){/*Aが４つの数字を思い浮かべる*/

    for( i=0 ; i<4 ; i++ ){   /*Bが４つの数字を思い浮かべる*/
      scanf("%d",&b[i]);
    }

    for( i=0 ; i<4 ; i++ ){   /*ヒットの数をカウント*/
      if( a[i] == b[i] ){
	x=x+1;
      }
    }

    for(i=0 ; i<4 ; i++){
      for(j=0 ; j<4 ; j++){
	if( a[i] != b[i] && a[i] == b[j] ){
	  y=y+1;
	}
      }
    }

    printf("%d %d\n",x,y);
    x=0;
    y=0;
  }

  return 0;

}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
typedef pair<int,int> pii;
int main(){  
    int h,w;
    cin >> h >> w;
    char s[h+2][w+2];
    rep(i,h+2) rep(j,w+2) s[i][j]='#';
    rep(i,h) rep(j,w) cin >> s[i+1][j+1];
    int ta[h+2][w+2];
    bool visited[h+2][w+2];
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};
    int ans = 0;
    rep(i,h) rep(j,w){
        if(s[i+1][j+1]!='#'){
            queue<pii> que;
            que.push(make_pair(i+1,j+1));
            rep(p,h+2) rep(q,w+2) ta[p][q]=0;
            //cout << "meu" << endl;
            while(!que.empty()){
                pii now = que.front();
                int nowx = now.first;
                int nowy = now.second;
                //cout << nowx << " " << nowy << endl;
                que.pop();
                rep(k,4){
                    if(s[nowx+dx[k]][nowy+dy[k]]=='.' && (ta[nowx+dx[k]][nowy+dy[k]]==0) && (nowx+dx[k]!=i+1 || nowy+dy[k] != j+1)){
                        ta[nowx+dx[k]][nowy+dy[k]] = ta[nowx][nowy]+1;
                        que.push(make_pair(nowx+dx[k],nowy+dy[k]));
                    }
                }
            }
            rep(p,h+2) rep(q,w+2) ans = max(ans,ta[p][q]);
        }
        //cout << "meu" << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char n[105],m[105];
    // ll n,m;
    scanf("%s%s",n,m);
    ll nl=strlen(n),ml=strlen(m);
    if(nl>ml){
        printf("GREATER\n");
    }else if(nl<ml){
        printf("LESS\n");
    }else{
        rep(i,0,nl){
            if( n[i]-m[i] >0){
                printf("GREATER\n");
                return 0;
            }
            if( n[i]-m[i] <0){
                printf("LESS\n");
                return 0;
            }
        }
        printf("EQUAL\n");
    }

    
    // printf("%lld\n");
    return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int d = Integer.parseInt(in.next());
            boolean ok = false;
            if (a <= b && b <= c) {
                if (Math.abs(a - b) <= d && Math.abs(b - c) <= d) {
                    ok = true;
                }
            } else {
                if (Math.abs(a - c) <= d) {
                    ok = true;
                }
            }
            out.println(ok ? "Yes" : "No");

        }

    }
}



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

int main(){
	int a,b;
	while(std::cin >> a >> b){
		if(a==0&&b==0) break;

		int n;
		std::cin >> n;
		std::vector<std::vector<int>> map(a,std::vector<int>(b,1)); //地図

		for(int i=0;i<n;++i){
			int x,y;
			std::cin >> x >> y;
			if(x==0&&y==0) break;
			map[x-1][y-1]=0;
			if(x==1){
				for(int y1=y;y1<b;y1++){
					map[x-1][y1]=0;
				}
			}
			if(y==1){
				for(int x1=x;x1<a;x1++){
					map[x1][y-1]=0;
				}
			}
		}

		for(int i=1;i<a;++i){
			for(int j=1;j<b;++j){
				if(map[i][j]>0){
					map[i][j] = map[i-1][j]+map[i][j-1];
				}
			}
		}
		std::cout << map[a-1][b-1] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <sstream>

using namespace std;

int main()
{
    string s;
    stringstream aux;
    int sum = 0, n;


    cin >> s;

    for(auto i : s)
    {
        sum += (i - '0');
    }

    aux << s;
    aux >> n;

    if(n % sum == 0)
        cout << "Yes";
    else
        cout << "No";
    cout << '\n';


}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



    class Program
    {
        static void Main(string[] args)
        {
            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long kosuu = 0;

            for (int i = 0; i < a[0]; i++)
            {
                long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();


                double c = Math.Pow(b[0], 2) + Math.Pow(b[1], 2);
                
                if (c <= Math.Pow(a[1], 2))
                {
                    kosuu += 1;
                }

            }

            Console.WriteLine(kosuu);

        }
    }

Measured memory_bytes: 41392
#include<bits/stdc++.h>
#define ll long long
#define MOD int(1e9+7)
#define pb push_back
using namespace std;

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

    if(n>m) swap(n,m);

    for(int i=0;i<m;i++) cout<<n;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	int c11, c12, c13, c21, c22, c23, c31, c32, c33;
	cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23 >> c31 >> c32 >> c33;
	if (c11 + c22 == c21 + c12 && c21 + c32 == c22 + c31 && c12 + c23 == c22 + c13 && c33 + c22 == c23 + c32)cout << "Yes\n";
	else cout << "No\n";
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll R,C,K;
ll V[3005][3005];
ll dp[3005][3005][4];
ll dp1[3005][3005];
int main(){
  cin>>R>>C>>K;
  for(int i=0;i<K;i++){
  ll r,c,v;cin>>r>>c>>v;
    V[r][c]=v;
  }for(int i=1;i<=R;i++)
    for(int j=1;j<=C;j++){
    if(V[i][j]==0){
    dp[i][j][0]=max(dp[i][j-1][0],dp1[i-1][j]);
       dp[i][j][1]=dp[i][j-1][1];
       dp[i][j][2]=dp[i][j-1][2];
       dp[i][j][3]=dp[i][j-1][3];
    }else{
     dp[i][j][0]=max(dp[i][j-1][0],dp1[i-1][j]);
dp[i][j][1]=max(dp[i][j-1][1],max(dp[i][j-1][0],dp1[i-1][j])+V[i][j]);
       dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+V[i][j]);
       dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+V[i][j]);
    
    }dp1[i][j]=max(max(dp[i][j][0],dp[i][j][1]),max(dp[i][j][2],dp[i][j][3]));
    
    }cout<<dp1[R][C]<<endl;
  return 0;
}

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

using namespace std;


int main()
{
	int N, K, A = 1;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		if (A > K)
			A += K;
		else
			A *= 2;
	}

	cout << A << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	map<int,pi> grid;
	for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) {
		int x; cin >> x;
		grid[x] = pi(i,j);
	}
	int n;
	cin >> n;
	vector<int> chosen(n);
	vector<vector<int> > bingo(3,vector<int>(3));
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		if (grid.count(a)) {
			bingo[grid[a].first][grid[a].second] = 1;
		}
	}
	// horizontal
	for (int i = 0; i < 3; ++i) {
		if (bingo[i][0]+bingo[i][1]+bingo[i][2]==3) {
			cout << "Yes";
			return 0;
		}
	}
	// vertical
	for (int i = 0; i < 3; ++i) {
		if (bingo[0][i]+bingo[1][i]+bingo[2][i]==3)  {
			cout << "Yes";
			return 0;
		}
	}
	// diagonal
	int res = 0;
	for (int i = 0; i < 3; ++i) res += bingo[i][i];
	if (res == 3 || bingo[0][2]+bingo[1][1]+bingo[2][0]==3) {
		cout << "Yes"; 
		return 0;
	}
	cout << "No";
	return 0;
}
	

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char s[1000009];
int main(){
	int a;
	cin>>a>>s;
	if(strlen(s)>a)
	{for(int i=0;i<a;i++)
	cout<<s[i];
	cout<<"...";
	}
	else cout<<s<<endl;
	
	
}

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

int main(){
ll n,k; cin>>n>>k;
ll a[n];
ll i;
for(i=0;i<n;i++){
    cin>>a[i];
}
ll dp[n];
dp[0]=0;
for(i=1;i<n;i++){
    ll m=INT_MAX;
    for(ll j=i-1;j>=max(0ll, i-k);j--){
     m=min(m, dp[j]+abs(a[i]-a[j]));
    }
    dp[i]=m;
}
cout<<dp[n-1]<<endl;

    return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int sum(int n){
	int ret=0;
	rep1(i,n+1)ret+=i;
	return ret;
}

signed main(void) {
	int n;
	cin >> n;
	int maxn=0;
	FOR(i,sqrt(2*n)-1,sqrt(2*n)+1){
		if(maxn!=0)break;
		if(sum(i)>n) maxn=i;
	}
	int skip=sum(maxn)-n;
	rep1(i,maxn+1){
		if(i==skip)continue;
		println(i);
	}
}

Measured memory_bytes: 3576
#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int p,l,r;
}NODE;

NODE tree[MAX];

void preOrder(int);
void inOrder(int);
void postOrder(int);

int main(){
  int i,n,id,left,right,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].l=left;
    tree[id].r=right;
    if(left!=NIL)tree[left].p=id;
    if(right!=NIL)tree[right].p=id;    
  }
  for(i=0;i<n;i++){
    if(tree[i].p==NIL)root=i;
  }
  
  printf("Preorder\n");
  preOrder(root);
  printf("\n");
  
  printf("Inorder\n");
  inOrder(root);
  printf("\n");
 
  printf("Postorder\n");
  postOrder(root);
  printf("\n");

  return 0;
}


void preOrder(int u){
  if(u==NIL){
    return;
  }
  printf(" %d",u);
  preOrder(tree[u].l);
  preOrder(tree[u].r);
}

void inOrder(int u){
  if(u==NIL){
    return;
  }
  inOrder(tree[u].l);
  printf(" %d",u);
  inOrder(tree[u].r);
}

void postOrder(int u){
  if(u==NIL){
    return;
  }
  postOrder(tree[u].l);
  postOrder(tree[u].r);
  printf(" %d",u);
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  int minx, maxx;
  if(n * 100 % 108 == 0) {
    minx = n * 100 / 108;
  }
  else {
    minx = n * 100 / 108 +1;
  }
  if((n + 1) * 100 % 108 == 0) {
    maxx = (n + 1) * 100 / 108;
  }
  else {
    maxx = (n + 1) * 100 / 108 +1;
  }
  if(maxx - minx <= 0) {
    cout << ":(" << endl;
  }
  else {
    cout << minx << endl;
  }
}

Measured memory_bytes: 3568
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
typedef long long LL;
int main(){
	LL n,k,x,y,ans = 0;
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;
	if(n > k){
		ans += k*x;
		ans += (n-k)*y;
	}else
		ans += n*x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    std::string S;
    cin >> S;

    vector<int> nums;
    for (int i = 0; i < S.size() - 2; ++i)
    {
        nums.push_back(stoi(S.substr(i, 3)));
    }

    std::transform(nums.begin(), nums.end(),
                   nums.begin(),
                   [](int n) { return abs(753 - n); });

    cout << *min_element(nums.begin(), nums.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi d(n); rep(i,n) cin >> d[i];
  sort(all(d));
  multiset<int> st{0};
  rep(i,n){
    if(i%2) st.insert(d[i]);
    else st.insert(24-d[i]);
  }
  int ans = INF;
  for(auto i = st.begin(); i != st.end(); i++) {
    for(auto j = st.begin(); j != st.end(); j++) {
      if(i == j) continue;
      chmin(ans, min(abs(*j-*i), 24+*i-*j));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] x = new long[n];
        long[] y = new long[n];
        long[] z = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
        }
        long ans = 0;
        Long[] w = new Long[n];
        for (int i = 0; i < (1 << 3); i++) {
            int xc = -1, yc = -1, zc = -1;
            if ((i & 0b100) > 0) xc = 1;
            if ((i & 0b010) > 0) yc = 1;
            if ((i & 0b001) > 0) zc = 1;
            for (int j = 0; j < n; j++) {
                w[j] = x[j] * xc + y[j] * yc + z[j] * zc;
            }
            Arrays.sort(w, Collections.reverseOrder());
            long sum = 0;
            for (int j = 0; j < m; j++) sum += w[j];
            ans = Math.max(ans, sum);
        }
        System.out.println(ans);
    }
}

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

const ll MAXN = 200000;

ll K, ans=0, tmp=0;
vector<ll> A(MAXN, 0);
string S;
set<string> ST;

signed main(){
    cin >> S >> K;
    
    for(int i=1;i<=min(5LL, (ll)S.size());i++) {
        for(int j=0;j<S.size()-i+1;j++) {
            ST.insert(S.substr(j, i));
        }
    }
    ll id=1;
    for(set<string>::iterator itr=ST.begin();itr!=ST.end();itr++) {
        if(id==K) {
            cout << *itr << endl;
            break;
        }
        id++;
    }
    
    return 0;
}

Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	first_a_ind := -1
	last_z_ind := -1
	for i, r := range s {
		if r == 'A' && first_a_ind == -1 {
			first_a_ind = i
		}
		if r == 'Z' {
			last_z_ind = i
		}
	}

	fmt.Println(last_z_ind - first_a_ind + 1)
}


Measured memory_bytes: 1920