akhauriyash/Code-Regression huggingface dataset:
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n;
	int sum = 0;

	fo(i,1,n+1)
	{
		if( i%3 == 0 or  i%5 == 0 ) continue;
		sum += i;
	}

	cout << sum << endl;
}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 8328
import java.util.*;
import java.io.*;

public class Main {
    static ArrayList<Integer>[] graph;
    static int[] res;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        graph = new ArrayList[n];
        for(int i =0; i < n; i++) {
            graph[i] = new ArrayList<>();
        }
        for(int i= 0; i < n-1; i++) {
            int a = scanner.nextInt()-1, b = scanner.nextInt()-1;
            graph[a].add(b); graph[b].add(a);
        }
        res = new int[n];
        for(int i = 0; i < q; i++) {
            res[scanner.nextInt()-1]+= scanner.nextInt();
        }
        dfs(0,0);
        for(int i = 0; i < n; i++) {
            if (i > 0) out.print(" ");
            out.print(res[i]);
        }
        out.println();
        out.flush();
    }
    static void dfs(int v, int p) {
        for(int edge: graph[v]) {
            if (edge == p) continue;
            res[edge] += res[v];
            dfs(edge, v);
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 134332
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i, j in zip(range(N - 1), range(1, N)):
    Asum = A[i] + A[j]
    if Asum <= K:
        continue
    eat = Asum - K
    d = min(eat, A[j])
    A[j] -= d
    eat -= d
    ans += d
    d = min(eat, A[i])
    A[i] -= d
    ans += d

print(ans)

Measured memory_bytes: 20068
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX ((int)pow(10,5) + 10)

vector<ll> g[MAX];
ll		  dp[MAX][2]; // 0 - white, 1- black

void dfs(ll hd, ll pr){
	dp[hd][0] = 1, dp[hd][1] = 1;
	for(auto hr: g[hd]){
		if(hr == pr)
			continue;
		dfs(hr, hd);
		dp[hd][0] *= (dp[hr][0] + dp[hr][1]);
		dp[hd][0] %= modulo;
		dp[hd][1] *= (dp[hr][0]);
		dp[hd][1] %= modulo;
	}
//	cout<<"at "<<hd<<" the answer "<<dp[hd][0]<<" "<<dp[hd][1]<<endl;
}

void deal(){
	ll n;
	cin>>n;
	fori(n-1){
		ll a, b;
		cin>>a>>b; --a, --b;
		g[a].pb(b), g[b].pb(a);
	}
	dfs(0,-1);
	cout<<(dp[0][0]+dp[0][1])%modulo;
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 12800
N, M = map(int, input().split())
Z = [list(map(int,input().split())) for i in range(M)]
kosuu = [1 for _ in range(N)]
red = [False for _ in range(N)]
red[0] = True

for i in range(M):
  x = Z[i][0] - 1
  y = Z[i][1] - 1
  if (kosuu[x] != 0 and red[x] == True):
    red[y] = True
  if (kosuu[x] == 1 and red[x] == True):
    red[x] = False
  kosuu[x] -= 1
  kosuu[y] += 1

ans = 0
for i in range(N):
  if red[i] == True:
    ans+=1

print(ans)

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

int main() {
	int N;
	scanf ("%d", &N);
	vector < int > A (N);
	for (int & x : A) scanf ("%d", &x);
	unordered_set < int > m;
	bool distinct = true;
	for (int x : A) {
		if (m.find (x) != m.end()) {
			distinct = false;
			break;
		}
		m.insert (x);
	}
	if (distinct) {
		printf ("YES\n");
	} else {
		printf ("NO\n");
	}
	return 0;
}


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

int main(void) {
    int n;cin>>n;
    int house[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) house[i][j][k] = 0;
        }
    }
    for (int i = 0; i < n; i++) {
        int b,f,r,v;cin>>b>>f>>r>>v;
        int tmp = house[b - 1][f - 1][r - 1] + v;
        house[b - 1][f - 1][r - 1] = min(max(0, tmp), 9);
    }
    for (int l = 0; l < 4; l++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 10; j++) {
                cout << " " << house[l][i][j];
            }
            cout << endl;
        }
        if (l < 3) cout << "####################" << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;
	cin >> n >> x;
	int minv = INF;
	rep(i,n){
		int m;
		cin >> m;
		minv = min(minv,m);
		x -= m;
	}
	cout << n + x / minv << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))


