akhauriyash/Code-Regression huggingface dataset:
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 10;
int n ;
int a[N] , cnt[62][2];
main(){
	scanf("%lld" , &n);
	rep(i , 1 , n)
		scanf("%lld" , a + i);

	int ans = 0;

	repb(i , n , 1){
		rep(j , 0 , 60){
			if(a[i] & (1ll << j)){
				ans += ((1ll << j)%mod*(cnt[j][0]))%mod;
				ans %= mod;
			}else ans += ((1ll << j)%mod*(cnt[j][1]))%mod , ans %= mod;
		}
		rep(j , 0 , 60){
			if(a[i] & (1ll << j)){
				cnt[j][1]++;
			}else cnt[j][0]++;
		}
	}
	cout << ans;
		
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
 
    string s;
    cin >> s;
    string res = "No";
    int num = s.size();
    rep(i,num-1) {
        if(s[i]==s[i+1]) continue;
        else res = "Yes";
    }
 
    cout << res;
 
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int h[n];
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	int mx = 0, ans = 0;
	for(int i = 0; i < n; i++){
		if(h[i] >= mx){
			ans++;
			mx = h[i];
		}
	}
	cout << ans;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	int ans = 0;
	rep(i,n){
		int l,r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		vi p(n);
		for(auto&m:p) scanf("%d", &m);

		int s=0;
		for(int i=0;i<k;i++)
		{
			s+=p[i];
		}
		int s_max=s;
		for(int i=k;i<n;i++)
		{
			s+=p[i]-p[i-k];
			if(s_max<s) s_max=s;
		}
		double ans=0.5*(s_max+k);
		printf("%f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C, K = [int(x) for x in input().split()]

    ans = 0
    if K <= A:
        print(K)
        return
    elif K <= A + B:
        print(A)
        return
    else:
        ans = A
        print(ans - (K - (A + B)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
import numpy as np
import math
import itertools

N = int(input())

X = []
for i in range(N):
  X.append(list(map(int,input().split())))

pattern = list(itertools.combinations(X, 2))
pattern2 = list(itertools.permutations(X))
dist_list = []

for i in pattern:
  a = np.array(i[0])
  b = np.array(i[1])
  dist_list.append(np.linalg.norm(a-b))
  
#係数求める
kaijou = math.factorial(N)
nC2 = len(pattern2)

k = (kaijou * (N-1)) / nC2

print(sum(dist_list)*k / len(pattern))

Measured memory_bytes: 16996
#include<bits/stdc++.h>
using namespace std;
int n,d[101],tmp,res;
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&tmp);
    if(d[tmp]==0){
      res++;
    }
    d[tmp]++;
  }
  printf("%d",res);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
typedef long double ld;
typedef pair <int,int> pii;
typedef vector <int> vi;
typedef long long ll;

void pre(){

}

void solve(){

  int n; cin>>n;
  map <int,int> m1;
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      for(int k=1;k<=100;k++){
        int temp=((i*i)+(j*j)+(k*k)+(i*k)+(i*j)+(j*k));
        m1[temp]++;
      }
    }
  }

  for(int i=1;i<=n;i++){
    cout<<m1[i]<<"\n";
  }
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  pre();
  int t; t=1;
  rep(i,t) solve();
  return 0;
}

/* Cherry, Please look at the stuff down */

/* 1) Did you checked special case (n==1)?
   2) Look at the code once, check whether there are some typos
   3) Cherry! Is contest over ??
   4) Do something instead of doing notthing
*/


Measured memory_bytes: 5488
#include<stdio.h>
int main(){
    int a, b, c, d;
    scanf("%d %d %d", &a, &b, &c);
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    if(a > b){
        d = a;
        a = b;
        b = d;
    }
    if(b > c){
        d = b;
        b = c;
        c = d;
    }
    printf("%d %d %d\n", a, b, c);
}


Measured memory_bytes: 2012
import math

def lcm(x, y):
    return x * y // math.gcd(x, y)

A, B, C, D = [int(_) for _ in input().split()]

a = A - 1
cd = lcm(C, D)
c = B // C - a // C
d = B // D - a // D
e = B // cd - a // cd

print(B - a - c - d + e)


Measured memory_bytes: 9112
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n;cin>>n;
  vll m(5,0);
  rep(i,0,n){
    string s;cin>>s;
    if(s[0]=='M')m[0]++;
    if(s[0]=='R')m[1]++;
    if(s[0]=='A')m[2]++;
    if(s[0]=='C')m[3]++;
    if(s[0]=='H')m[4]++;
  }
  sort(m.begin(),m.end());
  ll cnt=0,ans=0;
  rep(i,0,5){
    if(m[i]==0){
      cnt++;
    }
  }
  if(cnt>=3){
    cout<<0<<endl;
  }
  else{
    rep(i,0,5){
      rep(j,0,i){
        rep(k,0,j){
          ans+=m[i]*m[j]*m[k];
        }
      }
      
    }
    cout<<ans<<endl;
  }
  
}







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

