akhauriyash/Code-Regression huggingface dataset:
const val DREAM = "dream"
const val DREAMER = "dreamer"
const val ERASE = "erase"
const val ERASER = "eraser"

fun main(args: Array<String>) {
    var s = readLine()!!
    while(s.isNotEmpty()){
        when{
            s.startsWith(DREAMER)
                    && !s.substringAfter(DREAM).startsWith(ERASE) -> {
                s = s.substringAfter(DREAMER)
            }
            s.startsWith(ERASER)
                    && !s.substringAfter(ERASE).startsWith(ERASE)  -> {
                s = s.substringAfter(ERASER)
            }
            s.startsWith(DREAM) -> {
                s = s.substringAfter(DREAM)
            }
            s.startsWith(ERASE) -> {
                s = s.substringAfter(ERASE)
            }
            else -> {
                println("NO")
                return
            }
        }
    }
    println("YES")
}

Measured memory_bytes: 116512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class c> auto try_out(c a) -> decltype(cerr << a, 0);
char try_out(...);
struct debug {
#ifdef LOCAL
template<class c, class d> debug& operator << (pair<c,d> e) {
	return *this << "(" << e.first << ", " << e.second << ")";
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) != 1, debug&>::type operator << (c a) {
	cerr << boolalpha << a;
	return *this;
}
template<class c> typename enable_if<sizeof(try_out(declval<c>())) == 1, debug&>::type operator << (c a) {
	*this << "{";
	for (auto it = a.begin(); it != a.end(); it++)
		*this << ","[1 - (it != a.begin())] << *it;
	return *this << "}";
}
#else
template<class c> debug& operator << (c) {
	return *this;
}
#endif
};
#define err(x) debug() << "[" << #x << ": " << x << "]\n"
#define sz(x) ((int) (x).size())









int32_t main() 
{
	int n, p;
	cin >> n >> p;
	cout << (n * 3 + p) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long LL;

const int MOD = 1e9+7;

int dfs(vector<int> &dp,int h,vector<vector<int>>&table){
    if(h<=0) return 0;
    if(dp[h]!=-1) return dp[h];
    int cnt  = MOD;
    for(auto item:table){
        cnt = min(cnt,dfs(dp,h-item[0],table)+item[1]);
    }
    dp[h] = cnt;
    return dp[h];
}
void solve(){
    int h,n;
    cin>>h>>n;
    vector<vector<int>> table(n,vector<int>(2,0));
    for(int i=0;i<n;i++) cin>>table[i][0]>>table[i][1];
    vector<int> dp(h+1,-1);
    dp[0]= 0;
    cout<<dfs(dp,h,table)<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}



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

using namespace std;

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

    vector<string> list;

    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 1; j < 6; j++)
        {
            string q = s.substr(i, j);
            int c = count(list.begin(), list.end(), q);
            if (c == 0)
            {
                list.push_back(q);
            }
        }
    }
    sort(list.begin(), list.end());
    list.erase(unique(list.begin(), list.end()), list.end());
    cout << list[k - 1] << endl;
}