Int dict[108000];
Int supp = 0;
Int n, k;

Int cnt(){return supp;}
void add(Int x){
  if(x > k)return;
  if(dict[x]++ == 0)supp++;
}
void remove(Int x){
  if(x > k)return;
  if(dict[x]-- == 1)supp--;
}

int main(){
  Int res = INF;
  cin >> n >> k;
  vector<Int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  int r = 0;
  for(int i = 0;i < n;i++){
    while(r < n && cnt() < k)add(a[r++]);
    if(cnt() == k)res = min(res, r - i);
    remove(a[i]);
  }
  if(res == INF)res = 0;
  cout << res << endl;  
  return 0;
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, a, b; cin >> n >> a >> b;
  string s; cin >> s;
  int border = a+b;
  int out = 1, pass = 0;
  rep(i,s.size()) {
    if (pass < border) {
      if (s[i] == 'a') {
        cout << "Yes" << endl;
        pass++;
        continue;
      }
      if (s[i] == 'b' && b >= out) {
        cout << "Yes" << endl;
        pass++; out++;
        continue;
      }
    }
    cout << "No" << endl;
  }
  return 0;
}

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

/*
真上から見て
l : 左, r : 右
f : 前, b : 後ろ
d : 下, u : 上
*/

struct Dice
{
    int l, r, f, b, d, u;
    //前に回転
    void RollN()
    {
        int buff = d;
        d = f, f = u, u = b, b = buff;
    }
    //後ろに回転
    void RollS()
    {
        int buff = d;
        d = b, b = u, u = f, f = buff;
    }
    //左に回転
    void RollW()
    {
        int buff = d;
        d = l, l = u, u = r, r = buff;
    }
    //右に回転
    void RollE()
    {
        int buff = d;
        d = r, r = u, u = l, l = buff;
    }
    //時計回りに回転
    void RollR()
    {
        int buff = f;
        f = r, r = b, b = l, l = buff;
    }
    //反時計回りに回転
    void RollL()
    {
        int buff = f;
        f = l, l = b, b = r, r = buff;
    }
};

/*
0 -> 上, 1-> 後ろ
2 -> 右, 3-> 左
4 -> 前, 5-> 下
*/

Dice make_dice(int a[])
{
    Dice dice;
    dice.u = a[0], dice.b = a[1], dice.r = a[2], dice.l = a[3], dice.f = a[4], dice.d = a[5];
    return dice;
}

//p : 上面,　q : 後面, 同じ面があれば、どれかに合わせる
void set_dice(Dice &dice, int p, int q)
{
    for (int i = 0; i < 7; i++)
    {
        if (i < 4)
            dice.RollE();
        else
            dice.RollN();
        if (p == dice.u)
            break;
    }
    for (int i = 0; i < 4; i++)
    {
        dice.RollR();
        if (q == dice.b)
            break;
    }
}

//2つのサイコロが同じか
bool dice_equal(Dice dice1, Dice dice2)
{
    bool eq = false;
    for (int i = 0; i < 50; i++)
    {
        set_dice(dice2, dice1.u, dice1.b);
        if (dice1.u == dice2.u && dice1.d == dice2.d && dice1.r == dice2.r && dice1.l == dice2.l && dice1.f == dice2.f && dice1.b == dice2.b)
            eq = true;
    }
    return eq;
}

