akhauriyash/Code-Regression huggingface dataset:
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[500001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=500000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}
*/



lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,m,g;
lld x,y,n1,a,b=0,n2,h,z,c;
/*
void solve()
{
    cin>>n;
    ans=1;
    k=0;
    vector<lld > v;
    x=0;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(l);
        if(l==0) k=1;
        if(l>1000000000) x+=1; 
        //cout<<"A";
    }
    if(x>=2)
    {
        cout<<"-1";
        return;
    }
    if(k==1)
    {
        cout<<"0";
        return;
    }
    ans=1;

    for(i=0;i<n;i++)
    {
        ans*=v[i];
    //  cout<<ans<<" \n";
        if(ans > 1000000000000000000 || ans < 0)
        {
            cout<<"-1";
            return;
        }
    }
    cout<<ans;
}
*/

void solve()
{
    string s;
    cin>>n>>s;
    ans = n*(s[0]-'0');
    y = ((s[2]-'0')*10+s[3]-'0');
    y*=n;
    y/=100;
    ans+=y;
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
    }
    return 0;
}

Measured memory_bytes: 3636
s= sorted(input())
t= sorted(input(), reverse=True)

for i, j in zip(s, t):
  if i < j:
    print("Yes")
    break
  elif i > j:
    print("No")
    break
else:
  if len(s) < len(t):
    print("Yes")
  else:
    print("No")

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

using namespace std;

int n;
double x[8], y[8], dis[8][8], summ, temp;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i=0; i<n - 1; i++) {
		for (int j=i + 1; j<n; j++) {
			dis[i][j] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
			summ += dis[i][j];
		}
	}
	temp = (n - 1) * n / 2;
	summ /= temp;
	temp = n - 1;
	summ *= temp;
	cout << fixed << setprecision(15);
	cout << summ << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
    ll n;cin >>n;
    vector<ll>a(n);
    vector<ll>b(n);
    vector<ll>c(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >>b[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >>c[i];
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));
    vector<ll>cb(n);
    vector<ll>ca(n);
    for (int i = 0; i < n; ++i) {
        ll key=b[i];
        cb[i]=n-(upper_bound(all(c),key)-c.begin());
    }
    for (int i = 0; i < n; ++i) {
        ll key=a[i];
        ca[i]=n-(upper_bound(all(b),key)-b.begin());
    }
    sort(all(cb));
    ll ans=0;
    vector<ll>d(n+1,0);
    for (int i = 0; i < n; ++i) {
        d[i+1]=d[i]+cb[i];
    }
    for (int i = 0; i < n; ++i) {
        ans+=d[ca[i]];
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#define MAX 50
int solve(int, int);


int n,P[MAX];

int main(){
  int x,y,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&P[i]);
  }
  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&y);
    if( solve(0,y)){
      printf("yes\n");
    }
    else printf("no\n");
  }


  return 0;
}




int solve(int a,int b){
  int res=0;

  if(b == 0){
    return 1;
  }

  if(a >= n){
    return 0;
  }
  res = solve(a+1,b)||solve(a+1,b-P[a]);
  return res;
}
  
		   



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  
  if(N%10==2) ans++;
  if((N%100)-(N%10)==20) ans++;
  if((N%1000)-(N%100)==200) ans++;
  if((N%10000)-(N%1000)==2000) ans++;
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
A,B = gets.chomp.split.map(&:to_i)
p = (A / 0.08).ceil
q = ((A + 0.99) / 0.08).floor
r = (B / 0.1).ceil
s = ((B + 0.99) / 0.1).floor

n = (p..q).to_a.sort
m = (r..s).to_a.sort

if (n & m).length > 0
  puts (n & m).shift
else
  puts "-1"
end

