akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair 
#define f first
#define s second
#define int ll 
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
// this is triplet class , which will help us .
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
// this is for finding inversing multiplicative module of a number.
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
      lps[i] = j+1;
   i++;
   j++;
  }
  else{
        if(j != 0){
         j = lps[j-1];
        }
        else{
         lps[i] = 0;
         i++;
        }
  }
 }
 return lps[len-1];
}


int32_t main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin>>n>>k;
    int arr[n];
    int maxi = -1;
    for(int i = 0 ; i < n ;i++){
        cin>>arr[i];
        maxi = max(maxi , arr[i]);
    }
    int st = 1 , en = maxi;
    int ans = 1;
    while(st <= en){
            int mid = (st+en)/2;
            int cuts = 0;
            for(int i = 0 ; i < n ; i++){
                cuts += (arr[i] + mid-1)/mid;
                cuts--;
            }
            if(cuts <= k){
                 ans = mid;
                en = mid-1;
            }
            else{
                st = mid+1;
            }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n, m, k;
	cin >> n >> m >> k;
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a--, b--, c--, d--;
	
	string s[n];
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	vector<vector<bool>> vis(n, vector<bool>(m, false));
	vector<vector<bool>> enq(n, vector<bool>(m, false));
	queue<vector<int>> q; 	//{ x cord, y cord, dis} 
	q.push({a, b, 0});
	enq[a][b] = true;
	int max_stroke;
	
	while(!q.empty()) {
		int x = q.front()[0], y = q.front()[1];
		int dis = q.front()[2]; q.pop();
		if(x == c && y == d) {
			cout << dis << "\n";
			return 0;
		}
		if(vis[x][y]) continue;
		vis[x][y] = true;
		
		max_stroke = x;
		for(int i = 1; i <= k; i++) {
			if(x - i >= 0 && s[x - i][y] != '@' && vis[x - i][y] == false)
				max_stroke = x - i;
			else break;
		}
		for(int i = max_stroke; i < x; i++) {
			if(!enq[i][y])
				q.push({i, y, dis + 1}), enq[i][y] = true;
		}
		max_stroke = x;
		for(int i = 1; i <= k; i++) {
			if(x + i < n && s[x + i][y] != '@' && vis[x + i][y] == false)
				max_stroke = x + i;
			else break;
		}
		for(int i = max_stroke; i > x; i--) {
			if(!enq[i][y])
				q.push({i, y, dis + 1}), enq[i][y] = true;
		}
		max_stroke = y;
		for(int i = 1; i <= k; i++) {
			if(y - i >= 0 && s[x][y - i] != '@' && vis[x][y - i] == false)
				max_stroke = y - i;
			else break;
		}
		for(int i = max_stroke; i < y; i++) {
			if(!enq[x][i])
				q.push({x, i, dis + 1}), enq[x][i] = true;
		}
		max_stroke = y;
		for(int i = 1; i <= k; i++) {
			if(y + i < m && s[x][y + i] != '@' && vis[x][y + i] == false)
				max_stroke = y + i;
			else break;
		}
		for(int i = max_stroke; i > y; i--) {
			if(!enq[x][i])
				q.push({x, i, dis + 1}), enq[x][i] = true;
		}
	}
	cout << "-1\n";
}


Measured memory_bytes: 11536
#include<stdio.h>
#include <string.h>
#include<math.h>
#include<iostream>
using namespace std;

int main()
{
    int N, D;
    char c[3];
    long long L[101];
    int max = 0;
    int count = 0;

    cin >> N;

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

    for (int i = 0; i < N - 1; i++) {
        for (int j = N - 1; j >= i + 1; j--) {   //　右から左に操作
            if (L[j] < L[j - 1]) { 
                long long temp;
                temp = L[j];
                L[j] = L[j - 1];
                L[j - 1] = temp;              
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (L[i] != L[j])
                for (int k = j + 1; k < N; k++) {
                    if (L[k] != L[j])
                        if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) {
                            count++;
                        }
                }
        }
    }


    cout << count << endl;


    return 0;
}

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