struct UnionFind
{
    vector<int> par;
    UnionFind(int n) : par(n, -1){ }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    int N, M; cin >> N >> M;
    int a[M], b[M];
    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    int bridge = 0;
    for (int i = 0; i < M; i++)
    {
        UnionFind uf(N);
        for (int j = 0; j < M; j++)
        {
            if(j != i) uf.merge(a[j], b[j]);
        }
        if(!uf.issame(a[i], b[i])) bridge++;
    }

    cout << bridge << endl;
}

Measured memory_bytes: 256
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*define
*********************************/
int input_ary[ 10000 ];

/*********************************
*function
*********************************/
int main( void )
{
	int num1;
	int num2;

	scanf( "%d %d", &num1, &num2 );

	int answer1 = num1 / num2;
	int answer2 = num1 % num2;
	double answer3 = ( double )num1 / num2;

	printf( "%d %d %.6f\n", answer1, answer2, answer3 );

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int a,b;

	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
}


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

using ll = long long;
static const ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w, k;
  cin >> h >> w >> k;
  
  vector<vector<ll>> x(h + 1, vector<ll>(w + 2));
  x.at(0).at(1) = 1;
  
  for(int i = 0; i < h; i++){
    for(int bit = 0; bit < (1 << w - 1); bit++){
      bool possible = true;
      for(int j = 0; j < w - 2; j++){
        if((bit & (1 << j)) && (bit & (1 << (j + 1)))) possible = false;
      }
      if(possible == false) continue;
      
      for(int j = 1; j <= w; j++){
        if(bit & (1 << (j - 2)) && j != 1){
          x.at(i + 1).at(j - 1) += x.at(i).at(j);
        }
        else if(bit & (1 << (j - 1))) x.at(i + 1).at(j + 1) += x.at(i).at(j);
        else x.at(i + 1).at(j) += x.at(i).at(j);
        x.at(i + 1).at(j) %= MOD;
      }
    }
  }
  
  cout << x.at(h).at(k) % MOD << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
bool comp(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	string s; cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;
	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split(" "))
l = list(map(int,input().split(" ")))
H = sorted(l,key=int) 
c = 0
if(K >= N):
    c = 0
else:
    for i in range(K):
        del H[-1]
    for i in H:
        c = c+i
print(c)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
#define int long long
#define double long double
int gcd(int x, int y){
    if (y == 0)
        return x;
    x = x % y;
    gcd(y, x);
}
int keta(int n) {
    return to_string(n).length();
}