Measured memory_bytes: 1024
/*
ID: duttonl1
TASK: Knapsack_1.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

ll dp[100][100005];
int weight[105], val[105];
int N, W;

ll solve(int idx, int remW) {
    if (remW == 0 || idx == N) return 0;
    if (dp[idx][remW] != -1) return dp[idx][remW];
    if (weight[idx] > remW) {
        dp[idx][remW] = solve(idx + 1, remW);
    }
    else {
        dp[idx][remW] = 
            max(solve(idx+1, remW), 
                val[idx] + solve(idx+1, remW - weight[idx]));
    }
    return dp[idx][remW];
}

void run() {
    cin >> N >> W;
    fr(i,N) cin >> weight[i] >> val[i];
    memset(dp, -1, sizeof(ll) * 100 * 100005);
    cout << solve(0, W) << endl;
}




Measured memory_bytes: 78336
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_080_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC 9(2).

    01 T      PIC 9(4).

    01 INP    PIC X(12).
    01 a      PIC 9(3).
    01 b      PIC 9(4).
    01 ans    PIC X(4).

    01 ZS     PIC Z(4)9.
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO N A B.

    IF A * N <= B THEN
        MULTIPLY A BY N GIVING T
    ELSE
        MOVE B TO T
    END-IF

    MOVE T TO ZS

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <climits>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include<ctime>
#include<set>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n;
int d[100000];
cin>>n;
int i1=0,i2=0;
for(int i=0;i<n;i++)
{
     cin>>d[i];
     if(d[i]%4==0)
        i1++;
     else if(d[i]%2!=0)
        i2++;
}
if(i1+i2==n&&i2==i1+1)
    cout<<"Yes"<<endl;
else if(i1>=i2)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;



}


Measured memory_bytes: 640
import numpy as np

hoge = input().split()
N = int(hoge[0])
D = int(hoge[1])
X = []
hage = []
for i in range(N):
  huga = input().split()
  for j in range(D):
    hage.append(int(huga[j]))
  X.append(hage)
  hage = []

count = 0
huga = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(0,D):
      huga += pow(X[i][k] - X[j][k],2)
    if np.sqrt(huga).is_integer() == True:
      count += 1
    huga = 0
    
print(count)

Measured memory_bytes: 12408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
#define pb push_back
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};

ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}



void solve(){
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<s.size();i++){
		string g;
		g=s[i];
		ans+=stoi(g);
	}
if(ans%9==0){
	cout<<"Yes"<<endl;

}
else{
	cout<<"No"<<endl;

}
	
	
	
	return;
}




int main()
{  
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
    fast;
    ll t;
    t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    
   
  



#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
return 0;
}

Measured memory_bytes: 3756
import java.util.*;

public class Main {

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

        int x = sc.nextInt();
        int a = sc.nextInt();

        if(x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }

        return;
    }
}


Measured memory_bytes: 21844
/*
[abc130] F - Minimum Bounding Box
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_XY = 1e8;
const double INF = 1e18;

int dxy[2][4] = {{0, 1, 0, -1}, {1, 0, -1, 0}};

int N;
int xy[2][MAX_N];
int d[MAX_N];

double calc(double t) {
    double m[2][2];
    for (int c = 0; c < 2; c++) {
        m[c][0] = INF;
        m[c][1] = -INF;
        for (int i = 0; i < N; i++) {
            m[c][0] = min(m[c][0], xy[c][i] + dxy[c][d[i]] * t);
            m[c][1] = max(m[c][1], xy[c][i] + dxy[c][d[i]] * t);
        }
    }

    return (m[0][1] - m[0][0]) * (m[1][1] - m[1][0]);
}

double solve() {
    double l = 0, r = 2 * MAX_XY + 1;
    for (int i = 0; i < 100; i++) {
        double m1 = (2 * l + r) / 3.0, m2 = (l + 2 * r) / 3.0;
        if (calc(m1) < calc(m2)) {
            r = m2;
        } else {
            l = m1;
        }
    }

    return calc(l);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        char d_raw;
        cin >> xy[0][i] >> xy[1][i] >> d_raw;
        switch (d_raw) {
            case 'U':
                d[i] = 0;
                break;
            case 'R':
                d[i] = 1;
                break;
            case 'D':
                d[i] = 2;
                break;
            case 'L':
                d[i] = 3;
                break;
        }
    }

    cout << setprecision(16) << fixed << solve() << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

#define int ll

int h, w;
int p[100010], q[100010];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    while (cin >> h >> w) {
        using pii = pair<int, int>;
        priority_queue<pii> Q;
        for (int i = 0; i < h; i++) {
            cin >> p[i];
            Q.emplace(-p[i], 0); // tate
        }
        for (int i = 0; i < w; i++) {
            cin >> q[i];
            Q.emplace(-q[i], 1); // yoko
        }
        int ch = h+1, cw = w+1;

        int ans = 0;
        for (int i = 0; i < h + w; i++) {
            int x, f;
            tie(x, f) = Q.top();
            Q.pop();
            x = -x;
            if (f == 0) {
                ans += x*cw;
                --ch;
            } else {
                ans += x*ch;
                --cw;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5488
#include<stdio.h>

int main(void)
{
	int n,m,p;
	int a[101][101]={0};
	int b[101][101]={0};	
	long c[101][101]={0};
	int i,j,k,l,q,s,r;

	scanf("%d %d %d",&n,&m,&p);	

	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(k=0;k<m;k++){
		for(l=0;l<p;l++){
			scanf("%d",&b[k][l]);
		}
	}

	for(q=0;q<n;q++){
		for(s=0;s<p;s++){
			for(r=0;r<m;r++){
				c[q][s]=c[q][s]+a[q][r]*b[r][s];
			}
			if(s != p-1){
				printf("%ld ",c[q][s]);
			}
			else{
				printf("%ld",c[q][s]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;


int n;
int dp[112345];
int step[40];
vector<int> vec;
int main(){
  cin>>n;
  memset(dp,sizeof(dp),0x3f);

  dp[0]=0;
  dp[1]=1,dp[6]=1,dp[9]=1;

  for(int i=1;i<112300;i++){
    dp[i]=i;
  }

  for(int j=1;pow(6,j)<=112300;j++){
    int x=pow(6,j);
    vec.push_back(x);
  }

  for(int j=1;pow(9,j)<=112300;j++){
    int x=pow(9,j);
    vec.push_back(x);
  }

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



  for(int j=0;j<(int)vec.size();j++){
    for(int i=0;i<=112300;i++){
        if(vec[j]+i<=112300)dp[i+vec[j]]=min(dp[i]+1,dp[i+vec[j]]);
    }
  }



  cout<<dp[n]<<endl;


}


Measured memory_bytes: 640
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

score = [[0, 0, 0] for i in range(N + 1)]

my_dict = {}

for i, your_hand in enumerate(T):
    i += 1

    if i <= K:
        if your_hand == "s":
            score[i][0] = R + max(score[i-1])
            score[i][1] = max(score[i-1])
            score[i][2] = max(score[i-1])
            my_dict[i % K] = "r"
        elif your_hand == "p":
            score[i][0] = max(score[i-1])
            score[i][1] = S + max(score[i-1])
            score[i][2] = max(score[i-1])
            my_dict[i % K] = "s"
        else:
            score[i][0] = max(score[i-1])
            score[i][1] = max(score[i-1])
            score[i][2] = P + max(score[i-1])
            my_dict[i % K] = "p"

    else:
        if your_hand == "s":
            if my_dict[i % K] == "r":
                score[i][0] = max(score[i-1])
                score[i][1] = max(score[i-1])
                score[i][2] = max(score[i-1])
                my_dict[i % K] = ""
            else:
                score[i][0] = R + max(score[i-1])
                score[i][1] = max(score[i-1])
                score[i][2] = max(score[i-1])
                my_dict[i % K] = "r"
        elif your_hand == "p":
            if my_dict[i % K] == "s":
                score[i][0] = max(score[i-1])
                score[i][1] = max(score[i-1])
                score[i][2] = max(score[i-1])
                my_dict[i % K] = ""
            else:
                score[i][0] = max(score[i-1])
                score[i][1] = S + max(score[i-1])
                score[i][2] = max(score[i-1])
                my_dict[i % K] = "s"
        else:
            if my_dict[i % K] == "p":
                score[i][0] = max(score[i-1])
                score[i][1] = max(score[i-1])
                score[i][2] = max(score[i-1])
                my_dict[i % K] = ""
            else:
                score[i][0] = max(score[i-1])
                score[i][1] = max(score[i-1])
                score[i][2] = P + max(score[i-1])
                my_dict[i % K] = "p"

ans = max(score[N])
print(ans)



Measured memory_bytes: 68400
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll 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;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll dp[25][1010];

int main(){
    int n,k; cin >> n >> k;
	vl a(k); rep(i,k) cin >> a[i];
	comInit();
	dp[0][0] = 1;
	rep(i,k){
		rep(j,n+1){
			rep(k,a[i]+1){
				if(j+k > n) continue;
				dp[i+1][j+k] += dp[i][j] * com(n-j, k) % mod * com(n-k, a[i]-k) % mod;
				dp[i+1][j+k] %= mod;
			}
		}
	}
	cout << dp[k][n] << "\n";
}

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

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

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

  int a, b;
  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int M, N, dp[1 << 15];
int w[200010], t[200010];
int c[20], b[20];

signed main() {
    cin >> M >> N;
    for(int i=0; i<M; i++) {
        cin >> w[i+1] >> t[i+1];
        w[i+1] += w[i];
        t[i+1] += t[i];
    }
    for(int i=0; i<N; i++) {
        cin >> c[i] >> b[i];
    }

    fill(dp, dp + (1 << N), -1);
    dp[0] = 0;
    for(int bit=0; bit<(1<<N); bit++) {
        for(int i=0; i<N; i++) {
            if(bit >> i & 1) continue;
            int nbit = bit | (1 << i);
            int baseW = w[ dp[bit] ];
            int baseT = t[ dp[bit] ];

            int idx = upper_bound(w, w+M+1, baseW + c[i]) - w - 1;
            int jdx = upper_bound(t, t+M+1, baseT + b[i]) - t - 1;
            int k = min(idx, jdx);
            chmax(dp[nbit], k);
        }
    }

    cout << dp[(1 << N) - 1] << endl;
    return 0;
}


Measured memory_bytes: 6468
import Debug.Trace

main :: IO ()
main = do
    n <- readLn
    putStrLn $ solve n

solve :: Integer -> String
solve x
  | x <= 26 = [['a'..] !! fromIntegral (x - 1)]
  | (q, r) <- divMod (x - 1) 26 = solve q ++ [['a'..] !! fromIntegral r]

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  int tmp;
  
  for (int i=0;i<N;i++){
    cin >> tmp;
    V.at(i) = tmp;
  }
  sort(V.begin(),V.end());
  float ans=V.at(0);
  for (int j=1;j<N;j++){
    ans = (ans + V.at(j)) / 2;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
from sys import stdin
from copy import deepcopy

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

tmp = LI()

print(tmp[0]*tmp[1])

Measured memory_bytes: 9356
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()
    ans = 0
    
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if inlis[i] + inlis[j] > inlis[k] and inlis[k] - inlis[j] < inlis[i] and inlis[i] != inlis[j] and inlis[j] != inlis[k] and inlis[k] != inlis[i]:
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 67636
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
		    int n=Integer.parseInt(br.readLine());
		    
		   if(n>=30){
		       System.out.println("Yes");
		   }
		   else{
		        System.out.println("No");
		   }
		   
		    
		
    }
}

Measured memory_bytes: 25352
from collections import deque

n = int(input())
a_list = deque(map(int, input().split()))

p = 1
ans = 0
while len(a_list) > 0:
    if a_list.popleft() == p:
        p += 1
    else:
        ans += 1
if ans == n:
    ans = -1
print(ans)


Measured memory_bytes: 25244
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
  int n;
  P team[1000010];
  while(cin >> n , n){
    for(int i=0;i<n;i++){
      cin >> team[i].second;
      team[i].first = 0;
      for(int j=0;j<8;j++){
	int a; scanf("%d",&a);
	if(j % 2 == 0) team[i].first += a*60;
	else team[i].first += a;
      }
    }
    sort(team,team+n);
    cout << team[0].second << endl;
    cout << team[1].second << endl;
    cout << team[n-2].second << endl;
  }  
}

Measured memory_bytes: 9060
S = input()
T = input()

cnt = 0
l = []
for i in range(len(S)-len(T)+1):
    text = S[i:i + len(T)]
    for j in range(len(T)):
        if text[j] == T[j]:
            cnt += 1
    l.append(cnt)
    cnt = 0

print(len(T)-max(l))



Measured memory_bytes: 9104
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif


static void ABC112C_Pyramid();

#if 1
int main()
{
	ABC112C_Pyramid();

	fflush(stdout);
	return 0;
}
#endif



class ABC112C_dataset
{
public:
	int x = 0;
	int y = 0;
	int h = 0;
};



static bool ABC112C_dfs(const int maxHeight, int& calcH, int cx, int cy, ABC112C_dataset* data, int nowIdx, int dataCnt)
{
	if (nowIdx == dataCnt) {
		return true;
	}

	int X, Y;

	if (cx > data[nowIdx].x) {
		X = cx - data[nowIdx].x;
	}
	else {
		X = data[nowIdx].x - cx;
	}
	if (cy > data[nowIdx].y) {
		Y = cy - data[nowIdx].y;
	}
	else {
		Y = data[nowIdx].y - cy;
	}

	int height = data[nowIdx].h + X + Y;

	if ((calcH <= 0) && (maxHeight > 0) && (data[nowIdx].h > 0)) {
		calcH = height;
	}
	else if ((maxHeight <= 0) && (nowIdx == 0)){
		calcH = height;
	}

	if ((calcH == height) || ((maxHeight > 0) && (data[nowIdx].h == 0))) {
		if (ABC112C_dfs(maxHeight, calcH, cx, cy, data, nowIdx + 1, dataCnt)) {
			if (((calcH - X - Y) <= 0) || ((calcH - X - Y) == data[nowIdx].h)) {
				return true;
			}
		}
			
	}
	return false;
}

static void ABC112C_Pyramid()
{
	int N;
	ABC112C_dataset data[101];
	scanf(" %d", &N);

	int maxHeight = 0;
	for (int i = 0; i < N; i++) {
		scanf(" %d %d %d", &(data[i].x), &(data[i].y), &(data[i].h));
		if (maxHeight < data[i].h) {
			maxHeight = data[i].h;
		}
	}

	int Cx = -1, Cy = -1, H = -1;
	for (int cx = 0; cx <= 100; cx++) {
		for (int cy = 0; cy <= 100; cy++) {
			H = -1;
			if (ABC112C_dfs(maxHeight, H, cx, cy, data, 0, N)) {

				printf("%d %d %d\n", cx, cy, H);
				return;
			}
		}
	}
	printf("0 0 0\n");
}


Measured memory_bytes: 384
def main():
  while True:
    e = int(input())
    if e == 0:
      break
    ans = 1000000
    for z in range(int(e ** (1 / 3)) + 2):
      ez = e - z ** 3
      if ez < 0:
        break
      y = int(ez ** (1 / 2))
      x = ez - y ** 2
      if x >= 0 and y >= 0 and z >= 0:
        ans = min(ans, x + y + z)
    print(ans)

main()


Measured memory_bytes: 5708
#include <stdio.h>

int main(){
    long long int a,b,x;
    scanf("%lld %lld %lld",&a,&b,&x);
    long long int c,d,e;
    if(a!=0){
    c=(a-1)/x;
    d=b/x;
    e=d-c;
    printf("%lld\n",e);
    }else{
        d=b/x;
        printf("%lld\n",d+1);
    }
    return 0;
}

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

int main(){
    //ll N;
    string S;
    cin >> S;
    rep(i,3){
        if(S[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" <<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define vst vector<string>
ll mx=INT_MAX;
ll mi=INT_MIN;
const ll mod=1e9+7;
int main()
{
    vll v,vv(102,0),vvv[250000],so(250000,0);
    ll i,j,k,n,x=0,s=0;
    cin>>x;
    ll a,b;
    for(i=-1110;i<=1110;i++)
    {
        for(b=-1101;b<=1011;b++)
        {
            if(pow(i,5)-pow(b,5)==x)
            {
                cout<<i<<" "<<b;s=1;break;
            }
        }
        if(s==1) break;
    }
    
}

Measured memory_bytes: 11012
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

const ll MAX_N = 1e5;
vll E[MAX_N];
ll ans = 1;
ll K;

void dfs(ll s, ll f, ll sc, ll nc) {
    ans = ans * sc % MOD;
    for(auto e : E[s]) {
        if(e != f) {
            dfs(e, s, nc, K - 2);
            if(nc == 0) {
                return;
            }
            nc--;
        }
    }
    return;
}

int main() {
    ll i, j, k;
    ll N;
    cin >> N >> K;
    for(i = 0; i < N; i++) {
        E[i] = vll(0);
    }
    for(i = 0; i < N - 1; i++) {
        ll a, b;
        cin >> a >> b;
        E[a - 1].push_back(b - 1);
        E[b - 1].push_back(a - 1);
    }
    dfs(0, 0, K, K - 1);
    cout << ans << endl;

    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N, X;
    cin >> N >> X;
    if(500*N >= X){
        P("Yes");
    }else{
        P("No");
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n, tmp=0, cnt[10000+1]={0};
  scanf("%d", &n);
  for(int x=1; x<=100; x++){
    for(int y=1; y<=100; y++){
      for(int z=1; z<=100; z++){
        tmp = x*x + y*y + z*z + x*y + y*z + z*x;
        if( tmp <= 10000 ){ cnt[tmp]++; }
      }
    }
  }
  for(int i=1; i<=n; i++){ printf("%d\n",cnt[i]); }
  return 0;
}


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

using namespace std;

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

main(){
    int n;
    scanf("%d",&n);
    ll arr[n+1];
    arr[0] = 2; arr[1] = 1;
    for(int i=2;i<=n;++i){
       arr[i] = arr[i-1] + arr[i-2]; 
    }
    cout << arr[n] << endl;
}

Measured memory_bytes: 256
while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0): break
    c = 0
    for i in range(1,num[0]+1):
        for j in range(i+1,num[0]+1):
            if j <= i:
                continue
            k = num[1]-(i+j)
            if k > j and k <= num[0]:
                c+= 1
    print(c)


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

int main(){
    int s,m,h;
    
    cin>>s;
    
    h= s/3600;
    s= s%3600;
    m= s/60;
    s= s%60;
    
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


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

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

struct job_t {
    ll cost;
    ll deadline;
    bool passed;
};

int dfs(ll current, vector<job_t> job, ll id) {
    current += job[id].cost;

    return 0;
}

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

    vector<job_t> job(N);

    for (int i = 0; i < N; i++){ 
        ll a, b;
        cin >> a >> b;
        job[i] = job_t({ a, b, false });
    }

    sort(job.begin(), job.end(), [](job_t a, job_t b) { return a.deadline < b.deadline; });

    ll total = 0;
    bool flag = false;
    for (const auto j : job) {
        total += j.cost;
        if (total > j.deadline) {
            cout << "No";
            flag = true;
            break;
        }
    }

    if (!flag) {
        cout << "Yes";
    }

 
    return 0;
}



Measured memory_bytes: 4992
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    lli a,b,c,cnt=0;
    cin>>a>>b>>c;
    while(a%2==0&&b%2==0&&c%2==0)
    {
        if(a==b&&b==c)
        {
            cnt=-1;
            break;
        }

        cnt++;

        lli x=(b+c)/2,y=(a+c)/2,z=(a+c)/2;
        a=x;
        b=y;
        c=z;
    }
    cout<<cnt<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//フィールド
		int n = 0;
		ArrayList<Integer> uniqueList = new ArrayList<Integer>();
		//リスト作成
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		ArrayList<Integer> intList = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			int x = scanner.nextInt();
			intList.add(x);
		}


		System.out.println(new HashSet<>(intList).size());
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    string s;
    cin>>s;
    int ans,a=0,b=0,fa=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' && fa==0){
            a=i;
            fa=1;
        }else if(s[i]=='Z' && i>b){
            b=i;
        }
    }
    cout<<b-a+1<<endl;
    return 0;
}

Measured memory_bytes: 640
num_of_odd = num_of_even = 0
n, a, b  = map(int, input().split())

if a == 1 and b == 2:
    print('Borys')
elif a == n and b == n-1:
    print('Borys')
elif a < b:
    if (b-a) % 2:
        print('Borys')
    else:
        print('Alice')
elif a > b:
    if (a-b) % 2:
        print('Alice')
    else:
        print('Borys')

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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  for(i=1;i<s.size();i++){
    if(s[i-1]=='A' && s[i]=='C'){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val argList = (1..n).map {
        val tmp = readLine()!!.split(' ')
        tmp.subList(1, tmp.lastIndex + 1).map(String::toInt)
    }
    val count = (1..m).filter { num ->
        argList.all { it.contains(num) }
    }.count()
    println(count)
}

Measured memory_bytes: 38304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{ 
  int N;
  cin>>N;
  vector<int> vec (N+1,0);
  int S = 0;
  for (int i = 0; i <= N; i++)
  {
     cin>>vec[i];
     S += vec[i];
  }

  if((N > 0 && vec[0]>0 )||( N == 0 && vec[0] > 1))
  {
    cout<<-1<<endl;
    return;
  }

  int M = 1;
  int ANS = 1;
  vec.push_back(0);
  for (int i = 1; i <= N; i++)
  {
    M = min((int)(M<<1),S);
    ANS += M;
    if(vec[i] > M)
    {
      cout<<-1<<endl;
      return;
    }
    M -=vec[i];
    S -=vec[i];
  }
  


  cout<<ANS<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4748
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array

void maxself(int& a, int b){
    a = max(a, b);
}

void solve() {
    int n, w;
    cin >> n >> w;
    vector<int> dp(w+1); //0....w
    //dp[i] means the total maximum value of items with total weight exactly equal to i
    for(int item = 0;item < n; item++){
        int weight, value;
        cin >> weight >> value;
        for(int wa = (w-weight);wa >= 0; wa--){
            maxself(dp[wa+weight],dp[wa]+value);
        }
    }
    int ans = 0;
    for(int i = 0;i <= w; i++){
        maxself(ans,dp[i]);
    }
    cout << ans << "\n";
}

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

    int TC = 1;
    while (TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3960
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long n;
	cin >> n;
	long long n1 = n - 1;
	long long ans = 0;
	for (long long i = 1; i * i <= n1; i++) {
		if (n1 % i == 0) {
			if (i != 1) {
				ans++;
			}
			if ((n1 / i) != 1 && (n1 / i) != i) {
				ans++;
			}
		}
	}
	for (long long j = 1; j * j <= n; j++) {
		if (n % j == 0) {
			long long n2 = n;
			if (j != 1) {
				while (n2 % j == 0) {
					n2 /= j;
				}
				if (n2 % j == 1) {
					ans++;
				}
			}
			n2 = n;
			long long n3 = n / j;
			if (n3 != j) {
				while (n2 % n3 == 0) {
					n2 /= n3;
				}
				if (n2 % n3 == 1) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
N = int(input())

result = N
for i in range(0,N+1):
    count = 0
    tmp = i 
    while tmp > 0:
        count += tmp%6
        tmp //= 6
    tmp = N - i 
    while tmp > 0:
        count += tmp%9
        tmp //=9
    
    if result > count:
        result = count

print(result)

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 105;
int N, K;
int A[MAX_N];

signed main()
{
  cin >> N >> K;
  REP(n,MAX_N) {
    cin >> A[n];
  }

  int ans = 0;
  // )
  REP(l,N+1) {
    //[
    FOR(r,l,N+1) {
      int opecnt = l+(N-r);
      if(opecnt > K) {
        continue;
      } else {
        vector<int> v;
        int tmp = 0;
        REP(n,l) {
          v.emplace_back(A[n]);
        }
        FOR(n,r,N) {
          v.emplace_back(A[n]);
        }
        sort(begin(v), end(v));

        for(int vv : v) {
          if(vv < 0 && opecnt < K) {
            opecnt++;
            continue;
          }
          tmp += vv;
        }

        ans = max(ans, tmp);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from itertools import product

num = list(map(int, list(input())))
flag = False

for i in product(("+", "-"), repeat=3):
    # print(i)
    calc = num[0]
    for j, opt in enumerate(list(i)):
        if opt == "+":
            calc += num[j+1]
        else:
            calc -= num[j+1]

        if calc == 7:
            print("{}{}{}{}{}{}{}=7".format(num[0], i[0], num[1], i[1], num[2], i[2], num[3]))
            flag = True
            break

    if flag:
        break


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
 
  class Main {
 
    public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      int c = scanner.nextInt();
        int[] foo = {a, b, c};
         
        Arrays.sort(foo);
        
        System.out.println(foo[0] + " " + foo[1] + " " + foo[2]);
        scanner.close();
    }
 
}


Measured memory_bytes: 26372
#include <iostream>

using namespace std;

int main() {
    int X[] = {1, 5, 10, 50, 100, 500};

    int A = 0;
    for (int i = 0; i < 6; i++) {
        int C; cin >> C;
        A += X[i] * C;
    }
    cout << (A >= 1000) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
int main() {
  int N;
  int M;
  int C;
  scanf("%d %d %d",&N, &M, &C);

  int B[21];
  int i;
  for ( i = 0; i < M; ++i) {
    scanf("%d", &B[i]);
  }

  int A[21][21];
  int j;
  for ( i = 0; i < N; ++i) {
    for (j = 0; j < M; ++j) {
      scanf("%d", &A[i][j]);
    }
  }

  int test;
  int ans = 0;
  for ( i = 0; i < N; ++i) {
     for (j = 0; j < M; ++j) {
       test += A[i][j]*B[j];
     }
     test += C;
     if (test > 0) {
       ++ ans;
     }
     test = 0;
  }

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

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

vector<int> G[200000];
int N,Q;
ll ans[200000];
ll P[200000] = {0};

void dfs(int now,ll cnt, int pa){
  ans[now] = cnt;
  for(int i(0);i<int(G[now].size());i++){
    int next = G[now][i];
    if (pa != next) dfs(next,cnt+P[next], now);
  }
}

int main(){
  cin>>N>>Q;
  for(int i(0);i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for(int i(0);i<Q;i++){
    int p,x;
    cin>>p>>x;
    p--;
    P[p] += x;
  }
  dfs(0,P[0],-1);
  for(int i(0);i<N;i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 31872
n, k = map(int, input().split())
a = list(map(int, input().split()))+[0]
s = [0 for _i in range(n+1)]
for i in range(n):
    s[max(0, i-a[i])] += 1
    s[min(n, i+a[i]+1)] -= 1   
a = s.copy()+[0]
for j in range(min(100, k-1)):
    t = [0 for _i in range(n+1)]
    for i in range(n):
        a[i] += a[i-1]
        t[max(0, i-a[i])] += 1
        t[min(n, i+a[i]+1)] -= 1
    a = t.copy()+[0]
for i in range(1, n):
    a[i] += a[i-1]
print(*a[:n])

Measured memory_bytes: 193012
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<stdio.h>

using namespace std;
#define INF 1e15
#define MAX_V 100000

typedef struct{
    int to;
    long cost;
} edge; // 辺を定義

typedef struct{
    long dist; //　計算された距離
    int v; // ノードのインデックス
} vtx;

bool operator< (const vtx a, const vtx b){
    return a.dist > b.dist;  // ascend　これで小さい順に　vtxが出てくる
}
bool operator> (const vtx a, const vtx b){
    return a.dist < b.dist;  // ascend　これで小さい順に　vtxが出てくる
}

long distance(int s, int g, vector<edge> * G, int N){  // 結局は隣接リストに行先のその辺のコストを渡せば十分である。
    long d[N];
    fill(d, d + N, INF);

    priority_queue< vtx > que;
    d[s] = 0;
    que.push(vtx{d[s], s});
    
    while(!que.empty()){
        vtx now = que.top(); que.pop();
        if(now.dist > d[now.v]) continue;
        for(edge e : G[now.v]){
            if(d[e.to] > d[now.v] + e.cost){
                d[e.to] = d[now.v] + e.cost;
                que.push(vtx{d[e.to], e.to});
            }         
        }
    }
    if(d[g] == INF) return -1;
    else return d[g];
}

int main(){
    int N, M;
    cin >> N >> M;
    int l, r;
    long c;
    vector<edge> G[N];
    for(int i=0; i<M; i++){
        cin >> l >> r >> c;
        l--; r--;
        G[l].emplace_back(edge{r, c});
    }
    for(int i=0; i<N-1; i++) G[i+1].emplace_back(edge{i, 0});
    cout << distance(0, N-1, G, N) << endl;
    return 0;
}

Measured memory_bytes: 9340
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    std::string s; std::cin >> s;
    std::cout << s.substr(0, 3) << std::endl;
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//
	
	int n;
	cin >> n;
	cout << n * (n+1) / 2 << endl;

	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    ll n;cin>>n;
    char s[2][n];
    rep(i,2) rep(j,n) cin>>s[i][j];

    int cnt=0,cnt2=0;
    ll ans=3;
    rep(i,n){
        if(i==0&&s[0][0]==s[1][0]) continue;
        else if(i==0&&s[0][0]!=s[1][0]){
            i++;
            ans=6;
            continue;
        }
        if(i>0){
            if(s[0][i]==s[1][i]){
                if(s[0][i-1]!=s[1][i-1]) continue;
                else cnt++;
            }
        else{
            if(s[0][i-1]!=s[1][i-1]){
                cnt2++;
                i++;
            }
            else{
                cnt++;
                i++;
            }
        }
    }
    }

    while(cnt){
        ans=ans*2%MOD;
        cnt--;
    }
    while(cnt2){
        ans=ans*3%MOD;
        cnt2--;
    }

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


Measured memory_bytes: 256