akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define rep(i , j , k) for(int i = j ; i <= k ; i ++)
#define Rep(i , j , k) for(int i = j ; i >= k ; i --)

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

auto ot = [&]() { cerr << "ATS TXDY" << '\n' ; int ATS_nantf_txdy = true ; } ;
auto _ios = [&]() { ios :: sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ; } ;

namespace stO_ATS_Orz {
  template < class T > void cmax(T & x , T y) { if(x > y) x = y ; }
  template < class T > void cmin(T & x , T y) { if(x < y) x = y ; }
  template < class T > void abs(T x) { if(x < 0) x = -x ; }
  void main() {
    int n ;
    cin >> n ;
    int l = 0 , r = n , ans = 0 ;
    while(l <= r) {
      int mid = l + r >> 1 ;
      if(mid * 1.08 < n + 1) {
        l = mid + 1 ;
        ans = mid ;
      }
      else {
        r = mid - 1 ;
      }
    }
    if(ans * 1.08 >= n) { cout << ans << '\n' ; }
    else { cout << ":(" << '\n' ; }
  }
}
signed main() {
  _ios() ; ot() ;
  return stO_ATS_Orz :: main() , 0 ;
}


Measured memory_bytes: 256
#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)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N;
  cin >> N;
  vector<vector<pair<int,int> > > xy(N);
  REP(i,N){
    int a;
    cin >> a;
    REP(j,a){
      int x,y;
      cin >> x >> y;
      x--;
      xy[i].push_back(make_pair(x,y));

    }
  }

  // REP(i,N){
  //   REP(j,xy[i].size()){
  //     cout << xy[i][j].first << " " << xy[i][j].second << endl;
  //   }
  //   cout << "--\n";
  // }

  int ans=0;
  REP(i,pow(2,N)){
    vector<int> h(N);
    int ii=i;
    REP(j,N){
      h[j] = ii & 1;
      ii = ii >> 1;
    }

    bool flag=true;
    REP(i,N){
      if(h[i]==0)continue;
      REP(j,xy[i].size()){
        if(h[xy[i][j].first] != xy[i][j].second){
          flag=false;
          break;
        }
      }
    }

    if(flag==false)continue;

    int tmp=0;
    REP(j,N){
      if(h[j]==1)tmp++;
    }
    ans = max(ans,tmp);
  }

  cout << ans << endl;
}



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

#define int long long

const int N = 26;
int n, ans, mark[N];
string s;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	while (n--) {
		cin >> s;
		mark[s[0] - 'A']++;
	}
	vector <int> vec = {mark['M' - 'A'], mark[0], mark['R' - 'A'], mark[2], mark['H' - 'A']};
	
	for (int i = 0; i < 5; i++)
		for (int j = i + 1; j < 5; j++)
			for (int k = j + 1; k < 5; k++)
				ans += vec[i] * vec[j] * vec[k];
	cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val arr = io.StdIn.readLine().split(" ").map(_.toInt)
  val res = arr.zipWithIndex.foldLeft((0, 0))((acc, a) => if (a._2 < arr.length / 2) (acc._1 + a._1, acc._2) else (acc._1, acc._2 + a._1))
  if (res._1 > res._2) {
    println("Left")
  } else if (res._1 < res._2) {
    println("Right")
  } else {
    println("Balanced")
  }
}

Measured memory_bytes: 27216
#include<iostream>
#include<vector>
#include<iomanip>
#include<cmath>

using namespace std;

int main(){
  int n;

  cin >> n;

  int num = pow(2,n);
  vector<int> a;

  int temp;
  for(int i=0;i<num;++i){
    cin >> temp;
    a.push_back(temp);
  }

  for(int i=2;i<=num;i*=2){
    for(int j=0;j<num;j+=i){
      if(a[j] > a[j+i/2]){
        a[j] = a[j] - a[j+i/2];
      }else if(a[j] < a[j+i/2]){
        a[j] = a[j+i/2] - a[j];
      }
    }
  }

  cout << a[0] << endl;

  return 0;
}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	int N, L;
	cin >> N >> L;

	int total = N*(L-1) + N*(N+1)/2;
	int min = L;
	int max = L+N-1;

	if( min <=0 && max >= 0 )
		cout << total << endl;
	else if( min > 0 )
		cout << total - min << endl;
	else
		cout << total - max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    long long int i,j,k,l,inc,dec,t,r,mod=1000000007;
   	long long int c,d,e,s,ans=0,n,temp,m,p,x,y;
   	//cin>>t;
   	t=1;
   	while(t--)
   	{
   		cin>>n;
   		long long int a[n+1][3],dp[n+1][3];
   		for(i=1;i<=n;i++)
   		{
   			cin>>a[i][0]>>a[i][1]>>a[i][2];	
   			dp[i][0]=0;
   			dp[i][1]=0;
   			dp[i][2]=0;
		}
		dp[1][0]=a[1][0];
		dp[1][1]=a[1][1];
		dp[1][2]=a[1][2];
		for(i=2;i<=n;i++)
		{
			for(j=0;j<3;j++)
			{
				for(k=0;k<3;k++)
				{
					if(j!=k)
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
				}	
			}	
		}
		ans=max(dp[n][0],max(dp[n][1],dp[n][2]));
		cout<<ans<<endl;
	}
   	
	
   return 0;
}


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