main(){
    int n;
    cin >> n;
    string s;
    cin>>s;
    int ans=0;
    rep(i,1000){
        string t;
        int x=i;
        rep(j,3){
            t+='0'+x%10;
            x/=10;
        }
        int keta=0;
        rep(k,n){
            if(s[k]==t[keta]){
                keta++;
                if(keta==3){
                    break;
                }
            }
        }
        if(keta==3){
                    ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, ans=0; scanf("%d", &n);
	int a[n], dec[n];
	dec[0] = 0;
	for (int i=0; i<n; ++i) scanf("%d", a+i);
	for (int i=1; i<n; ++i) {
		dec[i] = a[i-1] >= a[i] ? dec[i-1] + 1 : 0;
		ans=max(ans, dec[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;

    string t = "";
    for(char c : s){
        if(c=='0'){
            t += "0";
        }
        else if(c=='1'){
            t += "1";
        }
        else{
            if(t.size()>0){
                t = t.substr(0, t.size()-1);
            }
        }
    }

    p(t);

    return 0;
}

Measured memory_bytes: 256
/*  ex9_2 Stack Cubes
    pandacodeb  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100001

typedef struct node{
    char color;
    struct node *next;
}node;

void push(node **first, char color){
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->color = color;
    new->next = *first;
    *first = new;
}

char pop(node **first){
    char color;
    node *tmp = *first;
    if (tmp == NULL)
        exit(1);
    color = tmp->color;
    *first = tmp->next;
    free(tmp);
    return color;
}

// void print_s(node **first){
//     node *tmp = *first;
//     while (tmp != NULL){
//         printf("%c", tmp->color);
//         tmp = tmp->next;
//     }
//     printf("\n");
// }

// int main(void){
//     int i;
//     char color, del;

//     //scanf("%d", &10);
//     node *first = NULL;
//     for (i = 0; i < 10; i++){
//         scanf(" %c", &color);
//         if (color == '0' || color == '1')
//             push(&first, color);
//         else
//             del = pop(&first);
//         print_s(&first);
//     }
//     return 0;
// }

int main(void){
    char *cubes, top;
    int count = 0, length;
    cubes = (char*) malloc(sizeof(char)*SIZE);
    scanf("%s", cubes);
    length = strlen(cubes);
    node *first = NULL;
    push(&first, cubes[0]);
    for (int i = 1; i < length; i++){
        if (first == NULL)
            push(&first, cubes[i]);
        else{
            top = pop(&first);
            if (top == cubes[i]){
                push(&first, top);
                push(&first, cubes[i]);
            }
            else
                count+=2;
        }
    }

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

Measured memory_bytes: 4904
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: i64 = itr.next().unwrap().parse().unwrap();
    let k: i64 = itr.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut bit: Vec<i64> = vec![0; 60];
    for i in a {
        for j in 0..60 {
            if i >> j & 1 == 1 {
                bit[j] += 1;
            }
        }
    }

    const INF: i64 = 1i64 << 60;
    let mut dp: Vec<Vec<i64>> = vec![vec![-INF; 2]; 66];
    dp[1][1] = 0;

    for i in (0..60).rev() {
        if k >> i & 1 == 1 {
            if dp[60 - i][0] != -INF {
                dp[60 - i + 1][0] = max(
                    dp[60 - i + 1][0],
                    dp[60 - i][0] + max(bit[i] * (1i64 << i), (n - bit[i]) * (1i64 << i)),
                );
            }
            if dp[60 - i][1] != -INF {
                dp[60 - i + 1][0] = max(dp[60 - i + 1][0], dp[60 - i][1] + bit[i] * (1i64 << i));
                dp[60 - i + 1][1] = max(
                    dp[60 - i + 1][1],
                    dp[60 - i][1] + (n - bit[i]) * (1i64 << i),
                );
            }
        } else {
            if dp[60 - i][0] != -INF {
                dp[60 - i + 1][0] = max(
                    dp[60 - i + 1][0],
                    dp[60 - i][0] + max(bit[i] * (1i64 << i), (n - bit[i]) * (1i64 << i)),
                );
            }
            if dp[60 - i][1] != -INF {
                dp[60 - i + 1][1] = max(dp[60 - i + 1][1], dp[60 - i][1] + bit[i] * (1i64 << i));
            }
        }
    }

    println!("{}", max(dp[61][0], dp[61][1]));
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
    for(int i=0;i<3001;i++){
        int p,q;
        cin >>p>>q;
        if(p==0 &&q==0)break;
        cout << min(p,q) <<" "<<max(p,q)  <<endl;  }
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    vector<vector<vector<ll>>> dp(n,vector<vector<ll>>(n,vector<ll>(2,0)));
    for(int i=0;i<n;i++)
    {
        dp[i][i][0]=a[i];
        dp[i][i][1]=-a[i];
    }
    for(int i=2;i<=n;i++)
    {
        for(int l=0;l+i-1<n;l++)
        {
            int r=l+i-1;
            dp[l][r][0]=max(a[l]+dp[l+1][r][1],a[r]+dp[l][r-1][1]);
            dp[l][r][1]=min(-a[l]+dp[l+1][r][0],-a[r]+dp[l][r-1][0]);
        }
    }
    cout << dp[0][n-1][0] << "\n";
    return 0;
}


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

int main(int argc, char* argv[]){
	int n;
	string s;
	cin >> n >> s;
	bool ans = true;
	if(n%2 != 0) ans = false;
	else {
		string s1,s2;
		s1 = s.substr(0,n/2);
		s2 = s.substr(n/2,n/2+1);
		if (s1 != s2) ans = false;
	}
	cout << ( ans ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String N;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = null;
        int n = Integer.parseInt(N.substring(N.length()-1, N.length()));
        if (n==2 || n==4 || n==5 || n==7 || n==9 ) {
        	answer = "hon";
        } else if (n==0 || n==1 || n==6 || n==8){
        	answer = "pon";
        } else if (n==3){
        	answer = "bon";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35572
#include<iostream>

using namespace std;

int main() {
	int a[5], k, flag = 0;
	for(int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;
	for(int i = 0; i < 5; i++) {
		if(flag != 0) {
			break;
		}
		for(int j = i + 1; j < 5; j++) {
			if(a[j] - a[i] > k) {
				flag++;
			}
		}
	}
	
	if(flag == 0) {
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;


int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)(a[0] + ('A'-'a')) << (char)(b[0] + ('A' - 'a')) << (char)(c[0] + ('A' - 'a')) << endl;

	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    
    if (a >= 13){
        cout << b << endl;
    }
    else if (a >= 6 && a <= 12){
        cout << b / 2 << endl;
    }
    else {
        cout << 0 << endl;
    }
}

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

int main() {
  int k, s;
  cin >> k >> s;
  int z = 0;
  int res = 0;
  for (int x = 0; x <= k; ++x){
    for (int y = 0; y <= k; ++y){
      z = s-x-y;
      if(0<=z && z <=k) ++res;
    }
  }
  cout << res << endl;
  return 0;
}


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

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int a[100];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0;; j++)
		{
			if (1 + a[i] * j <= d)
			{
				ans++;
			}
			else
			{
				break;
			}
		}
	}

	cout << ans + x << endl;
}

Measured memory_bytes: 256
/*
    Code by CNH_Tourist
    Date Created: 10/6/2019
*/
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unrolled-loops")

using namespace std;

/*---------------------Define--------------------*/
#define inp "TestCode.inp"
#define out "TestCode.out"
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileInOut freopen(inp,"r",stdin);freopen(out,"w",stdout);
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define X first
#define Y second
#define pi acos(-1)
#define pii pair<int,int>
#define ppiii pair< pair <int,int> ,int>
#define INF 1000000
#define endl '\n'
#define ll long long
#define pq priority_queue
const ll mod=1e9+7;
int test=1;
const int N=100100;
/*-----------------------------------------------*/

/*---------------SegmentTree Build---------------
void build(int node, int Start, int End)
{
    if(Start == End)
    {
        // Leaf node will have a single element
        tree[node] = A[start];
    }
    else
    {
        int mid = (Start + End) / 2;
        // Recurse on the left child
        build(2*node, Start, mid);
        // Recurse on the right child
        build(2*node+1, mid+1, End);
        // Internal node will have the sum of both of its children
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
------------------------------------------------*/

// dp[i][j] tong diem dat duoc vs i dong xu dau va trong do co j dong xu la tail.

int n;
double a[3030];
double dp[3030][3030];

int main()
{
    FAST
    //FileInOut
    cin>>n;
    cout<<setprecision(10)<<fixed;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1][0]=a[1];
    dp[1][1]=1-a[1];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=n/2;j++)
        {
            if(j==0)
                dp[i][j]+= dp[i-1][j]*a[i];
            else
                dp[i][j]+= (dp[i-1][j-1]*(1-a[i]) + dp[i-1][j]*a[i]);
        }
    }
    double res=0;
    for(int i=0;i<=n/2;i++)
    {
        res+=dp[n][i];
        //cout<<dp[n][i]<<" ";
    }
    cout<<endl<<res;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 300001;
static const ll MOD = 1000000007;

//--global--//



//----------//

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    
    int n;
    cin >> n;
    string str;
    cin >> str;
    int w[MAX];
    int e[MAX];
    fill(w, w+MAX, 0);
    fill(e, e+MAX, 0);
    rep2(i, 1, n){
        w[i] = w[i-1];
        if(str[i-1] == 'W'){
            w[i]++;
        }
        //cout << w[i] << endl;
    }
    for(int i=n-1-1; i>=0; i--){
        e[i] = e[i+1];
        if(str[i+1] == 'E'){
            e[i]++;
        }
        //cout << e[i] << endl;
    }
    int res = INTINF;
    rep(i, n){
        res = min(res, w[i] + e[i]);
    }

    cout << res << endl;
    return 0;
}


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

int main() {
    ll n, a, b, ans;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 0) ans = (b - a) / 2;
    else {
        if (a > n - b + 1) {
            ans = (b - a - 1) / 2 + (n - b + 1);
        } else {
            ans = (b - a - 1) / 2 + a;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::iter::Iterator;
use std::collections::HashSet;

fn main() {
    let _ = get_line();
    let input:String = get_line();
    let size = read_hash(input).len();
    let ans = if size % 2 == 0 { size-1 } else { size };
    println!("{}",ans);
}

// fn read_collection<T:Iterator::FromIterator> (s:String) -> T<u32> { type param not allowed
fn read_hash (s:String) -> HashSet<u32> {
    s.split_whitespace().map(|n|n.parse().unwrap()).collect()
}

fn get_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

Measured memory_bytes: 4092
#include <iostream>
 #include <math.h>
 #include <iomanip>
 using namespace std;
 #define ll long long

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

const double pi=acos(-1.0);

 double answer=2*R*pi;

 cout<<setprecision(20)<<fixed<<answer<<endl;
 return 0;
 }


Measured memory_bytes: 3776
'use strict'

function main(input) {
    const num = ~~(input.trim()) % 10
    switch (num) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            console.log('hon')
            break
        case 0:
        case 1:
        case 6:
        case 8:
            console.log('pon')
            break
        case 3:
            console.log('bon')
            break
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29620
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int p[200];
int main(){
	int n;
	scanf("%d",&n);
	int d[3][200];
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&d[0][i],&d[1][i],&d[2][i]);
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<n;j++){
			int res=1;
			for(int k=0;k<n;k++){
				if(k==j)continue;
				if(d[i][j]==d[i][k]){res=0;break;}
			}
			if(res==1)p[j]+=d[i][j];
		}
	}
	for(int i=0;i<n;i++){
		printf("%d\n",p[i]);
	}
}

Measured memory_bytes: 1192
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 


long long int N,M,K,A[200200];
string S;
int main()
{
    cout << fixed << setprecision(18);
    cin>>S;
    sort(S.begin(),S.end());
    IFYes(S=="abc");

    
}    


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

const int maxn = 2e5 + 10;

ll n,k,cnt0,cnt1,cnt2;
vector<int>v1,v2,v;

bool check(ll x)
{
	ll cnt = 0;
	if(x < 0) {
		for(int i = 0; i < cnt2; i++) {
			ll y = (-x) / v2[i];
			cnt += v1.end() - upper_bound(v1.begin(),v1.end(),y);
		}
	}
	else if(x == 0){
		cnt += cnt1 * cnt2;
	}
	else {
		cnt += cnt1 * cnt2;
		cnt += cnt0 * (cnt1 + cnt2);
		cnt += cnt0 * (cnt0 - 1) / 2;
		ll tmp = 0;
		for(int i = 0; i < cnt1; i++) {
			ll y = (x + v1[i] - 1) / v1[i];
			tmp += lower_bound(v.begin(),v.end(),y) - v.begin();
			v.push_back(v1[i]); 
		}
		v.clear();
		for(int i = 0; i < cnt2; i++) {
			ll y = (x + v2[i] - 1) / v2[i];
			tmp += lower_bound(v.begin(),v.end(),y) - v.begin(); 
			v.push_back(v2[i]);
		}
		v.clear();
		cnt += tmp;
	}
	return cnt >= k;

}

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;
		if(x > 0) v1.push_back(x);
		else if(x < 0) v2.push_back(-x);
		else cnt0++;
	} 
	cnt1 = v1.size(), cnt2 = v2.size();
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	ll l = -1e18 - 1, r = 1e18 + 1;
	while(r - l > 1){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid;
	}		
	cout <<  l << endl;
	return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 60
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int main() {
	string s; 
	cin >> s;
	int n = s.size()-1;
	if(s[n] == '2' or s[n] == '4' or s[n] == '5' or s[n] == '7' or s[n] == '9') cout << "hon" << endl;
	else if(s[n] == '3') cout << "bon" << endl;
	else cout << "pon" << endl;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 1;
  for (int i = 2;; i *= 2) {
    if (i > n) {
      break;
    }
    ans = i;
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3596
import java.lang.Math

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val Aarr = Array(N) { Pair(it, readInputLine().toInt()) }

    Aarr.sortBy { it.second }
    var cnt = 0

    for (i in 0 until N) {
        if (Math.abs(Aarr[i].first - i) % 2 == 1) {
            cnt++
        }
    }

    println(cnt / 2)
}

fun readInputLine(): String {
    return readLine()!!
}


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



int main()
{
    
	ios_base::sync_with_stdio(false); cin.tie(NULL);


	
	int cnt=0;
	string s;
	cin>>s;

	int m =0;

	for(int i =0 ;i<3;i++)
	{
		if(s[i]=='R')m++;
		else
		{
			cnt = max(m,cnt);
			m =0;
		}
	}
	cnt = max(m,cnt);
	
	cout<<cnt;
    return 0;
		
}








Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<vector>
#define inf 1000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    int n, sum = 0; cin >> n;

    vector<int>arr(n,0);
    fsr(i,n) cin >> arr[i];

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            sum += (arr[i] * arr[j]);
        }
    }

    cout << sum << endl;
}




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

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

