akhauriyash/Code-Regression huggingface dataset:
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int n, h[20]; cin >> n;
  REP(i, n) cin >> h[i];
  int ans = 1, mx = h[0];
  REP(i, n-1){
    if(h[i+1] >= mx){
      ans++;
      mx = h[i+1];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
int main(void){
   int n; cin >> n;
   int a[n];
   int cnt = 0;
   int now = 0;
   for (int i = 0; i < n; i++){
       cin >> a[i];
   }
   for (int j = 0; j < n + 1; j++){
       if (now == 1){
          cout << cnt << endl;
          break;
       }
       if (cnt >= n){
           cout << -1 << endl;
           break;
       }
       cnt++;
       now = a[now] - 1;
        
   }
   
    
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,k,x,y;
  scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
  if(k<n){
    printf("%d",k*x+(n-k)*y);
  }else{
    printf("%d",n*x);
  }
  return 0;
}


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

int main()
{
	long long int h,a,sum=0;
	cin>>h>>a;
	for(long long int i=0;i<a;i++)
	{
		long long int p;
		cin>>p;
		sum=sum+p;
	}
	if(h>sum)
	{
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def ceil(A, B):
    if A%B == 0:
        return A//B
    return A//B+1

def solve() -> Any:
    N = read_int()
    C, S, F = [], [], []
    for _ in range(N-1):
        c, s, f = read_ints()
        C.append(c)
        S.append(s)
        F.append(f)
    dp = [
        [0 for _ in range(N)] for _ in range(N)
    ]
    # dp[i][j] - minimum time for i-th train to arrive at j-th station
    for j in range(1, N):
        for i in range(j):
            if dp[i][j-1] <= S[j-1]:
                dp[i][j] = S[j-1]+C[j-1]
            else:
                k = ceil((dp[i][j-1]-S[j-1]), F[j-1])
                dp[i][j] = k*F[j-1]+S[j-1]+C[j-1]
                # k*F[j-1]+S[j-1] >= dp[i][j-1]
    for i in range(N):
        print(dp[i][N-1])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 78548
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll mod = 1e9 + 7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

ll dp[105][4][4][4];
// dp[i][b][c][d] := 長さがiで文字の最後の並びがbcdになるやつの総数
// ACGT = 0123

// 021を文字列として含まない
// 0?21 201 012 02?1 を文字列として含まない

int main(void){
    int N;
    cin >> N;
    rep(a,4)rep(b,4)rep(c,4)dp[3][a][b][c] = 1;
    dp[3][0][2][1] = 0;
    dp[3][2][0][1] = 0;
    dp[3][0][1][2] = 0;
    for(int i=3;i<N;i++){
        rep(j,4){ // j は新しく追加する文字
            rep(a,4)rep(b,4)rep(c,4){
                // 現在はabcの順に並んでいる
                if(b==0 && c==2 && j==1)continue;
                if(a==0 && c==2 && j==1)continue;
                if(b==2 && c==0 && j==1)continue;
                if(b==0 && c==1 && j==2)continue;
                if(a==0 && b==2 && j==1)continue;
                dp[i+1][b][c][j] += dp[i][a][b][c] % mod;
                dp[i+1][b][c][j] %= mod;
            }
        }
    }
    int ans = 0;
    rep(a,4)rep(b,4)rep(c,4){
        ans += dp[N][a][b][c];
        ans %= mod;
    }
    cout << ans%mod << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

const int MAXN = 200228;

ll x[MAXN];
ll p[MAXN];

ll ans = 0;
ll s;

void gt(ll x) {
    ans += abs(s - x);
    s = x;
}

void go(int l, int r) {
    if (x[r] < s) {
        return gt(x[l]);
    }

    if (x[l] > s) {
        return gt(x[r]);
    }
    if (p[l] >= p[r]) {
        p[l] += p[r];
        go(l, r - 1);
        return gt(x[r]);
    } else {
        p[r] += p[l];
        go(l + 1, r);
        return gt(x[l]);
    }
}

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);  
    int n;

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


    go(0, n - 1);

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

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    map<ll, ll> ile;
    ll odp = 0;
    if (a[0] == 0)
        ++odp;
    ile[a[0]] = 1;
    ll s = a[0];
    for (int i = 1; i < n; ++i)
    {
        s += a[i];
        if (s == 0)
            ++odp;
        if (ile.find(s) != ile.end())
        {
            odp += ile[s];
            ++ile[s];
        }
        else
            ile[s] = 1;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<VI>dp(N+1, VI(5, 0));
	VI A(N);
	REP(i, N)cin >> A[i];


	eFOR(i, 1, N) {



		REP(j, 5) {

			int cnt = INF;
			eREP(k, j)cnt = min(cnt, dp[i - 1][k]);

			if (j == 2) {
				if (A[i - 1] % 2)dp[i][2] = cnt;
				else dp[i][2] = cnt + 1;
			}

			if (j == 0 || j == 4)dp[i][j] = A[i - 1] + cnt;

			if (j == 3 || j == 1) {
				if (A[i - 1] == 0)dp[i][j] = cnt + 2;
				else if (A[i - 1] % 2)dp[i][j] = cnt + 1;
				else dp[i][j] = cnt;
			}
		}

		//cout << i << endl;
	}

	/*
	eREP(i, N) {
		REP(j, 5)cout << dp[i][j] << " ";
		cout << endl;
	}
	*/

	int ans = INF;
	REP(i, 5)ans = min(ans, dp[N][i]);

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 15872
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        final long b = sc.nextLong();
        int ans = 0;
        while (a <= b) {
            a *= 2;
            ans += 1;
        }
        System.out.println(ans);
    }
}

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

num = list(range(1,N+1))
ans = []


if M % 2 == 0:
    for i in range(M // 2):
        ans.append([i+1,M+1-i])
    for i in range(M // 2):
        ans.append([i+2+M,2*M+1-i])


if M % 2 != 0:
    for i in range(M // 2):
        ans.append([i+1,M-i])
    for i in range(M - M//2):
        ans.append([i+1+M,2*M+1-i])


for an in ans:
    print(an[0],an[1])


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

using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    if(b==c){
      cout << 1 << endl;
    }
    else{
      cout << 2 << endl;
    }
  }
  else if(b==c){
    cout << 2 << endl;
  }
  else if(a==c){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

//verified AOJ GRL_1
#define MAX_V 100000
template <typename T>
struct edge{int to;T cost;};

template <typename T>
void dijkstra(int s, vector<T> &d, vector<edge<T>> G[MAX_V]){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
    
    while( que.size() ){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge<T> e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int h,w,d;
    cin>>h>>w>>d;
    int n = h*w;
    
    vector<vector<int>> v(h,vector<int>(w));
    rep(i,h) rep(j,w) cin>>v[i][j];
    rep(i,h) rep(j,w) v[i][j]--;;

    vector<pii> vp(n);
    rep(i,h){
        rep(j,w){
            vp[v[i][j]] = pii(i,j);
        }
    }

    auto dist = [](pii a, pii b){
        return abs(a.first-b.first)+abs(a.second-b.second);
    };
    
    vector<edge<int>> G[90001];
    rep(i,n){
        if(i+d>=n)break;
        G[i].pb(edge<int>{(int)i+d,dist(vp[i],vp[i+d])});
    }
    
    
    rep(i,d){
        G[n].pb(edge<int>{(int)i,0});
    }
    vector<int> dd(n);
    dijkstra<int>(n,dd,G);
    
    int q;
    cin>>q;
    rep(lll,q){
        int l,r;
        cin>>l>>r;
        l--,r--;
        cout<<dd[r] - dd[l]<<endl;
    }
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int 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 k;
    cin >> k;
    print(a[k - 1]);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(int(input()) for i in range(n))
b=[0]
c=[0]
for i in range(n):
    b.append(max(b[i],a[i]))
    c.append(max(c[i],a[-i-1]))
del b[n]
del c[n]
 
for i in range(n):
    d=b[i]
    e=c[n-1-i]
    print(max(d,e))

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

int main() {
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << w*h/2.0 << " " << (x*2==w&&y*2==h) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;

    vector<ll> L(n+1,0);
    L[0]=0;
    L[1]=0;
    for(int i=2; i<=n; i++){
        if(s.substr(i-2,2)=="AC"){
            L[i]++;
        }
    }
    for(int i=0;i<n;i++){
        L[i+1] += L[i];
    }

rep(a,q){
    int l,r;cin>>l>>r;l--,r--;
    int ans;
    if(l==0){
      ans = L[r+1]-L[l];
    }
    else if(s.substr(l-1, 2)=="AC"){
      ans = L[r+1]-L[l]-1;
    }
    else{
      ans = L[r+1]-L[l];
    }
    cout << ans << endl;
}
    return 0;
}

Measured memory_bytes: 1872
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
c=0
for i in range(n):
    if a[i]>=b/4/m:
        c+=1
    else:
        c=c
if c>=m:
    print('Yes')
else:
    print('No')


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

int main() {

	while (true) {
		std::string s;
		int query;
		std::cin >> s;
		if (s == "-") break;
		std::cin >> query;
		
		while (query--) {
			int h;
			std::cin >> h;
			s = s.substr(h) + s.substr(0, h);
		}
		
		std::cout << s << '\n';
	}

	return 0;
}


Measured memory_bytes: 3152
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var inputList = cin.ReadIntArray(6);
            var a = inputList[0];
            var b = inputList[1];
            var c = inputList[2];
            var d = inputList[3];
            var e = inputList[4];
            var k = inputList[5];
            if (e-a > k)
            {
                Console.Write(@":(");
            }
            else
            {
                Console.Write(@"Yay!");
            }
        }
    }
    public class deci
    {
        public bool IsFinish { get; set; } = false;
        public int Len { get; set; }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

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

int main(){

    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    while(n>0){
        n/=k;
        ans++;
    }
    cout << ans << endl;


    return 0;
}  


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

int mod = 1'000'000'007;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    if (w == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<long long> pre_folk(w - 1, 1);
    for (int i = 2; i < w - 1; i++) pre_folk[i] = pre_folk[i - 1] + pre_folk[i - 2];
    vector<long long> rev_folk = pre_folk;
    reverse(rev_folk.begin(), rev_folk.end());
    vector<long long> folk(w - 1);
    for (int i = 0; i < w - 1; i++) folk[i] = pre_folk[i] * rev_folk[i];
    vector<long long> non_folk(w - 1, 1); if (w - 1 > 1) non_folk[1] = 2;
    for (int i = 2; i < w - 1; i++) non_folk[i] = non_folk[i - 1] + non_folk[i - 2];
    vector<vector<long long>> dp(h + 1, vector<long long>(w, 0));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            dp[i + 1][j] += dp[i][j] * (non_folk[max(0, j - 1)] * non_folk[max(0, w - j - 2)]) % mod;
            dp[i + 1][j] %= mod;
            if (j != 0) dp[i + 1][j - 1] += dp[i][j] * folk[j - 1] % mod;
            if (j != 0) dp[i + 1][j - 1] %= mod;
            if (j != w - 1) dp[i + 1][j + 1] += dp[i][j] * folk[j] % mod;
            if (j != w - 1) dp[i + 1][j + 1] %= mod;
        }
    }
    cout << dp[h][k - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

double H,W,x,y;

int main(void) {
    cin>>W>>H>>x>>y;

    cout<<W*H/2.0<<" "<<(x+x == W && y+y == H)<<endl;

    return 0;
}


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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  map<string, ll> D, S;
  for (ll i = 0; i < N; i++) {
    ll s = i + A[i];
    ll d = i - A[i];
    S[to_string(s)]++;
    if (d > 0) D[to_string(d)]++;
  }

  ll ans = 0;
  for(auto itr = D.begin(); itr != D.end(); ++itr) {
    ll d = itr->second;
    ll s = S[itr->first];
    ans += (s * d);
  }
  cout << ans << '\n';
  return 0;
}

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

const int Maxn = 100005;

int n;
char s[Maxn];
int res;

int main()
{
    scanf("%d", &n);
    scanf("%s", s);
    for (int i = 0, j; i < n; i = j) {
        j = i;
        while (j < n && s[i] == s[j]) j++;
        res++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

const int MAXN = 2e3 + 5;

int n, x, y;
int dist[MAXN][MAXN], ans[MAXN];

int main() {
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            dist[j][i] = dist[i][j] = j - i;
        }
    }
    dist[x][y] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            dist[i][j] = std::min(dist[i][j], std::min(dist[i][x] + dist[x][y] + dist[y][j], dist[i][y] + dist[y][x] + dist[x][j]));
            ++ans[dist[i][j]];
        }
    }
    for (int i = 1; i < n; ++i) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
const int Nmax = 1005;

int a[Nmax][Nmax], l, c, n, m, k, i, x, dir, j;

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> m >> k;

    l = 1; c = 1; dir = 1;
    for(i=1; i<=k; ++i)
    {
        cin >> x;
        while(x--)
        {
            a[l][c] = i;
            c += dir;
            if(c == m+1)
            {
                dir = -1;
                c = m;
                ++l;
            }
            else if(!c)
            {
                dir = 1;
                c = 1;
                ++l;
            }
        }
    }

    for(i=1; i<=n; ++i)
    {
        for(j=1; j<=m; ++j) cout << a[i][j] << ' ';
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 768
/*
    A story which will never end
    A story which never began
*/

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl '\n'
#define ll long long

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

    return 0;
}


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

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

Measured memory_bytes: 3632
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var spl = input.ReadLine().Split(' ');
        var d = int.Parse(spl[0]);
        var x = int.Parse(spl[1]);

        var c = 0;
        for(int i=0; i<n; i++) {
            var a = int.Parse(input.ReadLine());
            for (int j = 0; j * a + 1 <= d; j++) {
                c++;
            }
        }

        return c+x;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int mod = 1e9+7;
const int inf = 1e8;
void solve(){
    int a,b;
     cin>>a>>b;
     if(a==1)a+=200;
     if(b==1)b+=200;
     if(a==b)cout<<"Draw"<<endl;
     else if(a>b)cout<<"Alice"<<endl;
     else cout<<"Bob"<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    private def innerLoop(j: Int, p: Int): Unit = {
      notPrime(j)
      if(j + p <= top)innerLoop(j + p, p)
    }

    private def loop(i: Int): Unit = {
      val p = 2 * i + 3
      if(isPrime(i))innerLoop((p * p - 3) >>> 1, p)
      if(i < sqrtLimit)loop(i + 1)
    }

    private def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
      loop(0)
      Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else if(n==2)println(1)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65020
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i]) {
          ll mx = max(a[i], max(a[j], a[k]));
          if (2 * mx < a[i] + a[j] + a[k]) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int K;
    cin >> K;
    int ans = 0;
    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    cout << ans << endl;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}


int main(){
    int n;
    cin >> n;
    cout << 10 - n / 200 << endl;
    return 0;
}

Measured memory_bytes: 3676
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    V<ll> a(87);
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=86;i++) a[i]=a[i-1]+a[i-2];
    cout<<a[n]<<endl;
}

Measured memory_bytes: 256
N = int(input())
H = [int(h) for h in input().split()]
A = [0] * N
for n in range(N - 1):
    if H[n] >= H[n+1]:
        if n == 0:
            A[n] = 1
        else:
            A[n] = A[n - 1] + 1

print(max(A))

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

#define MAX_N 100291

int isPrime[ MAX_N + 1 ] = { 0, 0, 1, 1 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 5; i <= MAX_N; i += 6 )
		isPrime[ i ] = 1;

	for ( i = 7; i <= MAX_N; i += 6 )
		isPrime[ i ] = 1;

	for ( i = 5; i * i <= MAX_N; i += 6 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( i = 7; i * i <= MAX_N; i += 6 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 252 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 984
n=int(input())
anst,ansa=map(int,input().split())
for _ in range(1,n):
    t,a=map(int,input().split())
    if anst>t or ansa>a:
        mul=max(-(-anst//t),-(-ansa//a))
        anst=mul*t
        ansa=mul*a
    else:
        anst=t
        ansa=a
print(anst+ansa)

Measured memory_bytes: 9136
import sys

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

ans=0

for i in range(N):
	t=min(A[i], B[i])
	ans+=t
	A[i]-=t
	B[i]-=t

	t=min(A[i+1], B[i])
	ans+=t
	A[i+1]-=t
	B[i]-=t

print ans


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

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford

ABC = [[int(x) for x in input().split()] for _ in range(M)]
row,col,val = zip(*ABC)

# -1倍しておいて最短路問題にする
val = [-x for x in val]

# 求めたい経路の外の閉路にはまるとまずい
#graph = csr_matrix((val,(row,col)),(N+1,N+1))
#try:
#  dist = bellman_ford(graph,indices = [1])[0].astype(int)
#  answer = -dist[N]
#except:
#  answer = 'inf'
import numpy as np
from scipy.sparse.csgraph import connected_components

graph = csr_matrix((val,(row,col)),(N+1,N+1))

find_component_graph = csr_matrix(([1]*(M+1),(row+(N,),col+(1,))),(N+1,N+1))
_,labels = connected_components(find_component_graph,connection = 'strong')
idx = (labels == labels[1])

# 強連結成分に制限。ここに負閉路があれば～～
graph = graph[idx,:][:,idx]

try:
  dist = bellman_ford(graph,indices = [0])[0].astype(int)
  answer = -dist[-1]
except:
  answer = 'inf'

print(answer)

Measured memory_bytes: 14316
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;
 
int main(){
  int N,M,X,Y; cin>>N>>M>>X>>Y;
  vector<int> x(N),y(M);
  rep(i,N)cin>>x.at(i);
  rep(i,M)cin>>y.at(i);
  sort(begin(x),end(x));
  sort(begin(y),end(y));
  int xm = x.at(N-1), ym = y.at(0);
  if(xm<=ym){
    if(min(ym,Y)-max(xm,X)>0){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
}

Measured memory_bytes: 256
import bisect
INF = 10 ** 12

A, B, Q = list(map(int, input().split()))
S, T, X = [-INF], [-INF], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    X.append(int(input()))
S.append(INF)
T.append(INF)

for x in X:
    ans = INF
    sr = bisect.bisect_right(S, x)
    tr = bisect.bisect_right(T, x)
    for s in S[sr-1: sr+1]:
        for t in T[tr-1: tr+1]:
            ans = min(ans, abs(s-x) + abs(s-t), abs(t-x) + abs(s-t))
    print(ans)


Measured memory_bytes: 16160
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
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; }

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main() {
  const ll MOD = 1000000007;
    cin.tie(0);    
	ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[N];
    ll ans = 0;
    REP(i,N) cin >> A[i];
    ll cnt[N] = {} , prevcnt[N] = {};

    REP(i,N){
        REP(j,N){
            if(A[i] > A[j] ) cnt[i]++;
            if(A[i] > A[j] && i > j) prevcnt[i]++;
        }
    }
    REP(i,N){
        cnt[i] %= MOD;
        K %= MOD;
      	ll X = cnt[i]*K;
      	X %= MOD;
      	ll Y = X*(K+1);
      	Y %= MOD;
      	prevcnt[i] %= MOD;
      	Y -= ((K*prevcnt[i])%MOD*2)%MOD;
      	Y += MOD;
      	Y %= MOD;
        ans += (Y*modinv(2,MOD))% MOD;;
      //cout << ans << ' ' << cnt[i] << ' ' << K << endl;
        ans %= MOD;
      	//ans -= (K*prevcnt[i])%MOD;
      	//ans %= MOD;
            //cout << prevcnt[i]*2 << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp {
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail, n;
 
void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a,int b) {
  return a < b ? a : b; 
}
 
int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d",&n ,&q);
  for(i=1; i<=n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while(head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}


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

using namespace std;


int main() {

    int a, b, c, res;
    cin >> a >> b >> c;

    if(a < c && b < c){

        cout << (a*b)/2 << '\n';

    }
    else if (a< b && c < b) {

        cout << (a*c)/2 << '\n';

    }
    else if (b < a && c <a ) {

        cout << (b*c)/2 << '\n';

    }

    return 0;
}



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

int main() {
  int A,B;
  cin >> A >> B;

  int ans = 0;

  for (int i = 0; i < 2; i++) {
    if (A < B) ans += B--;
    else ans += A--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){

    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    
    // 2. X円を計算.
    int X = 0;
    rep(i, 100000){
        if((int)(i * 1.08) == N){
            X = i;
            break;
        }
    }
    
    // 3. 出力.
    if(X) printf("%d\n", X);
    else  puts(":(");
    return 0;
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var r, g, b, v int
    fmt.Scanf("%d %d %d", &r, &g, &b)
    v = r*100 + g*10 + b
    if v%4 == 0 {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, h;
	cin >> a >> b >> h;
	dunk((a + b) * h / 2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1000000007;
map<LL, LL> memo;
LL f(LL N)
{
    if (N == 0) return 1;
    if (N == 1) return 2;
    if (memo.count(N)) return memo[N];
    return memo[N] = (f(N / 2) + f((N - 1) / 2) + f(N / 2 - 1)) % MOD;
}
int main()
{
    LL N; cin >> N;
    cout << f(N) << endl;
    return 0;
}


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

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

  string T="keyence";
  for(int i=0;i<=7;i++){
    if(S.substr(0,i)==T.substr(0,i) && S.substr(S.size()-7+i,7-i)==T.substr(i,7-i)){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 5e5 + 111;
        
using namespace std;          

int n, t[4 * maxn];
string s;

void build(int v, int tl, int tr){
	if (tl == tr){
		int x = s[tl - 1] - 'a';
		x = (1 << x);
		t[v] = x;
		return;
	}                     
	int tm = (tl + tr) >> 1;
	build(v * 2, tl, tm);
	build(v * 2 + 1, tm + 1, tr);
	t[v] = t[v * 2] | t[v * 2 + 1];
}

void update(int v, int tl, int tr, int pos, int val){
	if (tl == tr){
		int x = (1 << val);
		t[v] = x;
		return;
	}
	int tm = (tl + tr) >> 1;
	if (pos <= tm)
		update(v * 2, tl, tm, pos, val);
	else
		update(v * 2 + 1, tm + 1, tr, pos, val);
	t[v] = t[v * 2] | t[v * 2 + 1];
}

int get(int v, int tl, int tr, int l, int r){
	if (tr < l || r < tl || l > r)
		return 0;
	if (tl >= l && tr <= r)
		return t[v];
	int tm = (tl + tr) >> 1;
	int x = get(v * 2, tl, tm, l, r);
	int y = get(v * 2 + 1, tm + 1, tr, l, r);
	return x | y;
}

void solve(){ 
	cin >> n >> s;

    build(1, 1, n);

    int q;

    cin >> q;

    while (q--){
    	int type;
    	cin >> type;
    	if (type == 1){
    		int pos;
    		char val;
    		cin >> pos >> val;
    		update(1, 1, n, pos, val - 'a');
    	}
    	else{
    		int l, r;
    		cin >> l >> r;
    		int x = get(1, 1, n, l, r);
    		cout << __builtin_popcount(x) << endl; 
    	}
    }
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 11164
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  
  int n;

  while(cin >> n){
    bool Prime[1000000] = {};
    int i,j,count;
    count = n;
    for(i = 2; i <= sqrt(n) ; i++){
      if(Prime[i] == false){        
	for(j = 2; i*j <= n ; j++){
	  if(!Prime[i*j]){
	    Prime[i*j] = true;
	    count--;
	  }
	}
      }
    }
    cout << count-1 << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

ll countab(string s)
{
    ll ans = 0;
    bool a = false;
    for (ll i = 0; i < (ll)s.size(); i++){
        if (a && s[i] == 'B') {
                ans++;
        }
        if (s[i] == 'A') {
            a = true;
        } else {
            a = false;
        }
    }
    return ans;
}

int main(void)
{
    ll N;
    string tmp;
    cin >> N;
    ll ans = 0;
    ll p = 0, q = 0, r = 0, s = 0;
    for (ll i = 0; i < N; i++) {
        cin >> tmp;
        ans += countab(tmp);
        if (tmp.back() == 'A') {
            if (tmp.front() == 'B') {
                s++;
            } else {
                q++;
            }
        } else {
            if (tmp.front() == 'B') {
                r++;
            } else {
                p++;
            }
        }
    }

    if (s == 0) {
        ans += min(q, r);
    } else {
        if (q == 0) {
            if (r == 0) {
                ans += s - 1;
            } else {
                ans += s;
            }
        } else {
            if (r == 0) {
                ans += s;
            } else {
                ans += s + 1 + min(q - 1, r - 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n,m;
char s[2000][2000];
int dp[2000][2000];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	m=read();

	for(int i=1;i<=n;++i){
		scanf("%s",s[i]+1);
	}
	
	dp[1][1]=1;

	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(s[i][j]!='#' && i+j!=2){
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}

	printf("%d\n",dp[n][m]);

    return 0;
}

Measured memory_bytes: 13552