using namespace std;
/*
int main(){
    string s;
    cin>>s;
    int m[26]={0};
    if(s=="zyxwvutsrqponmlkjihgfedcba")cout<<"-1"<<endl;
    else if(s.length()<26){
        for(int i=0;i<s.length();++i){
            m[s[i]-'a']=1;
        }
        for(int i=0;i<s.length()+1;++i){
            if(m[i]==0){
                s+=i+'a';
                break;
            }
        }
        cout<<s<<endl;
    }else{
        for(int i=25;i>0;--i){
            if(s[i-1]<s[i]){
                if(s[i]=='z'){
                    char c='z';
                    for(int j=i;j<26;++j){
                        if(s[i-1]<s[j])c=min(c,s[j]);
                    }
                    s[i-1]=c;
                    s=s.substr(0,i);
                }
                else{
                    char c='z';
                    for(int j=i;j<26;++j){
                        if(s[i-1]<s[j])c=min(c,s[j]);
                    }
                    s[i-1]=c;
                    s=s.substr(0,i);
                }
                break;
            }
        }
        cout<<s<<endl;
    }
}
*/
int main(){
    int n;
    cin>>n;
    int k=1;
    if(n==3){
        printf("2 5 63\n");
        return 0;
    }
    while(n>3){
        if(3*k>30000)break;
        printf("%d %d ",3*k,3*(k+2));
        k+=4;
        n-=2;
    }
    if(0){
        int f=1;
        while(n>0){
            printf("%d %d ",2*f,2*(f+1));
            f+=2;
            n-=2;
        }
    }else{
        int f=1;
        while(n>1){
            if(2*f>30000)break;
            printf("%d %d ",2*f,2*(f+1));
            f+=3;
            n-=2;
        }
        f=3;
        while(n>0){
            printf("%d ",2*f);
            f+=3;
            n--;
        }
    }
    printf("\n");
}

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

using namespace std;

const int N = 1e5+1;

#define pii pair<int,int>
#define fi first
#define se second

vector<pii> g[N];
vector<pair<pii,int>> edge;
vector<bool> ck(N);

int n,m,ans[N];

void dfs(int u){
	ck[u] = true;
	for(auto v:g[u]){
		if(!ck[v.fi]) ans[v.fi] = ans[u] + v.se, dfs(v.fi);
	}
}

