akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000


int keta(ll x)
{
    int count = 0;
    while(x)
    {
        x/=10;
        count++;
    }
    return count;
}

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    /*ABC150 B
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    */

    /*ABC136 B
    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        int even=0;
        int num = i;
        while(num)
        {
            num/=10;
            even++;
        }
        if(even%2!=0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    */
    /*ABC106 B
    int n;
    cin>>n;
    int count=0;
    for(int i=10;i<=n;i++)
    {
        int num = i;
        int yakusu=0;
        for(int j=1;j<=num;j++)
        {
            if(j%2==0)
            {
                continue;
            }
            if(num%j==0)
            {
                yakusu++;
            }    
        }
        if(yakusu==8)
        {
            count++;
        }
    }    
    cout<<count<<endl;
    */
    /*ABC120 B
    int a,b,k;
    cin>>a>>b>>k;
    int count=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0 && b%i==0)
        {
           count++;
        }
        if(count==k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    */
    /*ABC057 C
    ll n;
    cin>>n;
    int ans = keta(n);
    for(ll i=1;i*i<=n;i++)
    {
        int cur=0;
        if(n%i==0)
        {
            ll b = n/i;
            cur = max(keta(i),keta(b));
        }
        else continue;

        if(cur<ans)
        {
            ans = cur;
        }
    }

    cout<<ans<<endl;
    */
    /*ABC095 C
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ab=2*c;
    int cost = a*x+b*y;
    for(int i=0;i<=100000;i++)
    {
        int temp=0;
        temp +=i*ab+max(x-i,0)*a+max(y-i,0)*b;
        cost = min(temp,cost);
    }
    cout<<cost<<endl;
    */
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<1000;i++)
    {
        int c[3]={i/100,(i/10)%10,i%10};
        int x = 0;
        for(int j=0;j<n;j++)
        {
            if(s[j]==('0'+c[x]))
            {
                x++;
            }
            if(x==3)
            {
                break;
            }
        }
        if(x==3) count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <array>
#include <utility>

template <unsigned int N> struct shuumai{
    unsigned int minPrime[N + 1];
    unsigned int Primes[N + 1];
    unsigned int size_;

    constexpr shuumai(void): minPrime(), Primes(), size_(0U){
        minPrime[0] = 1; minPrime[1] = 1;
        for(int even = 2, odd = 3; odd <= N; even += 2, odd += 2){
            minPrime[even] = 2;
            minPrime[odd] = odd;
        }
        if(!(N & 1)) minPrime[N] = 2;
        Primes[size_++] = 2;

        for(int x = 3; x <= N; x += 2){
            if(minPrime[x] == x) Primes[size_++] = x;
            for(int y = 0; y < size_ and Primes[y] <= minPrime[x] and x * Primes[y] <= N; ++y)
                    minPrime[x * Primes[y]] = Primes[y];
        }
    }
    // 範囲for文用の begin() と end()
    const unsigned int *begin(void) const noexcept{ return Primes; }
    const unsigned int *end(void) const noexcept{ return Primes + size_;}
    const unsigned int size(void) const {return this.size_;}
};

using uint = unsigned int;
constexpr uint N = 1e6;
constexpr uint M = 1e3;
constexpr uint mod = 1e9 + 7;
constexpr shuumai<N> P;
std::array<uint, N + 1> Count;

// aの逆元を求める関数
const unsigned int inverse(unsigned int a) noexcept {
    unsigned int b = mod;
             int u = 1,   v = 0;
    while (b) {
        unsigned int t = a / b; 
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    if(u < 0) u += mod;
    return u;
}

// a^nを返す関数
const uint power(uint a, uint n)noexcept{
    unsigned long long res = 1, waiting = a;
    while(n){ 
        if(n & 1) { res *= waiting; res %= mod; }
        waiting *= waiting; waiting %= mod; 
        n >>= 1;
    }
    return res;
}

uint fastRead(void) {
	char c;
	while(true){
        c = getchar();
        if('0' <= c and c <= '9') break;
	}
    uint res = c - '0';
	while(true){
		c = getchar();
        if(c < '0' or c > '9') break;
		res = 10 * res + (c - '0');
	}
    return res;
}


int main(void){
    uint n = fastRead();
    uint inv_sum = 0;
    for(uint _ = 0; _ < n; ++_){
        uint a = fastRead();
        inv_sum += inverse(a); if(inv_sum >= mod) inv_sum -= mod;
        while(a - 1U){
            uint fac = P.minPrime[a];
            uint cnt = 1; a /= fac;
            while(a % fac == 0) a /= fac, cnt++;
            if(Count[fac] < cnt) Count[fac] = cnt; 
        }
    }

    unsigned long long int lcm = 1;
    for(unsigned int x : P) if(Count[x]) (lcm *= power(x, Count[x])) %= mod;
    unsigned int res = lcm * inv_sum % mod;
    
    printf("%u\n", res);
    return 0;
}

Measured memory_bytes: 3200
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B, C, D, E, F = map(int, input().split())

    max_deisity = 100 * E / (100 + E)
    MAX = -1
    W = 0
    S = 0
    for a in range(F // (100 * A) + 1):
        rest1 = F - a * A * 100
        for b in range(rest1 // (100 * B) + 1):
            if a == 0 and b == 0:
                continue

            water = a * A * 100 + b * B * 100
            rest2 = F - water
            for c in range(rest2 // C + 1):
                rest3 = rest2 - C * c
                for d in range(rest3 // D + 1):
                    sugar = C * c + D * d

                    if water + sugar > F:
                        continue

                    density = 100 * sugar / (water + sugar)
                    if max_deisity < density:
                        continue

                    if density > MAX:
                        MAX = density
                        W = water
                        S = sugar

    print(W + S, S)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int h = sc.nextInt();
				int w = sc.nextInt();
				if(h+w == 0) break;

				int dia = h * h + w * w;
				int min = Integer.MAX_VALUE;
				int minh = 151;
				int minw = 151;

				for(int i=1; i<150; i++) {
					for(int j=i+1; j<151; j++) {
						int dia2 = i * i + j * j;
						if(dia2 >= dia) {
							if(dia2==dia && h>=i) {
								continue;
							}
							if(min>dia2) {
								min = dia2;
								minh = i;
								minw = j;
							}
						}
					}
				}
				System.out.println(minh + " " + minw);
			}
		}
	}
}


Measured memory_bytes: 27708
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = (1LL << 60);
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int n;
int a[100010][3];

int dp[100010][3];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	rep(i, n) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	int ans = 0;
	rep(i, 3) {
		chmax(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

	string s;
	cin >> s;
  
	int min;
    int max;
  
   	for(int i=0; i<s.size(); i++) {
      if(s[i] == 'A'){
        min = i;
        break;
      }
    }
    for(int i=s.size()-1; i>=0; i--) {
      if(s[i] == 'Z'){
        max = i;
        break;
      }
    }
 
  cout << max-min+1 << endl;
}

Measured memory_bytes: 640
N,M = map(int,input().split())
branch_list = []
for i in range(M):
    branch_list.append(list(map(int,input().split())))

visited = [1]

def dfs(now):
    global cnt
    if len(visited) == N:
        cnt += 1
        return cnt
    for br in branch_list:
        if now in br:
            next_node = br[1-br.index(now)]
            if not next_node in visited:
                visited.append(next_node)
                dfs(next_node)
                visited.remove(next_node)
    return cnt
cnt = 0
dfs(1)
print(cnt)

                

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

int n;
vii a(15, vi(15));

bool judge(int x) {
  rep (i, n) {
    if (x & (1 << i)) {
      rep (j, n) {
        if (a[i][j] == 0) continue;
        else if (a[i][j] == 1) {
          if (x & (1 << j)) {}
          else return false;
        }
        else {
          if (x & (1 << j)) return false;
        }
      }
    }
  }
  return true;
}

signed main() {
  cin >> n;
  rep (i, n) {
    int m;
    cin >> m;
    rep (j, m) {
      int x, y;
      cin >> x >> y;
      x--;
      if (y) a[i][x] = 1;
      else a[i][x] = -1;
    }
  }

  int ans = 0;
  rep (i, 1 << n) {
    if (judge(i)) {
      int cnt = 0;
      rep (k, n) {
        if (i & (1 << k)) {
          cnt++;
        }
      }
      chmax(ans, cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

dh = 2 * math.pi * ((H + M / 60)/12)
dm = 2 * math.pi * (M/60)

dw = min((dh - dm) % (2 * math.pi), (dm - dh) % (2 * math.pi))
w = (A ** 2 + B ** 2 - 2 * A * B * math.cos(dw)) ** (1/2)

print(w)


Measured memory_bytes: 9500
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
 
int minn[500010],d[500010],n,m,q;
bool ans[500010];
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
int main()
{
    n=rd();m=rd();
    for (int i=1;i<=n;i++) d[i]=rd();
    minn[n+1]=1;
    for (int i=n;i;i--)
    {
        if (minn[i+1]*2>d[i]) minn[i]=minn[i+1]+d[i];
        else minn[i]=minn[i+1];
        minn[i]=min(minn[i],m+1);
    }
    int hh=m;
    for (int i=1;i<=n;i++)
    {
        ans[i]=(hh>=minn[i+1]);
        hh=min(hh,abs(hh-d[i]));
    }
    q=rd();
    while (q--) puts(ans[rd()]?"YES":"NO");
    return 0;
}

Measured memory_bytes: 6400
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [str(i) for i in input().split()]

    if a[0] == "H" and a[1] =="H":
        print("H")
    elif a[0] == "D" and a[1] =="H":
        print("D")
    elif a[0] == "D" and a[1] =="D":
        print("H")
    else:
        print("D")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (d == 1) cout << 1 << endl;
  else cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
   int D,N;

    cin >> D >> N;
    int s =1;
        rep(i,D) s*=100;
        if(N % 100 != 0)
            cout << N*s << endl;
        else if(N % 100 == 0)
            cout << (N + 1)*s << endl;

    return 0;
}

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

using pii = pair<int, int>;
const int inf = 1e9;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return std::vector<decltype(val)>(n, std::move(val));
}

int main() {
    int n; cin >> n;
    vector<int> p(n), vs = {-inf, inf};
    for(auto& x : p) {
        cin >> x;
        vs.push_back(x);
        vs.push_back(-x);
    }
    sort(begin(vs), end(vs));
    vs.erase(unique(begin(vs), end(vs)), end(vs));
    auto get_idx = [&] (int val) -> int {
        return lower_bound(begin(vs), end(vs), val) - begin(vs);
    };
    vector<vector<int>> g(n);
    for(int i = 0; i < n; ++i) {
        int k; cin >> k;
        g[i].resize(k);
        for(auto& c : g[i]) {
            cin >> c;
            c--;
        }
    }

    auto max_dp = table(n, vs.size(), vs.size(), make_pair(-inf, 0));
    auto min_dp = table(n, vs.size(), vs.size(), make_pair(inf, 0));
    function<pii(int, int, int, bool)> dfs = [&] (int v, int alpha, int beta, bool is_min) {
        if(g[v].empty()) return make_pair(1, p[v]); // leaf

        auto& res = (is_min ? min_dp[v][alpha][beta] : max_dp[v][alpha][beta]);
        if(abs(res.first) != inf) return res;

        sort(begin(g[v]), end(g[v]));
        do {
            int talpha = alpha;
            pii cur = make_pair(0, -inf);
            for(auto const ch : g[v]) {
                auto val = dfs(ch, get_idx(-vs[beta]), get_idx(-vs[talpha]), is_min);
                val.second = -val.second;
                cur.first += val.first;
                if(val.second >= vs[beta]) {
                    cur.second = val.second;
                    break;
                }
                if(val.second > vs[talpha]) {
                    talpha = get_idx(val.second);
                }
            }
            if(cur.second == -inf) { // not occured val.second >= beta
                cur.second = vs[talpha];
            }
            if(is_min) res = min(res, cur);
            else       res = max(res, cur);
        } while(next_permutation(begin(g[v]), end(g[v])));

        return res;
    };

    cout << dfs(0, 0, vs.size() - 1, true).first << " " << dfs(0, 0, vs.size() - 1, false).first << endl;
}



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

namespace ConsoleApp92 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = st[0];
            int W = st[1];

            var s = new string[H];
            for (int i = 0; i < H; i++) {
                s[i] = Console.ReadLine();
            }

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    bool checker = false;

                    if (s[i][j] == '#') {
                        if (i - 1 >= 0) {
                            if (s[i - 1][j] == '#') {
                                checker = true;
                            }
                        }
                        if (i + 1 < H) {
                            if (s[i + 1][j] == '#') {
                                checker = true;
                            }
                        }
                        if (j - 1 >= 0) {
                            if (s[i][j - 1] == '#') {
                                checker = true;
                            }
                        }
                        if (j + 1 < W) {
                            if (s[i][j + 1] == '#') {
                                checker = true;
                            }
                        }

                        if (checker == false) {
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }

            Console.WriteLine("Yes");

        }
    }
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 202;

int main(){
  string s; cin >> s;
  map<char,ll> mp;
  ll N = s.size();
  rep(i,N){
    if(EXIST(mp,s[i])) mp[s[i]]++;
    else mp[s[i]] = 1;
  }
  ll ans = N * (N-1) / 2 + 1;
  for(char c = 'a'; c <= 'z'; c++) ans -= mp[c]*(mp[c]-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll H){
    ll S = floor(log2(H)), sum = 0;
    rep(i, S + 1) sum += pow(2, i);
    cout << sum << "\n";
}

int main() {
    ll H;
    ignore_ret(scanf("%lld",&H));
    solve(H);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define rep(i,j,k) for(int i=j;i<k;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1LL;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
vector<pii> v;
int dp[3030][3030];
int solve(int i,int j){
    if(j<=0 or i==v.size()) return 0;
    int &x = dp[i][j];
    if(x!=-1) return x;
    return x = max(solve(i+1,j), solve(i+1,j-v[i].ff) + v[i].ss);
}

main(){
    fastio;
    int n,p;
    cin >> n >> p;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin >> v[i].ff >> v[i].ss;
    }
    ms(dp,-1);
    sort(td(v));
    cout << solve(0,p) << endl;
}   

Measured memory_bytes: 72192
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

#include <sstream>      // std::ostringstream

std::vector<std::string>split(const std::string &str, char sep) {
	std::vector<std::string>v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

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

	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	vector<string>V;
	const LL day = 2019 * 365 + 31 * 4 + 30;

	bool ret = true;

	cin >> S;

	V = split(S, '/');

	if (atoi(V.at(0).c_str()) * 365 + atoi(V.at(1).c_str()) * 31
		+ atoi(V.at(1).c_str()) > day) {
		ret = false;
	}

	if (ret)
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;

	return 0;

}

Measured memory_bytes: 256
import math
n=int(input())
z=0
d=0
ans=0
for i in range(1,n+1):
  for x in range(1,int(math.sqrt(n)+1)):
    for y in range(1,int(math.sqrt(n)+1)):
      d=x*x+y*y+2*x*y-4*(x*x+y*y+x*y-i)
      if d<0:
        continue
      z=(math.sqrt(d)-(x+y))/2
      if z.is_integer() and z>=1:
        ans+=1
      else:
        continue
  print(ans)
  ans=0
    

Measured memory_bytes: 70372
<?php

$stack = array();
$result = array();
while (!feof(STDIN)) {
    $input = rtrim(fgets(STDIN));
    if ('0' === $input) {
        $result[] = array_pop($stack);
    } else {
        $stack[] = $input;
    }
}

foreach ($result as $key => $value) {
    printf("%d\n", $value);
}


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

int main() {
   string s;
   cin >> s;
   for(char c = 'a'; c <= 'z'; c++) {
      int count = 0;

      for(int i=0; i<s.size(); i++) {
         if(s[i] == c) count++;
      }
      if(count % 2 == 1) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <atcoder/dsu>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    vector<array<int, 3>> Z(n);
    for (int i = 0; i < n; i++){
        cin >> X[i] >> Y[i];
        Z[i] = {--Y[i], --X[i], i};
    }
    
    sort(Z.begin(), Z.end());
    atcoder::dsu dsu(n);
    stack<array<int, 2>> S;

    for (const auto &[y, x, i]: Z){
        array<int, 2> mi = {x, i};
        while (!S.empty() and S.top()[0] < x){
            dsu.merge(i, S.top()[1]);
            mi = min(mi, S.top());
            S.pop();
        }
        S.push(mi);
    }

    for (int i = 0; i < n; i++)
        cout << dsu.size(i) << endl;

}

Measured memory_bytes: 7892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length();
		int a=0;
		for(int i=0;i<(len-1)/2;i++) {
			if((char)s.charAt(i)!=(char)s.charAt(len-1-i)) {
				a=-1;
				break;
			}
		}
		for(int i=0;i<(len-1)/4;i++) {
			if((char)s.charAt(i)!=(char)s.charAt(((len-1)/2)-i-1)) {
				a=-1;
				break;
			}
		}
		for(int i=0;i<(len-1)/4;i++) {
			if((char)s.charAt(((len+3)/2)+i-1)!=(char)s.charAt(len-1-i)){
				a=-1;
				break;
			}
		}
		if(a==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = input()
    print(" ".join(a.split(",")))
    return

#B
def B():
    k, s = LI()
    ans = 0
    for i in range(k + 1):
        for j in range(k + 1):
            if 0 <= s - (i + j) <= k:
                ans += 1
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 41836
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int cnt = 0;
	FOR(i,a,b+1){
		if(c%i==0) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>

#define MAX 21

int main(){
	char str[MAX];
	char str_rev[MAX];
	int i;
	
	scanf("%s", str);
	
	for(i = 0; i < MAX; i++)
	{
		str_rev[i] = 0;
	}
	
	for(i = 0; i < (MAX-1); i++)
	{
		if(str[i] != 0)
		{
			str_rev[MAX-2-i] = str[i];
		}
		else
		{
			break;
		}
	}
	
	printf("%s\n", str_rev+(MAX-1-i));

	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
#define MAX 500002
#define MOD 1000000007
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void initialize(){
    COMinit();
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp,cc;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  rep(i,n) scanf("%d",&a[i]);
  
  cc = 1;
  rep(i,min(n,m+1)){    
    tmp = COM(n,i);
    tmp *= COM(n-1,n-i-1);
    tmp %= MOD1;
    result+=tmp;
    result%=MOD1;    
  }
  printf("%lld",result);
  return 0;
}

Measured memory_bytes: 13824
#include <stdio.h>
#include <string.h>
int main(void){
  char str[1001],order[8];
  char temp,rep[1001];
  int i,j,k,l,n;
  int a,b;
  
  scanf("%s",str);
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
      scanf("%s %d %d",order,&a,&b);
      if(strcmp(order,"print")==0){
          for(j=a;j<=b;j++){
              printf("%c",str[j]);
              if(j==b) printf("\n");
          }
      }
      else if(strcmp(order,"reverse")==0){
          k=(b-a)/2;
          for(j=a;j<=a+k;j++){
              temp=str[j];
              str[j]=str[a+b-j];
              str[a+b-j]=temp;
          }
      }
      else if(strcmp(order,"replace")==0){
          scanf("%s",rep);
          for(j=a,l=0;j<=b;j++,l++){
              str[j]=rep[l];
          }
      }
  }
  
  return 0;
}



Measured memory_bytes: 2104
import sys

H, W = map(int, input().split())
square = []
for i in range(H):
    a = list(map(str, input()))
    square += a

if H == W == 1:
    print('Yes')
    sys.exit()
    
for i in range(H*W):
    if square[i] == '#':
        if i % W != W-1:
            if square[i+1] == '#':
                continue
        if i % W != 0:
            if square[i-1] == '#':
                continue
            
        if i-W >= 0:
            if square[i-W] == '#':
                continue
        if i+W <= H*W:
            if square[i+W] == '#':
                continue
        print('No')
        sys.exit()
        
print('Yes')
            


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

using namespace std;

typedef long long int lli;

int main() {
    int n; cin >> n;
    vector <int> as(n + 1, 0), bs(n, 0);
    
    for (int i = 0 ; i < n + 1; i++) { cin >> as[i]; }
    for (int i = 0 ; i < n; i++) { cin >> bs[i]; }

    lli ans = 0;
    ans += min(as[n], bs[n-1]);
    bs[n-1] -= min(as[n], bs[n-1]);
    for (int i = n - 1; i > 0; i--) {
        lli d = as[i];
        lli t = min(as[i], bs[i]);
        ans += t;
        as[i] -= t;
        t = min(as[i], bs[i-1]);
        ans += t;
        bs[i-1] -= t;
    }
    ans += min(as[0], bs[0]);
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> e(n);
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    ll ans = k;
    queue<int> que;
    que.push(0);
    bool reached[n] = {};
    reached[0] = true;
    int depth = 0;

    if ((int)e[0].size() + 1 > k) {
        cout << 0 << endl;
        return 0;
    }

    while (!que.empty()) {
        int now = que.front();
        que.pop();
        depth++;
        int sz = e[now].size();
        rep(i, 0, sz) {
            int next = e[now][i];
            if ((int)e[next].size() + 1 > k) {
                cout << 0 << endl;
                return 0;
            }
            if (reached[next]) continue;
            que.push(next);
            reached[next] = true;
        }
        if (depth == 1) {
            rep(i, 1, sz + 1) {
                ans *= (k - i);
                ans %= MOD;
            }
        }
        if (depth >= 2) {
            rep(i, 1, sz) {
                ans *= (k - i - 1);
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6648
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println((x*x*x));
        }
        catch (IOException e) {
            System.out.println(e);
        }
        catch(NumberFormatException e){
            System.out.println("The input age was not correct");
        }
    }
}


Measured memory_bytes: 24308
import math
n_ = 10**5 + 3
mod = 10**9+7
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def nCr(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
count=0
for i in range(N-K+1):
    count=(count+((A[i]-A[N-1-i])*nCr(N-i-1,K-1)))%(10**9+7)
print(count)

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

int main()
{

  int n,m;
  cin >> n >> m;

  int c[1001],d[1001];
  for(int i = 1; i <= n;i++) cin >> d[i];
  for(int j = 1; j <= m;j++) cin >> c[j];

  int dp[1001];
  const int INF = 1000000001;
  for(int i = 1;i <= n ;i++) dp[i] = INF;
  dp[0] = 0;

  for(int j = 1;j <= m; j++){
    for(int i = n ;i > 0; i--){
      int move = dp[i-1] + c[j]*d[i];
      if(move < dp[i])	dp[i] = move;
    } 
  }
  cout << dp[n] << endl;
  return 0;

}


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

int main(){
  int X; cin >> X;
  if(X<4){
    cout << 1 << endl;
    return 0;
  }
  int mx=0,kouho;
  for(int i=2; i<sqrt(X); i++){
    kouho=i*i;
    while(kouho<=X){
      mx=max(mx,kouho);
      kouho*=i;
    }
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int i,s=0x6ffffff;
    cin>>a;
    for(i=1;i<a.length();i++){
    if(a[i]!=a[i-1]){
    s=min(s,max(i,(int)a.length()-i));
    }}
    cout<<min(s,(int)a.length())<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int H, W, i, t;

	while (1)
	{
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0) 
			break;

		for (i = 0; i < H; i++)
		{
			for (t = 0; t < W; t++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2044
import java.util.*;
import java.math.BigDecimal;

public class Main{
    public static void main(String[] args){
        BigDecimal A, B;
        Scanner sc = new Scanner(System.in);
        A =sc.nextBigDecimal();
        B = new BigDecimal(2).multiply(A).multiply(new BigDecimal(3.14159265359));
        System.out.println(B);
    }
}



Measured memory_bytes: 37452
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

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

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main() {
	int n;
	cin >> n;
	VI p(n);
	vector<bool> a(n);
	rep(i, n) {
		cin >> p[i];
		if (i + 1 == p[i]) a[i] = true;
		else a[i] = false;
	}

	int cnt = 0;
	rep(i, n) {
		if (a[i] == true) {
			cnt++; i++;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
//	FAST;
	ll n,tw,i,j;
	ll m = 100000000000000;
	cin >> n >> tw;
	ll w[n],v[n];
	fr(i,0,n)
		cin >> w[i] >> v[i];
	ll k[2][100001];
	fr(i,0,n+1)
	{
		fr(j,0,100001)
		{
			if(j == 0)
				k[1][j] = 0;
			else if(i == 0)
				k[1][j] = m;
			else
				k[1][j] = min(k[0][j], k[0][max((ll)0,(j-v[i-1]))] + w[i-1]);
		}
		fr(j,0,100001)
			k[0][j] = k[1][j];
	}
	for(i=100000;i>=0;i--)
	{
		if(k[0][i] <= tw)
		{
			cout << i;
			return 0;
		}
	}
}


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

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

///////////////////////////////////////////////////////////////////////////


int main() { 

    string S;
    cin >> S;

    if(S == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3572
#include <iostream>
#include <numeric>

using namespace std;

int main(){

    int n;
    cin >> n;

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

    int ans = accumulate(w, w+n, 0);

    for(int t=0; t<n-1; t++){
        int s1 = accumulate(w, w+t+1, 0);
        int s2 = accumulate(w+t+1, w+n, 0);
        
        if(abs(s1-s2) < ans){
            ans = abs(s1-s2);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import exit
N = int(input())
 
cnt = 0
for i in range(N):
    x,y = map(int,input().split())
    if cnt == 3:
        print("Yes")
        exit(0)
    if x == y:
        cnt += 1
    else:
        cnt = 0

if cnt == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62316
#
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
#
s = 0
next_i = 0
opt = 0
for i in range(0,n):
    s = s + b[a[i]-1]
    if a[i] == next_i:
        s = s + opt
    next_i = a[i]+1
    if next_i <= n:
        opt = c[a[i]-1]
    else:
        opt = 0

print(s)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
#define fr(i,n) for(int i=0;i<n;i++)

int main()
{
    std::ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector <int> h(n);
    vector <int> dp(n,INF);
    for(int &x:h){cin>>x;}
    dp[0]=0;
    for(int i=1;i<n;i++)
    {   int y = INF;
        for(int j=i-k;j<i;j++)
        {
            if(j<0){j=0;}

            auto x=dp[j]+abs(h[i]-h[j]);

            if(x<y){y=x;}
        }
        dp[i]=y;
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef pair<ll, double> PD;
//ll mod = 1000000009;
//ll mod = 998244353;

int gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n%m);
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
}

Measured memory_bytes: 256
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };






signed main() {
	int n;
	vector<double>list;
	double m, sum=0;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		double num;
		cin >> num;
		list.push_back(num);
		sum += num;
	}

	double jyo = sum / (4 * m);
	int cnt = 0;

	for (int i = 0; i < n; i++) {
		if (jyo <= list[i])cnt++;
	}

	if (cnt >= (int)m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int A,B,C;
    cin >> A >> B >> C;
    cout << ((A<C && C<B || C<A && B<C) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s1=sc.next();
    char[] c1=s1.toCharArray();
    String s2=sc.next();
    char[] c2=s2.toCharArray();
    boolean flg=false;
    if(c1[0]==c2[2]){
      if(c1[1]==c2[1]){
        if(c1[2]==c2[0]){
          flg=true;
        }
      }
    }
    if(flg){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 22484
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
long long o[2][2351][2201];
long long l[2221];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[3];

P u[1];
queue<P> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<int> v[3];


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
  
}

long long f(int i,int n,int m)
{
  if(n==0) return 0;
  if(a-n-m+1==b)
  {
    return l[max(a-b-1,0)];
  }
  //printf("%d %d %d\n",i,n,m);
  if(o[i][n][m]>=0) return o[i][n][m];
  long long x=f(0,n-1,m+1);
  x+=f(1,n-1,m);
  x%=mod;
  if(i&&m) x=(x+f(1,n,m-1))%mod;
  return o[i][n][m]=x;
  
}

int main()
{
  l[0]=1;
  for(int t=1;t<=2010;t++)
  l[t]=l[t-1]*2%mod;
  memset(o,-1,sizeof(o));
  scanf("%d %d",&a,&b);
  printf("%lld",f(0,a,0));
}
//0
//16




Measured memory_bytes: 81408