const int INF = 10000000;
int n, cost[16][16+1], dp[100000];

int dfs(int S) {
  if (S == (1<<n)-1) return 0;
  if (dp[S] >= 0) return dp[S];
  
  int res = INF;
  rep(i,n) {
    if ((S>>i) & 1) continue;
    
    int min_c = cost[i][0];
    REP(j,1,n+1)
      if ((S>>(j-1)) & 1)
        min_c = min(min_c, cost[i][j]);
    
    res = min(res, dfs(S|1<<i) + min_c);
  }
  
  return dp[S] = res;
}

void solve() {
  memset(dp, -1, sizeof dp);
  rep(i,n)
    rep(j,n+1)
      cin>>cost[i][j];
  
  cout<<dfs(0)<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    LL T1, T2; cin >> T1 >> T2;
    LL A1, A2, B1, B2;
    cin >> A1 >> A2 >> B1 >> B2;
    if (A1 - B1 < 0) {
        swap(A1, B1);
        swap(A2, B2);
    }
    LL s1 = (A1-B1)*T1;
    LL s2 = (A2-B2)*T2;
    if ((A1-B1)*T1 + (A2-B2)*T2 > 0)  cout << "0" << endl;
    else if ((A1-B1)*T1 + (A2-B2)*T2 == 0)  cout << "infinity" << endl;
    else  cout << s1/(-(s1+s2)) * 2 - 1 + (s1%(-(s1+s2)) == 0 ? 1 : 2) << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef long long LL;
int W,H,T[100][101];
char room[100][101];
int dist[10][100][101];
vector<P> hole,point;
void dijkstra(int p) {
	static int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
	priority_queue<PP,vector<PP>,greater<PP> > Q;
	Q.push(PP(0,point[p]));
	dist[p][point[p].first][point[p].second]=0;
	while(!Q.empty()) {
		PP pp=Q.top(); Q.pop();
		if(dist[p][pp.second.first][pp.second.second]<pp.first) continue;
		for(int i=0;i<4;i++) {
			int nx=pp.second.first+dx[i],ny=pp.second.second+dy[i];
			if(0>nx||nx>=W||0>ny||ny>=H||room[ny][nx]=='#') continue;
			int nd=pp.first+T[pp.second.first][pp.second.second];
			if(dist[p][nx][ny]>nd) {
				dist[p][nx][ny]=nd;
				Q.push(PP(nd,P(nx,ny)));
			}
		}
	}
}
int main() {
	int sx,sy,gx,gy;
	scanf("%d %d",&W,&H);
	for(int i=0;i<H;i++) {
		scanf("%s",room[i]);
		for(int j=0;j<W;j++) {
			T[j][i]=1;
			if(room[i][j]=='#') hole.push_back(P(j,i)),T[j][i]=1<<30;
			else if(room[i][j]=='M') point.push_back(P(j,i));
			else if(room[i][j]=='S') sx=j,sy=i;
			else if(room[i][j]=='G') gx=j,gy=i;
		}
	}
	point.insert(point.begin(),P(sx,sy));
	point.push_back(P(gx,gy));
	for(int i=0;i<hole.size();i++) {
		for(int dx=-2;dx<=2;dx++) {
			for(int dy=-2;dy<=2;dy++) {
				int nx=hole[i].first+dx;
				int ny=hole[i].second+dy;
				if(0>nx||nx>=W||0>ny||ny>=H) continue;
				int k=max(abs(dx),abs(dy));
				if(k==1) {
					T[nx][ny]=max(T[nx][ny],3);
				}else if(k==2) {
					T[nx][ny]=max(T[nx][ny],2);
				}
			}
		}
	}
	fill((int*)dist,(int*)(dist+10),1<<30);
	for(int i=0;i<point.size();i++) {
		dijkstra(i);
	}
	int perm[]={1,2,3,4,5};
	int ans=1<<30;
	do {
		int sum=0,k=0;
		for(int i=0;i<(point.size()-2);i++) {
			int idx=perm[i];
			sum+=dist[k][point[idx].first][point[idx].second];
			k=idx;
		}
		sum+=dist[k][point[point.size()-1].first][point[point.size()-1].second];
		ans=min(ans,sum);
	}while(next_permutation(perm,perm+(point.size()-2)));
	printf("%d\n",ans);
}

Measured memory_bytes: 1664
sx, sy, tx, ty = (int(x) for x in raw_input().split())
first = "R" * (tx-sx) + "U" * (ty - sy)
second = "L" * (tx-sx) + "D" * (ty - sy)
third = "D" + "R" * (tx-sx+1) + "U" * (ty-sy+1) + "L"
fourth = "U" + "L" * (tx-sx+1) + "D" * (ty-sy+1) + "R"
print first + second + third + fourth


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200000
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int P[MAXN+5], n, Ans;
int main()
{
	n = read(); for(rint i = 1; i <= n; P[read()] = i, i++);
	for(rint i = 1, j; i <= n; Ans = max(Ans,j-i+1), i = j+1) for(j = i; j < n && P[j+1]>P[j]; j++); 
	printf("%d\n",n-Ans); return 0;
}

Measured memory_bytes: 1024
def f(i):
    if i == 0:
        return 2

    if i == 1:
        return 1

    A = [2, 1]
    for _ in range(i - 1):
        A[0], A[1] = A[1], A[0] + A[1]
    return A[-1]


N = int(input())
print(f(N))


Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10**7)
memo = [-1] * 110000  # memo[i]がi円についての答え


