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

using namespace std;

int main(){
  
  //freopen("input.txt","r",stdin);
  //freopen("outputu.txt","w",stdout);
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)cout<<"x";
  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> a(N), indeg(N), h(N);
	for(int i = 0; i < N; ++i){
		cin >> a[i];
		--a[i];
		indeg[a[i]]++;
	}
	indeg[a[0]]--;
	queue<int> Q;
	for(int i = 0; i < N; ++i){
		if(indeg[i] == 0)
			Q.push(i);
	}
	int res = 0;
	while(!Q.empty()){
		int v = Q.front(); Q.pop();
		if(a[v] == 0) continue;
		if(h[v] == K-1){
			++res;
			h[v] = -1;
		}
		h[a[v]] = max(h[a[v]], h[v] + 1);
		indeg[a[v]]--;
		if(indeg[a[v]] == 0){
			Q.push(a[v]);
		}
	}
	if(a[0] != 0)
		++res;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll a, b;
	cin >> a >> b;
	vs v(a);
	REP(i, a) cin >> v[i];
	string s;
	REP(i, b + 2) s += "#";
	cout << s << endl;
	REP(i, a) cout << '#' << v[i] << '#' << endl;
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	string S;
	cin >> S;

	bool res = true;
	for(int i = 0; i < 3; i++){
		if(S[i] == S[i+1]) res = false;
	}

	cout << (res ? "Good" : "Bad") << '\n';

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

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

        int N = scanner.nextInt();

        int res = N;
        for (int i = 0; i <= N; i++) {
            int cc = 0;
            int t = i;
            while (t > 0) {
                cc += t % 6;
                t /= 6;
            }
            t = N - i;
            while (t > 0) {
                cc += t % 9;
                t /= 9;
            }
            if (res > cc) {
                res = cc;
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

double fastpow(double a, ll n){  // a^n
  double res = 1;
  while(n > 0){
    if(n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}

int K;
int f(int a, int c){
  if(a >= K) return c;
  return f(a*2, ++c);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N >> K;
  double ans = 0;
  for(int i = 1; i <= N; i++){
    int cnt = f(i, 0);
    ans += fastpow(0.5, cnt) / N;
  }
  cout << fixed << setprecision(12) << ans << endl;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    ll H;
    cin >> H;
    ll res = 0;
    ll b = 1;
    while (H) {
        H /= 2;
        res += b;
        b *= 2;    
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

class Card {
 private:
    char toMark(int n) {
        char m;
        switch ((n-1)/13) {
        case 0:
            m = 'S';
            break;
        case 1:
            m = 'H';
            break;
        case 2:
            m = 'C';
            break;
        case 3:
            m = 'D';
            break;
        }
        return m;
    }

    int weight(char m) const {
        int w;
        switch (m) {
        case 'S':
            w = 13 * 0;
            break;
        case 'H':
            w = 13 * 1;
            break;
        case 'C':
            w = 13 * 2;
            break;
        case 'D':
            w = 13 * 3;
            break;
        }
        return w;
    }

 public:
    char mark;
    int number;

    Card() {}

    explicit Card(int num) {
        mark = toMark(num);
        number = num - weight(mark);
    }

    int toNumber() const {
        return weight(mark) + number;
    }

    bool operator == (const Card c) {
        return toNumber() == c.toNumber();
    }

    bool operator < (const Card c) const {
        return toNumber() < c.toNumber();
    }
};

int main() {
    int n;
    deque<Card> cards;
    cin >> n;

    Card c;
    for (int i = 0; i < n; i++) {
        cin >> c.mark >> c.number;
        cards.push_back(c);
        }

    sort(cards.begin(), cards.end());

    for (int i = 1; i <= 52; i++) {
        c = Card(i);
        if (cards.front() == c) {
            cards.pop_front();
        } else {
            cout << c.mark << ' ' << c.number << '\n';
        }
    }
    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>
#include<queue>

typedef long long ll;
#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define pqi_ priority_queue<int, vector<int>, greater<int>>
#define pqll_ priority_queue<ll, vector<ll>, greater<ll>>

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

  cout << ceil(N/2) / N << endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())

s = [int(input()) for i in range(n)]

sum_s = sum(s)
not_list = [num for num in s if num % 10 != 0]


if sum_s % 10 == 0:
    if len(not_list) == 0:
        sum_s = 0
    else:
        sum_s -= sorted(not_list)[0]

print(sum_s)

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

#define MAX(a , b) (a > b? a : b)
#define MIN(a , b) (a < b? a : b)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const double pi = 2.0*acos(0.0);

bool status[1000009];
int N = 1000009;
vector<int> prime;

void seive()
{
    int m = 3;
    int n = 5;
    prime.pb(1);
    prime.pb(2);
    for (int i=3;i<=N;i++)
    {
        if (i%m==0 || i%n==0)
        {
            status[i] = true;
        }
    }

    for (int i=3;i<=N;i++)
    {
        if (status[i] == false)
        {
            prime.pb(i);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    seive();
    int n;
    cin >> n;

    int k = upper_bound(all(prime),n) - prime.begin();
    ll sum = 0;
    for (int i=0;i<k;i++)
    {
        sum = sum + prime[i];
    }
    cout << sum << endl;

    return 0;
}


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

using namespace std;
using ll = long long;


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

int lcm(int m, int n ) {
    if (0 == m || 0 == n)
        return 0;
    return (m / gcd(m, n)) * n; // lcm = m * n / gcd(m,n)
}

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

    int n;
    cin >> n;
    int res;
    cin >> res;
    while (--n) {
        int a;
        cin >> a;
        res = lcm(res, a);
    }
    cout << res << '\n';

    return 0;
}



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

int main(){
	int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
	int x,y;
	cin>>x>>y;
	(a[x]==a[y]) ? cout<<"Yes"<<endl : cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void print_day (int d){
	int i = d % 7;
	if (i==0) printf ("Monday\n");
	else if (i==1) printf ("Tuesday\n");
	else if (i==2) printf ("Wednesday\n");
	else if (i==3) printf ("Thursday\n");
	else if (i==4) printf ("Friday\n");
	else if (i==5) printf ("Saturday\n");
	else printf ("Sunday\n");
}

int main(void) {
	const int DAY_JUN_1ST = 3;
	const int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int i, m, d, date;
	while (scanf ("%d %d", &m, &d)){
		if (m==0) break;
		date = DAY_JUN_1ST;
		for (i=0; i<m-1; i++) date += month[i];
		date += (d-1);
		print_day (date);
	}
	return 0;
}

Measured memory_bytes: 0
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]
u=set()
for i in range(N):
    u.add(s[i])
for i in range(M):
    u.add(t[i])
v=list(u)
w=[0 for i in range(len(v))]
for i in range(N):
    for j in range(len(w)):
        if s[i]==v[j]:
            w[j]+=1
for i in range(M):
    for j in range(len(w)):
        if t[i]==v[j]:
            w[j]-=1
print(max([0,max(w)]))


Measured memory_bytes: 3188
L = int(input())

N = L.bit_length()

E = []
for i in range(1, N):
    E.append((i, i + 1, 0))
    E.append((i, i + 1, 2 ** (i - 1)))

s = 2 ** (N - 1)
for i in reversed(range(N - 1)):
    if (L >> i) & 1:
        E.append((i + 1, N, s))
        s += 2 ** i

print(N, len(E))
for a, b, c in E:
    print(a, b, c)


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

N =int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
ABS = sorted(AB,key = lambda x:x[1])
now = 0
for i in range(N):
    now += ABS[i][0]
    if now > ABS[i][1]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 48376
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;

ll n,m,k,x,y,l,r;
string s,t;
char c;

int main() {
    fast;
    cout << "? 10000000000" << endl;
    cin >> c;

    if (c == 'Y') {
        x = 2;
        while (true) {
            cout << "? " << x << endl;
            cin >> c;
            if (c == 'Y') {
                cout << "! " << x / 2 << endl;
                return 0;
            }
            x *= 10;
        }
    }

    x = 1;
    for1(i, 10) {
        cout << "? " << x << endl;
        cin >> c;
        if (c == 'Y') x *= 10;
    }

    l = x, r = x * 10, n = x * 10;
    while (l <= r) {
        m = l + r >> 1;
        cout << "? " << m << endl;
        cin >> c;
        if (c == 'Y') {
            r = m - 1;
            n = min(n, m);
        } else {
            l = m + 1;
        }
    }

    cout << "! " << n / 10 << endl;
    return 0;
}

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

int main() {
	char str[1001];
	scanf("%s", str);
	int n, s, w, e;
	n = 0;
	s = 0;
	w = 0;
	e = 0;
	for(int i = 0; i < (int)strlen(str); i++) {
		if(str[i] == 'N') {
			n++;
		}else if(str[i] == 'S') {
			s++;
		}else if(str[i] == 'W') {
			w++;
		}else if(str[i] == 'E') {
			e++;
		}
	}
	bool ans = true;
	if(n > 0 && s == 0) {
		ans = false;
	}else if(s > 0 && n == 0) {
		ans = false;
	}else if(w > 0 && e == 0) {
		ans = false;
	}else if(e > 0 && w == 0) {
		ans = false;
	}
	if(ans) {
		printf("%s\n", "Yes");
	}else {
		printf("%s\n", "No");
	}
}

Measured memory_bytes: 256
//DEEPANSHU RAWAT
//BTECH/10530/18
//INFORMATION TECHNOLOGY

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
 */
/*************************************************************************************************************************/
#include<bits/stdc++.h>
#define ull unsigned long long
#define lld long long int
#define infi LLONG_MAX
#define ninfi LLONG_MIN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define e endl
#define mod 1000000007
#define modd 20000
using namespace std ;
/**************************************************************************************************************************/

/**************************************************************************************************************************/
int main()
    {
        ios_base::sync_with_stdio(false);//FOR FAST INPUT OUTPUT METHOD
        cin.tie(NULL);
        cout.tie(NULL);
    
        string s;
        cin>>s;
        lld i,j;
        lld count=0,count1=0,count2=0;
        for(i=0;i<=j;i++)
        {
            j=s.length()-i-1;
            {
                if(s[i]!=s[j])
                {
                    count++;
                    break;
                }
            }

        }
          j=s.length()-1;
        for(i=0;i<=j;i++)
        {
            j=s.length()/2 -i-1;
            if(s[i]!=s[j])
            {
                count1++;
                break;
            }

        }

        for(i=s.length()/2 + 1;i<=j;i++)
        {
            j=s.length()-i-1;
            if(s[i]!=s[j])
            {
                count2++;
                break;
            }

        }
        if(count>0||count1>0||count2>0)
        {
            cout<<"No"<<e;
        }else{
            cout<<"Yes"<<e;
        }
}
       
/**************************************************************************************************************************/                            


Measured memory_bytes: 256
import sys

def main():
    _input = sys.stdin.readline

    N, W = map(int, _input().split())
    wv = [list(map(int, _input().split())) for _ in range(N)]

    wv.sort()

    DP = [-1] * (W+1)
    DP[0] = 0

    sum_w = 0
    for w, v in wv:
        sum_w += w
        for j in range(min(W, sum_w), w-1, -1):
            if DP[j-w] == -1:
                continue
            if DP[j] < DP[j-w] + v:
                DP[j] = DP[j-w] + v
    print(max(DP))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
#pragma GCC optimize ("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, x, ans = 0;
	cin >> a >> b >> c >> x;
	x /= 50;
	for (int i = 0; i <= a; i++)
		for (int j = 0; j <= b; j++)
			for (int k = 0; k <= c; k++)
				if (10 * i + 2 * j + k == x)
					ans++;
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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


int main() {
    int l,r,d;
    cin >> l >> r >> d;

    int ans = 0;
    for(int i = l ; i <= r ; i++) {
        if(i % d == 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<limits>
#include<algorithm>

using sll = signed long long;

int main() {

	sll n;
	std::cin >> n;

	std::vector<sll> v;
	v.resize(n);

	sll max_{};

	for (auto&e : v) {
		std::cin >> e;
		max_ += e;
	}
//	max_*= -1;

	sll t{}, ans{std::numeric_limits<sll>::max()};
	for (int i{0}; i < n-1; ++i) {

		t += v[i];
		max_ -= v[i];
//		std::cout << t << " " << max_ << "\n";
		ans = std::min(ans, std::abs(max_ - t) );
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]

ab_sort = sorted(ab, key=lambda x: x[0])
ans = 0
num = 0
# a=money b=num
for a, b in ab_sort:
    if num + b >= M:
        ans += (M - num) * a
        break
    else:
        num += b
        ans += a * b
print(ans)

Measured memory_bytes: 18892
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
    int n, h[21], max = -1, ans = 0;

    if(scanf("%d", &n) == 1);

    for(int i = 0; i < n; i++) {
        if(scanf("%d", &h[i]) == 1);
        if(h[i] >= max) {
            max = h[i];
            ans++;
        }
    }
    

      printf("%d", ans);

      return 0;
}

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

int main(){
	int l, r, d;
	int ans = 0;
	cin >> l >> r >> d;
	for (int i = l; i <= r; i++){
		if (i%d == 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main()
{
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int n[3];
  n[0] = 0, n[1] = 0, n[2] = 0;

  int now = 0;
  int next;

  while (1) {
    if (s[now].size() == n[now]) {
      char ans = 'A' + now;
      cout << ans << endl;
      break;
    }
    next = s[now][n[now]];
    char nextchar = next;
    n[now]++;
    now = next - 'a';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int, int>;
// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   Sieve s(200000);
   int x; cin >> x;
   while (!s.isPrime(x))
      x++;
   cout << x << endl;
}

Measured memory_bytes: 4264
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
S = input()

r, l = 0, 0

for i in range(N):
    si = S[i]
    if si == "(":
        l += 1
    elif si == ")":
        if l > 0:
            l -= 1
        else:
            r += 1

print(r*"(" + S + ")"*l)

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input();
  string s = input<string>();

  int diff = 0;
  range(i, 0, N) {
    if (s[i] == 'R') diff++;
    else diff--;
  }

  cout << (diff > 0 ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

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

	ll p[4];
	p[0] = (ll)a * (ll)c;
	p[1] = (ll)a * (ll)d;
	p[2] = (ll)b * (ll)c;
	p[3] = (ll)b * (ll)d;

	printf("%lld", max({ p[0],p[1],p[2],p[3] }));

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

using intbool = pair<int, bool>;

signed main(){
    int N; cin >> N;
    vector<vector<intbool>> testimony(N,vector<intbool>(0));
    rep(i,N){
        int A; cin >> A;
        rep(j,A){
            int x, y; cin >> x >> y;
            testimony[--x].push_back(intbool(i,y==0));
        }
    }
    
    bitset<15> is_unkind = 0;
    int max_honests = 0;
    rep(i,1<<N){
        is_unkind = i;
        bool has_contradiction = false;
        rep(j,N){
            for(auto t : testimony[j]){
                int speaker = t.first;
                if(is_unkind[speaker]) continue;
                
                bool remark = t.second;
                bool truth = is_unkind[j];
                if(remark != truth){
                    has_contradiction = true;
                    goto BREAK_LABEL;
                }
            }
        }
        BREAK_LABEL:
        if(has_contradiction) continue;
        max_honests = max(max_honests,N-(int)is_unkind.count());
    }
    cout << max_honests << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>

using namespace std;

int main(int argc, const char *argv[]) {
  int H, N;

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

  int sum = accumulate(A.begin(), A.end(), 0);
  if(sum < H){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

typedef long long int LLI;
typedef pair<int, bool> Data;
typedef pair<LLI, Data> Event;

int W;
int H;
LLI ls[2];
LLI cnt[2];
LLI ps[114514];
LLI qs[114514];
vector<Event> es;

int main() {
  scanf("%d%d", &H, &W);
  ls[0] = H;
  ls[1] = W;

  for (int i=0; i<H; i++) {
    scanf("%lld", &ps[i]);
    es.emplace_back(Event(ps[i], Data(i, 0)));
  }

  for (int i=0; i<W; i++) {
    scanf("%lld", &qs[i]);
    es.emplace_back(Event(qs[i], Data(i, 1)));
  }

  sort(es.begin(), es.end());

  LLI ans = 0;
  for (auto &e : es) {
    LLI cost = e.first;
    int idx = e.second.first;
    int k = e.second.second;

    ans += cost * (ls[1^k]+1 - cnt[1^k]);
    cnt[k]++;
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 7408
var main = function(s) {
  s=s.split('\n');
  var A = s[0];
  var B = A.split(' ');
	var	N = parseInt(B[0]);
    var K = parseInt(B[1]);
    N = N-K;
  	var count = 1;
  	while(0<N){
      N = N-(K-1);
      count++;
    }
  console.log(count);
    return 0; 
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 8012
s = input()

if s == "SUN":
  print("7")
elif s == "MON":
  print("6")
elif s == "TUE":
  print("5")
elif s == "WED":
  print("4")
elif s == "THU":
  print("3")
elif s == "FRI":
  print("2")
else:
  print("1")

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

int main() {
    int n;
    string str;
    string copy;
    cin >> str;
    copy = str;
    n = str.length() - 1;//+を入れることができる場所の数
    long long  total = 0LL;
    for (int bit = 0; bit < (1 << n); ++bit)
    {
       
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) { 
                S.push_back(i+1);
            }
        }

       
        for (int i = (int)S.size()-1; i>=0; --i) {
            if (i == (int)S.size() - 1)
                total += stoll(str.substr(S[i]));
            else total += stoll(str.substr(S[i], S[i+1]-S[i]));
            if (i == 0) {
                total += stoll(str.erase(S[i]));
                str = copy;
             }
            
               
            
        }
        if ((int)S.size() == 0) total += stoll(str);
    }
    cout << total ;
    
    

}

Measured memory_bytes: 3588
# 
import sys

from sys import stdin
input = lambda: stdin.readline().rstrip()


H, W, K = map(int,input().split())

c = []

for i in range(H):
    c.append(list(input()))

answer = 0
def count(h_target, w_target):
    cnt = 0
    for h in range(H):
        for w in range(W):
            if c[h][w] == '#' and h not in h_target and w not in w_target:
                cnt+=1
    if cnt == K:
        return 1
    else:
        return 0

h_format = '0' + str(H) + 'b'
w_format = '0' + str(W) + 'b'
for h in range(2**(H)):
    for w in range(2**(W)):
        #print("----1------")
        #print(list(format(h,h_format)))
        #print(list(format(w,w_format)))
        h_target = [n for n, v in enumerate(list(format(h,h_format))) if v == '1']
        w_target = [n for n, v in enumerate(list(format(w,w_format))) if v == '1']
        #print("----2-----")
        #print(h_target)
        #print(w_target)
        answer += count(h_target,w_target)

print(answer)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    map<ll, ll> mp;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        ll d;
        cin >> d;
        mp[d]++;
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++) {
        ll t;
        cin >> t;
        if(mp[t]) {
            mp[t]--;
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))


signed main(){ INIT;
    VAR(string, s);
    s[3] = '8';
    OUTL(s);
RET;}


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


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


	int n, sum = 0;
	cin >> n;
	

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += __gcd(__gcd(i, j), k);
			}
		}
	}
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3612
fun main(args: Array<String>) {
  println(questionB(readLine()!!.toInt()))
}
 
fun questionB(n: Int): String {
    if (n !in 1..100) return "No"
 
    for (i in 1..9) {
        for (j in 1..9) {
            if (n == i * j) return "Yes"
        }
    }
 
    return "No"
}

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

#define int long long

int Len[55]; // Len[level]: levelバーガー全体の長さ
int Pat[55]; // Pat[level]: levelバーガーのパティ数

// levelとlayerを投げると、パティ数が返ってくる関数
int rec(int level, int layer) {
  if (level == 0) {
    return 1;
  }

  if (layer == 1) { // 範囲1
    return 0;
  } else if (layer <= Len[level-1] + 1) { // 範囲2
    return rec(level-1, layer-1);
  } else if (layer <= Len[level-1] + 2) { // 範囲3
    return Pat[level-1] + 1;
  } else if (layer <= 2 * Len[level-1] + 2) { // 範囲4
    return Pat[level-1] + 1 + rec(level-1, layer - Len[level-1] - 2);
  } else { // 範囲5
    return 2 * Pat[level-1] + 1;
  }
}

signed main() {
  // 入力
  int N, X;
  cin >> N >> X;

  // バーガーの長さとパティの数を前計算
  Len[0] = Pat[0] = 1;
  for (int i = 1; i <= N; i++) {
    Len[i] = Len[i-1] * 2 + 3;
    Pat[i] = Pat[i-1] * 2 + 1;
  }

  // 出力
  cout << rec(N, X) << endl;

   return 0;
}


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

int n,k,a[maxn],ans=0;
string s;
int main()
{
	cin>>n>>k;
	cin>>s;
	for(int i=1;i<=n;++i)
	{
		if(s[i-1]=='L') a[i]=1;
		else a[i]=0;
	}
	a[0]=-1,a[n+1]=-1;
	for(int i=1;i<=n;++i)
	{
		if(a[i]==1 && a[i-1]==1) ans++;
		else if(a[i]==0 && a[i+1]==0) ans++;
	}
	cout<<min(ans+2*k,n-1);
	return 0;
} 

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d,e,f,g;
  cin>>a>>b>>c>>d>>e;
  if((a+b)<c*2) cout<<d*a+b*e;
  else{
    f=c*(max(e,d)*2);
    g=c*(min(e,d)*2);
    if(e<d) g+=(a*(d-e));
    else g+=(b*(e-d));
    if(f<g) cout<<f;
    else cout<<g;
  }
  cout<<"\n";
}

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


int main()
{
  ll n, m;
  cin >> n >> m;
  multiset<ll> ms;
  
  for (ll i = 0; i < n; ++i) {
    ll j;
    cin >> j;
    ms.insert(j);
  }

  for (ll i = 0; i < m; ++i) {
    auto itr = ms.end();
    --itr;
    auto val = *itr;
    ms.erase(itr);
    ms.insert(val >> 1);
  }
  ll ans = 0;
  for (auto itr = ms.begin(); itr != ms.end(); ++itr) {
    ans += *itr;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
int mod=1e9+7;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
void pro(LL *a,LL *b){
    LL c[4]={0,0,0,0};
    for(int i = 0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                c[i*2+j]+=a[i*2+k]*b[k*2+j];
                c[i*2+j]%=mod;
            }
        }
    }
    for(int i = 0;i<4;i++)
        a[i]=c[i];
}
LL f_pow(LL *a,LL b){
    LL res[4]={1,0,0,1},temp[4]={a[0],a[1],a[2],a[3]};
    while(b){
        if(b&1)pro(res,temp);
        pro(temp,temp);
        b>>=1;
    }
    return (res[0]+res[1])%mod;
}
int main(){
    int h,w;
    LL k;
    scanf("%d %d %lld",&h,&w,&k);
    if(k==0||k==1){
        printf("1\n");
        return 0;
    }
    char c[1005][1005];
    int ver=0,hor=0;
    int tot=0;
    for(int i=  0;i<h;i++){
        scanf("%s",c[i]);
        for(int j =0;j<w;j++){
            if(c[i][j]=='#')tot++;
        }
    }
    for(int i = 0;i<h;i++){
        if(c[i][0]==c[i][w-1]&&c[i][0]=='#'){
            ver++;
        }
    }
    for(int i = 0;i<w;i++){
        if(c[0][i]==c[h-1][i]&&c[0][i]=='#'){
            hor++;
        }
    }
    if(ver&&hor){
        printf("1\n");
    }
    else if(!ver&&!hor){
        printf("%lld\n",f_pow(tot,k-1));
    }
    else{
        if(ver){
            LL cnt=0;
            for(int i = 0;i<h;i++){
                for(int j=0;j<w-1;j++){
                    if(c[i][j]==c[i][j+1]&&c[i][j]=='#')cnt++;
                }
            }
            LL a[4]={tot,-cnt+mod,0,ver};
            printf("%lld\n",f_pow(a,k-1));
        }
        else{
            LL cnt=0;
            for(int i = 0;i<h-1;i++){
                for(int j=0;j<w;j++){
                    if(c[i][j]==c[i+1][j]&&c[i][j]=='#')cnt++;
                }
            }
            LL a[4]={tot,-cnt+mod,0,hor};
            printf("%lld\n",f_pow(a,k-1));
        }
    }
}


Measured memory_bytes: 1280
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
int K;
int H[300];
long long dp[301][301];
long long nx[301][301];
int main(){
  int i, m;
  long long res = 4611686016279904256LL;
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  if(N==K){
    wt_L(0);
    wt_L('\n');
    return 0;
  }
  for(i=(0);i<(K+1);i++){
    int j;
    for(j=(0);j<(N+1);j++){
      dp[i][j] = 4611686016279904256LL;
    }
  }
  for(m=(0);m<(N);m++){
    for(i=(0);i<(K+1);i++){
      int j;
      for(j=(0);j<(N+1);j++){
        nx[i][j] = 4611686016279904256LL;
      }
    }
    if(m<=K){
      nx[m][m] = H[m];
    }
    for(i=(0);i<(K+1);i++){
      int j;
      for(j=(0);j<(m);j++){
        chmin(nx[i][m], dp[i][j] +max_L((long long)H[m] - H[j], 0));
      }
    }
    for(i=(0);i<(K);i++){
      int j;
      for(j=(0);j<(m);j++){
        chmin(nx[i+1][j], dp[i][j]);
      }
    }
    for(i=(0);i<(K+1);i++){
      int j;
      for(j=(0);j<(N+1);j++){
        dp[i][j] = nx[i][j];
      }
    }
  }
  for(i=(0);i<(K+1);i++){
    int j;
    for(j=(0);j<(N+1);j++){
      chmin(res, dp[i][j]);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191111-2

// --- original code ---
// int N, K, H[300];
// ll dp[301][301], nx[301][301];
// 
// {
//   ll res = ll_inf;
//   rd(N,K,H(N));
//   if(N==K) wt(0), return 0;
//   rep(i,K+1) rep(j,N+1) dp[i][j] = ll_inf;
//   rep(m,N){
//     rep(i,K+1) rep(j,N+1) nx[i][j] = ll_inf;
//     if(m<=K) nx[m][m] = H[m];
//     rep(i,K+1) rep(j,m) nx[i][m] <?= dp[i][j] + max((ll)H[m] - H[j], 0);
//     rep(i,K) rep(j,m) nx[i+1][j] <?= dp[i][j];
//     rep(i,K+1) rep(j,N+1) dp[i][j] = nx[i][j];
//   }
//   rep(i,K+1) rep(j,N+1) res <?= dp[i][j];
//   wt(res);
// }


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


int n, k;
int w[123456];

bool func(int P){
	int truck = 1, weight = 0;
	rep(i, n){
		if (w[i] > P) return false;

		if (weight + w[i] <= P) weight += w[i];
		else {
			weight = w[i]; truck++;
		}
	}
	if (truck <= k) return true;
	else return false;
}

signed main(){


	cin >> n >> k;
	rep(i, n) cin >> w[i];

	int ng = 0, ok = 1e9;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

//		cerr << mid << " " << func(mid) << endl;

		if (func(mid)) ok = mid;
		else ng = mid;
	}

	cout << ok << endl;
	return 0;
}



Measured memory_bytes: 3864
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		sc.close();

		int a = 18;
		for (int i = 1; i <= 18; i++) {
			if (1 << i > l) {
				a = i - 1;
				break;
			}
		}

		int n = a + 2;
		List<Obj> list = new ArrayList<>();
		for (int i = 0; i < a; i++) {
			list.add(new Obj(n - i - 1, n - i, 0));
			list.add(new Obj(n - i - 1, n - i, 1 << i));
		}
		int a2 = 1 << a;
		int rem = l;
		int now = 0;
		int to = 2;
		while (rem > 0) {
			if (rem >= a2) {
				list.add(new Obj(1, to, now));
				now += a2;
				rem -= a2;
			} else {
				to++;
				a2 /= 2;
			}
		}

		System.out.println(n + " " + list.size());
		for (Obj o : list) {
			System.out.println(o.u + " " + o.v + " " + o.w);
		}
	}

	static class Obj {
		int u, v, w;

		public Obj(int u, int v, int w) {
			this.u = u;
			this.v = v;
			this.w = w;
		}
	}
}


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

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define _shv(v) for (auto _t1 : v) cerr << _t1 << " "; cerr << endl;
#define dbg(x) cerr << #x << ": " << (x) << endl;
#define dbgv(v) cerr << #v << ": "; _shv(v);
#define dbgm(m) cerr << #m << ":" << endl; for (auto _t2 : m) { _shv(_t2); }

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

template<typename T> inline void prt(T x) { cout << x << endl; }
template<typename T> inline int sz(T& x) { return x.size(); }
template<typename T> inline ll pow2(T n) { return 1ll << n; }
template<typename T, typename U> inline int bit(T x, U n) { return x >> n & 1; }
template<typename T, typename U>
inline bool cmax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool cmin(T& m, U x) { if (m > x) { m = x; return true; } return false; }


int main() {
    int n, l;
    cin >> n >> l;
    vi v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];

    vvi dp(n + 1, vi(l + 1, 0));
    rep(i, n) {
        repp(j, 0, l) {
            if (j < w[i]) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }
    prt(dp[n][l]);

    return 0;
}



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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
  static_assert(I >= 1);
  static_assert(N >= 1);
  if constexpr (I == 1){
    return std::vector<T>(a[N - I], value);
  }else{
    return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
  }
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}


namespace haar_lib {}

namespace solver {
  using namespace haar_lib;

  constexpr int m1000000007 = 1000000007;
  constexpr int m998244353 = 998244353;

  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  void solve(){
    int N; std::cin >> N;

    std::vector<int64_t> count(N + 1);

    for(int A = 1; A <= N; ++A){
      for(int X = A; X <= N; X += A){
        count[X] += 1;
      }
    }

    int64_t ans = 0;

    for(int i = 1; i <= N - 1; ++i){
      ans += count[i];
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n;
    sci(n);
    vll pref(n+1);
    pref[0] = 0;
    rep(i,0,n-1){
        int x;
        sci(x);
        pref[i+1] = pref[i] + x;
    }
    vvll dp(n+1,vll(n+1,INF));//dp[l][r] = total minimum cost of combining [l,r] into 1 element.
    rrep(l,n,1){
        rep(r,l,n){
            if(l == r){
                dp[l][r] = 0;
            }
            else{
                rep(i,l,r-1){
                    dp[l][r] = min(dp[l][r],dp[l][i]+dp[i+1][r] + pref[r]-pref[l-1]);
                }
            }
        }
    }
    cout << dp[1][n] << endl;
}

Measured memory_bytes: 4948