akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    int a[n]; lint b[n];
    rep(i, n) scanf("%d%lld", &a[i], &b[i]);
    lint ans = 0;
    rep(i, n)if((k | a[i]) == k) ans += b[i];
    rep(i, 31)if((k>>i)&1){
        lint tmp = 0;
        rep(j, n)if(((k>>(i+1)) | (a[j]>>(i+1))) == (k>>(i+1)) && !((a[j]>>i)&1)){
            tmp += b[j];
        }
        ans = max(ans, tmp);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1408
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, t;
    scan(n, t);
    auto a = readln.split.to!(int[]);
    a ~= 0;

    int mn = a[0];
    int mx = a[0];
    int md = 0;
    int ans;

    foreach (i ; 1 .. n + 1) {
        if (a[i] > mn) {
            mx = max(mx, a[i]);
        }
        else {
            if (md < mx - mn) {
                ans = 1;
                md = mx - mn;
            }
            else if (md == mx - mn) {
                ans++;
            }
            mn = mx = a[i];
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

using namespace std;

struct node{

	long long int a,b;

};

bool cmp(node e,node f)

{

	if(e.a!=f.a)

	return e.a<f.a;

	else

	return e.b>f.b;

}

int main(){

long long int n,m,y=0;

cin>>n>>m;

node d[n+1];

for(int i=1;i<=n;i++)

cin>>d[i].a>>d[i].b;

sort(d+1,d+n+1,cmp);

for(int i=1;i<=n;i++){

	if(d[i].b<m)

	{

		y+=d[i].a*d[i].b;

		m-=d[i].b;

	}

	else

	{

		y+=d[i].a*m;

		break;

	}

}

cout<<y;

}




Measured memory_bytes: 1792
package main
 
import (
	"fmt"
)
 
func main() {
	var s string
	fmt.Scanf("%s", &s)
	
	var isBad bool
	
	isBad = false
	for i := 0; i < 3; i++{
	    if s[i] == s[i+1] {
	        isBad = true
	    }
	    
	}
	
	if isBad {
        fmt.Printf("Bad")
	} else {
	    fmt.Printf("Good")
	}
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,c,i;
	scanf("%d %d %d", &a, &b, &c);
	for(i=1; i<=b; i++)
	{
		if(a*i%b==c)
		{
			printf("YES\n");
			break;
		}
		if(i==b)
		printf("NO\n");
	}
	
	return 0;
}

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

if n%2 == 1:
    print("No")
#print(type(n/2+1))
# print (s[0:int(n/2)] )
# print(s[int(n/2):])
elif s[0:int(n/2)] == s[int(n/2):]:
    print("Yes")
else:
    print("No")


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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define PI acosl(-1.0)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;


const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
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;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll n;
	cin>>n;
	vector<ll> v(n);
	rep(i, 0, n) cin>>v[i];
	ll ans = 1;
	ll minn = v[0];
	rep(i, 1, n)
	{
		if(minn >= v[i]) ans++;
		chmin(minn, v[i]);
	}
	cout<<ans<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1792
N, A, B, C = list(map(int, input().split()))
lList = []
INF = 10 ** 9
for i in range(N):
    lList.append(int(input()))

def calcMinMP(lList, ALen, BLen, CLen, mp):
    if not lList:
        return mp + abs(A-ALen) + abs(B-BLen) + abs(C-CLen) - 30 if min(ALen, BLen, CLen) > 0 else INF
    l = lList[0]
    mpList = []
    mpList.append(calcMinMP(lList[1:], ALen, BLen, CLen, mp))
    mpList.append(calcMinMP(lList[1:], ALen+l, BLen, CLen, mp+10))
    mpList.append(calcMinMP(lList[1:], ALen, BLen+l, CLen, mp+10))
    mpList.append(calcMinMP(lList[1:], ALen, BLen, CLen+l, mp+10))
    return min(mpList)

print(calcMinMP(lList, 0, 0, 0, 0))

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int main() {
	string s;
	cin >> s;

	int n = s.length();
	int left = 15 - n;

	if (count(s.begin(), s.end(), 'o') + left >= 8) {
		ANS("YES")
	}
	else {
		ANS("NO")
	}
	return 0;

}


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

using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	b = abs(a - b);
	c = abs(a - c);
	if (b < c) cout << "A"<<endl;
	else cout << "B"<<endl;
    return 0;
}

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

#define ALL(x) (x).begin(), (x).end()
#define EB emplace_back

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;

struct Edge {
    Edge () {}
    Edge (int t, int d, int e) : to(t), dist(d), enemy(e){}
    int to, dist, enemy;
};

typedef vector<Edge> VE;
typedef vector<VE> VVE;

struct State {
    State () {}
    State (int v_, int d, int c) : v(v_), dist(d), cost(c) {}
    int v, dist, cost;
    bool operator > (const State &s) const {
        return cost > s.cost;
    }
};

int N, M, L;

VVE es;

int solve() {
    // dist[v][dist] = min_enemy;
    VVI dist(N, VI(L + 1, INF));

    priority_queue<State, vector<State>, greater<State>> q;
    q.push(State(0, 0, 0));

    while (q.size()) {
        State c = q.top();
        q.pop();

        // ????°??????????????????????
        if (c.cost > dist[c.v][c.dist]) continue;

        // ?¬?
        for (auto e : es[c.v]) {
            for (int i = 0; i < 2; i++) { // use
                State n;
                n.v = e.to;
                n.dist = c.dist + (i ? e.dist : 0);
                n.cost = c.cost + (i ? 0 : e.enemy);

                // ???????????????????????????
                if (n.dist > L) continue;

                if (dist[n.v][n.dist] > n.cost) {
                    dist[n.v][n.dist] = n.cost;
                    q.push(State(n.v, n.dist, n.cost));
                }
            }
        }
    }

    return *min_element(ALL(dist[N - 1]));
}

int main(void) {
    while (cin >> N >> M >> L, N) {
        es.clear();
        es.resize(N);

        for (int i = 0; i < M; i++) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            --a; --b;
            es[a].EB(b, d, e);
            es[b].EB(a, d, e);
        }

        cout << solve() << endl;
    }

    return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
#define dump(x) cout << #x << " = " << x << "\n";
#define SELECTOR(_1, _2, _3, SELECT, ...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__, _rep1, _rep0)(__VA_ARGS__)
#define _rep0(i, n) for (ll i = 0; i < n; ++i)
#define _rep1(i, k, n) for (ll i = k; i < n; ++i)
template <typename T> void vecout(const T &v) {
  for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n")) {
    cout << *it;
  }
}

double dp[303][303][303]={};

void solve(){
  // main coding
  ll n; cin>>n;
  vector<ll> cnt(3);
  rep(_,n) {
    ll a; cin>>a;
    --a;
    cnt[a]++;
  }
  function<double(ll,ll,ll)> calc=[&](ll i,ll j,ll k){
    if(dp[i][j][k]) return dp[i][j][k];
    double l=i+j+k;
    if(l==0) return 0.0;
    return dp[i][j][k]=(i?calc(i-1,j,k)*i/l:0)+(j?calc(i+1,j-1,k)*j/l:0)+(k?calc(i,j+1,k-1)*k/l:0)+n/l;
  };
  cout<<calc(cnt[0],cnt[1],cnt[2])<<"\n";
}

int main(){
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 217472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    rep(i, 0, x) cin >> a[i];
    rep(i, 0, y) cin >> b[i];
    rep(i, 0, z) cin >> c[i];

    sort(a, a + x, greater<ll>());
    sort(b, b + y, greater<ll>());
    sort(c, c + z, greater<ll>());

    vector<ll> d;
    rep(i, 0, x) {
        rep(j, 0, y) {
            d.push_back(a[i] + b[j]);
        }
    }

    sort(all(d));
    reverse(all(d));

    vector<ll> ans;
    int mnd = min(k, (int)d.size());
    int mnc = min(k, z);
    rep(i, 0, mnd) {
        rep(j, 0, mnc) {
            ans.push_back(d[i] + c[j]);
        }
    }


    sort(all(ans));
    reverse(all(ans));

    rep(i, 0, k) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 43236
/*
 * atcoder/abc144/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

double degree(double rad) {
  return rad * 180 / M_PI;
}

double a, b, x;
bool up = false;
double capacity(double theta) {
  if (up) {
    return a * b - a * a * tan(theta) * 0.5;
  }

  return b * b * tan(M_PI / 2 - theta) * 0.5;
}

void solve() {
  cin >> a >> b >> x;
  x /= a;
  up = x > a * b * 0.5;

  double left = 0, right = M_PI / 2;
  loop(_,0,100) {
    double theta = (left + right)/2;
    // まだ傾けられる
    if (capacity(theta) >= x) left = theta;
    // 溢れた
    else right = theta;
  }
  cout << degree(left) << endl;
}
int main() {
  cout.precision(10); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int A, B;
  cin >> A >> B;
  cout << (A - 1) * (B - 1) << "\n";
  // print();
}

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

// debug start
	template <typename A, typename B>
	string to_string(pair<A, B> p);
	 
	template <typename A, typename B, typename C>
	string to_string(tuple<A, B, C> p);
	 
	template <typename A, typename B, typename C, typename D>
	string to_string(tuple<A, B, C, D> p);
	 
	string to_string(const string& s) {
	  return '"' + s + '"';
	}
	 
	string to_string(const char* s) {
	  return to_string((string) s);
	}
	 
	string to_string(bool b) {
	  return (b ? "true" : "false");
	}
	string to_string(vector<bool> v) {
	  bool first = true;
	  string res = "{";
	  for (int i = 0; i < static_cast<int>(v.size()); i++) {
	    if (!first) {
	      res += ", ";
	    }
	    first = false;
	    res += to_string(v[i]);
	  }
	  res += "}";
	  return res;
	}
	 
	template <size_t N>
	string to_string(bitset<N> v) {
	  string res = "";
	  for (size_t i = 0; i < N; i++) {
	    res += static_cast<char>('0' + v[i]);
	  }
	  return res;
	}
	 
	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;
	}
	 
	template <typename A, typename B>
	string to_string(pair<A, B> p) {
	  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
	}
	 
	template <typename A, typename B, typename C>
	string to_string(tuple<A, B, C> p) {
	  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
	}
	 
	template <typename A, typename B, typename C, typename D>
	string to_string(tuple<A, B, C, D> p) {
	  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
	}
	 
	void debug_out() { cerr << endl; }
	 
	template <typename Head, typename... Tail>
	void debug_out(Head H, Tail... T) {
	  cerr << " " << to_string(H);
	  debug_out(T...);
	}
	 
	#ifndef ONLINE_JUDGE
	#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
	#else
	#define debug(...) 42
	#endif
// end debug

	#define int long long

const int mxN = 3e5 + 1;

int x, k;
int a[mxN];

void solve() {
	cin >> x;
	x ^= 1;
	cout << x;
}

int32_t main() {
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
		freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    //this can be opted out if you want to print the output to the sublime console
		freopen("output.txt", "w", stdout);
	#endif

	// for fast i/o
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);

	// test cases
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 3616
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    ls = [chr(i) for i in range(97, 97 + 26)]
    c = str(readline().rstrip().decode('utf-8'))
    for i in range(1, len(ls)):
        if ls[i-1] == c:
            print(ls[i])
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    int n;
    cin >> n;
    vector<int>L(n);
    for(int i=0;i<n;i++)cin >> L[i];
    sort(L.begin(),L.end());
    int x=L[n-1];
    int y=0;
    for(int i=0;i<n-1;i++)y+=L[i];
    if(y>x)cout << "Yes";
    else cout << "No";
    cout << endl;
}

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




Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int f[n][5][2];
    int p[n][11];
    for(int i=0;i<n;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<2;k++)cin >> f[i][j][k];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++)cin >> p[i][j];
    }
    int ans=-1e9;
    for(int i=1;i<(1 << 10);i++){
        int tmp=0;
        for(int j=0;j<n;j++){
            int count=0;
            for(int k=0;k<10;k++){
                if( ((i & (1 << k))>0) && f[j][k/2][k%2])count++;
            }
            tmp+=p[j][count];
        }
        ans=max(ans,tmp);
    }
    cout << ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pi acos(-1)
//#define e 2.7182818284590452354
int main()
{
    string s,s1; cin >> s;
    ll d = s.size();
    for(ll i = 0 ; i < d / 2; i++)
    {
        s1 += "hi";
    }
    if(s1 == s)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';

//    ll d = count(s.begin() , s.end() , 'h');
//    ll e = count(s.begin() , s.end() , 'i');
//    if(d == e)
//        cout << "Yes" << '\n';
//    else
//        cout << "No" << '\n';
//    d = 0, e = 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int f[]={4,1,4,1,2,1,2,1},p[8],r,P;
    while(cin>>p[0]){
        for(int i=1;i<8;i++)cin>>p[i];
        for(int i=0;i<8;i++){
            int n=0;
            for(int j=0;j<8;j++)if(f[(i+j)%8]<p[j])n+=p[j]-f[(i+j)%8];
            if(r>n||i==0){
                r=n;
                P=i;
            }
            else if(r==n){
                for(int j=0;j<8&&f[(i+j)%8]<=f[(P+j)%8];j++){
                    if(f[(i+j)%8]<f[(P+j)%8]){
                        P=i;
                        break;
                        }
                    }
                }
        }
        for(int i=0;i<7;i++)cout<<f[(P+i)%8]<<" ";
            cout<<f[(P+7)%8]<<endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int a = 0, b = 0;
  int i;

  for ( i = 0; i < 4; ++i )
  {
    int t;

    scanf ( "%d", &t );
    a += t;
  }
  for ( i = 0; i < 4; ++i )
  {
    int t;

    scanf ( "%d", &t );
    b += t;
  }

  printf ( "%d\n", MAX( a, b ) );

  return ( 0 );
}

Measured memory_bytes: 0
while (True):
    a, op, b = input().split()
    if (op == '+'):
        print(int(a) + int(b))
    elif (op == '-'):
        print(int(a) - int(b))
    elif (op == '*'):
        print(int(a) * int(b))
    elif (op == '/'):
        print(int(a) // int(b))
    elif (op == '?'):
        break



Measured memory_bytes: 5592
H, N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

mA = max(A)

INF = 1001001001
DP = [INF for _ in range(H+1)]
DP[0] = 0
for h in range(H):
    for j in range(N):
        nh = min(h+A[j], H)
        DP[nh] = min(DP[nh], DP[h] + B[j])

print(DP[H])

Measured memory_bytes: 41708
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int INF=1e18;

int dist(int a,int b,int c){
    return abs(b-a)+abs(c-b);
}

signed main()
{
    int A,B,Q; 
    cin>>A>>B>>Q;
    vint s(A+2),t(B+2);
    REP(i,A) cin>>s[i+1];
    REP(i,B) cin>>t[i+1];

    s[0]=-INF; s[A+1]=INF;
    t[0]=-INF; t[B+1]=INF;

    while(Q--){
        int x; cin>>x;
        int sR,sL,tR,tL;
        sR=*lower_bound(ALL(s),x);
        sL=*(upper_bound(ALL(s),x)-1);
        tR=*lower_bound(ALL(t),x);
        tL=*(upper_bound(ALL(t),x)-1);

        int ans=INF;
        REP(i,2) REP(j,2){
            int &a=(i==0? sR:sL);
            int &b=(j==0? tR:tL);
            ans=min(ans,dist(x,a,b));
            ans=min(ans,dist(x,b,a));
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 2944
'use strict'

// inputに入力データ全体が入る
function Main(input) {
  let row = input.split('\n');
  // Setで値をとるだけでユニークにできる
  let n = parseInt(row[0], 10);
  let x = row.slice(1,n+1);
  var a = new Set(x);
  console.log('%d',a.size);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int h, w, a, b;
int main(){
	scanf("%d%d%d%d", &h, &w, &a, &b);
	rep(i,h){
		rep(j,w) printf("%d", (j<a)^(i<b));
		puts("");
	}
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<unordered_map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
const ll mod = 1000000007;
const ll OO = (ll)1e18;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(double base, ll power){
	if (power == 1) return base;
	if (power % 2 == 0) return fast_power((base*base), power / 2);
	else return(base*fast_power((base*base), power / 2));
}
//#pragma warning (disable : 4996)
void file()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(2);
}
int next_power(int x)
{
	int y = log(x) / log(2);
	y = (1 << (y + 1));
	return y;
}
vi vec;
int binary__search(int num)
{
	int lo = 0, hi = vec.size() - 1, mid;
	while (lo <= hi)
	{
		mid = (lo + hi) / 2;
		if (vec[mid] == num)
			return mid;
		if (vec[mid] > num)
			hi = mid - 1;
		else
			lo = mid + 1;
	}
	return -1;
}
int main(){

	file();

	int n;
	cin >> n;
	int x, y;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		vec.push_back(x);
	}
	sort(all(vec));
	int ans = 0;
	while (vec.size())
	{
		x = vec.back();
		vec.pop_back();
		y = next_power(x);
		y = binary__search(y - x);
		if (y != -1)
		{
			vec.erase(vec.begin() + y);
			ans++;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(void) {
	int H, R;
	scanf("%d", &H);
	scanf("%d", &R);
	if (H == (-1*R)) {
		printf("0\n");
	}
	else if (H >=0 && 0<=R) {
		printf("1\n");
	}
	else {
		printf("-1\n");
	}
	return 0;
}


Measured memory_bytes: 2692
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const ll INF = 1e18+1;



int H, W;
string s[50];
bool visited[50][50];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};


int main() {
    cin >> H >> W;
    int blacks = 0;
    for (int i = 0; i < H; i++) {
        cin >> s[i];
        for (int j = 0; j < W; j++) {
            if (s[i][j] == '#') blacks++;
        }
    }
    
    
    priority_queue<pair<int,int> ,vector<pair<int,int> >,greater<pair<int,int> >> que;
    que.push(make_pair(1,0)); visited[0][0] = true;
    while (!que.empty()) {
        pair<int,int> p = que.top(); que.pop();
        if (p.second % W == W-1 && p.second / W == H-1) {
            cout << max(0,(H * W - p.first) - blacks) << endl;
            return 0;
        }
        for (int i = 0; i < 4; i++) {
            int x = p.second / W + dx[i];
            int y = p.second % W + dy[i];
            //cout << x << " " << y << " " << endl;
            if (x >= 0 && y >= 0 && x < H && y < W &&
                !visited[x][y] && s[x][y] == '.') {
                
                visited[x][y] = true;
                que.push(make_pair(p.first+1, W*x+y));
            }
        }
    }
    cout << -1 << endl;





}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ');
        long n = long.Parse(input[0]);
        long k = long.Parse(input[1]);
        long abs = 0;
        long margin = 0;
       
        
        margin = n % k;
        abs = Math.Abs(margin - k);
        
        long result =(abs >= margin)? margin: abs;
    
        
        Console.WriteLine(result);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <list>
#include <utility>


using namespace std;


vector<pair<int, int>> vertexes;
bool visited[9];
bool used[29];
int N, M;


int visit(int i, int depth)
{
    // cout << "i: " << i << ", depth: " << depth << endl;
    if (depth == N)
        return 1;

    int ans = 0;
    for (int j = 0; j < M; j++) {
        if (used[j])
            continue;

        pair<int, int> v = vertexes[j];
        if (v.first == i && !visited[v.second]) {
            visited[v.second] = used[j] = true;
            ans += visit(v.second, depth + 1);
            visited[v.second] = used[j] = false;
        } else if (!visited[v.first] && v.second == i) {
            visited[v.first] = used[j] = true;
            ans += visit(v.first, depth + 1);
            visited[v.first] = used[j] = false;
        }
    }
    return ans;
}


int main(void)
{
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        vertexes.push_back(make_pair(a, b));
    }

    for (int i = 0; i <= 9; i++)
        visited[i] = false;
    for (int i = 0; i < M; i++)
        used[i] = false;

    visited[1] = true;

    int ans = visit(1, 1);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 1e5 + 5;
ll n, a[N], b[N], c[N], dp[N][5];
ll solve(int idx, int state){
    if(idx >= n)
        return 0;
    if(dp[idx][state] != -1)
        return dp[idx][state];
    ll mx = 0;
    if(state != 0)
        mx = max(mx, solve(idx + 1, 0) + a[idx]);
    if(state != 1)
        mx = max(mx, solve(idx + 1, 1) + b[idx]);
    if(state != 2)
        mx = max(mx, solve(idx + 1, 2) + c[idx]);
    dp[idx][state] = mx;
    return mx;
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    cout << solve(0, 3);
    return 0;
}

Measured memory_bytes: 14528
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
  int x,n,t;
  cin>>x>>n;
  set<int>s;
  for(int i=0;i<n;i++){
  cin>>t;
    s.insert(t);  
  }
  int ans=1000,m=1000;
  for(int i=-1;i<=101;i++){
      if(s.find(i)==s.end()){
          if(abs(x-i)<ans){
              ans = abs(x-i);
              m=i;
          }
      }
  }
  
  cout<<m;
    return 0;
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n,a[100005];
priority_queue<int> pq;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		pq.push(a[i]);
	}
	while(pq.size()!=1)
	{
		int a=pq.top();
		pq.pop();
		int b=pq.top();
		pq.pop();
		int x=a%b,y=b;
		if(x) pq.push(x);
		pq.push(b);
	}
	cout<<pq.top()<<endl;
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> v;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j <= 5; j++)
        {
            v.push_back(s.substr(i, j));
        }
    }
    sort(ALL(v));
    unique(ALL(v));
    OP(v[k - 1]);
    return 0;
}

Measured memory_bytes: 1660
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
typedef pair<int, int> P;

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

ll h[100010];
ll dp[100010];


int main(void) {
	int n, k;
	cin >> n >> k;
	for (int i = 1;i <= n;i++)cin >> h[i];
	for (int i = 0;i < 100001;i++)dp[i] = 1000000000;
	dp[1] = 0;
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= k;j++) {
			if (n >= i + j) {
				ll margin = abs(h[i + j] - h[i]);
				dp[i + j] = min(dp[i + j], dp[i] + margin);
			}
		}
	}
	cout << dp[n] << endl;
}

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

#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int Maxn  =  2019;
const ld  pi   =  acos(-1);
const int mod =  1000000007;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}


int32_t main(){ IOS
    double n,k;    cin>>n>>k;
    cout << ceil(n/k) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
MOD=10**9+7
N=int(input())
ans=1
prime=set()
prime.add(2)
numofdiv=[0]*(N+2)
for h in range(2,N+1):
    flag=1
    for j in prime:
        if h%j==0:
            flag=0
            break
    if flag==1:
        prime.add(h)

for i in range(2,N+1):
    for p in prime:
        while(i%p==0):
            numofdiv[p]+=1
            i//=p
#print(numofdiv)
for q in range(N+2):
    ans*=numofdiv[q]+1
    ans%=MOD
print(ans)


Measured memory_bytes: 8976
//***Faithless is he that says farewell when the road darkens***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll x,y;
	cin>>x>>y;
	if(y%2!=0){
		cout<<"No";
		return 0;
	}
	ll q=(y/2)-x;
	ll p=x-q;
	if((p>=0)&&(q>=0)) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3632
#include <iostream>

#define MAX 1299710

bool is_prime[MAX];

int main(int argc,char* argv[]){
  
  for(int i = 2; i < MAX; i++){
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;

  for(int i = 2; i <= 1140; i++){
    if(is_prime[i]){
      for(int j = 2*i; j < MAX; j += i){
	is_prime[j] = false;
      } 
    }
  }

  while(true){
    int n;

    std::cin >> n;

    if(n == 0){
      break;
    }

    int low = 0, high = 0;

    for(low = n; low >= 0; low--){
      if(is_prime[low]){
	break;
      }
    }

    for(high = n; high < MAX; high++){
      if(is_prime[high]){
	break;
      }
    }
    
    std::cout << (high - low) << std::endl;
  }

  return 0;
  
}

Measured memory_bytes: 2424
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
s = input().split()

li = set()

for i in s:
    li.add(i)

if len(li) == 3:
    print("Three")
elif len(li) == 4:
    print("Four")
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
	
int main(){
  int i,j;
  int N;
  cin>>N;
  vector<int> vc;
  for(i=0;i<N;i++){
	int x;
	cin>>x;
	vc.push_back(x);
  }
  sort(vc.begin(),vc.end());
  int k=vc[N-1];
  vector<int>::iterator lit=lower_bound(vc.begin(),vc.end(),(k+1)/2);
  int n=lit-vc.begin();
  int l=vc[n];
  int m=vc[n-1];
  int s=vc[n-2];
  if(abs(l*2-k)<=abs(m*2-k)&&l!=k) cout<<k<<" "<<l<<endl;
  else if(m!=k) cout<<k<<" "<<m<<endl;
  else cout<<k<<" "<<s<<endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#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 RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int W,H,N;
	cin>>W>>H>>N;
	int minx=0,miny=0,maxx=W,maxy=H;
	
	int x,y,a;
	REP(i,N){
		cin>>x>>y>>a;
		switch(a){
			case 1:
				chmax(minx,x);
				break;
			case 2:
				chmin(maxx,x);
				break;
			case 3:
				chmax(miny,y);
				break;
			case 4:
				chmin(maxy,y);
				break;
		}
	}
	cout<<(max(0,maxx-minx))*(max(0,maxy-miny))<<endl;

	return 0; 
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) scanf("%d", &a[i]);
    int ans = 0, x = 0;
    REP(i,n){
        if (x == 0) x = 2;
        else if (x == 2){
            if (a[i] > a[i-1]) x = 1;
            if (a[i] < a[i-1]) x = -1;
        }else if (x == 1){
            if (a[i] < a[i-1]){
                ans++;
                x = 2;
            }
        }else if (x == -1){
            if (a[i] > a[i-1]){
                ans++;
                x = 2;
            }
        }
        // cout << ans << " " << x << endl;
    }
    ans++;
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N, A, B;
string S;

signed main()
{
    cin >> N >> A >> B >> S;
    int passed = 0;
    int only_b = 1;
    REP(i, N) {
        if(S[i] == 'a') {
            if(passed < A + B) {
                printf("Yes\n");
                passed++;
            }
            else {
                printf("No\n");
            }
        }
        else if(S[i] == 'b') {
            if(passed < A + B && only_b <= B) {
                printf("Yes\n");
                passed++;
                only_b++;
            }
            else {
                printf("No\n");
            }
        }
        else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

    string s;
    cin >> s;
    long long int n = s.size();

    vector< long long int > v;
    v.push_back( 0 );

    for ( long long int i = 0; i < n; i++ ) {
        if ( s[i] == '<' ) {
            v.push_back( v[i] + 1 );
        } else {
            v.push_back( 0 );
        }
    }

    for ( long long int i = n - 1; i >= 0; i-- ) {
        if ( s[i] == '<' ) continue;
        v[i] = max( v[i+1] + 1, v[i] );
    }

    long long int ans = 0;
    for ( long long int i = 0; i <= n; i++ ) {
        ans += v[i];
    }
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<i<<endl;
#define fi first
#define sc second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
//#define P pair<int,int>
using namespace std;
const int INF=1e17+5;
const int maxn=2e5+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

int32_t main()
{
    IOS
    cin>>n>>m;
    cout<<n/(2*m+1)+(n%(2*m+1)!=0);
    return 0;
}


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

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

void Main(){
  int n;
  cin>>n;
  int count[3]={0,0,0};//0:その他,1:2,2:4
  rep(i,0,n){
    int l;
    cin>>l;
    if((l&3)==0){
      count[2]++;
    }else if((l&3)==2){
      count[1]++;
    }else{
      count[0]++;
    }
  }
  
  (count[1]==0 && count[0]<= count[2]+1) || (count[1]!=0 && count[0]<=count[2]) ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

int main(){
  cin.tie(nullptr);                  // 標準入出力高速化
  ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fast_power(ll, ll, ll);
ll slow_power(ll, ll, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

const int N = 1e5 + 7;
int pos[N];
vector<int> G[N];
int vis[N];
int cnt;

void dfs(int v)
{
    vis[v] = cnt;
    for (int s : G[v])
        if (!vis[s])
            dfs(s);
}

int main()
{
    int n = si();
    int m = si();

    for (int i = 1; i <= n; ++i)
        pos[si()] = i;
    
    for (int i = 0; i < m; ++i) {
        int x = si(), y = si();

        G[x].pb(y);
        G[y].pb(x);
    }

    for (int i = 1; i <= n; ++i)
        if (!vis[i]) {
            ++cnt;
            dfs(i);
        }

    int res = 0;

    for (int i = 1; i <= n; ++i)
        if (vis[i] == vis[pos[i]])
            ++res;

    pi(res);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fast_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slow_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

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


Measured memory_bytes: 8576
A,B,K=map(int,input().split())
count=0
Len=min(A,B)
kari=[]
for i in range(Len):
    I=i+1
    if A%I==0 and B%I==0:
        kari.append(I)
kari.sort(reverse=True)
print(kari[K-1])

Measured memory_bytes: 3060
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL n, m, k, sum = 0;
	cin >> n >> m >> k;
	vector<LL> a(n), b(m);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	int ai = n - 1, bi = 0, c = n, ans = 0;
	while (sum > k && ai >= 0) {
		sum -= a[ai];
		--ai;
		--c;
	}
	while (true) {
		while (bi < m && sum + b[bi] <= k) {
			sum += b[bi];
			++bi;
			++c;
		}
		ans = max(ans, c);
		if (ai < 0) {
			break;
		}
		sum -= a[ai];
		--ai;
		--c;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  
  int N;
  string S,T;
  cin >> N;
  cin >> S >> T;
  string c = "";
  for (int i=0; i < N; i++) {
    c += S.at(i);
    c += T.at(i);
  }
  cout << c << endl;
}

Measured memory_bytes: 256