int main()
{
    int a[6], b[6];
    for (int i = 0; i < 6; i++)
        cin >> a[i];
    Dice dice1 = make_dice(a);
    for (int i = 0; i < 6; i++)
        cin >> b[i];
    Dice dice2 = make_dice(b);
    bool f = (dice_equal(dice1, dice2));
    cout << (f ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3100
n, m = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(m)]
A.sort(key=lambda x: x[1])

posi = 0
count = 0
for i in range(m):
    if A[i][0] >= posi:
        count += 1
        posi = A[i][1]

print(count)

Measured memory_bytes: 22820
{-
  a + 2 sqrt(ab) + b < c
  2 sqrt(ab) < c - a - b
-}


solve :: Int -> Int -> Int -> Bool
solve a b c
  | c - a - b < 0 = False
  | otherwise = 4*a*b < (c-a-b)*(c-a-b)


test :: IO ()
test = do
  print $ solve 2 3 9 == False
  print $ solve 2 3 10 == True
  print $ solve 1 1 1 == False
  print $ solve 1 1 2 == False

main = do
  [a,b,c] <- map read . words <$> getLine
  putStrLn $ if solve a b c then "Yes" else "No"


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

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

signed main(){
    int N, a[3];
    cin >> N;
    REP(i, N) cin >> a[i];
    if(N == 2) a[2] = a[1];
    int g = gcd(gcd(a[0], a[1]), a[2]);
    FOR(i, 1, g + 1){
        if(g % i == 0) PRINT(i);
    }
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<math.h>
#define N 500000
void maxHeapify(int *,int,int);
//void builtMaxHeap(int *,int,int);
int main()
{
  int i,A[N+1],n,a;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
    }
  a=n/2;
   for(i=a;i>=1;i--)
    {
     
      maxHeapify(A,i,n);
    }
   for(i=1;i<=n;i++)
     {
       printf(" %d",A[i]);
     }
   printf("\n");
   return 0;
}

void maxHeapify(int A[],int i,int n)
{
  int b,c,l,r,largest;
  l = 2*i;
  r = 2*i+1;
  if(l<=n && A[l] >A[i])largest = l;
  else largest = i;
  if( r <= n && A[r] > A[largest] )largest = r;
  if(largest !=i)
    {
      b = A[i];
      c = A[largest];
      A[largest] = b;
      A[i] = c;
      
      maxHeapify(A,largest,n);
    }
}

/*void builtMaxHeap(int A[],int a,int n)
{
  int i;
  for(i=a;i>1;i--)
    {
      maxHeapify(A,i,n);
    }
}
*/



Measured memory_bytes: 3700
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    int l, r, d;
    scanf("%d%d%d", &l,&r,&d);
    printf("%d\n", r/d - (l-1)/d);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

	int N;
	cin >> N;

	vector<P> A;
	ddvi G(N+1);
	for(int i=0; i<N-1; i++){
		int a,b;
		cin >> a >> b;
		A.emplace_back(a,b);
		G[a].eb(b);
		G[b].eb(a); // どっち向きに探索が来てもいいようにグラフ構成
	}

	int K=0; // 使う色の最小値

	// 色を付けた木の構成を行う (どん欲)
	// 適当な点を根として幅優先探索
	// 各頂点では，子との間の色を順に決める
	// 色は，探索中の点で使われてない色(番号)のうち最少を選ぶ

	map<pair<int,int>,int> I; //辺(u,v)の色
	vi cs(N+1,0); // 親との間の辺の色

	vi used(N+1,0); // 探査済み記憶
	queue<int> que; // DFSのキュー

	used[1] = 1;
	que.emplace(1);
	// ノード1を根とする．
	while(!que.empty()){
		int v = que.front();
		que.pop();
		if(K<(int)G[v].size()) K=G[v].size(); // ノードに接続する辺の最大値を記憶
		int cur=1;
		for(int u:G[v]){
			if(used[u]) continue;
			if(cur==cs[v]) cur++; // 使われている色(番号)スキップ
			cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++; // 色決めてからインクリメント
			used[u]=1;
			que.emplace(u);
		}
	}

	cout << K << "\n";
	for(auto p:A) cout << I[p] << "\n";

return 0;
}

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

const int MAX_K = (int)3000 + 5;

int x[MAX_K][MAX_K];
int n, k;

int getsize(int x1, int y1, int x2, int y2) {
  return x[x2][y2] - x[x2][y1] - x[x1][y2] + x[x1][y1];
}