signed main(){
	cin >> n >> m;
	for(int i=0;i<m;++i){
		int u,v,c;
		cin >> u >> v >> c;
		edge.push_back({{u,v},c});
		g[u].push_back({v,c}), g[v].push_back({u,-c});
	}
	for(int i=1;i<=n;++i) if(!ck[i]) dfs(i);
	
	bool ok = true;
	for(auto e:edge){
		ok &= (ans[e.fi.se]-ans[e.fi.fi]==e.se);
	}
	cout << (ok ? "Yes" : "No");
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

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

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define X first
#define Y second

using ll = long long;
using ld = long double;

ll a, b, c;
ll k;

/*
void cpy(ll c[3][3], ll a[3][3]) {
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            a[i][j] = c[i][j];
        }
    }
}

void mul(ll a[3][3], ll b[3][3]) {
    ll c[3][3];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                add(c[i][j], mul(a[i][k], b[k][j]));
            }
        }
    }
    cpy(c, a);
}

void mypw(ll a[3][3], ll b) {
    ll c[3][3];
    memset(c, 0, sizeof(c));
    for (int i = 0; i < 3; ++i) c[i][i] = 1;
    while (b) {
        if (b & 1) mul(c, a);
        b >>= 1;
        mul(a, a);
    }
    cpy(c, a);
}
*/

void run() {
    cin >> a >> b >> c;
    cin >> k;
    ll ans = 0;

    if (k % 2 == 0) {
        ans = a - b;
    } else {
        ans = b - a;
    }
    cout << ans << endl;
}

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


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

int main() {
    int N; cin >> N;
    vector<int> V(N);
    for (int i = 0; i < N; i++) cin >> V[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int c; cin >> c;
        ans += max(0, V[i] - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct dice
{   int f[7],f0[7];
    void r(int a,int b,int c,int d){
        int t;
        t = f[a];
        f[a] = f[d];
        f[d] = f[c];
        f[c] = f[b];
        f[b] = t;
    }
    void roll(char cmd){
        switch (cmd){
        case 'S': r(1,2,6,5); break;
        case 'N': r(1,5,6,2); break;
        case 'W': r(1,4,6,3); break;
        case 'E': r(1,3,6,4); break;    
        case 'R': r(2,3,5,4); break;
        }
    }
    void MvTop(int n){
        switch (n){
        case 2: roll('N'); break;
        case 3: roll('E'); break;
        case 4: roll('W'); break;
        case 5: roll('S'); break;
        case 6: roll('N'); roll('N'); break;
        default: break;
        }
    }
    void copy(){
        for(int i=1;i<=6;i++)
            f0[i] = f[i];
    }
    void back(){
        for(int i=1;i<=6;i++)
            f[i] = f0[i];
    }
    bool e(dice d){
        for(int i=1;i<=6;i++)
            if(f[i]!=d.f[i]) return 0;
        return 1;
    }
    bool equal(dice d){
        copy();
        for(int i=1;i<=6;i++){
            MvTop(i);
            for(int j=1;j<=4;j++){
                roll('R');
                if(e(d)) return 1; 
            }
            back();
        }
        return 0;
    }
};
int main(){
    dice d[2];
    for(int k=0;k<2;k++)
        for(int i=1;i<=6;i++)
            cin>>d[k].f[i];
    bool same = d[1].equal(d[0]);
    cout<<(same ? "Yes\n":"No\n");
    return 0;
}


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

using namespace std;

typedef long long ll;
ll mod = 1000000007;
#define f first
#define s second
#define ss string
#define mp make_pair
#define pb push_back
#define p pair<int, int>
#define pp pair<int, p>
#define v vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<p>
#define vpp vector<pair<int, p>>
#define vv vector<v>
#define vvl vector<vl>
#define vvp vector<vp>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repa(i, a, n) for(int i = a; i <= (n); ++i)
#define repd(i, n) for(int i = n; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    v a(n);
    int t = 0;
    rep(i, n){
        cin >> a[i];
        t = (t^a[i]);
    }
    rep(i, n){
        int g = t^a[i];
        cout << g << " ";
    }
    return 0;
}   

Measured memory_bytes: 3940
#include <iostream>
#include <cstdio>
#include <queue>
#include <utility>
using namespace std;

int n;
vector<int> edge[101];
vector<int> weight[101];

int v[100];
int M = 1001001001;


int dijkstra(int a){
	for(int i=0; i<100; i++){
		v[i] = M;
	}
	priority_queue<pair<int, int> > pq;
	pq.push(pair<int,int>(0, a));

	while(!pq.empty()){
		pair<int, int> t = pq.top();
		pq.pop();
		if(v[t.second]!=M) continue;

		v[t.second] = -t.first;
		for(int i=0; i<edge[t.second].size(); i++){
			pq.push(pair<int, int>(t.first-weight[t.second][i], edge[t.second][i]));
		}
	}


}

int main(){
	int m;
	cin >> n >> m;
/*
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			dst[i][j] = M;
		}
	}
	*/

	for(int i=0; i<m; i++){
		int a, b, c, d;
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		edge[a-1].push_back(b-1);
		weight[a-1].push_back(c);
		edge[b-1].push_back(a-1);
		weight[b-1].push_back(d);
	}
	int x1, x2, y1, y2;
	scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
	int ans = 0;
	dijkstra(x1-1);
	ans += v[x2-1];
	dijkstra(x2-1);
	ans += v[x1-1];
	cout << y1 - y2 - ans << endl;
	return 0;
}

Measured memory_bytes: 1268
#include<bits/stdc++.h>
#define lb long double
#define eps 1e-10
using namespace std;
struct Po{lb x,y;}p0,p1,q0,q1;
int t;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
lb operator ^(Po x,Po y){return x.x*y.x+x.y*y.y;}
bool dotinline(Po x,Po y,Po z){
	if (x.x>y.x) swap(x,y);
	if (z.x<x.x-eps||z.x>y.x+eps) return 0;
	if (x.y>y.y) swap(x,y);
	if (z.y<x.y-eps||z.y>y.y+eps) return 0;
	return 1;
}
bool getcross(Po p0,Po p1,Po q0,Po q1){
	Po np=p1-p0,nq=q1-q0;
	lb a1=np*(q0-p0),a2=np*(q1-p0),a3=nq*(p0-q0),a4=nq*(p1-q0);
	if (a1*a2<-eps&&a3*a4<-eps) return 1;
	if (fabs(a1)<eps&&dotinline(p0,p1,q0)) return 1;
	if (fabs(a2)<eps&&dotinline(p0,p1,q1)) return 1;
	if (fabs(a3)<eps&&dotinline(q0,q1,p0)) return 1;
	if (fabs(a4)<eps&&dotinline(q0,q1,p1)) return 1;
	return 0;
}
lb dis(Po x){return sqrtl(x.x*x.x+x.y*x.y);}
lb getd(Po x,Po y,Po z){
	if (((y-x)^(z-x))<eps)return dis(x-z);
	if (((x-y)^(z-y))<eps)return dis(y-z);
	return fabs((y-x)*(z-x))/dis(x-y);
}
int main(){
	scanf("%d",&t);
	while (t--){
		get(p0);get(p1);get(q0);get(q1);
		if (getcross(p0,p1,q0,q1)) printf("0\n");
		else printf("%.10Lf\n",min(min(getd(p0,p1,q0),getd(p0,p1,q1)),min(getd(q0,q1,p0),getd(q0,q1,p1))));
	}
	return 0;
}


Measured memory_bytes: 3240
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(str(input()))

S = collections.Counter(S) 
maxFreq = S.most_common()[0][1]

S = sorted(S.items())
values, counts = zip(*S)

for v, c in zip(values, counts):
    if c == maxFreq:
        print(v)

Measured memory_bytes: 47056
def lP(l: list) -> None:
    for i in range(len(l)-1):
        print(l[i], end = ' ')
    print(l[len(l)-1])

N = int(input())
l = list(map(int, input().split()))
for i in range(1, N):
    lP(l)
    v = l[i]
    for j in range(i-1, -1, -1):
        if v >= l[j]:
            break
        l[j+1] = l[j]
        l[j] = v
lP(l)


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

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

int ans[N];
int loop=0;
bool primecheck=true;


for (int i=11; i<55556; i=i+10){
  primecheck=true;

  for (int j=2; j <= sqrt(i); ++j){
    if(i % j == 0){
      primecheck = false;
    }
  }

  if(primecheck && (i % 5 == 1)){
    ans[loop] = i;
    ++loop;
  }
  if(loop == N) break;
}

for(int i=0; i<N; ++i) cout << ans[i] << " ";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n;
  cin >> n;
  vi data(n);
  rep(i,n) cin >> data[i];
  int ans = 0;
  repa(i,1,n-1) {
    if(data[i-1] < data[i] && data[i] < data[i+1]) ans++;
    else if(data[i+1] < data[i] && data[i] < data[i-1]) ans++;
  }
  cout << ans;
  hinata;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <tuple>
#include <numeric>

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
typedef unsigned int uint;

const int N = 10;

int field[N][N];

int dd[] = { 1, 1, 2 };
bool drop(int val, int x, int y, int size){
	rep(s, 3){
		if (s != size) continue;
		if (x - dd[s] < 0 || x + dd[s] >= N || y - dd[s] < 0 || y + dd[s] >= N) return false;

		rep(k, 2) for (int i = y - dd[s]; i <= y + dd[s]; ++i){
			for (int j = x - dd[s]; j <= x + dd[s]; ++j){
				if (size == 1 || abs(x - j) + abs(y - i) <= dd[s]){
					if (k) field[i][j] += val;
					else if (field[i][j] + val < 0) return false;
				}
			}
		}
	}
	return true;
}

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

vector<tuple<int, int ,int>> ans;

bool dfs(int x, int y, int n){
	if (x == N) return dfs(0, y + 1, n);
	if (y == N) return n == 0;

	if (!field[y][x]) return dfs(x + 1, y, n);
	for (int i = 2; i >= 0; --i){
		bool b = drop(-1, x + dx[i], y + dy[i], i);
		if (b && dfs(x, y, n-1)){
			ans.push_back(MT(x+dx[i], y+dy[i], i + 1));
			return true;
		}
		if(b) drop(1, x + dx[i], y + dy[i], i);
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	rep(i, N) rep(j, N) cin >> field[i][j];

	dfs(0, 0, n);

	for (auto t : ans){
		int x, y, s;
		tie(x, y, s) = t;
		cout << x << ' ' << y << ' ' << s << '\n';
	}

	return 0;
}

Measured memory_bytes: 1208
n, m = map(int, input().split())
box = [1]*(n+1)
red = [False]*(n+1)
red[1] = True

for i in range(m):
    x, y = map(int, input().split())
    if red[x]:
        red[y] = True
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = False

print(red.count(True))


Measured memory_bytes: 10280
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun reach-positions (n m line)
  (let ((res (make-array (1+ n) :initial-element nil))
        (cnt 1))
    (setf (aref res 0) t)
    (loop for i from 1 to n
          when (and (not (aref line i)) (not (zerop cnt)))
            do (progn
                 (setf (aref res i) t)
                 (incf cnt))
          when (and (>= i m) (aref res (- i m)))
            do (decf cnt))
    res))

(defun make-ans (pos m line)
  (when (zerop pos)
    (return-from make-ans nil))
  (loop for i from (max 0 (- pos m)) to pos
        when (aref line i)
          return (cons (- pos i) (make-ans i m line))))

(defun main (n m line)
  (let ((reach (reach-positions n m line)))
    (when (not (aref reach n))
      (return-from main (list -1)))
    (reverse (make-ans n m reach))))

(let* ((n (read))
       (m (read))
       (line (coerce (collect-times (1+ n) (char= (read-char) #\1))
                     'vector)))
  (reduce (lambda (last x)
            (when last
              (princ #\space))
            (princ x)
            x)
          (main n m line)
          :initial-value nil))


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

int main() {
  int n;
  cin >> n;
  VI a(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  double r;
  double sum=0;
  for(int i=0;i<n;i++){
    r=1.000000/a.at(i);
    sum+=r;
  }
  cout << 1.000000/sum <<endl;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d))
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef int long long ll;
const long double pi = 3.14159265358979323846264338327950288;
string a;
ll ans = 0;
void solve(int i,ll wa) {
	if (i == a.size()) {
		ans += wa;
		return;
	}
	for (int j = 1; j <= (a.size() - i); j++) {
		string g = a.substr(i, j);
		solve(i + j, wa + stoll(g));
	}
}
int main() {
	cin >> a;
	solve(0, 0);
	cout << ans << endl;
	cin >> a;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	map<char, int> c;
	string S;  cin >> S;
	for(int i = 0 ; i < N ; i++)  c[S[i]] += 1;

	ll ans = 1;
	for(int i = 0 ; i <= 26 ; i++){
	 if(c['a' + i] != 0)  ans *= c['a' + i] + 1;
     ans %= MOD;
    }

	cout << (ans - 1) % MOD << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> cc(n);
  rep(i, n) cin >> cc.at(i);
  vector<int> c;
  rep(i, n){
    if(i == 0 || cc.at(i) != cc.at(i-1)){
      c.push_back(cc.at(i));
    }
  }
  n = c.size();
  vector<mint> dp(n+1, 0);
  dp.at(0) = 1;
  map<int, mint> mp;
  rep(i, n){
    dp.at(i+1) = dp.at(i) + mp[c.at(i)];
    mp[c.at(i)] += dp.at(i);
    // for(auto p : mp){
    //   cerr << p.first << " " << p.second.x << endl;
    // }
    // cerr << dp.at(i+1).x << endl;
    // cerr << "-------------" << endl;
  }
  // rep(i, n+1) cerr << dp.at(i).x << " ";
  // cerr << endl;
  cout << dp.at(n).x << endl;
  return 0;
}

Measured memory_bytes: 18644
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

long long c[200001];

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

	vector<vector<int>> G(N + 1);
	for (auto i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (auto i = 0; i < Q; ++i)
	{
		int p, x;
		cin >> p >> x;
		c[p] += x;
	}

	bool used[200001];
	memset(used, 0, sizeof(used));

	queue<int> q;
	q.push(1);
	while (!q.empty())
	{
		auto v = q.front();
		q.pop();
		if (used[v])
		{
			continue;
		}

		used[v] = true;

		for (auto u : G[v])
		{
			if (used[u])
			{
				continue;
			}

			c[u] += c[v];
			q.push(u);
		}
	}

	for (auto i = 1; i <= N; ++i)
	{
		if (i > 1)
		{
			cout << " ";
		}
		cout << c[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 16500
n = int(input())
s = input()

r = s.count("R"); g = s.count("G"); b = s.count("B")

count = 0
for d in range(1, (n - 1) // 2 + 1):
    for i in range(n - 2 * d):
        if s[i] != s[i + d] and s[i + d] != s[i + 2 * d] and s[i + 2 * d] != s[i]:
            count += 1

print(r * g * b - count)


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

int main(){
  int x;
  cin>>x;
  double ans=0;
  for(int i=1;i*i<=x;i++){
    for(int j=2;j<=10;j++){
      if(pow(i,j)<=x){
        ans=max(ans,pow(i,j));
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#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 dp[3001][3001];

int main() {
    int n, t;
    cin >> n >> t;
    vector<P> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());

    for(int i = 1; i <= n; ++i) {
        for (int j = 1; j <= t; ++j) {
            if (j >= a[i-1].first) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i-1].first]+a[i-1].second);
            } else dp[i][j] = dp[i-1][j];
        }
    }

    int ans = 0;
    rep(i,n) {
        ans = max(ans, dp[i][t-1] + a[i].second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const char d[] = {'R', 'G', 'B'};

int n;
char c[4004];
int prefr[4004];
int prefg[4004];
int prefb[4004];
long long ans;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> c[i], prefr[i] = prefr[i - 1] + (c[i] == 'R'), prefb[i] = prefb[i - 1] + (c[i] == 'B'), prefg[i] = prefg[i - 1] + (c[i] == 'G');
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			if(c[i] != c[j])
			{
				for(int i1 = 0; i1 < 3; i1++)
				{
					if(d[i1] != c[i] && d[i1] != c[j]) 
					{
						if(d[i1] == 'R') 
						{
							ans += prefr[n] - prefr[j];
							int k = j + j - i;
							if(k <= n && c[k] == 'R') ans--; 
						}
						if(d[i1] == 'G') 
						{
							ans += prefg[n] - prefg[j];
							int k = j + j - i;
							if(k <= n && c[k] == 'G') ans--;
						}
						if(d[i1] == 'B') 
						{
							ans += prefb[n] - prefb[j];
							int k = j + j - i;
							if(k <= n && c[k] == 'B') ans--;
						}
					}
				}	
			}
		}
	}
	cout << ans;
}      

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

using lli = int64_t;

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

    lli lcm; cin >> lcm;

    for(int i = 1; i < n; i++)
    {
        lli k; cin >> k;

        lcm = lcm / __gcd(lcm, k) * k;
    }

    cout << lcm << endl;
    return 0;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


    int n;
    cin>> n;

    cout << ((n+ 110)/ 111) *111;
    nl;

    return 0;
}


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

int main() {
  int N;
  ll W;
  cin >> N >> W;
  
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w.at(i) >> v.at(i);
  }
  
  vector<ll> dp(N * 1000 + 1, W + 1);
  dp.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N * 1000; j >= 0; j--) {
      if (0 <= j - v.at(i) && j - v.at(i) <= N * 1000) {
        dp.at(j) = min(dp.at(j), dp.at(j - v.at(i)) + w.at(i));
      }
    }
  }
  
  ll ans;
  for (int i = N * 1000; i >= 0; i--) {
    if (dp.at(i) != W + 1) {
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
a = [0] * M
b = [0] * M
c = [0] * M
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    c[i] = -c[i]
    
INF = 10 ** 13
dist = [INF] * N

dist[0] = 0

for loop in range(N-1):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]

ans = dist[N-1]

nega = [0] * N

for loop in range(N):
    for i in range(M):
        if dist[a[i]-1] == INF:
            continue
        if dist[b[i]-1] > dist[a[i]-1] + c[i]:
            dist[b[i]-1] = dist[a[i]-1] + c[i]
            nega[b[i]-1] = 1
        if nega[a[i]-1] == 1:
            nega[b[i]-1] = 1

if nega[N-1]:
    print('inf')
else:
    print(-ans)

Measured memory_bytes: 47832
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace atcoder;

vector<pair<ll,ll>> primeFactorDecomp(ll n){
      vector<pair<ll,ll>> ret;
      ll m=n;
      for(ll i=2;i*i<=m;i++){
            if(n%i!=0) continue;
            int cnt=0;
            while(n%i==0){
                  cnt++;
                  n/=i;
            }
            ret.push_back({i,cnt});
      }
      if(n>1){
            ret.push_back({n,1});
      }
      return ret;
}

ll s[200020];

ll solve(ll n){
  if(n==1)return 1;
  vector<pair<ll,ll>> v=primeFactorDecomp(n);
  if(v.size()==1){
    if(v[0].first==2){
      return 2*n-1;
    }else{
      return n-1;
    }
  }
  ll ret=longinf;
  ll num=v.size();
  ll x=1;
  rep(i,num)x*=2;
  for(ll i=1;i<x;i++){
    vector<ll> r,m;
    ll M=1;
    rep(j,num){
      M=1;
      rep(_,v[j].second){
        M*=v[j].first;
      }
      ll w=solve(M);
      if(i & (1 << j)){
        r.push_back(0);
        m.push_back(w+1);
      }else{
        r.push_back((w+1+w)%(w+1));
        m.push_back(w+1);
      }
    }
    if(crt(r,m).first==0){
      ret=min(ret,crt(r,m).second);
    }else{
      ret=min(ret,crt(r,m).first);
    }
  }
  return ret;
}

int main(){
  ll n;
  cin >> n;
  cout << solve(n) << endl;
  
return 0;}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int nums[100010];
int main(){
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    nums[tmp]++;
  }
  int ans = 0;
  int mx = 0;
  for (int i = 1; i <= 100000;i++){
    if (mx < nums[i-1] + nums[i] + nums[i+1]){
      ans = i;
      mx = nums[i-1] + nums[i] + nums[i+1];
    } 
  }
  cout << mx << endl;
 

  return 0;
}


Measured memory_bytes: 3980
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll,ll> Pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int N,M,K,T;

int main(void)
{
	ll a,b,c,d; cin >> a >> b >> c >> d;
	cout << MAX2(a*b,c*d);
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

double f(int a,int b,int c,int d){
    double t=a*d-b*c;
    t/=sqrt(a*a+b*b);
    t/=sqrt(c*c+d*d);
    t=asin(t);
    t*=180/acos(-1);
    t=abs(t);
    // cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<t<<endl;
    if(a*c+b*d<0)t=180-t;
    return t;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n;
    cin>>n;
    double out=inf;
    vvi in(n+2,vi(2));
    rep(i,n)rep(j,2)cin>>in[i+1][j];
    vi t(n+2);
    rep(i,n+2)t[i]=i;
    do{
        double s=0;
        s+=f(1,0,in[t[1]][0],in[t[1]][1]);
        rep(i,n){
            int a=in[t[i+1]][0]-in[t[i+0]][0];
            int b=in[t[i+1]][1]-in[t[i+0]][1];
            int c=in[t[i+2]][0]-in[t[i+1]][0];
            int d=in[t[i+2]][1]-in[t[i+1]][1];
            s+=f(a,b,c,d);
        }
        // cout<<s<<endl;
        cmin(out,s);
    }while(next_permutation(t.begin()+1,t.begin()+n+1));
    cout<<shosu(9)<<out<<endl;
}



Measured memory_bytes: 3516
#include <iostream>

using namespace std;

int main(void) {

	int N, M, C, B[100], A[100][100];

	cin >> N >> M >> C;

	for (int i = 1; i <= M; i++) {
		cin >> B[i];
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			cin >> A[i][j];
		}
	}

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		int tmp = 0;
		for (int j = 1; j <= M; j++) {
			tmp += A[i][j] * B[j];
		}
		tmp += C;

		if (tmp > 0) { ans++; }
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

int N;
ll A,B,C,D;

int main(){
	cin>>N>>A>>B>>C>>D;
	bool flg=false;
	REP(i,N){
		if (max(A+i*C,B+(N-i-1)*C)<=min(A+i*D,B+(N-i-1)*D)){
			flg=true;
			break;
		}
	}
	cout<<(flg ? "YES" : "NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 3076.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const int MOD = 998244353;

/* typedef */

typedef long long ll;

/* global variables */

int xs[MAX_N], e2s[MAX_N + 1];

/* subroutines */

int powmod(int a, int n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", xs + i);

  e2s[0] = 1;
  for (int i = 1; i <= n; i++) e2s[i] = e2s[i - 1] * 2 % MOD;

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int d = (ll)xs[i] * powmod(1 + xs[i], i) % MOD * e2s[n - 1 - i] % MOD;
    sum = (sum + d) % MOD;
  }

  printf("%d\n", sum);
  return 0;
}



Measured memory_bytes: 10916
#include <iostream>

int main(void){
    int a[3];
    std::cin >> a[0] >> a[1] >> a[2];
    for(int i=0;i<3;i++){
        for(int j=i+1;j<3;j++){
            if(a[i]>a[j]){
                int t=a[j];
                a[j]=a[i];
                a[i]=t;
            }
        }
    }
    std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll crab(ll e){
    ll mi = inf;
    FOR(z, 0, 101){
        FOR(y, 0, 1001){
            ll rest = e - z*z*z - y*y;
            if(rest>=0){
                ll x = rest;
                chmin(mi, x+y+z);
            }
        }
    }
    return mi;
}

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

    // input
    while(true){
        ll e; cin >> e;
        if(e==0){
            return 0;
        }
        ll m = crab(e);
        p(m);
    }
    
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int array[6];
    int N=5;
    string ret ="Yay!";
    for(int i=0;i<=N;i++) {
    cin >> array[i];
    }
    
    for(int n =4 ;n>-1 ;n--){
    for(int j =0;j<5;j++){
    if(abs(array[j]- array[n]) > array[5]){
        ret=":(";
    }
    }
}
    cout << ret;
}

Measured memory_bytes: 256
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 12

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	cout << fixed;
	cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n, m;
	cin >> n >> m;
	
	bool sides[n][n];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			sides[i][j] = false;
		}
	}
	
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		
		sides[a - 1][b - 1] = true;
		sides[b - 1][a - 1] = true;
	}
	
	vector<int> vertexes;
	for (int i = 0; i < n; i++)
	{
		vertexes.push_back(i);
	}
	
	int counter = 0;
	do
	{
		if (vertexes[0] != 0)
		{
			continue;
		}
		
		bool flag = true;
		for (int i = 0; i < (n - 1); i++)
		{
			if (sides[vertexes[i]][vertexes[i + 1]] == false)
			{
				flag = false;
				break;
			}
		}
		
		if (flag == true)
		{
			counter++;
		}
	}
	while (next_permutation(vertexes.begin(), vertexes.end()));
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


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

int main() {
	int n, k;
	int sum = 1;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		if ((sum + k) > sum * 2) { sum += sum; }
		else if ((sum + k) <= sum * 2) { sum += k; }
	}
	cout << sum << endl;
}

Measured memory_bytes: 3604