def rec(n):
    if n == 0:
        return 0
    if memo[n] != -1:
        return memo[n]  # 探索済みならリターン

    res = n
    pow6 = 1
    while pow6 <= n:
        res = min(res, rec(n - pow6) + 1)
        pow6 *= 6

    pow9 = 1
    while pow9 <= n:
        res = min(res, rec(n - pow9) + 1)
        pow9 *= 9
    memo[n] = res
    return res


N = int(input())
rec(N)
print(memo[N])


Measured memory_bytes: 89716
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
int main()
{
string s;
cin>>s;
if(s=="Sunny"){
    cout<<"Cloudy";
}
else if(s=="Cloudy"){
    cout<<"Rainy";
}
else{
    cout<<"Sunny";
}


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    char c;
    cin>>c;
    if(isupper(c)) cout<<"A\n";
    else cout<<"a\n";
    return 0;
}

Measured memory_bytes: 3620
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define dbg2(x) for(auto &i:x){for(auto j:i){cout<<j<<" ";}cout<<endl;}
#define dbgp(x) for(auto i:x){cout<<i.ff<<" "<<i.ss<<endl;}
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/


void solver(){
    double d,s,t;
    cin>>d>>s>>t;
    if(d/s<=t)
        cout<<"Yes"<<ENDL;
    else
        cout<<"No"<<ENDL;
    ret;
}