int main() {
    scanf("%d %d", &n, &k);

    int a, b;
    char c;
    for (int i = 0; i < n; ++i) {
      scanf("%d %d %c", &a, &b, &c);
      if(c == 'W') b+=k;
      // a %= 2 * k, b %= 2 * k;
      x[a % (2 * k) + 1][b % (2 * k) + 1] += 1;
    }

    for (int i = 1; i <= 2 * k; ++i) for (int j = 1; j <= 2 * k; ++j) {
      x[i][j] = x[i][j] + (x[i - 1][j] + x[i][j - 1] - x[i - 1][j - 1]);
    }

    int ans = 0, dual, sum;

    for (int i = 1; i <= k; ++i) for (int j = 1; j <= k; ++j){
      sum = getsize(0, 0, i, j);
      sum += getsize(i, j, k + i, k + j);
      sum += getsize(k + i, k + j, 2 * k, 2 * k);
      sum += getsize(k + i, 0, 2 * k, j);
      sum += getsize(0 ,k + j, i, 2 * k);
      dual = n - sum;
      sum = max(dual, sum);
      ans = max(ans, sum);
    }

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

Measured memory_bytes: 24832
#include <iostream>

using namespace std;

int main(void)
{
	int N, P, A,c[2] = {0,0};
	cin >> N >> P;
	unsigned long long int ans = 1;

	for (int i = 0; i < N; i++) {
		cin >> A;
		c[A % 2]++;
	}
	if (c[0] == N) {
		if (P == 1) {
			ans = 0;
		} else {
			ans = 2;
		}
	}

	for (int i = 1; i <= N - 1; i++) {
		ans *= 2;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define endl "\n"
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef long long ll;
#define MOD 1000000007;
 
int main() 
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a; cin >> a;
    int x = a*a;
    cout << a + a*a + x*a << endl;
    
    
    
    return 0;
}

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

int main()
{
	std::string O, E;
	std::cin >> O;
	std::cin >> E;

	int i;
	for( i = 0; i < E.length(); i++ ){
		std::cout << O[i] << E[i];
	}
	
	if ( O.length() == E.length() ){
		std::cout << std::endl;
	}else{
		std::cout << O[ O.length() - 1 ] << std::endl;
	}

	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	ll money = 1e5;

	FOR(i,0,N){
		money *= 1.05;
		money = (money + 999) / 1000 * 1000;
	}

	printf("%lld\n",money);

	return 0;
}

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

int main(){
	ll N, W;
	cin>>N>>W;
	std::vector<ll> wt(N);
	std::vector<ll> v(N);
	std::vector<std::vector<ll> > memo(N+1, std::vector<ll> (W+1));
	for(int i=0; i<N; i++){
		cin>>wt[i]>>v[i];
	}
	for(int i=0; i<=N; i++){
		for(int w=0; w<=W; w++){
			if(i==0 || w == 0){
				memo[i][w] = 0;
			}
			else if(w >= wt[i-1]){
				memo[i][w] = std::max(v[i-1] + memo[i-1][w-wt[i-1]], memo[i-1][w]);
			}
			else{
				memo[i][w] = memo[i-1][w];
			}
		}
	}
	cout<<memo[N][W];
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

#define bit(x) (1<<(x))
int dp[(1<<21)+10][4],pd[(1<<21)+10][4],ret[(1<<21)+10];
int n,k;
char s[(1<<21)+10];
void gao(int x) {
	int m=bit(x);
	rep(i,0,bit(x+1)) rep(ban,0,4) dp[i][ban]=0;
	rep(i,0,m) dp[i+m][0]=s[i]=='1';
	per(k,1,x+1) {
		rep(i,0,bit(x+1)) rep(ban,0,4) pd[i][ban]=dp[i][ban],dp[i][ban]=0;
		rep(i,0,bit(x+1)) rep(ban,0,4) {
			int pl=i>>k,pm=(i>>(k-1))&1,pr=i&(bit(k-1)-1);
//			printf("%d ban: %d pl:%d pr: %d %d\n",k,ban,pl,i&(bit(k)-1),pd[i][ban]);
			dp[(pl<<(k-1))+pr][ban|(1<<pm)]+=pd[i][ban];
			if ((ban&bit(pm))==0) {
				dp[((pl*2+pm)<<(k-1))+pr][0]+=pd[i][ban];
			}
		}
	}
//	puts("-------");
	rep(i,0,bit(x+1)) rep(ban,0,4) ret[i]+=dp[i][ban];
}
int main() {
	scanf("%d%d",&n,&k);
	rep(i,0,n+1) {
		scanf("%s",s);
		if (i==0) continue;
		gao(i);
	}
/*	rep(S,1,bit(n+1)) {
		printf("%d %d\n",S,ret[S]);
	}*/
	per(i,1,n+1) rep(sl,bit(i),bit(i)+bit(i)) if (ret[sl]>=k) {
		per(j,0,i) printf("%d",(sl>>j)&1);
		puts("");
		return 0;
	}
}


Measured memory_bytes: 75136
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
A = inl()


def solve():
    cum = [0] * (N + 1)
    for i in range(N - 1, -1, -1):
        cum[i] = cum[i + 1] + A[i]
    count = Counter()
    ans = 0
    for i in range(N):
        count[cum[i]] += 1
        ans += count[cum[i + 1]]
    return ans


print(solve())


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

int n,s;

int dfs(int n,int s,int k){
    if(n==0){
        return (s==0)?1:0;
    }
    int res=0;
    for(int i=k;i<10;i++){
        res+=dfs(n-1,s-i,i+1);
    }
    return res;
}

int main(){
    while(cin>>n>>s,n||s){
        cout<<dfs(n,s,0)<<endl;
    }
}


Measured memory_bytes: 3060
# coding: utf-8
# Your code here!

s = input()

fs = s[:2]
bs = s[2:]

if fs>"00" and fs<="12":
    if bs>"00" and bs<="12":
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if bs>"00" and bs<="12":
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

#define REP(i,n) for(int i=0;i<n;i++)
namespace roll {
	using H = unsigned long long;
	//0123456789
	constexpr H p[] = { 1000000009,
		1000000007,
		90001 };
	constexpr int MX = 1123456;
	H hs[3][MX];
	H rh[3][MX];
	template<int m = 1>
	void build(const string s) {
		const int n = s.size();
		REP(i, m) {
			hs[i][0] = 0;
			rh[i][0] = 1;
			REP(i, m)REP(j, n) {
				hs[i][j + 1] = hs[i][j] * p[i] + s[j];
				rh[i][j + 1] = rh[i][j] * p[i];
			}
		}
	}
	template<int m = 1>
	H get(const int l, const int r) {
		H ret = 0;
		REP(i, m) {
			ret ^= hs[i][r] - hs[i][l] * rh[i][r - l];
		}
		return ret;
	}
}

int id[112345];
int latte[112345];
priority_queue<int> que;
int main() {
	string s; int n;
	while (cin >> s >> n) {
		int len = s.size();
		string all = s;
		vector<string> p(n);
		cin >> p;
		for (int i : range(n)) {
			id[i] = all.size();
			all += p[i];
		}
		id[n] = all.size();
		roll::build(all);
		vector<set<int>> h(len+1);
		int k = 0;
		for (int i : range(n)) {
			if (p[i].size() <= len) {
				h[p[i].size()].insert(roll::get(id[i], id[i + 1]));
				latte[k++] = p[i].size();
			}
		}
		sort(latte, latte + k);
		k = unique(latte, latte + k) - latte;
		int ret = 0;
		for (int i : range(len)) {
			if (que.empty() == false && -que.top() == i) {
				ret++;
				while (que.empty()==false)que.pop();
			}
			for (int j : range(k)) {
				if (i + latte[j] <= len) {
					if (h[latte[j]].count(roll::get(i, i + latte[j])))
						que.push(-(i + latte[j]));
				}
			}
		}
		if (que.empty() == false)ret++;
		while (que.empty() == false)que.pop();
		cout << ret << endl;
	}
	
	return 0;
}



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


#define ll long long
#define ull unsigned ll
#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define vll vector <ll>
#define vull vector <ull>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF (int)1e9
#define EPS 1e-9
#define pb emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0



int main ()

{
    fast;
    
    int a, b;
    cin >> a >> b;

    if (a <= 9 && b <= 9)
    {
        cout << a*b << endl;
        return 0;
    }
    else
    {
        cout << -1 << endl;
    }
    


    return 0;
}

Measured memory_bytes: 256
X = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

yaku = make_divisors(X)
def fun(x, a):
    return(5*x**4-10*a*x**3+10*a**2*x**2-5*a**3*x+a**4)


for one in yaku:
    for i in range(10**5):
        if fun(i, one)==X/one:
            print(i, i-one)
            exit()

Measured memory_bytes: 70592
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        a: i64,
        b: i64,
        c: i64,
        d: i64,
    }

    for i in 0..n {
        let i = i as i64;
        let n = n as i64;
        let m = a + i * d - (n - i - 1) * c;
        if m - (d - c) * (n - 1) <= b && b <= m {
            println!("YES");
            return;
        }
    }
    println!("NO");
}


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



int main() {
	int n,k,a,x,sum=0;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a;
		x=abs(a-k);
		x=min(a,x);
		sum+=x*2;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Q;
  int sum=0;
  string S;
  cin >> N >> Q >> S;
  vector<int> a(S.length(),0);
  for(int i=0;i<S.length();i++){
    if(S[i]=='A' && S[i+1]=='C'){
      sum+=1;
    }
    a[i+1]=sum;
  }
  for(int i=0;i<Q;i++){
    int l,r;
    cin >> l >>r;
    cout << a[r-1]-a[l-1] << endl;
  }
}

Measured memory_bytes: 1408
from itertools import combinations, product
from collections import Counter
def calc(a):
    ret = 10 ** 20
    for comb in combinations(a, 2):
        tmp = abs(comb[0] - comb[1])
        ret = min(ret, min(tmp, 24-tmp))
    return ret

def main():
    N = int(input())
    D = list(map(int, input().split()))
    # 0時間がある場合 高橋君の必ずかぶるので 0
    if D.count(0):
        return 0
    cnt = Counter(D)
    # 3つ以上のかぶりがある場合 0
    if max(cnt.values()) >= 3: return 0
    # 12時間が複数ある場合 0
    if cnt[12] >= 2: return 0
    d = []
    d2 = [0]
    single_cnt = 0
    for i, c in cnt.items():
        if i == 12:
            d2.append(12)
        elif c == 1:
            d.append((i, 24-i))
            single_cnt += 1
        elif c == 2:
            d2.append(i)
            d2.append(24-i)
    ans = 0
    for prod in product(range(2), repeat=single_cnt):
        tmp = []
        for i, p in enumerate(prod):
            tmp.append(d[i][p])
        ans = max(ans, calc(tmp + d2))
    return ans
            
print(main())


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

int mp[5];

int main(){
	
	REP(i,3){
		int a, b;cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	
	REP(i,5){
		if(mp[i] > 2){
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
	
	return 0;
}


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

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int x;
  cin >> x;
  int ans = x*x*x;
  cout << ans << endl;
}





Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vii         vector<pair<int,int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define int long long int
using namespace std;
int n;
char mock(int x){
    if((to_string(x) <= to_string(n) && x <= n) ||
            (to_string(x) > to_string(n) && x  > n))return 'Y';
    return 'N';
}
bool query(int x){
    while(x < 1e10)x *= 10;
    cout << "? " << x << endl;
    //char s = mock(x);
    string s;cin >> s;
    if(s == "Y")return true;
    else return false;
}
bool query1(int x){
    cout << "? " << x << endl;
    string s;cin >> s;
    //char s = mock(x);
    if(s == "Y")return true;
    else return false;

}
void ans(int x){
    cout << "! " << x << endl;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //cin >> n;
    int prev = 0;
    for(int dig = 1; dig <= 10; dig++){
        int s = 0, e = 9;
        int temp = -1;
        while(s <= e){
            int mid = (s +e) >> 1;
            int x = prev*10 + mid;
            if(query1(x)){
                temp = mid; 
                s = mid+1;
            }else{
                e = mid-1;
            } 
        }
        if(temp == 9){//might be last digit
            // 1. check if the last digit is 9
            // 2. if it is not nine then this is the last digit
            // 3. if it is nine then check with 80 whether this is the last digit
            bool last = false;
            if(!query(prev*10 + 8)){
               //last digit is nine  
               if(!query1((prev*100 + 80)))last= true;
            }else{
                last = true;
            }
            if(!last)goto leave;
            FOR(i, 9+1){
                if(prev == 0 && i == 0)continue;
                if(query(prev*10 + i)){
                    prev= prev*10 + i;
                    break;
                }
            }
            break;
        }
leave:
        prev = (prev)*10 + temp;
    }
    ans(prev);
}




Measured memory_bytes: 596
#include<stdio.h>
int main(void){
    int a[4],b[4],i,j;
    for(;;){
        int hit=0,blow=0;
        for(i=0;i<4;i++){
            if(scanf("%d",&a[i])==EOF)return 0;
        }
        for(i=0;i<4;i++){
            if(scanf("%d",&b[i])==EOF)return 0;
            if(a[i]==b[i]){
                //printf("hit");
                hit++;
            }
            else{
                for(j=0;j<4;j++){
                    if(b[i]==a[j]){
                        //printf("blow\n");
                        blow++;
                    }
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    return 0;
}

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

using namespace std;

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

    long long int n,num,ans=1,prev_ans=0;bool br=false,br1=false;
    cin>>n;

    for(int i=0;i<n;i++){
        cin>>num;
        ans*=num;//cout<<ans<<"\n";

        if(num==0){
            br1=true;
        }

        if(ans<prev_ans){
            br=true;
        }
        prev_ans=ans;
    }

    if(br1==true){
        cout<<0<<"\n";return 0;
    }

    if(ans>=0 && ans<=1000000000000000000 && br!=true){
        cout<<ans<<"\n";
    }
    else{
        cout<<-1<<"\n";
    }



    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int k,x;
  cin >> k >> x;
  for(int i = x-k+1;i <= k+x-1;i++){
    cout << i;
    cout << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    int a;
    rep(0, i, N)
    {
        cin >> a;
        while (a % 2 == 0)
        {
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
l, r = map(int, input().split())
a = (l-1)//2019
b = r//2019
if a!=b:
  print('0')
  exit()
l=l%2019
r=r%2019
res=2019
for i in range(l, r+1):
  for j in range(i+1, r+1):
    temp = (i*j)%2019
    if temp<res:
      res=temp
print(res)

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

using namespace std;

int main(int argc, char *argv[]) {
    //
    //  締切が小さいもの, 仕事量が小さいものでソート
    //  順番に足していき、全てが達成できるならYes
    //  そうでないならNo
    //

    int N;
    cin >> N;
    vector<pair<int, int>> parr;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        parr.push_back(make_pair(b, a));
    }

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

    int sum = 0;
    bool ok(true);
    for (auto& var: parr) {
        int limit = var.first;
        sum += var.second;
        if (limit < sum) {
            ok = false;
            break;
        }
    }

    cout << ((ok) ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main()
{
	int indx;
	int arr[5];
	for(int i=0;i<5;i++)
	{
		cin>>arr[i];
		if(arr[i]==0)
		{
			indx=i+1;
		}
	}

	cout<<indx<<endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int n;
vector<vector<int>> v(2e5+1);

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int a; cin >> a;
        v[a].push_back(i);
    }
    if (v[1].size() == 0) {
        cout << "-1"; return 0;
    }
    int ans = n-1;
    for (int pos : v[1]) {
        int pos1 = pos;
        for (int i = 2; i <= n; ++i) {
            int e = -1;
            for (int j : v[i]) {
                if (j > pos1) {
                    e = j;
                    break;
                }
            }
            if (i == n && e != -1) {
                ans = 0; break;
            }
            if (e == -1) {
                ans = min(ans, n - (i-1)); break;
            } else {
                pos1 = e;
            }
            /*
            int b = 0, e = v[i].size() - 1;
            while (b < e) {
                int m = b + ((e-b)>>1);
                if (v[i][m] < pos1) {
                    b = m + 1;
                } else {
                    e = m;
                }
            }
            if (e == -1 || v[i][e] < pos1) {
                ans = min(ans, n - (i-1)); break;
            } else {
                pos1 = v[i][e];
            }
            */
        }
    }
    cout << ans;


    return 0;
}


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

using namespace std;



void solve()
{
  unsigned long long L[87] = { 2, 1 };
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[n] << "\n";
}

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

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#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 <queue>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

//const LL mod = 1e9 + 7;



int main() {
	
	LL x;
	cin >> x;
	LL num = (x / 11LL) * 2LL;
	x -= (x / 11LL) * 11LL;
	if(x<=0){}
	else if (x <= 6LL) { num+=1LL; }
	else { num += 2LL; }
	cout <<num  << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define VJ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mp make_pair()
#define vi(x) vector<int>x
#define vl vector<long long int>
#define vc vector<char> 
using namespace std;


void solve(){
	
		int n;
		cin>>n;
		vector<int>v(n);
		for(int i=0;i< n;i++){
			cin>>v[i];
		}
		ll height=0;
		for(int i=1;i<n;i++){
			if(v[i-1]>v[i]){
				int curr=v[i-1]-v[i];
				v[i]+=curr;
				height+=curr;
			}
		}
		cout<<height;
	
}

int main(){
	 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	 #endif
	VJ
	solve();
	return 0;
}


Measured memory_bytes: 3988
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007

int main(){
  int i,w=0,b=0;
  char W[100000],B[100000];
  scanf("%s",W);
  int s=strlen(W);
  for(i=0;i<s;i++)B[i]=W[i];
  if(W[0]=='0'){w=1;W[0]=1;}
  else {b=1;B[0]=1;}
  for(i=0;i<s-1;i++)
  if(W[i]==W[i+1]){
    w++;
    if(W[i]=='0')W[i+1]='1';
    else W[i+1]='0';
  }
  for(i=0;i<s-1;i++)
  if(B[i]==B[i+1]){
    b++;
    if(B[i]=='0')B[i+1]='1';
    else B[i+1]='0';
  }
  printf("%d\n",MIN(w,b));
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int A, B;
	cin >> A >> B;

	if (A + B > 9) {
		cout << "error" << endl;
	}
	else {
		cout << A + B << endl;
	}
}

Measured memory_bytes: 256
while true
    line = gets.chomp
    break if line == "0 0"
    n, w = line.split.map(&:to_i)
    arr = []
    n.times{arr << gets.to_i}
    arr2 = Array.new(arr.max / w + 1, 0)
    arr.each{|x| arr2[x / w] += 1}
    ink, max = 0.01, arr2.max
    arr2.each_with_index{|x, i| ink += Rational(x, max) * Rational(arr2.length - 1 - i , arr2.length - 1)}
    puts ink
end


Measured memory_bytes: 6896
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n = int(ri())
a = Ri()

xor  = 0
for i in a:
    xor  =xor ^ i

ans = []
for i in a:
    ans.append(xor^i)

print(*ans)

Measured memory_bytes: 106968
"""
カンガルー
時刻iで長さiのジャンプをするx-i,x,x+i
0からスタートして、座標Xにつくまでの時間
"""

X = int(input())
# 大体のやつ
n = int((2*X)**0.5)+1
S = n*(n+1)//2

if S-X >= n:
    print(n-1)
else:
    print(n)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  double h, a;
  cin >> h >> a;
  cout << ceil(h / a) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int out = 1;
    int i=0;
    char c = s[i];
    for(;i<n;i++){
        if(s[i] != c )
        {
            out ++;
            c = s[i];
        }
    }
    cout << out;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.buffer.readline
in_n = lambda: int(input())
in_nn = lambda: map(int, input().split())
in_s = lambda: input().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')]

MOD = 10**9 + 7
INF = 8 * 10**18


def main():

    print("ABC" + in_s())


if __name__ == '__main__':
    main()


Measured memory_bytes: 9128