Measured memory_bytes: 1788
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    
    int ans = 0;
    
    if(a.length() != b.length()) {
      System.out.println("-1");
    }
    
    for(int i=0; i<a.length(); i++) {
      if(a.charAt(i) != b.charAt(i)) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 41416
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
bool f[100009];

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    vec.push_back(a);
  }
  vec.erase(unique(vec.begin(),vec.end()),vec.end());

  int ans=0;
  for(int i=1;i<(int)vec.size()-1;i++){
    if(!f[i-1]&&(vec[i-1]<vec[i]&&vec[i]>vec[i+1]||vec[i-1]>vec[i]&&vec[i]<vec[i+1])){
      f[i]=true;
      ans++;
    }
  }
  cout<<ans+1<<endl;
  return(0);
}


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<map>
#include<set>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

ll pas[2001][2001];
void init() {
	rep(i, 2001) {
		rep(j, 2001) {
			if (i == 0 || j == 0)pas[i][j] = 1;
			else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]) % mod;
		}
	}
}

void solve() {
	init();
	int n, k; cin >> n >> k;
	vector<ll> dp(n + 1);
	rep1(i, k) {
		if (n - k < i - 1) {
			cout << 0 << endl; continue;
		}
		ll ans = pas[i - 1][k-i] * pas[i][n-k-i+1] % mod;
		cout << ans << endl;
	}
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout<<fixed<<setprecision(10);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int pre,n,A[110000];
long long ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&A[i]);
	ans=0;
	for (int i=1;i<=n;i++){
		int k=pre+1;
		if (A[i]<=k){
			pre=max(pre,A[i]); continue;
		}
		ans+=(A[i]-1)/k;
		pre=max(pre,1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#define ll long long
#define inf 1e9
#define eps 1e-10
#define mod 9901
#define mkp make_pair
using namespace std;
int i,j,k,m,s,t,n,ans1,ans2,n1,nn,m1,mx;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int kabs(int a)
{
   if (a<0) return -a;
   return a; 
}
void add(int &x,int y)
{
   x+=y;
   if (x>=mod) x-=mod;
}
void dec(int &x,int y)
{
	x-=y;
	if (x<0) x+=mod;
}
char ch[101000];
int main()
{
	scanf("%s",ch+1);
	n=strlen(ch+1);
	for (i=2;i<=n;i++)
		if (ch[i]!=ch[i-1])
			s++;
	printf("%d\n",s);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
ll x;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> x;
	ll sum = 100;
	ll i;
	for(i = 0;;i++){
		if(sum >= x){
			break;
		}
		sum += (sum / 100);
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;
 
char mapd[2000][2000];
int N, M;
int sx, sy;
int gx, gy;
 
int d[2000][2000];
 
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
 
void bfs() {
    queue<P> que;
    
    rep(i, N) rep(j, M) d[i][j] = INF;
    rep(i, N) rep(j, M) {
        if (mapd[i][j] == '#') {
            que.push(P(i, j));
            d[i][j] = 0;
        }
    }
 
    while(que.size()) {
        P p = que.front(); que.pop();
        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
 
            if (0 <= nx && nx < N && 0 <= ny && ny < M && mapd[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                //cout << "d[" << nx << "][" << ny << "] = " << d[nx][ny] << endl;
            }
        }
    }
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, N) rep(j, M) cin >> mapd[i][j];
    int ans = 0;
    bfs();
    rep(i, N) {
        rep(j, M) {
            if (d[i][j] != INF) {
                ans = max(ans, d[i][j]);
                //cout << d[i][j];
            }
        }
        //cout << endl;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 20752
N=io.read("*n", "*l")
S=io.read()

T={}
T["R"]=0
T["G"]=0
T["B"]=0
for i=1,N do
    T[S:sub(i,i)] = T[S:sub(i,i)] + 1
end

M=T["R"]*T["G"]*T["B"]

for i=1,N do
    x=S:sub(i,i)
    for j=1,(N-i)//2 do
        y=S:sub(i+j,i+j)
        z=S:sub(i+2*j,i+2*j)
        if x~=y and y~=z and z~=x then
            M = M-1
        end
    end
end

print(M)

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

vector<bool> d(10,false);

bool det(int n){
  while(n > 0){
    int num = n%10;
    if(d.at(num)){
      return false;
    }
    n /= 10;
  }
  return true;
}

int main() {
  int n,k;
  cin >> n >> k;
  
  for(int i = 0; i < k; i++){
    int num;
    cin >> num;
    d.at(num) = true;
  }

  while(1){
    if(det(n)){
      cout << n << endl;
      break;
    }else{
      n++;
    }
  }
}


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

using ll = long long;
using namespace std;
using ld = long double;

#define rep(i, n) for (i; i < (ll)n; ++i)
#define all(x) begin(x), end(x)

int main()
{
  ll K;
  cin >> K;
  ll ans = 0;
  ll a=1, b=1, c=1;
  rep(a, K+1) {
    b = 1;
    rep(b, K+1) {
      c = 1;
      rep(c, K+1) {
        // cout << a << b << c << " ";
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import math
import random
from operator import itemgetter
import re
import sys
from itertools import accumulate
from collections import defaultdict
from collections import deque
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
N,A,B = map(int,input().split())
X = [int(i) for i in input().split()]
ans = 0
for i in range(N-1):
    if (X[i+1]-X[i])*A > B:
        ans += B
    else:
        ans += (X[i+1]-X[i])*A
print(ans)

Measured memory_bytes: 88940
N = int(input())
C = {}
for i in range(N):
    buf = input()
    if buf in C:
        C[buf] += 1
    else:
        C[buf] = 1
max_n = max(C.values())
max_values = [i[0] for i in C.items() if i[1] == max_n]
for line in sorted(max_values):
    print(line)


Measured memory_bytes: 96060
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
int N;
int main(int argc, char const *argv[])
{
cin>>N;
if(N%1000%111==0||N/10%111==0){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[6];
	scanf("%s",a) ;
	int i ;
	int s =0;
	for(i=0 ; a[i]!='\0' ;i++)
	{
		if(a[i]=='+')
		{
			s++;
		}else s-- ;
	}
	printf("%d",s) ;
	
	
	
	return 0 ;
 } 

Measured memory_bytes: 128
def solve(n, a):
    edge = {i: set() for i in range(n)}
    for i in range(n):
        edge[i].add(a[i]-1)
    num = 0
    for v, neighbors in edge.items():
        for u in neighbors:
            if (u in edge) and (v in edge[u]):
                num += 1
    return num // 2

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

Measured memory_bytes: 43356
#include <iostream>

using namespace std;

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

int main(void){
int w,h,c, g;
cin >> w >> h >> c;
g = gcd(w,h);
cout << (w*h/g/g*c) << endl;
return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define gcd __gcd
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vec(cr)vector<cr>
#define fr(j, n)for(int i=j; i<n; i++)
#define scan(cr)for(auto &it:cr)cin >> it
#define all(cr)cr.begin(), cr.end()
#define sz(cr)cr.size()
#define Test() int t; for(cin >> t; t>0; t--)
#define deb(x)cout << #x << ":" << x << '\n'
int lcm(int a, int b){ return a/gcd(a, b) * b; }

int main(){
	string s;
	cin >> s;
	int cnt=0, dis=0;
	for(int i=0; i<s.size(); i++){
		if(s[i]==s[i+1] && s[i]=='R')cnt++;
		if(s[i]=='R')dis++;
	}
	if(cnt==0 && dis==0)cout << 0;
	else cout << cnt+1;
	return 0;
}


Measured memory_bytes: 3592
N, X, M = map(int, input().split())

now = X
used = [X]
i = 1
T = True
while T:
  if i == N:
    print(sum(used))
    quit()
  else:
    next_ = (now * now) % M
    if next_ in used:
      T = False
    else:
      used.append(next_)
      now = next_
    i += 1  

count = used.index(next_)
ans = sum(used[:count])
#print(ans)
roop = len(used) - count
roop_ans = sum(used[count:])
#print(roop, roop_ans)
index = (N - count) % roop
#print(index)
ans += roop_ans * int((N - count) // roop)
#print(ans)
#if index == 0:
#  index = roop
  
ans += sum(used[count:count + index]) 
  
print(ans)
#print(used)    


Measured memory_bytes: 68352
#include<iostream>
using namespace std;
int main(){
    int n,m,t;
    cin>>n>>m;
    int R[n][m]={};
    int S[m][1]={};
    int T[n][1]={};
    for (int i=0;i<n;i++){
        for(int x=0;x<m;x++){
            cin>>R[i][x];
        }
    }
    for (int i=0;i<m;i++){
        cin>>S[i][0];
    }
    for (int i=0;i<n;i++){
        for(int x=0;x<m;x++){
            t+=R[i][x]*S[x][0];
        }
        cout<<t<<endl;
        t=0;
    }
    
    
}




Measured memory_bytes: 3120
// finish date: 2019/6/26

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int medA, medB;
    if (N % 2) {
        medA = A[N / 2];
        medB = B[N / 2];
        cout << int(medB - medA + 1) << endl;
    } else {
        medA = A[N / 2 - 1] + A[N / 2];
        medB = B[N / 2 - 1] + B[N / 2];
        cout << int(medB - medA + 1) << endl;

    }

}


Measured memory_bytes: 4772
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	int n;
	int num[1001], p[1001], q[1001], r[1001];
	int P, Q, R, C;

	while (scanf("%d", &n), n != 0){
		int check = 0;

		for (int i = 0; i < n; i++){
			scanf("%d%d%d%d", &num[i], &p[i], &q[i], &r[i]);
		}
		scanf("%d%d%d%d", &P, &Q, &R, &C);

		for (int i = 0; i < n; i++){
			if (P < p[i] || Q < q[i] || R < r[i] || C < (p[i] + r[i]) * 4 + q[i] * 9){
				check++;
			}
			else {
				cout << num[i] << endl;
			}
		}

		if (n == check){
			cout << "NA" << endl;
		}
	}

	return (0);
}

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

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

Measured memory_bytes: 0
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
dp = [INF for _ in range(N+1)]

dp[0] = 0

for i in range(1, N+1):
    # 6
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 6
    # 9
    power = 1
    while power <= i:
        dp[i] = min(dp[i], dp[i-power] + 1)
        power *= 9

print(dp[N])

Measured memory_bytes: 47344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] b = new long[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }

        long sum = 0;
        for (int i = 0; i < b.length; i++) {
            if (b[i] - a[i] > 0) {
                sum += a[i];
                b[i] -= a[i];
                a[i] = 0;
                if (b[i] - a[i + 1] > 0) {
                    sum += a[i + 1];
                    b[i] -= a[i + 1];
                    a[i + 1] = 0;
                } else {
                    sum += b[i];
                    a[i + 1] -= b[i];
                    b[i] = 0;
                }
            } else {
                sum += b[i];
                a[i] -= b[i];
                b[i] = 0;
            }
        }
        System.out.println(sum);
    }

}



Measured memory_bytes: 83008
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
ll ok(ll n){
  ll cu=0;
  while(n%2==0){
    n/=2;
    cu++;
  }
  return cu;
}
int main(){
  ll n,m;
  cin>>n>>m;
  vll a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll k=ok(a[0]);
  a[0]>>=k;
  for(int i=1;i<n;i++){
    if(ok(a[i])!=k){
      COUT(0);
      return 0;
    }
    a[i]>>=k;
  }
  k--;
  m>>=k;
  ll j=1;
  rep(i,n){
    j=lcm(j,a[i]);
    if(j>m){
      cout<<0<<endl;
      return 0;
    }
  }
  m/=j;
  COUT((m+1)/2);
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>

int main(){
    int x;
    scanf("%d",&x);
    if(x < 4){
        printf("1\n");

        return 0;
    }
    int max = 0;
    for(int i = 2; i <= sqrt(x); i++){
        for(int j = 1;; j++){
            if(pow(i,j) <= x && x <= pow(i,j + 1)){
                if(max < pow(i,j)){
                    max = pow(i,j);
                }
            }
            if(pow(i,j) > x){
                break;
            }
        }
    }
    printf("%d\n",max);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(long long 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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int binary(long long bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

int main(){
  int a,b,c,d;
  cin >> a >> b >> c;
  if (a*c <= b) {
    cout << c ;
  } else {
    for(int i = 0; i*a<=b;i++) {
      d = i;
    }
    cout << d;
  }
} 

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			if(str.charAt(0) == str.charAt(2)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


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

int main(){
  vector<int> x(6,0);
  REP(i,6) cin>>x.at(i);
  if(x.at(5)<x.at(4)-x.at(0)) cout<<":(";
  else cout<<"Yay!";
}

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

int main(){
  int n;
  cin >> n;
  int dp[n+1][3];
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0] = dp[0][1] = dp[0][2] = 0;
  for (int i = 0; i < n; i++){
    dp[i+1][0] = max(dp[i][1]+a[i], dp[i][2]+a[i]); 
    dp[i+1][1] = max(dp[i][2]+b[i], dp[i][0]+b[i]); 
    dp[i+1][2] = max(dp[i][0]+c[i], dp[i][1]+c[i]); 
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    ll K;
    cin >> K;
    const ll N = 50;

    const ll a = K / N;
    const ll b = K % N;

    cout << N << endl;
    for (ll i = 0; i < b; i++) {
        const ll v = (a + 1) * (N + 1) - K + (N - 1);
        assert(v >= 0);
        if (i != 0) {
            cout << " ";
        }
        cout << v;
    }
    for (ll i = b; i < N; i++) {
        const ll v = a * (N + 1) - K + (N - 1);
        // const ll v = (a >= b) ? a * (N + 1) - K : (a * (N + 1) + (b - a)) - K;
        assert(v >= 0);
        cout << " " << v;
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
/*16D8103008D Yukki Nishimura 5/14 */

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

using namespace std;

#define MAX 100000

bool check(int C[], int y,int j) {
	if (j != 0) {
		for (int i = 0; i < j; i++) {
			if (C[i] == y) {
				return true;
			}
		}
	}

	return false;  //探索失敗
}

int func(int S[], int T[], int q, int n)
{
	int s = n;
	int t = q;
	int j = 0;

	int C[MAX] = { };


	for (int i = 0; i < s; i++) {
	
		for (int k = 0; k < t; k++) {
			if (check(C, S[i],j)) {
				break;
			}

			else if (S[i] == T[k]) {
				C[j] = S[i];
				j++;
				break;
			}
			
		}
	}
	
	return j;
}



int main(void)
{
	int n, q, c;

	int S[MAX] = { }, T[MAX] = { };

	cin >> n;


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

	cin >> q;

	for (int i = 0; i < q; i++) {
		cin >> T[i];

	}

	c = func(S, T, q, n);

	cout << c << endl;

	return 0;


}




Measured memory_bytes: 4268
#include <iostream>
using namespace std;
int main(){
	int r,c,i,j;
	int sum;
	cin>>r>>c;
	int num[r+1][c+1];
for(i=0;i<r+1;i++){
 for(j=0;j<c+1;j++){
     num[i][j]=0;
}
}
	for(i=0;i<r;i++){
		sum=0;
		for(j=0;j<c;j++){
			cin>>num[i][j];
			sum+=num[i][j];
		}
		num[i][c]=sum;
	}


	for(j=0;j<c+1;j++){
		for(i=0;i<r;i++){
		num[r][j]+=num[i][j];
		}
	}
   for(i=0;i<r+1;i++){
	   for(j=0;j<c+1;j++){
                   if(j){
                      cout<<" ";
                   }
		   cout<<num[i][j];
		   if(j==c){
			   cout<<endl;
		   }
		 }

	   }
   return 0;
   }

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int n,i,c_w=0,c_e=0,at,max=0;
	char s[300001];
	int w[300001]={0};
	int e[300001]={0};
	scanf("%d%s",&n,s);
	
	for(i=0;i<n;i++){
		if(s[i]=='E'){
			c_e++;
			e[i]=c_e;
			w[i]=c_w;
		}
		if(s[i]=='W'){
			w[i]=c_w;
			e[i]=c_e;
			c_w--;
		}
	}
	for(i=0;i<n;i++)
		w[i]+=abs(c_w);
	
	for(i=1;i<n-1;i++){
		at=w[i+1]+e[i-1];
		if(at>max)
			max=at;
	}
	at=w[1];
	if(at>max)
		max=at;
	at=e[n-2];
	if(at>max)
		max=at;
	
	printf("%d",n-1-max);
	return 0;
}
	

Measured memory_bytes: 2816
// Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Type
template <typename T> using P = pair<T, T>;
using ll = long long;
using ull = unsigned long long;

// Constants
const ll INF = 1e18;
const ll MOD = 1000000007;


// 辺
template <typename T>
struct Edge {
  int to;
  T cost;
  Edge(int to, T cost) : to(to), cost(cost) {}
};

// ノード
template <typename T>
struct Node {
  vector< Edge<T> > edges;
  Node() {}
  void addEdge(int to, T cost) {
    edges.push_back(Edge<T>(to, cost));
  }
};

// グラフ
template <typename T>
class Graph {
  private:
    int nodeN;
    vector< Node<T> > graph;
  public:
    Graph(int nodeN) {
      this->nodeN = nodeN;
      for(int i = 0; i < nodeN; i++) {
        graph.push_back(Node<T>());
      }
    }
    /**
      辺を追加する
      */
    void addEdge(int from, int to, T cost) {
      graph[from].addEdge(to, cost);
    }
    /**
      ベルマンフォード法
      計算量: O(|V|・|E|)
      */
    vector<T> bellmanFord(int s) {
      // 距離情報初期化
      vector<T> d(this->nodeN, -INF);
      d[s] = 0;

      // 全ての辺に対して、this->nodeN回更新を掛ける
      for(int i = 0; i < this->nodeN; i++) {
        for(int j = 0; j < this->nodeN; j++) {
          for(int k = 0; k < this->graph[j].edges.size(); k++) {
            Edge<T> edge = this->graph[j].edges[k];
            if(d[j] != -INF && d[edge.to] < d[j] + edge.cost) {
              d[edge.to] = d[j] + edge.cost;
              // 負閉路検出
              if(i == this->nodeN-1 && edge.to == this->nodeN-1) {
                d[this->nodeN - 1] = -INF;
                return d;
              }
            }
          }
        }
      }
      return d;
    }
    /**
      getter
      */
    int getNodeN() {
      return this->nodeN;
    }
};

int main() {
  // 入力
  int N, M;
  cin >> N >> M;
  Graph<ll> graph = Graph<ll>(N);
  for(int i = 0; i < M; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    graph.addEdge(a, b, c);
  }

  vector<ll> d = graph.bellmanFord(0);

  if(d[N-1] != -INF) {
    cout << d[N-1] << endl;
  } else {
    cout << "inf" << endl;
  }

  return 0;
}

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

int main(){
        int N;
        cin >> N;
        cout << (1+N)*N/2 << endl;
        return 0;
}


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

int main() {
    int n;
    int T;
    int q;
    int count = 0;
    
    scanf("%d", &n);
    int S[n];
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }
    
    scanf("%d", &q);
    
    for (int j = 0; j < q; j++) {
        scanf("%d", &T);
        for (int k = 0; k < n; k++) {
            if (T == S[k]) {
                count++;
                break;
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s;cin>>s;
	int q;cin>>q;int t[q],f[q];char c[q];
	int sum=0;
	rep(i,q){
		cin>>t[i];
		if(t[i]==2) cin>>f[i]>>c[i];
		sum+=t[i];
	}
	deque<char> dq;
	for(auto i:s) {
		if(sum%2==0) dq.push_back(i);
		else dq.push_front(i);
	}
	int cnt=0;
	for(int i=0;i<q;i++){
		if(t[i]==1) cnt++;
		else{
			if((sum+cnt+f[i])%2==1) dq.push_front(c[i]);
			else dq.push_back(c[i]);
		}
		//cout<<s<<"\n";
	}
	for(auto p:dq) cout<<p;
	cout<<"\n";
}

Measured memory_bytes: 2688
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
#define pii pair<int,int>
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 2e5+10;
const int mod = 998244353;
const int inf = 1e9+10;

int n, k;
int a[maxn];
int L[maxn], R[maxn];
vector<int> stk;

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n;
    for(int i = 1; i <= n; i++)
    {
        cin>> a[i];
        if(stk.size())
            while(a[i] < a[stk.back()])
            {
                stk.pop_back();
                if(stk.empty()) break;
            }
        if(stk.size()) L[i] = stk.back()+1;
        else L[i] = 1;
        stk.push_back(i);
    }
    stk.clear();
    ll ans = 0;
    for(int i = n; i >= 1; i--)
    {
        if(stk.size())
            while(a[i] < a[stk.back()])
            {
                stk.pop_back();
                if(stk.empty()) break;
            }
        if(stk.size()) R[i] = stk.back()-1;
        else R[i] = n;
        stk.push_back(i);

        ans += a[i] * (R[i]-i+1) * (i-L[i]+1);
    }
    cout<< ans;
}

 


 

Measured memory_bytes: 6644
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    for (int i = 0; i < 110; i++) {
      for (int j = 0; j < 100100; j++) {
        dp[i][j] = INF;
      }
    }
    dp[0][0] = 0;
    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < 100100; ++sum_v) {

            // i 番目の品物を選ぶ場合
            if (sum_v - value[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }

            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    // 最適値の出力
    long long ans = 0;
    for (int i = 0; i < 100100; i++) {
      if (dp[N][i] <= W) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 89632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
  int n,l,i,sum=0,minn,x;
  cin>>n>>l;
  minn = 10000000;

  for(i=1;i<=n;i++)
  {
    sum = sum + l+i-1;
    if(minn>abs(l+i-1))
    {
      minn = abs(l+i-1);
      x=i;
    }
   
  }
  sum = sum - (l+x-1);

  cout<<sum<<endl;

  return 0;
}

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

int main(){
    string S; cin >> S;

    int p = 0, g = 0;
    int ans = 0;    
    for (int i = 0; i < S.length(); i++){
        if (S[i] == 'g'){
            if (g == p){
                g++;
            }else{
                p++;
                ans++;
            }
        }else{
            if (g == p){
                g++;
                ans--;
            }else{
                p++;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
def inputs(): return [int(x) for x in input().split()]
a1 = inputs()
a2= inputs()
a3=inputs()
n = int(input())
N = []
for i in range(n):
  N.append(int(input()))
cnt= [0]*8
for j in range(3):
  if a1[j] in N:
    cnt[0] +=1
for j in range(3):
  if a2[j] in N:
    cnt[1] +=1
for j in range(3):
  if a3[j] in N:
    cnt[2] +=1
for j in range(3):
  if a1[j] in N and a2[j] in N and a3[j] in N:
    cnt[3+j] +=3
if a1[0] in N and a2[1] in N and a3[2] in N:
  cnt[6] +=3
if a1[2] in N and a2[1] in N and a3[0] in N:
  cnt[7] +=3
if 3 in cnt:
  print("Yes")
else:
  print("No")

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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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; }

double ki(double a){
    int su = 0;
    for(int i = 1; i <= a; i++) su += i;
    return su / a;
}

int main(){
ll n, k;
cin >> n >> k;
vector<ll>a(n);
REP(i, n) cin >> a.at(i);
ll ans = 0;
REP(i, n){
    ll cnt = 0, cnt2 = 0;
    REP(j, n)if(a.at(j) < a.at(i)) cnt++;
    for(int j = i + 1; j < n; j++) if(a.at(j) < a.at(i)) cnt2++;
ans += (cnt2 * k) % MOD;
ans %= MOD;
ans += k * (k - 1) / 2 % MOD * cnt % MOD;
ans %= MOD;
}
print(ans);
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();
    int[] A = new int[N + 1];

    for (int i = 0; i < N - 1; i++) {
      int num = sc.nextInt();
      A[num] += 1;
    }
    for (int i = 1; i <= N; i++) {
      System.out.println(A[i]);
    }

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 55092
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

//typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX = 1e9 + 5;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> c(3);
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		int cnt = 0;
		for (int j = 0; j < 3; j++) {
			if (c[j] == a[i]) {
				cnt++;
			}
		}

		ans = (ans * cnt) % MOD;
		for (int j = 0; j < 3; j++) {
			if (c[j] == a[i]) {
				c[j] = a[i] + 1;
				break;
			}
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    int a, b;
    
    cin >> a >> b;
    
    if(a == b) {
        cout << "Draw\n";
    } else if(((a>b)&&((a!=13)||(b!=1)))||((a==1)&&(b==13))) {
        cout << "Alice\n";
    } else {
        cout << "Bob\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, l;
  cin >> n >> l;
  
  int t1, t2, temp;
  int min = 999;
  for(int i=0; i<n; i++){
    temp = l+i;
    t2 += temp;
    if(min>abs(temp)){
      min = abs(temp);
      t1 = temp;
    }
  }
  
  cout << t2-t1 << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))

cng = [0]*(N+1)
for i in range(2, N+1):
    if A[i] > A[i-1]:
        cng[i] = 1
    elif A[i] < A[i-1]:
        cng[i] = -1

money = 1000
stock = 0

for i in range(1, N):
    # buy
    if cng[i+1] == 1:
        ds = money // A[i]
        dm = ds * A[i]
        stock += ds
        money -= dm
    # sell
    elif cng[i+1] == -1:
        ds = stock
        dm = ds * A[i]
        stock -= ds
        money += dm

if stock != 0:
    money += stock * A[N]

print(money)

Measured memory_bytes: 9180
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

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

func main() {
	var a int
	var b int
	var c int
	fmt.Scan(&a, &b, &c)

	arr := []int{a + b, a - b, a * b}
	sort.Sort(sort.IntSlice(arr))

	fmt.Println(arr[2])
}

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

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct node{
  int p,lc,rs;
};
struct node T[MAX];
int n,D[MAX],h[MAX];
void deep(int,int);void print(int);
int height(int);int culc(int);
int main(){
  int l,r,z=0,a,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p=NIL;
  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&l,&r);
    T[a].lc=l;T[a].rs=r;
    if(l!=NIL)T[l].p=a;
    if(r!=NIL)T[r].p=a;
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL)z=i;
  }
  deep(z,0);height(z);
  for(i=0;i<n;i++)print(i);
  return 0;
}

void deep(int p,int q){
  if(p==NIL)return 0;
  D[p]=q;
  deep(T[p].lc,q+1);deep(T[p].rs,q+1);
}
int height(int x){
  int h1=0,h2=0;
  if(T[x].lc!=NIL)h1=height(T[x].lc)+1;
  if(T[x].rs!=NIL)h2=height(T[x].rs)+1;
  return h[x]=(h1>h2?h1:h2);
}

int culc(int u){
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].lc!=u&&T[T[u].p].lc!=NIL)return T[T[u].p].lc;
  if(T[T[u].p].rs!=u&&T[T[u].p].rs!=NIL)return T[T[u].p].rs;
  return NIL;
  
}

void print(int z){
  int cnt=0;
  printf("node %d:",z);
  printf(" parent = %d,",T[z].p);
  printf(" sibling = %d,",culc(z));
  if(T[z].lc!=NIL)cnt++; if(T[z].rs!=NIL)cnt++;
  printf(" degree = %d,",cnt);
  printf(" depth = %d,",D[z]);
  printf(" height = %d,",h[z]);
  if(T[z].p==NIL)printf(" root\n");
  else if(T[z].lc==NIL&&T[z].rs==NIL)printf(" leaf\n");
  else printf(" internal node\n");
}



Measured memory_bytes: 2112