MAIN1

Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


int main() {
	int n;
	cin >> n;

	ll a[n + 1];
	ll left = 0;

	rep(i, n + 1) {
		cin >> a[i];
		left += a[i];
	}
	ll ans = 0;
	ll cur_v = 1;

	rep(i, n + 1) {
		ans += cur_v;

		cur_v -= a[i];
		if (cur_v < 0) {
			cout << -1 << endl;
			return 0;
		}
		left -= a[i];

		cur_v = min(cur_v * 2,left);

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3964
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
a = list(map(int,input().split()))

l = [0] * (n+1)
r = [0] * (n+1)

for i in range(n):
    l[i+1] = gcd(l[i],a[i])

for i in range(n-1, -1, -1):
    r[i] = gcd(r[i+1],a[i])

m = []
for i in range(n):
    m.append(gcd(l[i],r[i+1]))
print(max(m))

Measured memory_bytes: 14060
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

// 4
// 1 3 2 4
int main(){
    std::ios_base::sync_with_stdio(false);
    int n; cin>>n;
    std::vector<pair<int,int>> v;
    std::vector<int> A;
    rep(i,n){int a; cin>>a; v.push_back(make_pair(a,i)); A.push_back(a);}
    sort(v.begin(), v.end()); reverse(v.begin(), v.end());
    UnionFind uf(n);
    ll ans = 0LL;
    rep(i,n){
      //cout << i << " " << v[i].first << " " << v[i].second << endl;
      int left=0, right=0;
      if(v[i].second-1 >= 0 && A[v[i].second-1]>A[v[i].second]){
        left = uf.size(A[v[i].second-1]-1);
        uf.unionSet(A[v[i].second-1]-1, v[i].first-1);
        ans += (left+0LL)*(v[i].first+0LL);
      }
      if(v[i].second+1 < n && A[v[i].second+1]>A[v[i].second]){
        right = uf.size(A[v[i].second+1]-1);
        uf.unionSet(A[v[i].second+1]-1, v[i].first-1);
        ans += (right+0LL)*(v[i].first+0LL);
      }
      ans+=((left+0LL)*(right+0LL)+1LL)*(v[i].first+0LL)+0LL;
      //cout << v[i].first << " " << left << " " << right << " " << ans << endl;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3696
import Control.Applicative
import Control.Monad
import Data.List

main = do
  [n, m] <- map read . words <$> getLine
  es <- map (map pred . map read) . map words <$> replicateM m getLine
  print . length . filter (isBridge n es) $ es

isBridge :: Int -> [[Int]] -> [Int] -> Bool
isBridge n es [u, v] = not . (!! v) . (!! u) . foldl1' mul . replicate n $ toMatrix n (delete [u, v] es)

toMatrix :: Int -> [[Int]] -> [[Bool]]
toMatrix n es = [[f i j | j <- [0..n-1]] | i <- [0..n-1]]
  where
    f :: Int -> Int -> Bool
    f i j
      | i == j    = True
      | otherwise = [i, j] `elem` es || [j, i] `elem` es

mul :: [[Bool]] -> [[Bool]] -> [[Bool]]
mul a b = [[foldl1' (||) $ zipWith (&&) x y | y <- transpose b] | x <- a]

Measured memory_bytes: 10508
#include<stdio.h>

int main() {
	char a;
	while (scanf("%c",&a)) {
		if (a >= 'A'&&a <= 'Z') {
			a += 32;
		}
		else if (a >= 'a'&&a <= 'z') {
			a -= 32;
		}
		else if (a == '\n')break;
		printf("%c", a);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    char a;
    cin >> a;
    if(a >= 'A' && a <= 'Z') cout << "A" << endl;
    else cout << "a" << endl; 
    return 0;
}

Measured memory_bytes: 3632