akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] li = new long[n];
        for(int i = 0; i < n; i++){
            li[i] = sc.nextLong();
        }
        Arrays.sort(li);
        Change[] changes = new Change[m];
        for(int i = 0; i < m; i++){
            int count = sc.nextInt();
            long diff = sc.nextLong();
            changes[i] = new Change(count,diff);
        }
        Arrays.sort(changes);
        long ans = 0;
		int j = 0;
		for (int i = 0; i < n; i++) {
			if (j >= m || li[i] >= changes[j].diff) {
				ans += li[i];
			} else {
				ans += changes[j].diff;
				changes[j].count--;
				if (changes[j].count == 0) {
					j++;
				}
			}
		}
		System.out.println(ans);
    }
}

class Change implements Comparable<Change>{
    int count;
    long diff;
    public Change(int c, long d){
        this.count = c;
        this.diff = d;
    }
    public int compareTo(Change c){
        if(this.diff < c.diff){
            return 1;
        }else if(this.diff > c.diff){
            return -1;
        }
        return 0;
    }
}



Measured memory_bytes: 95640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int X, Y, Z;
  long K;
  long A[1000];
  long B[1000];
  long C[1000];
  multiset<long> ansSet;

  scanf("%d %d %d %ld", &X, &Y, &Z, &K);
  for (int i=0;i<X;i++)
    scanf("%ld", &A[i]);
  for (int i=0;i<Y;i++)
    scanf("%ld", &B[i]);
  for (int i=0;i<Z;i++)
    scanf("%ld", &C[i]);
  for (int i=0;i<X;i++)
    for (int j=0;j<Y;j++)
      for (int k=0;k<Z;k++) {
        long sum = A[i]+B[j]+C[k];
        if (ansSet.size() < K) {
          ansSet.insert(sum);
        } else {
          if (*ansSet.begin() < sum) {
            ansSet.erase(ansSet.begin());
            ansSet.insert(sum);
          }
        }
      }
  long a = 0;
  for (auto itr = ansSet.rbegin(); itr != ansSet.rend(); itr++) {
    printf("%ld\n", *itr);
    a++;
    if (a>=K) break;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

class Problem
{
private:
	// Variables
	string s;
	
public:
	// Methods
	void input ()
	{
		cin >> s;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		cout << (string::npos != s.find('a') && string::npos != s.find('b') && string::npos != s.find('c') ? "Yes" : "No") << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	ll n, k;
	string s;
	cin >> n >> s >> k;
	rep(i, n) {
		if (s[i] != s[k - 1])s[i] = '*';
	}
	cout << s << endl;
	ggr
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define ll long long 
#define nl cout<<"\n"
#define fr(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
const ll inf=1e15;
//////////////   debugger class  starts from here///// 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////  debugger class ends here /////////////
ll cal(string s){
	ll n=s.size();
	if(n==1)return 0;
	ll dp[n+2][26];
	memset(dp,63,sizeof dp);
	for(ll i=0;i<26;i++){
		dp[0][i]=(((s[0]-'a')==i)?0:1);
	}
	// fr(i,26)cout<<dp[0][i]<<" ";nl;
	for(ll i=1;i<n;i++){
		for(ll j=0;j<26;j++){
			ll ad=((s[i]-'a')!=j);
			ll mn=inf;
			for(ll k=0;k<26;k++){
				if(j==k)continue;;
				mn=min(mn,dp[i-1][k]);
			}
			dp[i][j]=ad+mn;
		}
		// fr(j,26)cout<<dp[i][j]<<" ";nl;

	}
    ll mn=inf;
    fr(i,26)mn=min(dp[n-1][i],mn);
    return mn;
}
signed main()
{
	
     		string s;ll k;
     		cin>>s>>k;string c=s;
     		vector<ll>ans(16);
     		for(int i=1;i<=15;i++){
     			ans[i]=cal(c);
     			c=c+s;
     		}

     		if(k<=5){
     			cout<<ans[k];
     		}
     		else{
     			ll inc=ans[5]-ans[3];
     			if(k&1){
     				cout<<ans[3]+(inc)*(k-3)/2;
     			}
     			else{
     				cout<<ans[2]+(inc)*(k-2)/2;
     			}
     			
     		}

}

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

if N == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

dic = {}
for v in factorization(N):
    dic[v[0]] = v[1]
#print(dic)


lst = []
for i in dic:
    for j in range(1, dic[i]+1):
        lst.append(i**j)
lst.sort()


cnt = 0
for i in lst:
    if  N % i == 0 and N // i > 0:
        N = N / i
        cnt += 1
print(cnt)

Measured memory_bytes: 9512
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;

  vector<int> ac(N + 1, 0);
  vector<int> cnt_was(N + 1, 0);

  for (int i = 0; i < M; ++i) {
    int p;
    string S;
    cin >> p >> S;

    if (S == "AC") {
      ac[p] = 1;
    } else {
      if (!ac[p]) {
        cnt_was[p]++;
      }
    }
  }

  int cnt_ac = 0, cnt_wa = 0;
  for (int i = 1; i <= N; ++i) {
    if (ac[i]) {
      cnt_ac++;
      cnt_wa += cnt_was[i];
    }
  }
  cout << cnt_ac << " " << cnt_wa << endl;

  return 0;
}


Measured memory_bytes: 4060
#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 x, t;
  cin >> x >> t;

  if (x - t >= 0) {
    cout << x - t << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


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

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    int town[r];
    rep(i, 0, r) {
        cin >> town[i];
        town[i]--;
    }

    int d[n][n];
    rep(i, 0, n) rep(j, 0, n) d[i][j] = INF;
    rep(i, 0, n) d[i][i] = 0;
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int ans = INF;
    sort(town, town + r);
    do {
        int tmp = 0;
        rep(i, 0, r - 1) tmp += d[town[i]][town[i + 1]];
        ans = min(ans, tmp);
    } while (next_permutation(town, town + r));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
mat = [[False]*3 for i in range(3)]
a_mat = []
for i in range(3):
  a_list = list(map(int, input().split()))
  a_mat.append(a_list)
n = int(input())
for i in range(n):
  b = int(input())
  for x in range(3):
    for y in range(3):
      if a_mat[x][y] == b:
        mat[x][y] = True

if mat[0][0] and mat[0][1] and mat[0][2] \
or mat[1][0] and mat[1][1] and mat[1][2] \
or mat[2][0] and mat[2][1] and mat[2][2] \
or mat[0][0] and mat[1][0] and mat[2][0] \
or mat[0][1] and mat[1][1] and mat[2][1] \
or mat[0][2] and mat[1][2] and mat[2][2] \
or mat[0][0] and mat[1][1] and mat[2][2] \
or mat[0][2] and mat[1][1] and mat[2][0]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 00:15:23 2020

@author: Kanaru Sato
"""

N = int(input())
S = input()
target = "ABC"

count = 0

for i in range(0,N-2):
    if S[i:i+3] == target:
        count += 1
        
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

#define MAX 100000

unsigned int L[MAX / 2 + 1], R[MAX / 2 + 2];
int cnt;

void merge(unsigned int A[], int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
	for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
	L[n1] = R[n2] = UINT_MAX;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
	}
}

void mergeSort(unsigned int A[], int n, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int main(void) {
	int i, n;
	unsigned int *A;
	cnt = 0;
	scanf("%d", &n);
	A = (unsigned int *)malloc(n * sizeof(unsigned int));
	for (i = 0; i < n; i++) {
		scanf("%u", &A[i]);
	}
	mergeSort(A, n, 0, n);
	cnt = 0;
	int sameCnt = 0;
	unsigned int prev = A[0];
	for (i = 1; i < n; i++) {
		if (A[i] == prev) sameCnt++;
		else {
			if (sameCnt % 2 == 0) {
				cnt++;
			}
			sameCnt = 0;
			prev = A[i];
		}
	}
	if (sameCnt % 2 == 0) {
		cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N=0;
    cin >> N;
    N=N%10;
    if(N==2||N==4||N==5||N==7||N==9){
        cout<<"hon";
    }
    else if(N==0||N==1||N==6||N==8){
        cout<<"pon";
    }    
    else{
        cout<<"bon";
    }
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int N;
	cin>>N;
	int cnt;
	if(1<=N && N<10)
	{
		cnt = N;
	}
	if(10<=N && N<100)
	{
		cnt = 9;
	}
	if(100<=N && N<1000)
	{
		cnt = 9 + N - 99;
	}
	if(1000<=N && N<10000)
	{
		cnt = 909;
	}
	if(10000<=N && N<100000)
	{
		cnt = 909 + N - 9999;
	}
	if( N == 100000)
	{
		cnt = 90909;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll A, B, C, X;
  cin >> A >> B >> C >> X;

  ll ans = 0;
  rep(i, A + 1) {
    rep(j, B + 1) {
      rep(k, C + 1) {
        ll p = 500 * i + 100 * j + 50 * k;
        if (p == X) ans++;
      }
    }
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    rep(i,10000){
        ll x;
        cin >> x;
        if (x == 0) break;
        cout << "Case " << i + 1 << ": " << x << endl;
    }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll dig_sum(ll n){
    
    ll ans = 0;
    while(n > 0){
        ans += n % 10;
        n = n / 10;
    }
    return ans;
}

double get_sunuke(ll n){
    return 1.0*n/dig_sum(n);
}
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);


    // for(int i = 1; i <= 100; i++){
    //     cout << get_sunuke(i) << endl;
    // }

    // for(int i = 20000; i <= 100000; i++){
    //     if( 1.0 * i / dig_sum(i) < 1.0 * 19999 / dig_sum(19999)){
    //         cout << "atta" << endl;
    //     }
    // }

    vector<ll> cord;
    ll base = 1;

    for(int i = 0; i < 15; i++){
        for(int r = 1; r < 150; r++){
            cord.push_back(base*(r+1)-1);
        }
        base *= 10;
    }

    sort(cord.begin(), cord.end());
    cord.erase(unique(cord.begin(), cord.end()), cord.end());

    for(ll i = 0; i < cord.size(); ++i){
        for(ll j = i + 1; j < cord.size(); ++j){
            if(get_sunuke(cord[i]) > get_sunuke(cord[j]))
            {
                cord.erase(cord.begin() + i--);
                break;
            }
        }
    }

    ll K;
    cin >> K;
    for(ll i = 0; i < K; ++i){
        cout << cord[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 384
import sys, math, collections, heapq, itertools
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    file = sys.stdin.readline #single: int(file()), line: map(int, file().split())
    N = int(file())
    point = [[int(i) for i in file().split()] for j in range(N)]
    length = (point[0][0] + point[0][1]) % 2
    for i in range(1, N):
        if sum(point[i]) % 2 != length:
            print(-1)
            break
    else:
        d = [pow(2, i) for i in range(31)]
        direction = {("0", "0"): "L", ("1","1"): "R", ("0", "1"): "D", ("1", "0"): "U"}
        ans = ""
        add = (0 if length == 1 else 1)
        if add == 1: d.append(1)
        for i in range(N):
            U, V = point[i][0] + point[i][1] + add, point[i][0] - point[i][1] + add
            ubit = format((U + pow(2, 31) - 1)//2, "b").zfill(31)
            vbit = format((V + pow(2, 31) - 1)//2, "b").zfill(31)
            arm = ""
            for j in reversed(range(31)):
                arm += direction[(ubit[j], vbit[j])]
            if add == 1: arm += "L"
            ans += arm + "\n"
        print(len(d))
        print(" ".join(map(str, d)))
        print(ans)

    INF = 10 ** 25
    mod = 7 + 10 ** 9
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3696
#include<stdio.h>
#include<algorithm>
using namespace std;

int a[1000];
int b[1000];
int main(){
	int n, m, in;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < m; i++){
		scanf("%d", &in);
		for (int  j= 0;; j++)
			if (a[j] <= in){ b[j]++; break; }
	}
	printf("%d\n", max_element(b, b + n) - b + 1);
}

Measured memory_bytes: 1032
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    A_sum = sum(A)
    ans = 1
    tmp_v = 1
    if A[0] > 1:
        print(-1)
        sys.exit()
    if A[0] == 1:
        if N == 0:
            print(1)
        else:
            print(-1)
        sys.exit()
    for i in range(N):
        if A[i+1] > tmp_v*2:
            print("-1")
            sys.exit()
        tmp_v = min(tmp_v*2, A_sum)
        ans += tmp_v
        A_sum -= A[i+1]
        tmp_v -= A[i+1]
    print(ans)



if __name__ == '__main__':
    main()

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


def read():
    S = input().strip()
    return S,


def solve(S):
    alphabets = ['A', 'C', 'G', 'T']
    max_count = 0
    count = 0
    for s in S:
        if s in alphabets:
            count += 1
        else:
            max_count = max(max_count, count)
            count = 0
    max_count = max(max_count, count)
    return max_count


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 3060
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [1e10] * N
dp[0] = 0
for i in range(1, N):
    if i < K:
        for j in range(i):
            dp[i] = min(dp[i], dp[i-j-1] + abs(h[i]-h[i-j-1]))
    else:
        for j in range(K):
            dp[i] = min(dp[i], dp[i-j-1] + abs(h[i]-h[i-j-1]))
print(dp[N-1])

Measured memory_bytes: 55392
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    double a=100;
    for(int i=0;i<n;i++){
        a*=1.05;
        if((a-(int)a)>0)a+=(1-(a-(int)a));
    }
    cout<<(int)a<<0<<0<<0<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  string s[3];
  REP(i, 3) cin >> s[i];
  REP(i, 3) cout << s[i][i];
  cout << endl;
} 

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long a = sc.nextLong();
	        long b = sc.nextLong();
	        long c = sc.nextLong();
	        
	        long sahen = (a+b-c)*(a+b-c)-4*a*b;
	        	
	        
	        if(sahen>0&&a+b-c<0) {
	        	System.out.println("Yes");
	        } else {
	        	System.out.println("No");
	        }

	        
	 }
	 

}


Measured memory_bytes: 23124
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string S = Console.ReadLine();            

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == '+')
                {
                    ans++;
                }
                else if (S[i] == '-')
                {
                    ans--;
                }
            }           

            Console.WriteLine(ans);

            return;
        }
    }

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, t, s, g, x, y, d, c, p[20], q[50], r[50], w[20][100][100], z[100][100], b[20020];

signed main() {
	while (1) {
		cin >> n >> m >> t >> s >> g;
		s--, g--;
		if (n==0) break;
		rep(i,t) rep(j,n) rep(k,n) if (j!=k) w[i][j][k] = inf;
		rep(i,m) {
			cin >> x >> y >> d >> c;
			x--, y--, c--;
			chmin(w[c][x][y],d), chmin(w[c][y][x],d);
		}
		rep(o,t) rep(k,n) rep(i,n) rep(j,n)
		    chmin(w[o][i][j], w[o][i][k]+w[o][k][j]);
		rep(i,t) cin >> p[i];
		rep(i,t) {
			rep(j,p[i]-1) cin >> q[j];
			rep(j,p[i]) cin >> r[j];
			rep(j,p[i]-1) repst(k,(j==0 ? 1 : q[j-1]+1),q[j]) b[k] = b[k-1] + r[j];
			repst(k,q[p[i]-2]+1,20000) b[k] = b[k-1] + r[p[i]-1];
			rep(j,n) rep(k,n) if (w[i][j][k]!=inf) w[i][j][k] = b[w[i][j][k]];
		}
		rep(i,n) rep(j,n) if (i!=j) z[i][j] = inf;
		rep(o,t) rep(i,n) rep(j,n) chmin(z[i][j], w[o][i][j]);
		rep(k,n) rep(i,n) rep(j,n)
		    chmin(z[i][j], z[i][k]+z[k][j]);
		cout << (z[s][g]==inf ? -1 : z[s][g]) << ln;
	}
}


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

public class Main{
    public static void main(String[] args){
        Scanner ir=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);
        int n=ir.nextInt();
        int m=ir.nextInt();
        long t=ir.nextLong();
        long[] a=new long[n];
        for(int i=0;i<n;i++){
            a[i]=ir.nextLong();
        }
        long res=a[0]-m;
        for(int i=0;i<n-1;i++){
            res+=Math.max(a[i+1]-a[i]-2*m,0);
        }
        res+=Math.max(t-a[n-1]-m,0);
        out.println(res);
        out.flush();
    }
}


Measured memory_bytes: 26396
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


class Ruiseki_lr():
    """左右からの畳み込みをそれぞれ計算する"""
    def __init__(self, array, op, e):
        self.op = op
        self.e = e

        n = len(array)
        self.left = [e] * (n + 1)
        self.right = [e] * (n + 1)
        for i in range(n):
            self.left[i + 1] = self.op(self.left[i], array[i])
        for i in reversed(range(n)):
            self.right[i] = self.op(self.right[i + 1], array[i])

    def left(self, p):
        """区間[0, p)の畳み込み結果を返す"""
        return self.left[p]
    
    def right(self, p):
        """区間[p, n)の畳み込みを返す"""
        return self.right[p]

    def fold(self, p):
        """p番目を除いた区間[0, n)の畳み込み結果を返す"""
        return self.op(self.left[p], self.right[p + 1])


n = int(input())
a = list(map(int, input().split()))
ru = Ruiseki_lr(a, gcd, 0)

ans = 0
for i in range(n):
    ans = max(ru.fold(i), ans)
print(ans)



Measured memory_bytes: 63984
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int a,b;
	string c;
	for(int i=0;i<9;i++){
        cin>>c>>a>>b;
        cout<<c<<" "<<a+b<<" "<<a*200+b*300<<endl;
	}


	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;
 
using namespace std;


int main()   {
    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, 1000);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(n);
        int k = 1;
        ll no_names = 1, so_far = 0;
        while (true) {
            no_names *= 26;
            so_far +=no_names;
            if (n<=so_far) {break;}
            k++;
        }
        so_far -= no_names;
        n -= so_far+1;
        string ans(k, 'a');
        for(int i = k-1; i>=0; --i) {
            ans[i] = 'a' + (n%26);
            n/=26;
        }
        cout << ans << endl;
    }

//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 3628
<?php
$input_array = explode(" ", fgets(STDIN));
$eligible_num = array();
for ($i = 1; $i <= $input_array[0]; $i++) {
    $num_array = str_split($i);
    $num_sum = array_sum($num_array);
    if ($input_array[1] <= $num_sum and $num_sum <= $input_array[2]) {
        array_push($eligible_num, $i);
    }
}
echo array_sum($eligible_num);
?>

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

int main() {
  int n, i;
  cin >> n;
  vector<tuple<string, int, int>> sp(n);
  for (i = 0; i < n; i++) {
    cin >> get<0>(sp[i]) >> get<1>(sp[i]);
    get<1>(sp[i]) *= -1;
    get<2>(sp[i]) = i;
  }
  sort(sp.begin(), sp.end());
  for (i = 0; i < n; i++)
    cout << get<2>(sp[i])+1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;
const int MaxN = 2e5 + 5;
long long a[MaxN], b[MaxN];

int main()
{
	int n;
	long long x, y;
	cin >> n;
	long long ans1, ans2;
	x = (n - 1)/2;
	y = n / 2;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	ans1 = a[(n-1)/2];
	ans2 = a[n / 2];
	for(int i = 0; i < n; i++) {
		if(b[i] <= ans1) printf("%lld\n", ans2);
		else printf("%lld\n", ans1);
	}
}

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

bool palindrome(string s){
  bool flag=true;
  rep(i,s.size()) if(s[i]!=s[s.size()-1-i]) flag=false;
  return flag;
}

int main(){
  string s;cin>>s;
  ll n=s.size();
  string s1=s.substr(0,n/2),s2=s.substr(n/2+1,n/2);
  if(palindrome(s) && palindrome(s1) && palindrome(s2)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
  int n,k,q;
  cin>>n>>k>>q;

  int a[n+1];
  for(int i =0;i<=n;i++) a[i]=0;
  for (int i=0;i<q;i++){
    int x;
    cin>>x;
    a[x]=a[x]+1;
  }

  for(int j=1;j<=n;j++){
    if(q-a[j]<k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int main()
{
	int N;
	ll K;
	cin >> N >> K;
	vector<ll> A(N);
	ll S(0);
	for(int i(0);i<N;++i){
		cin >> A[i];
		S += A[i];
	}
	vector<ll> d;
	for(int i(1);i*i<=S;++i){
		if(S % i == 0){
			d.push_back(i);
			d.push_back(S/i);
		}
	}
	int M = d.size();
	vector<ll> a(N);
	ll a_sum,sum_left,sum_right,target_d,d_max(0);
	for(int i(0);i<M;++i){
		target_d = d[i];
		a_sum = 0;
		for(int j(0);j<N;++j){
			a[j] = A[j] % target_d;
			a_sum += a[j];
		}
		sort(a.begin(),a.end());
		sum_left = a_sum;
		sum_right = 0;
		ll swap_num = 1e18;
		for(int j(N-1);j>=0;--j){
			sum_left -= a[j];
			sum_right += target_d-a[j];
			swap_num = min(swap_num, max(sum_left, sum_right));
		}
		if(swap_num <= K) d_max = max(d_max, target_d);
	}
	cout << d_max << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


def main():
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


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

int main()
{
    int h, w;
    cin >> h >> w;
    int a[h][w];
    rep(i, h)
    {
        rep(j, w) cin >> a[i][j];
    }

    int cnt = 0;
    vector<tuple<int, int, int, int>> ans;
    //現在位置を示す値
    int i = 0, j = 0;
    while (1)
    {
        if (i % 2 == 0)
        {
            if (j == w - 1)
            {
                if (i == h - 1)
                    goto end;
                if (a[i][j] % 2 == 1)
                {
                    cnt++;
                    ans.emplace_back(i + 1, j + 1, i + 2, j + 1);
                    a[i + 1][j]++;
                }
                i++;
            }
            else
            {
                if (a[i][j] % 2 == 1)
                {
                    cnt++;
                    ans.emplace_back(i + 1, j + 1, i + 1, j + 2);
                    a[i][j + 1]++;
                }
                j++;
            }
        }
        if (i % 2 == 1)
        {
            if (j == 0)
            {
                if (i == h - 1)
                    goto end;
                if (a[i][j] % 2 == 1)
                {
                    cnt++;
                    ans.emplace_back(i + 1, j + 1, i + 2, j + 1);
                    a[i + 1][j]++;
                }
                i++;
            }
            else
            {
                if (a[i][j] % 2 == 1)
                {
                    cnt++;
                    ans.emplace_back(i + 1, j + 1, i + 1, j);
                    a[i][j - 1]++;
                }
                j--;
            }
        }
    }
end:
    cout << cnt << endl;
    rep(i, cnt)
    {
        cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i]) << " " << get<3>(ans[i]) << endl;
    }
}

Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	int F[100][5][2];
	for (auto i = 0; i < N; ++i)
	{
		for (auto j = 0; j < 5; ++j)
		{
			for (auto k = 0; k < 2; ++k)
			{
				cin >> F[i][j][k];
			}
		}
	}

	vector<vector<long long>> P(N);
	for (auto i = 0; i < N; ++i)
	{
		auto& temp = P[i];
		for (auto j = 0; j <= 10; ++j)
		{
			long long p;
			cin >> p;
			temp.push_back(p);
		}
	}

	auto result = LLONG_MIN;
	for (auto i = 1; i < 1024; ++i)
	{
		auto sum = 0ll;
		for (auto j = 0; j < N; ++j)
		{
			auto count = 0;
			for (auto k = 0; k < 10; ++k)
			{
				if ((i & (1 << k)) != 0)
				{
					if (F[j][k / 2][k % 2] == 1)
					{
						++count;
					}
				}
			}

			sum += P[j][count];
		}

		result = max(sum, result);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, M, ans[int(1e5 + 5)];
Pii Graph[int(1e5 + 5)];
int Group[int(1e5 + 5)], Count[int(1e5 + 5)];

int main(){
  scanf("%lld%lld", &N, &M);
  for (int i = 0; i < M; i++){
    int A, B; scanf("%d%d", &A, &B);
    A--; B--;
    Graph[i] = mp(A, B);
  }
  for (int i = 0; i < N; i++){
    Group[i] = i; Count[i] = 1;
  }
  
  for (int i = M - 1; i >= 0; i--){
    ans[i] = ans[i + 1];
    int A = Graph[i].fi, B = Graph[i].se;
    int GA = Group[A], GB = Group[B];
    while (GA != Group[GA]) GA = Group[GA];
    while (GB != Group[GB]) GB = Group[GB];

    if (GA == GB) continue;
    ans[i] += Count[GA] * Count[GB];
    Count[min(GA, GB)] += Count[max(GA, GB)];
    Group[max(GA, GB)] = min(GA, GB);
  }

  for (int i = 1; i <= M; i++){
    printf("%lld\n", N * (N - 1) / 2 - ans[i]);
  }
  
  return 0;
}


Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin >> a >> b >> c;
if (a>b){d=a; a=b; b=d;}
if (b>c){d=b; b=c; c=d;}
if (a>b){d=a; a=b; b=d;}
cout << a << " " << b << " " << c <<endl;
return 0;
}


Measured memory_bytes: 3100
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
ans1 = max(x[0] + x[1] for x in d) - min(x[0] + x[1] for x in d)
ans2 = max(x[0] - x[1] for x in d) - min(x[0] - x[1] for x in d)
print(max(ans1, ans2))

Measured memory_bytes: 102844
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;

int n;
int a[55];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>n;
  FOR(i,0,n) cin>>a[i];

  vector<pair<int,int>> res;
  int t=0;
  FOR(i,0,n) 
    if (abs(a[t])<abs(a[i])) t=i;

  if (a[t]!=0) {
    FOR(i,0,n)
      if ((a[t]<0 && a[i]>0) || (a[t]>0 && a[i]<0)) {
        a[i]+=a[t];
        res.emplace_back(t,i);
      }
  }

  if (a[t]>0) {
    FOR(i,0,n-1) {
      a[i+1]+=a[i];
      res.emplace_back(i,i+1);
    }
  } else if (a[t]<0) {
    DOWN(i,n,1) {
      a[i-1]+=a[i];
      res.emplace_back(i,i-1);
    }
  }

  cout<<SZ(res)<<endl;
  assert(SZ(res)<=2*n);
  FOR(i,0,n-1) assert(a[i]<=a[i+1]);
  FOR(i,0,SZ(res))
    cout<<res[i].first+1<<' '<<res[i].second+1<<'\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    int curmin = (n + 1);
    int ans = 0;
    rep(i, n)
    {
        if (curmin >= v[i])
        {
            ans++;
        }
        curmin = min(curmin, v[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
c=[1]
i=1
while (6**i<=100000):
  c.append(6**i)
  i+=1
i=1
while (9**i<100000):
  c.append(9**i)
  i+=1
c.sort()
m=[0]
for i in range(1,n+1):
  mi=1000000
  for j in range(len(c)):
    if i-c[j]<0:
      break
    if m[i-c[j]]+1<mi:
      mi=m[i-c[j]]+1
  m.append(mi)
print(m[n])

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int a;
    cin >> a;
    cout << a*a*a << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h> 
using namespace std; 
// driver code 
int main() 
{ 
	int n;cin>>n;
	string s;
	cin>>s;
	int co=0;
	for(int y=0;y<s.length();y++)
	{
	    if(s[y]=='R')
	    {
	        co++;
	    }
	}
	int z=0;
	for(int g=0;g<co;g++)
	{
	    if(s[g]=='R')
	    {
	        z++;
	    }
	}
	cout<<co-z<<endl;
} 


Measured memory_bytes: 3752
n = int(input())
ali = list(map(int, input().split()))
q = int(input())

opelates = []
for _ in range(q):
    opelates.append(list(map(int, input().split())))

numCntList = [0 for _ in range(10**5+1)]
for num in ali:
    numCntList[num] += 1
total = sum(ali)

for op in opelates:
    pre = op[0]
    nex = op[1]
    preCnt = numCntList[pre]
    if preCnt >= 1:
        numCntList[pre] = 0
        numCntList[nex] += preCnt
        total += (nex-pre)*preCnt
    print(total)

Measured memory_bytes: 32948
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 
#define pll pair<ll,ll>



void solve()
{
    ll m,n;
    cin>>n>>m;
    ll a[n];
    ll tot=0;
    f(i,0,n)cin>>a[i],tot+=a[i];
    ll ans =0;
    f(i,0,n)
    if(4*m*a[i]>=tot)ans++;
    if(ans>=m)cout<<"Yes\n";
    else cout<<"No\n";
}

int main()
{
   ll t;
   t=1;
   // cin>>t; 
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
arr = gets.chomp.split(" ").map(&:to_f).map{|a| (1 + a) / 2}
sum = arr.slice(0, k).inject(:+)
max = sum
#p arr
(n-k).times do |i|
	sum = sum - arr[i] + arr[i + k]
	max = sum if max < sum
end
puts max

Measured memory_bytes: 17540
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int d = Integer.valueOf(arr01[1]);

        int temp = d * 2 + 1;

        System.out.println(n % temp == 0 ? n / temp : (n / temp) + 1);

    }

}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<tuple<int, int, int>> C(N);
    for (int i = 0; i < N; i++) {
        C[i] = make_tuple(A[i] + B[i], A[i], B[i]);
    }
    sort(rbegin(C), rend(C));
    long long score = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            score += get<1>(C[i]);
        } else {
            score -= get<2>(C[i]);
        }
    }
    cout << score << endl;
    return 0;
}


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

int main(){
    ll n, m; cin >> n >> m;
    ll ans = 1;
    for(ll i = 1; i*i <= m; i++){
        if(m % i == 0){
            ll tmp = m/i;
            if(tmp >= n) ans = max(ans, i);
            if(i >= n) ans = max(ans, tmp);
        }
    }
    if(n == 1) ans = m;
    cout << ans << endl;
}


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

vector<int>v[200];

int main()
{
   int n; cin>>n;
   
   for( int i=0;i<n;i++)
   {
   	int a,b; cin>>a>>b;
   	v[i].push_back(a);
   	v[i].push_back(b);
   }
   
   for( int i=2;i<n;i++)
   {
    if( v[i][0]== v[i][1] &&v[i-1][0]== v[i-1][1] && v[i-2][0]== v[i-2][1]  )
    {
    	cout<<"Yes"<<endl;
    	return 0;
	}
   }
   
   cout<<"No"<<endl;
   
   
}

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

int main() {
  string s;
  cin>>s;
  for(int i=1; i <= s.size(); i++){
    if((i%2==1 && s.at(i-1) == 'L') || (i%2==0 && s.at(i-1) == 'R')){
      cout<<"No";
      return 0;
    }
  }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import math
a, b, x = list(map(int, input().split()))

height = x / (a ** 2)
side = a * height

if side <= a * b / 2:
    edge = side * 2 / b
    print(90 - math.degrees(math.atan(edge/b)))
else:
    edge = (a * b - side) * 2 / a
    print(math.degrees(math.atan(edge/a)))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MaxN = 532;
int c[MaxN], s[MaxN], f[MaxN];

int main (void)
{
  int n, i, j;
  scanf ("%d", &n);
  for (i = 0; i < n - 1; i++)
    scanf ("%d %d %d", &c[i], &s[i], &f[i]);
  for (i = 0; i < n; i++)
  {
    int cur = 0;
    for (j = i; j < n - 1; j++)
    {
      cur = max (cur, s[j]);
      while (cur % f[j] != 0)
        cur++;
      cur += c[j];
    }
    printf ("%d\n", cur);
  }
  return 0;
}

Measured memory_bytes: 128
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val M, D = sc.nextInt()

    var count = 0L
    var m = 1
    while (m <= M) {
      var d = 22
      while (d <= D) {
        val Array(d10, d1) = d.toString.map(_.toString.toInt).toArray
        if (d1 >= 2 && d1 * d10 == m) {
          count += 1
        }
        d += 1
      }
      m += 1
    }

    println(count)
  }

}


Measured memory_bytes: 35312
#b

# B > A
# C > B

A, B, C = map(int, input().split())
K = int(input())

k = 0
while B<=A:
    B*=2
    k += 1

while C<=B:
    C*=2
    k+=1
    
if k<=K:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9168
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

bool comp(vll a,vll b){
    return a[1]<b[1];
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,K;
    cin>>N>>K;
    
    if(K>(N-1)*(N-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    
    cout<<N-1+(N-1)*(N-2)/2-K<<endl;
    for(int i=2;i<=N;i++){
        printf("%d %d\n",1,i);
    }
    
    ll count=0;
    for(int i=2;i<=N-1;i++){
        if(count==(N-1)*(N-2)/2-K)break;
        for(int j=i+1;j<=N;j++){
            if(count==(N-1)*(N-2)/2-K)break;
            printf("%d %d\n",i,j);
            count++;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,k;
const int m=1e+9+7;
long long ans,x,y;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;++i){
		x+=i;
		y+=n-i;
	}
	for(int i=k;i<=n+1;++i){
		ans=(ans+y-x+1)%m;
		x+=i;
		y+=n-i;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(4);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    //*
    if( a % 2 == 0 ){
        cout << a << endl;
    } else {
        cout << a * 2 << endl;
    }
    //*/
    
    //cout << ans << endl;

    return 0; 
}


Measured memory_bytes: 3544
#include<stdio.h>

int main(void){
	int P,Q,R;scanf("%d%d%d",&P,&Q,&R);
  	if(P>=Q&&P>=R){
    	printf("%d\n",Q+R);
    }else if(Q>=P&&Q>=R){
    	printf("%d\n",P+R);
    }else{
    	printf("%d\n",P+Q);
    }
  	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int cnt=0;
  int i;
  for(i=1;i<=n;i+=2){
    int c=0;
    int j;
    for(j=1;j<=i;j++){
      if(i%j==0) c++;
    }
    if(c==8) cnt++;
  }
  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128