void nextv(int m, vector<int> &per){
  int n;
  for(int i=per.size()-1; i>=0; --i){
    if(per[i] != m){n = i; break;}
  }
  int ni = per[n] +1;
  for(int i=n; i<(int)per.size(); ++i){
    per[i] = ni;
  }
}

int main(){
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> pt(q,vector<int>(4));
  for(int i=0; i<q; ++i){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b;
    pt[i][0] = a;
    pt[i][1] = b;
    pt[i][2] = c;
    pt[i][3] = d;
  }
  vector<int> per(n,1);
  per[n-1] = 0;
  int ans = 0;
  while(per[0] == 1){
    nextv(m,per);
    int nans=0;
    for(int i=0; i<q; ++i){
      if(per[pt[i][1]] - per[pt[i][0]] == pt[i][2]){
        nans += pt[i][3];
      }
    }
    ans = max(ans, nans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int sumOfDigit(int data){
  string s = to_string(data);
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    ans += s.at(i) - '0';
  }
  return ans;
}

int main(int argc, const char * argv[]) {
  int n, a, b;
  cin >> n >> a >> b;
  int tmp;
  int total = 0;
  for(int i = n; i > 0; i--){
    tmp = sumOfDigit(i);
    if(tmp >= a && tmp <=b){
      total +=i;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int yj_rainbow=0;
	int c=0;
	bool yj[8] = {false};
	int miny, maxy;

	cin >> n;
	vector <int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] < 3200)yj[a[i] / 400] = true;
		else yj_rainbow++;
	}
	for (int i = 0;i < 8;i++)if (yj[i] == true)c++;
	
	if (yj_rainbow == 0) {
		miny = c;
		maxy = c;
	}
	else if (c==0) {
		miny = 1;
		maxy = yj_rainbow;
	}

	else {
		miny = c;
		maxy = yj_rainbow + c;
	}

	cout << miny << " " << maxy << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN	200005
int n, value[MAXN], now[MAXN];
bool check(int mid) {
	for (int i = 1; i <= 2 * n - 1; i++)
		now[i] = value[i] > mid;
	if (now[n] == now[n - 1] || now[n] == now[n + 1]) return now[n];
	int l = n, r = n;
	while (l > 1 && now[l] != now[l - 1]) l--;
	while (r < 2 * n - 1 && now[r] != now[r + 1]) r++;
	if (now[l] == now[r]) return now[l];
	int m = (l + r) / 2;
	if (n <= m) return now[l];
	else return now[r];
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n - 1; i++)
		scanf("%d", &value[i]);
	int l = 1, r = 2 * n - 1;
	while (l < r) {
		int mid = (l + r) / 2;
		if (check(mid)) l = mid + 1;
		else r = mid;
	}
	printf("%d\n", l);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main() {
  int n, d, ans = 0;
  scanf("%d%d", &n, &d);
  int x[n][d];
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < d; j++) {
      scanf("%d", &x[i][j]);
    }
  }
  for (size_t i = 0; i < n-1; i++) {
    for (size_t j = i+1; j < n; j++) {
      int a = 0;
      for (size_t k = 0; k < d; k++) {
        a += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for (size_t k = 1; k <= a; k++) {
        if (a == k*k) {
          ans++;
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
using namespace std;
int a,b,n;
pair<int,int> p[40];
int f(int x,int y){
  if(x==a&&y==b) return 1;
  else if(x>a||y>b) return 0;
  for(int i=0;i<n;++i) if(x==p[i].first&&y==p[i].second) return 0;
  return f(x+1,y)+f(x,y+1);
}

int main(){
  int x,y,A;
  while(cin>>a>>b,a||b){
    cin>>n;
    for(int i=0;i<n;++i){
      cin>>x>>y;
      pair<int,int> q(x,y);
      p[i]=q;
    }
    A=f(1,1);
    cout<<A<<endl;
  }
  return 0;
}

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

#define MAX 200000

int N, Q;
int MEMO_IX[26];
int MEMO[26][MAX];
char s[MAX+1];
char t[MAX];
char d[MAX];
int robo[MAX + 2];

void print_robo(int N) {
    for (int j = 0; j < N + 2; j++) {
        printf("%d,", robo[j]);
    }
    printf("\n");
}

int can_stay(int start) {
    for (int i = 0; i < Q; i++) {
        if (s[start - 1] == t[i]) {
            if (d[i] == 'L') {
                start--;
                if (start == 0) return -1;
            }
            else if (d[i] == 'R') {
                start++;
                if (start == N + 1) {
                    return 1;
                }
            }
        }
    }
    return 0;
}

int main() {
    scanf("%d %d\n", &N, &Q);
    scanf("%s\n", s);
    for (int i = 0; i < Q; i++) {
        char t_, d_;
        scanf("%c %c\n", &t_, &d_);
        t[i] = t_;
        d[i] = d_;
    }

    int max_left = 0;
    int min_right = N + 1;
    int stay_max = -1;
    int stay_min = -1;

    while (max_left + 1 < min_right) {
        int start = (max_left + min_right) / 2;
        int state = can_stay(start);
        if (state == 0) {
            stay_max = start;
            stay_min = start;
            break;
        }
        if (state == -1) {
            max_left = start;
        } else {
            min_right = start;
        }
    }
    if (stay_max == -1) {
        printf("0\n");
    } else {
        while (max_left + 1 < stay_min) {
            int start = (max_left + stay_min) / 2;
            int state = can_stay(start);
            if (state == -1) {
                max_left = start;
            } else if (state == 0) {
                stay_min = start;
            } else {
                printf("DIE!");
                exit(1);
            }
        }
        while (stay_max + 1 < min_right) {
            int start = (stay_max + min_right) / 2;
            int state = can_stay(start);
            if (state == 1) {
                min_right = start;
            } else if (state == 0) {
                stay_max = start;
            } else {
                printf("DIE!");
                exit(1);
            }
        }
        printf("%d\n", N - max_left - (N + 1 - min_right));
    }
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,m,a,b,c=0,d=0;
  cin>>n>>m;
  vector<P> p(n);
  for(int i=0;i<n;i++){
    cin>>a>>b;
    p[i]=P(a,b);
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    if(p[i].second+c<m){
      c+=p[i].second;
      d+=p[i].first*p[i].second;
    }else{
      d+=(m-c)*p[i].first;
      break;
    }
  }
  cout<<d;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll N;
  cin >> N;
  vector<ll> A(N);

  FOR(i,0,N) cin >> A[i];

  FOR(i,1,N){
    if(A[i]>A[i-1]+1){
      cout << -1 << endl;
      return 0;
    }
  }

  if(A[0]!=0){
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  FOR(i,0,N-1){
    if(A[i+1]<=A[i]){
      ans += A[i];
    }
  }

  ans += A[N-1];

  cout << ans << endl;

}




Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;
	cout << (1800 * M + 100 * N)*pow(2,M) << "\n";
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*(n+1)
for i in reversed(range(1,n+1)):
    if sum(b[i::i])%2!=a[i]:
        b[i]=1
print(sum(b))
for i,j in enumerate(b):
    if j==1:
        print(i,end=' ')


Measured memory_bytes: 8756
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,a[N],c[N],Mx;
void GG(){ printf("Impossible"); exit(0);}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]),c[a[i]]++;
	for(i=n;i>=1;i--)
		if(c[i]) break;
	Mx=i;
	if(c[Mx]==1) GG();
	c[Mx]-=2;
	for(i=1;i<Mx;i++){
		if(!c[max(i,Mx-i)]) GG();
		c[max(i,Mx-i)]--;
	  }
	for(i=(Mx+1)/2;i>=1;i--)
		if(c[i]) GG();
	printf("Possible");
	return 0;
}


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

int main() {
	string s;
    while(cin>>s){
        int joi=0,ioi=0;
        for(int i=0;i<s.size()-2;i++){
            if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I')joi++;
            if(s[i]=='I'&&s[i+1]=='O'&&s[i+2]=='I')ioi++;
        }
        cout<<joi<<endl<<ioi<<endl;
    }
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main()
{
    string s;
    cin >> s;
    if(s[0]==s[1] && s[1]==s[2]){
        ANS("No")
    }
    else{
        ANS("Yes")
    }
    return 0;
}


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

using namespace std;

string s = "CODEFESTIVAL2016";

int main() {
  string in = "";
  cin >> in;
  int cnt = 0;
  for (int i=0; i<s.size(); i++) {
    if (in.at(i) != s.at(i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef unsigned long long uli;

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define nin ll n;cin>>n;
#define ain ll n;cin>>n;ll arr[n];for(ll i=0;i<n;i++){cin>>arr[i];}
#define out(arr,n) for(ll i=0;i<n;i++){cout<<arr[i]<<" ";}cout<<'\n';
#define fr(i,n) for(ll i=0;i<n;i++)
#define fri(i,l,n) for(ll i=l;i<n;i++)
#define sr(a,n) sort(a,a+n);
#define gr(a,n) sort(a,a+n,greater<ll>());
#define cen cout<<endl;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>


const ll MAX = 1e5 + 10;
const ll mod = 1e9 + 7;


int main() {
    fastio;
    //test{}
    //test{ ain;}
    ll n;
    cin>>n;
    ll d = n%10;
    if(d==2 || d==4 || d==5 || d==7 || d==9){
        cout<<"hon";
    }else if(d==0 || d==1 || d==6 || d==8){
    cout<<"pon";}else if(d==3){
    cout<<"bon";}








}


Measured memory_bytes: 3652
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as V
import qualified Data.IntSet as S
import Data.Bool (bool)

main :: IO ()
main = do
  (h : w : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    encode :: (Int, Int) -> Int
    encode (i, j) = i * w + j
    decode :: Int -> (Int, Int)
    decode n = divMod n w
    shiftU :: Int -> Maybe Int
    shiftU n = let {(i, j) = decode n; i' = pred i} in bool Nothing (Just . encode $ (i', j)) (i' >= 0)
    shiftD :: Int -> Maybe Int
    shiftD n = let {(i, j) = decode n; i' = succ i} in bool Nothing (Just . encode $ (i', j)) (i' < h)
    shiftL :: Int -> Maybe Int
    shiftL n = let {(i, j) = decode n; j' = pred j} in bool Nothing (Just . encode $ (i, j')) (j' >= 0)
    shiftR :: Int -> Maybe Int
    shiftR n = let {(i, j) = decode n; j' = succ j} in bool Nothing (Just . encode $ (i, j')) (j' < w)
    candidates :: Int -> [Int]
    candidates n = [shiftU n, shiftD n, shiftL n, shiftR n] >>= maybe [] pure
  as <- V.fromList . concat . map (T.foldr ((:) . (== '#')) []) . T.lines <$> T.getContents :: IO (V.Vector Bool)
  let
    bijs = filter (as V.!) $ [0..(pred (h * w))] :: [Int]
    n = search 0 bijs (S.fromAscList bijs) :: Int
    search :: Int -> [Int] -> S.IntSet -> Int
    search k targets blacks | null targets' = k
                            | otherwise = search (succ k) targets' blacks'
      where
        (targets', blacks') =  foldr step ([], blacks) . concat . map candidates $ targets
  print n

step :: Int -> ([Int], S.IntSet) -> ([Int], S.IntSet)
step t (ts, bs) = if S.member t bs then (ts, bs) else (t : ts, S.insert t bs)

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 147196
#include <stdio.h>
int main(void){
    int n,i,g=0;
    scanf("%d",&n);
    int a[n],b[n-1];
    for(i=0;i<n-1;i++)  scanf("%d",&b[i]);
    a[0]=b[0];
    for(i=0;i<n-2;i++){
        if(b[i]<=b[i+1]) a[i+1]=b[i];
        else a[i+1]=b[i+1];
    }
    a[n-1]=b[n-2];
    for(i=0;i<n;i++) g+=a[i];
    printf("%d\n",g);
    return 0;
}

Measured memory_bytes: 128
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define sort(v) sort(all(v))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--)
    {
		int n;
		cin>>n;
		if(n%10==3) cout<<"bon";
		else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout<<"pon";
		else cout<<"hon";
		cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3588
n=int(input())
a=0
b=0
l=[]
for i in range(n):
  c=int(input())
  l.append(c)
a=max(l)
L=sorted(l)
b=L[-2]
for i in range(n):
  if l[i]==a:
    print(b)
  else:
    print(a)

Measured memory_bytes: 19056
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	string str;
	vector<int> count('z'-'a',0);
	while (1) {
		cin >> str;
		if (cin.eof()) {
			break;
		}
		for (int i = 0; i < str.length(); ++i) {
			if (str[i] >= 'a' && str[i] <= 'z') {
				++count[str[i]-'a'];
			}
			else if (str[i] >= 'A' && str[i] <= 'Z') {
				++count[str[i]-'A'];
			}
		}
	}
	for (int i = 'a'; i <= 'z'; ++i) {
		cout << (char)i << " : " << count[i-'a'] << endl;
	}
	return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pi acos(-1.0)
#define is_palindrome(str) equal(str.begin(),str.begin() + str.size()/2, str.rbegin())
vector<int> prime;
bitset<100010>mark;
void sieve( int n)
{

     mark[0]=mark[1]=1;
    int i,j,limit=sqrt(n*1.0)+2;
    for(i=4; i<=n; i+=2)
        mark[i]=1;
      prime.push_back(2);
    for(i=3; i<=n; i+=2)
        {
            if(!mark[i])
                {
                   prime.push_back(i);
                    if(i<=limit)
                        {

                            for(j=i*i; j<=n; j+=i*2)

                                mark[j]=1;
                        }
                }

        }


}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    sieve(100010);

     int s,t,k,s1;
     cin>>k;


     cout<<*lower_bound(prime.begin(),prime.end(),k)<<endl;

    return  0;
}



Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  int cnt = 0;
  int pre = -1;
  for(int i = 0; i < N; i++) {
    int now = S[i] - 'a';
    if(pre == now) {
       
    }
    else {
      cnt++; 
    } 
    pre = S[i] - 'a';
  }
  
  cout << cnt;
  return 0;
}


Measured memory_bytes: 512
n,m = map(int, input().split())
a=[]
for i in range(n):
    a.append(tuple(map(int, input().split())))

dp = []
for i in range(m+1):
    dp.append([0 for j in range(n+1)])

def f(fn):
    global dp, a
    for i in range(1,m+1):
        for j in range(i,n+1):
            if j == i:
                dp[i][j] = sum(map(fn, a[:j]))
            else:
                dp[i][j] = max(dp[i][j-1], dp[i-1][j-1] + fn(a[j-1]))

ans = []
f(lambda x: x[0]+x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: x[0]+x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: x[0]-x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: x[0]-x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]+x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]+x[1]-x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]-x[1]+x[2])
ans.append(dp[m][n])
f(lambda x: -x[0]-x[1]-x[2])
ans.append(dp[m][n])

print(max(ans))


Measured memory_bytes: 60252
from math import floor

A, B, N = map(int, input().split())

if N // B >= 1:
    if B != 1:
        x = B - 1
    else:
        x = 1
else:
    x = N

#print(x)
result = floor(A * x // B) - A * floor(x / B)

print(result)

Measured memory_bytes: 9144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    llong k;

    cin >> k;
    cout << a[k - 1] << endl;

    return 0;
}


Measured memory_bytes: 764
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

res = 1000000000 + 7

main = do
  [k, x] <- readIntegerList
  putStrLn $ if 500 * k >= x then "Yes" else "No"

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
int main(){
	string d;
	cin>>d;
	int tot=0;
	int g=0;
	int l=d.size();
	if(d[0]==d[l-1])
	{
		if(l%2==0)
		cout<<"First";
		else cout<<"Second";
	}
	else{
		if(l%2==1)cout<<"First";
		else cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] n = new String[3];
		int cnt = 0;
		n = sc.next().split(""); String msg = "";
		for(int i = 0; i < n.length; i++) {
			if (n[i].equals("7")) cnt++;
		}
		System.out.println(cnt > 0 ? msg = "Yes" : "No");
	}
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,t,a;
    cin>>n>>t>>a;
    int h[n];
    int s=1000000;
    for(int i=0;i<n;i++){
        cin>>h[i];
        if(1000*t-h[i]*6>a*1000){
            s=min(s,1000*t-h[i]*6-a*1000);
        }
        else{
            s=min(s,a*1000-1000*t+h[i]*6);
        }
    }
    for(int i=0;i<n;i++){
        if(1000*t-h[i]*6>a*1000){
           if(s==1000*t-h[i]*6-a*1000){
              cout<<i+1<<endl; 
           }
        }
        else{
           if(s==a*1000-1000*t+h[i]*6){
              cout<<i+1<<endl; 
           }
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		int[] answer = new int[n];

		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				int direct = j - i;
				int shortCut = dist(i, x) + 1 + dist(j, y);
				int dist = Math.min(direct, shortCut);
				answer[dist]++;
			}
		}

		for (int i = 1; i < n; i++) {
			print(answer[i]);
		}

	}

	public static int dist(int p, int q) {
		return Math.max(q - p, p - q);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 24532
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, w, x, y;
    cin >> h >> w >> x >> y;

    out((h - x)*(w - y));
    
    
    re0;
}

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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv( maxN+5, 1 );
vcL fac( maxN+5, 1 );

void ADD(lli &x, lli y) {
	x += y;
	if ( x >= mod ) x -= mod;
	if ( x < 0 ) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = ( x%mod + mod ) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if ( e&1 ) MUL( ans, b );
		MUL( b, b );
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow( n, mod-2 );
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod-mod/i) * inv[ mod%i ] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[ i-1 ] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if ( a < b ) return 0;

	MUL( ans, inv[ fac[ a-b ] ] );
	MUL( ans, inv[ fac[b] ] );
	MUL( ans, fac[a] );

	return ans;
}

lli Lucas(lli n, lli m) {
	if ( m == 0 ) return 1;
	return cm( n%mod, m%mod ) * Lucas( n/mod, m/mod ) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas( n, m );
}

/// coding area ///

const lli maxn = 1E5;

void precal() {

	return;
}

void solve() {
	lli n = 1, m, sum = 0, ans = 0, cnt = 0, cnt0 = 0, ext = 0;
	string s;
	cin >> n;

	vcL num(n);
	for (auto &x : num) cin >> x;
	
	for (int i = 1; i < n-1; ++i) {
		if ( num[i] != max({ num[i-1], num[i], num[ i+1 ] }) and num[i] != min({ num[i-1], num[i], num[ i+1 ] }) ) ++cnt;
	}
	
	cout << cnt << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}




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

int main() {
    int r, D, x_2000;
    cin >> r >> D >> x_2000;
    int64_t s = x_2000;

    for (int i = 2001; i <= 2010; i++) {
        s = r * s - D;
        cout << s << endl;
    }

}

Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define PI 3.1415926535897
#define MEMS(a,b) memset(a,b,sizeof(a))
#define LL long long
#define U unsigned

vector<int> a;

bool check(int v) {
	LL sz = a[v];
	FOR(i, 0, a.size()) {
		if (i == v) {
			continue;
		}
		if (sz + sz >= a[i]) {
			sz += a[i];
		}
		else {
			return false;
		}
	}
	return true;
}

int main()
{
#ifdef Fcdkbear
	freopen("in.txt", "r", stdin);
	double beg = clock();
	//freopen("out.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	a.resize(n);
	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	int l = 0;
	int r = (int)a.size() - 1;
	int res = 0;
	while (l <= r) {
		int m = (l + r) / 2;
		if (check(m)) {
			res = (int)a.size() - m;
			r = m - 1;
		}
		else {
			l = m + 1;
		}
	}
	cout << res << endl;

#ifdef Fcdkbear
	double end = clock();
	fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
using namespace std;
inline char gc() {
	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
const int maxn=300+5;
int n,D1,D2;
struct Solver {
	int col[maxn<<1][maxn<<1];
	vector< pair<int,int> > V;
	void init(int D) {
		for(int i=0;i<2*n;++i) for(int j=0;j<2*n;++j) {
			if(i*i+j*j==D) {
				V.push_back(make_pair(i,j));
				V.push_back(make_pair(-i,j));
				V.push_back(make_pair(i,-j));
				V.push_back(make_pair(-i,-j));
			}
		}
	}
	void dfs(int x,int y,int c) {
		if(col[x][y]!=-1) return;
//		debug("%d %d %d\n",x,y,c);
		col[x][y]=c;
		for(int i=0;i<V.size();++i) {
			int _x=x+V[i].fi,_y=y+V[i].se;
			if(_x<0||_x>=n*2) continue;
			if(_y<0||_y>=n*2) continue;
			dfs(_x,_y,c^1);
		}
	}
	void sol(int D) {
		init(D);
		memset(col,-1,sizeof(col));
//		debug("---\n");
		for(int i=0;i<2*n;++i) for(int j=0;j<2*n;++j) if(col[i][j]==-1) {
			dfs(i,j,0);
		}
	}
} solver[2];
int main() {
	rd(n),rd(D1),rd(D2);
	solver[0].sol(D1),solver[1].sol(D2);
	vector< pair<int,int> > S[4];
	for(int i=0;i<2*n;++i) for(int j=0;j<2*n;++j) {
		S[solver[0].col[i][j]<<1|solver[1].col[i][j]].push_back(make_pair(i,j));
	}
	for(int i=0;i<4;++i) if(S[i].size()>=n*n) {
		for(int j=0;j<n*n;++j) printf("%d %d\n",S[i][j].fi,S[i][j].se);
		return 0;
	}
	assert(0);
}

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

using namespace std;

int main()
{
	long long n;
	vector<long long> arr;
	vector<pair<long long, long long>> loc;
	double sol = 0.0;
	long long perm = 1;

	//freopen("input.txt", "r", stdin);

	scanf("%lld", &n);

	for (long long i = 0; i < n; i++)
	{
		long long input1, input2;

		scanf("%lld %lld", &input1, &input2);

		arr.push_back(i);

		loc.push_back(make_pair(input1, input2));

		perm *= i + 1;
	}

	for (long long i = 0; i < perm; i++)
	{
		for (long long j = 0; j < n - 1; j++)
		{
			double xsq, ysq;

			xsq = (double)loc[arr[j+1]].first - (double)loc[arr[j]].first;
			xsq = xsq*xsq;
			ysq = (double)loc[arr[j + 1]].second - (double)loc[arr[j]].second;
			ysq = ysq*ysq;

			sol += sqrt(xsq + ysq);
		}

		next_permutation(arr.begin(), arr.end());
	}

	sol /= (double)perm;

	printf("%.10lf\n", sol);

	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
s, t = len(S), len(T)
p = 'UNRESTORABLE'
n = -1
if t <= s:
  for i in range(s-t+1):
    f = 1
    for j in range(t):
      if S[i+j] != '?' and S[i+j] != T[j]:
        f = -1
    if f == 1:
      n = i
  if n >= 0:
    p = ''
    for k in range(s):
      if k < n or k > n + t - 1:
        if S[k] == '?':
          p = p[:] + 'a'
        else:
          p = p[:] + S[k]
      else:
        p = p[:] + T[k - n]
print(p)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int v, e;
    cin >> v >> e;
    int graph[15][15];
    for(int i = 0; i < v; i++){
        for(int j = 0; j < v; j++){
            graph[i][j] = mod;
        }
    }
    for(int i = 0; i < e; i++){
        int s, t, d;
        cin >> s >> t >> d;
        graph[s][t] = d;
    }
    int result[(1 << 15)][15];
    for(int i = 0; i < (1 << (v - 1)); i++){
        for(int j = 0; j < v - 1; j++){
            result[i][j] = mod;
        }
    }
    // ??´?????????v-1????????????????????????????????£????????????????????¨???????????????v-1????????????????????????????????¢????¶?????????????
    for(int i = 0; i < v - 1; i++){
            if(graph[v - 1][i] != mod) result[(1 << i)][i] = graph[v - 1][i];
    }
    // ??????????????????v-1??????????????????????????§?¨????
    for(int i = 1; i < (1 << (v - 1)); i++){
        for(int j = 0; j < v - 1; j++){
            // ????????????????????????j????????????????????¨??????
            if(((1 << j) & i) == 0) continue;
            // cout << i << " " << j << endl;
            int tmp = (i ^ (1 << j));
            for(int k = 0; k < v - 1; k++){
                // ?????????k?????????j??????????????£?????¶???i???????????¨??????
                if(((1 << k) & tmp) == 0 || result[tmp][k] == mod || graph[k][j] == mod) continue;
                result[i][j] = min(result[i][j], result[tmp][k] + graph[k][j]);
            }
            // cout << i << " " << j << " " << result[i][j].first << " " << result[i][j].second << endl;
        }
    }
    int ans = mod;
    // v-1???????????????v-1??????????????????????¶?????????¨
    for(int i = 0; i < v - 1; i++){
        if(result[(1 << (v - 1)) - 1][i] == mod || graph[i][v - 1] == mod) continue;
        ans = min(ans, result[(1 << (v - 1)) - 1][i] + graph[i][v - 1]);
    }
    if(ans == mod) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
(let* ((n (read))
       (m (read))
       (lst (loop :repeat m :collect (loop :repeat (read) :collect (read))))
       (lst-a (loop :repeat m :collect (read))))
  (defun f (k)
    (map 'list (lambda (a b)
                 (= b (mod (loop :for l :in a :count (char= #\1 (aref k (1- l)))) 2))) lst lst-a))
  (princ (loop :for a :from 0 :upto (1- (expt 2 n)) :count (equal (f (format nil (format nil "~1~~A,'0B" n) a)) (make-sequence 'list m :initial-element T)))))

Measured memory_bytes: 21476
#include<bits/stdc++.h>
#define debug printf("%d %s\n",__LINE__,__FUNCTION__)
typedef long long ll;
typedef std::pair<int,int> pii;
#define pb push_back
#define mk make_pair
#define fi first
#define se second

int _w;FILE* _f;

using namespace std;

const int N=5010;

int n,k,p[N],c[N],vis[N],dfs_clock,siz[N],pos[N][N];

ll f[N][N],ans=-2e18,mx[N][N];

void dfs(int u){
    if(vis[u]){
        siz[u]=dfs_clock+1-vis[u];
        return;
    }
    vis[u]=++dfs_clock;
    mx[1][u]=f[1][u]=c[p[u]];pos[1][u]=p[u];
    dfs(p[u]);
    siz[u]=siz[p[u]];
}

int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&p[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&c[i]);
    }
    for(int i=1;i<=n;i++){
        // mx[0][i]=-2e18;
        if(!vis[i]){
            dfs(i);
        }
    }
    for(int i=2;i<=n;i++){
        for(int j=1;j<=n;j++){
            pos[i][j]=p[pos[i-1][j]];
            f[i][j]=f[i-1][j]+c[p[pos[i-1][j]]];
            mx[i][j]=max(mx[i-1][j],f[i][j]);
        }
    }
    // for(int i=1;i<=3;i++){
    //     for(int j=1;j<=n;j++){
    //         printf("pos[%d][%d]=%d\n",i,j,pos[i][j]);
    //     }
    // }
    // for(int i=1;i<=3;i++){
    //     for(int j=1;j<=n;j++){
    //         printf("f[%d][%d]=%d\n",i,j,f[i][j]);
    //     }
    // }
    // for(int i=1;i<=3;i++){
    //     for(int j=1;j<=n;j++){
    //         printf("mx[%d][%d]=%d\n",i,j,mx[i][j]);
    //     }
    // }
    for(int i=1;i<=n;i++){
        ll tmp=0;int now=i;
        if(f[siz[i]][i]>0){
            tmp=(ll)(k/siz[i])*f[siz[i]][i];
            tmp+=mx[(k%siz[i])][i];
            if(k>siz[i]){
                if(mx[siz[i]][i]>(f[siz[i]][i]+mx[(k%siz[i])][i])){
                    tmp+=mx[siz[i]][i]-f[siz[i]][i]-mx[(k%siz[i])][i];
                }
            }
        }
        else{
            if(k>siz[i]){
                tmp=mx[siz[i]][i];
            }
            else{
                tmp=mx[(int)k][i];
            }
        }
        ans=max(ans,tmp);
        // printf("tmp[%d]=%lld\n",i,tmp);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 493268
#include<stdio.h>

main(){
  float a, b, c, d, e, f;
  float x, y;

  while(scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f) != EOF){
    x = (c*e - f*b)/(a*e - d*b);
    y = (c - a*x)/b;
    if(x == 0)
      printf("0.000 %0.3f\n", y);
    else if(y == 0)
      printf("%0.3f 0.000\n", x);
    else
      printf("%0.3f %0.3f\n", x, y);
  }
  return 0;
}

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

int main(){
  int n,q;
  cin>>n>>q;
  priority_queue<int>s[n];
  while(q--){
    int a,b,c;
    cin>>a>>b;
    if(!a){
      cin>>c;
      s[b].push(c);
    }
    else if(a==1){
      if(!s[b].empty())cout<<s[b].top()<<endl;
    }
    else if(!s[b].empty())s[b].pop();
  }
}


Measured memory_bytes: 4052
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll N; cin >> N;
    vector<ll> a(N); rep(i, N) cin >> a[i];
    vector<ll> dp(N + 1, -1);
    dp[0] = 1000;
    rep(i, N){
        dp[i + 1] = dp[i];
        rep(j, i){
            chmax(dp[i + 1], dp[j] % a[j] + (dp[j] / a[j]) * a[i]);
        }
    }
    pt(dp[N]);
    return 0;
}

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

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

    vector<vector<int>> dist(2, vector<int>(n, 0));
    queue<int> q;
    for (int i = 0; i < 2; i++) {
        dist[0][1] = 1;
        dist[1][n] = 1;
        q.push(i ? n : 1);
        while (!q.empty()) {
            int cur = q.front();
            q.pop();
            for (int to : adj[cur]) {
                if (!(dist[i][to])) {
                    dist[i][to] = dist[i][cur] + 1;
                    q.push(to);
                }
            }
        }
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (dist[0][i] > dist[1][i]) {
            sum++;
        }
    }
    cout << (sum >= (n + 1) / 2 ? "Snuke" : "Fennec") << endl;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll ans = 0;
  cin >> N;
  vi L(N);
  REP(i, N) cin >> L.at(i);
  sort(L.begin(), L.end());
  L.push_back(99999);
  for (int j = 0; j < N - 2; j++) {
    for (int k = j + 1; k < N - 1; k++) {
      for (int m = k + 1; m <= N; m++) {
        if (L.at(m) >= L.at(j) + L.at(k)) {
          ans += (m - k - 1);
          //          cout << ans << endl;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    short n;
    cin>>n;
    long long l0 = 2, l1 = 1, lk;
    for (short i = 2; i <= n; i++)
    {
        lk = l0 + l1;
        l0 = l1;
        l1 = lk;
    }
    cout<<l1;
}

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) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

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

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

signed main() {
  init();
  string S;
  cin >> S;
  bool ok = false;
  if (S == "AKIHABARA") ok = true;
  if (S == "KIHABARA") ok = true;
  if (S == "AKIHBARA") ok = true;
  if (S == "AKIHABRA") ok = true;
  if (S == "AKIHABAR") ok = true;
  if (S == "KIHBARA") ok = true;
  if (S == "KIHABRA") ok = true;
  if (S == "KIHABAR") ok = true;
  if (S == "AKIHBRA") ok = true;
  if (S == "AKIHBAR") ok = true;
  if (S == "AKIHABR") ok = true;
  if (S == "AKIHBR") ok = true;
  if (S == "KIHABR") ok = true;
  if (S == "KIHBAR") ok = true;
  if (S == "KIHBRA") ok = true;
  if (S == "KIHBR") ok = true;
  if (ok) YN;
  return 0;
}

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


int main() {
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> vec(N, vector<int>(3));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> vec.at(i).at(j);
        }
    }
    vector<vector<int>> m(W, vector<int>(H, 0));

    for (int i = 0; i < N; ++i) {
        if (vec.at(i).at(2) == 1){
            for (int j = 0; j < vec.at(i).at(0); ++j) {
                for (int k = 0; k < H; ++k) {
                    m.at(j).at(k) = 1;
                }
            }
        } else if (vec.at(i).at(2) == 2) {
            for (int j = vec.at(i).at(0); j < W; ++j) {
                for (int k = 0; k < H; ++k) {
                    m.at(j).at(k) = 1;
                }
            }
        } else if (vec.at(i).at(2) == 3) {
            for (int j = 0; j < W; ++j) {
                for (int k = 0; k < vec.at(i).at(1); ++k) {
                    m.at(j).at(k) = 1;
                }
            }
        } else if (vec.at(i).at(2) == 4) {
            for (int j = 0; j < W; ++j) {
                for (int k = vec.at(i).at(1); k < H; ++k) {
                    m.at(j).at(k) = 1;
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < W; ++i) {
        for (int j = 0; j < H; ++j) {
            if(m.at(i).at(j) == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256