akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define VMAX 10000

int main(){
    int n;
    cin >> n;
    vector<unsigned short> A(2000000+1);
    vector<unsigned short> B(2000000+1);
    vector<int> c(VMAX + 1);
    for(int i = 0;i <= VMAX ;i++){
        c.at(i) = 0;
    }

    for(int i = 0;i<n;i++){
        cin >> A.at(i+1);
        c.at(A.at(i+1))++;
    }

    for(int i = 1; i<=VMAX;i++) c.at(i) = c.at(i) + c.at(i-1);

    for(int j = 1;j <= n;j++){
        B.at(c.at(A.at(j))) = A.at(j);
        c.at(A.at(j))--;
    }

    for(int i = 1; i <= n; i++){
        if(i>1) cout << " ";
        cout << B.at(i);
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 10764
K = int(input())
ans = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(ans[K-1])

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

string sign(int i) {
    if (i == 0) return "+";
    else return "-";
}

int main() {
    int n; cin >> n;
    int a = n / 1000;
    int b = n / 100 % 10;
    int c = n / 10 % 10;
    int d = n % 10;
	
  	bool isEnd = false;
    REP(i, 2) {
        REP(j, 2) {
            REP(k, 2) {
                if (a + b * (1 - i * 2) + c * (1 - j * 2) + d * (1 - k * 2) == 7 && !isEnd) {
                    cout << a << sign(i) << b << sign(j) << c << sign(k) << d << "=7" << endl;
                	isEnd = true;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN =2e5+5;
int seg[5*MAXN][4];
int arr[MAXN];
map<int,int> m1;
int n;
void build(int curr,int l,int r){
    if(l==r){
        seg[curr][l%2] = arr[l];
        seg[curr][1-(l%2)] = 1e9;

        return;
    }
    int mid = (l+r)/2;
    build(2*curr,l,mid);
    build(2*curr+1,mid+1,r);
    seg[curr][0] = min(seg[2*curr][0],seg[2*curr+1][0]);
    seg[curr][1] = min(seg[2*curr][1],seg[2*curr+1][1]);

}
int query(int curr,int l,int r,int tl,int tr,int par){

    if(l>tr||r<tl){
        return 1e9;
    }
    if(tl<=l && r<=tr){
        return seg[curr][par];
    }
    int mid = (l+r)/2;
    return min(query(2*curr,l,mid,tl,tr,par),query(2*curr+1,mid+1,r,tl,tr,par));
}
struct segment{
    int l,r;
    bool operator<(const segment& rhs) const
    {
        return query(1,1,n,l,r,l%2) > query(1,1,n,rhs.l,rhs.r,(rhs.l)%2);
    }
};
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        m1[arr[i]] = i;
    }
    build(1,1,n);
    priority_queue<segment> pq;
    segment s1;
    s1.l = 1;
    s1.r = n;
    pq.push(s1);

    while(!pq.empty()){
        segment x = pq.top();
        pq.pop();
        int val = query(1,1,n,x.l,x.r,(x.l)%2);

        int pos = m1[val];
        if(pos>x.l){
            segment newseg;
            newseg.l = x.l;
            newseg.r = pos-1;
            pq.push(newseg);
        }
        int val2 = query(1,1,n,pos+1,x.r,1-((x.l)%2));
        int pos2 = m1[val2];
        if(pos2-pos>1){
            segment newseg;
            newseg.l = pos+1;
            newseg.r = pos2-1;
            pq.push(newseg);
        }
        if(pos2<x.r){
            segment newseg;
            newseg.l = pos2+1;
            newseg.r = x.r;
            pq.push(newseg);
        }
        cout<<val<<" "<<val2<<" ";
    }
}


Measured memory_bytes: 21504
s = [int(i) for i in input().split(' ')]
 
n = [0] * 2
 
for i in s:
    if i == 5:
        n[0] += 1
    elif i == 7:
        n[1] += 1
 
if n[0] == 2 and n[1] == 1:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
def isprime(x):
    if x == 2:
        return True
    elif (x < 2) | (x%2 == 0):
        return False
    for i in range(3, int(x**0.5)+1, 2):
        if x%i == 0:
            return False
    return True


n = int(input())
count = 0
for i in range(n):
    if isprime(int(input())):
        count += 1
print(count)


Measured memory_bytes: 5672
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        string line = Console.ReadLine();
        int count = 0;

        for (int i = 0; i < 6; i++){
            if(line[i] == '1'){
                count++;
            }
        }

        Console.WriteLine(count.ToString());
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
using namespace std;
int n, s, i;
long long sum;
int v[105];
int main(){
    cin>> n >> s;
    for(i = 1; i <= n; i++){
        cin>> v[i];
        sum += v[i];
    }
    sort(v + 1, v + n + 1);
    if(sum == s){
        cout<< n;
        return 0;
    }
    if(sum >= s){
        sum = 0;
        for(i = 1; i <= n; i++){
            sum += v[i];
            if(sum > s){
                cout<< i - 1;
                return 0;
            }
        }
    }
    else{
        cout<< n - 1;
    }
}


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

signed main(){
int n,m;
cin >> n;
map<int,int> a;
for(int i = 0; i < n; i++){
    int c;
    cin >> c;
    if(a.count(c))
    a[c]++;
    else{
    a[c] = 1;
    }
}  
bool ans = true;
cin >> m;
for(int i = 0; i < m; i++){
    int c;
    cin >> c;
    if(a.count(c)){
    a[c]--;
    if(a[c] < 0)
    ans = false;
    }
    else 
    ans = false;
}  
ans ? cout << "YES" : cout << "NO";
cout << endl;
}

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

int N, T;
int dp[3010][2][3010];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> T;
    rep(i, N) {
        int A, B; cin >> A >> B;
        rep(j, T) {
            dp[i+1][0][j] = max(dp[i+1][0][j], dp[i][0][j]);
            if (j+A<T) dp[i+1][0][j+A] = max(dp[i+1][0][j+A], dp[i][0][j]+B);
            
            dp[i+1][1][j] = max(dp[i+1][1][j], dp[i][1][j]);
            if (j+A<T) dp[i+1][1][j+A] = max(dp[i+1][1][j+A], dp[i][1][j]+B);
            
            dp[i+1][1][j] = max(dp[i+1][1][j], dp[i][0][j]+B);
        }
    }
    cout << dp[N][1][T-1] << endl;
}

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


void solve(long long A, long long B, long long N){
    long long ans=0;
    cout<<min(N,B-1)*A/B-A*(min(N,B-1)/B)<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<int>> S(H + W - 1, std::vector<int>(H + W - 1));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            std::cin >> c;
            S[i + j][i - j + W - 1] = (c == '#' ? 1 : 0);
        }
    }
    auto yoko = S, tate = S;
    for (int i = 0; i < H + W - 1; i++) {
        for (int j = 1; j < H + W - 1; j++) { yoko[i][j] += yoko[i][j - 1]; }
    }
    for (int j = 0; j < H + W - 1; j++) {
        for (int i = 1; i < H + W - 1; i++) { tate[i][j] += tate[i - 1][j]; }
    }
    ll ans = 0;
    for (int y = 0; y < H + W - 1; y++) {
        for (int i = 0; i < H + W - 1; i++) {
            for (int j = i + 1; j < H + W - 1; j++) {
                if (S[y][i] * S[y][j] == 0) { continue; }
                const int l = j - i;
                if (y >= l) {
                    const int point = yoko[y - l][j] - (i == 0 ? 0 : yoko[y - l][i - 1]);
                    ans += point;
                }
                if (y + l < H + W - 1) {
                    const int point = yoko[y + l][j] - (i == 0 ? 0 : yoko[y + l][i - 1]);
                    ans += point;
                }
            }
        }
    }
    for (int x = 0; x < H + W - 1; x++) {
        for (int i = 0; i < H + W - 1; i++) {
            for (int j = i + 1; j < H + W - 1; j++) {
                if (S[i][x] * S[j][x] == 0) { continue; }
                const int l = j - i;
                if (x >= l) {
                    const int point = tate[j - 1][x - l] - tate[i][x - l];
                    ans += point;
                }
                if (x + l < H + W - 1) {
                    const int point = tate[j - 1][x + l] - tate[i][x + l];
                    ans += point;
                }
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 4480
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll d[mm];
int main()
{
	ll n,m,i,j,k,kk,a,b,t;
    cin>>n;
    printf("%.3f",3.141592653589*n*2);

}

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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int r;
    cin>>r; cout<<(r*r)<<'\n';
}



Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	char A,B;
	cin >> A >> B;
	bool flag = true;
	if( A=='H'){
		if( B=='H'){
			flag = true;
		}else{
			flag = false;
		}
	}else{
		if( B=='H'){
			flag = false;
		}else{
			flag = true;
		}
	}
	if( flag ){
		cout << "H" << endl;
	}else{
		cout << "D" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
q,h,s,d=map(int,input().split())
n=int(input())
cperl=[q*8,h*4,s*2,d]
if n%2==0:
  print(int((n//2)*min(cperl)))
else:
  if min(cperl)==cperl[3]:
    print(int(cperl[3]*(n//2)+min(cperl[:3])//2))
  else:
    print(int(n*(min(cperl)//2)))


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

int main() {
  int K, X;
  cin >> K >> X;
  int sta = X - K + 1;
  rep(i, 2*K - 2) {
    cout << sta << " ";
    sta += 1;
  }
  cout<< X + K - 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)(1e7))
#define pi (2*acos(0))
#define mp make_pair
#define M ((int)(1e9 + 7))
#define xx first
#define yy second
#define NN ((int)(5e5+2))
#define N ((int)(2e5 + 5))
#define pq priority_queue
///#define Q queue
#define eps 0
#define log 20
#define pb push_back
#define MOD 998244353


using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int lu;

typedef tree < int ,  null_type ,  less < int > ,  rb_tree_tag ,  tree_order_statistics_node_update > o_set;

char s[N];

int cnt[30];

int main()
{
    scanf("%s",s);
    int n = strlen(s), sum = 0;
    ll ans = 1;
    for(int i = n-1; i>=0; i--){
        ans += sum-cnt[s[i]-'a'];
        sum++;
        cnt[s[i]-'a']++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef vector<int> vi;
typedef pair<int, int> P;

struct edge{
	int cost, to;
	edge(int t, int c):to(t), cost(c){}
	bool operator<(const edge &r)const{
		return cost > r.cost;
	}
};

vector<edge> G[101];
int n;

int dijkstra(int start, int goal){
	priority_queue<edge> q;
	q.push(edge(start, 0));
	vector<int> v(n, 0);

	int ans = -1;
	while(!q.empty()){
		edge s = q.top();
		q.pop();

		if(v[s.to]) continue;
		v[s.to] = s.cost;

		if(s.to == goal){
			ans = s.cost;
			break;
		}

		for(int i = 0; i < G[s.to].size(); i++){
			edge next = s;
			next.to = G[s.to][i].to;
			next.cost += G[s.to][i].cost;
			q.push(next);
		}
	}

	return ans;
}

int main(){
	int k;
	while(cin >> n >> k, n|k){
		rep(i, n) G[i].clear();
		rep(i, k){
			int m;
			cin >> m;
			if(m){
				int c, d, e;
				cin >> c >> d >> e;
				c--, d--;
				G[c].push_back(edge(d, e));
				G[d].push_back(edge(c, e));
			}else{
				int a, b;
				cin >> a >> b;
				cout << dijkstra(a-1, b-1) << endl;
			}
		}
	}
 
    return 0;
}

Measured memory_bytes: 1256
N,K = map(int,input().split())
ans = [0 for i in range(N+1)]
food = {}
food1 = []
for i in range(1,N+1):
    food[i] = 0
for i in range(N):
    t,d = map(int,input().split())
    food1.append((d,t))
food1.sort()
syurui = 0
sum = 0
import heapq
x = []
heapq.heapify(x)
for i in range(1,N+1):
    d,t = food1[-i]
    if food[t] == 0:
        if i > K:
            if len(x) == 0:
                break
        sum += d
        food[t] = 1
        syurui += 1
        if i > K:
            y = heapq.heappop(x)
            sum -= y
    else:
        if i <= K:
            sum += d
            heapq.heappush(x,d)
    if syurui == K:
        ans[K] = max(sum + K**2,ans[K])
        break
    else:
        ans[syurui] = max(sum + syurui**2,ans[syurui])
print(max(ans))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  vector<int> a(5);
  int rem = 0, ans = 0;
  for (int i = 0; i < 5; ++i) {
    cin >> a[i];
    int aa = (a[i] + 9) / 10 * 10;
    ans += aa;
    // cerr << ans << '\n';

    rem = max(rem, aa - a[i]);
  }
  ans -= rem;

  cout << ans << '\n';

  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 A, B;
	cin >> A >> B;

	if (B == 1) {
	    cout << 0 << endl;
	} else {
	    cout << (B+A-3)/(A-1) << endl;
	}
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
C = Counter(S)
print('AC x ', end='')
print(C['AC'])
print('WA x ', end='')
print(C['WA'])
print('TLE x ', end='')
print(C['TLE'])
print('RE x ', end='')
print(C['RE'])

Measured memory_bytes: 16624
#include <iostream>

using namespace std;
int Fibonacci(int n)
{
    int dp[n];
    for(int i=0;i<=n;i++)
    {
        if(i==0||i==1) dp[i]=1;
        else dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[n];
}
int main()
{
    int n;
    while(cin>>n)
        cout<<Fibonacci(n)<<endl;
}

Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iterator>
using namespace std;

int main(){
    #ifdef INPUT
        freopen("input","r",stdin);
//        freopen("output","w",stdout);
    #endif // INPUT
//    ios::sync_with_stdio(false);
//    cin.fill(NULL);

    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(b+b>=a) printf("0\n");
        else printf("%d\n",a-b-b);
    }

    return 0;
}


Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    H = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    inf=10**10
    dp=[inf]*N
    dp[0]=0
    for i in range(N-2):
        dp[i+1]=min(dp[i+1],dp[i]+abs(H[i]-H[i+1]))
        dp[i+2]=min(dp[i+2],dp[i]+abs(H[i]-H[i+2]))
    i=N-2
    dp[i+1]=min(dp[i+1],dp[i]+abs(H[i]-H[i+1]))
    print(dp[N-1])



if __name__ == "__main__":
    main()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    // odd*odd = odd
    ll N;
    cin >> N;

    if(N%2==1){
        cout << 0 << endl;
        return 0;
    }

    N = N-(N%10);
    ll ans=0;
    for(ll i=5*2;i<=N;i*=5){
        ans += ll(N/i);
    }
    
    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	ll n;
	cin >> n;
	ll quo = 0;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n%i == 0) quo = max(quo, i);
	}
	ll ans = quo + n / quo - 2;
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll>v(n);rep(i,n)cin>>v[i];
    sort(all(v));
    ll ans=0;ll com=v[0];
    rep(i,n-1){
        if(com*2<v[i+1])ans=i+1;
        com+=v[i+1];
    }
    cout<<n-ans;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int a = tmp[0], b = tmp[1], x = tmp[2];

	long S = a*a*b;

	if (x*2 < S)
	{
	    double c = x * 2.0 / (a*b);
	    double tan = c / b;
	    double theta = Math.Atan(tan);

	    //WriteLine($"a={a}, b={b}, x={x}");
	    //WriteLine($"S={S}, c={c}, tan={tan}, theta={theta}");
	    WriteLine((Math.PI/2 - theta)*180.0/Math.PI);
	}
	else
	{
	    long S2 = S - x;

	    double c = S2 * 2.0 / (a*a);
	    double tan = c / a;
	    double theta = Math.Atan(tan);

	    //WriteLine($"a={a}, b={b}, x={x}");
	    //WriteLine($"S={S}, S2={S2}, c={c}, tan={tan}, theta={theta}");
	    WriteLine(theta*180.0/Math.PI);
	}
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    ll x,y;
    cin >> x >> y;
    if(abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}


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

int N;
vector<int>V;
void dfs(int t,int p){
    if(t==0){
        for(int i=0;i<V.size();i++){
            if(i)cout<<" ";
            cout<<V[i];
        }
        cout<<endl;
        return;
    }
    for(int i=min(t,p);i>0;i--){
        V.push_back(i);
        dfs(t-i,i);
        V.pop_back();
    }
}

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

    while(cin>>N,N){
        V.clear();
        dfs(N,N);
    }
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 200000;
 
int main(){
    int N,K;
    int H[MAX];
    long long ans = 0;
 
    cin >> N >> K;
 
    if(N - K <= 0){
        cout << 0 << endl;
        return 0;
    }
 
    for(int i = 0;i < N;i++){
        cin >> H[i];
    }
 
    sort(H,H + N);
 
    for(int i = 0;i < N - K;i++){
        ans += H[i];
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

def partition(a, p, r):
    x = a[r-1]
    i = p-1
    for j in range(p,r-1):
        if a[j] <= x:
            i = i+1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r-1] = a[r-1], a[i+1]
    return i+1
pivot = partition(a, 0, n)
l = [str(a[i]) for i in range(pivot)]
r = [str(a[i]) for i in range(pivot+1, n)]
print(' '.join(l) +' [' + str(a[pivot]) + '] ' + ' '.join(r))



Measured memory_bytes: 16596
N, M = map(int, input().split())
MOD = 10**9 + 7

if abs(N - M) >= 2:
    print(0)
    exit(0)

fact = [1 for _ in range(M + 100)]
for i in range(1, M + 100):
    fact[i] = (fact[i - 1] * i) % MOD

if N == M:
    ans = fact[N] * fact[N] % MOD * 2 % MOD
else:
    ans = fact[N] * fact[M] % MOD

print(ans)

Measured memory_bytes: 7064
using System;

public class Hello{
  public static void Main(){
    int M = 500;
    var str = Console.ReadLine().Split(' ');
    int K = int.Parse(str[0]);
    int X = int.Parse(str[1]);
    if(K*M>=X){
      Console.Write("Yes");
    }else{
      Console.Write("No");
    }
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> q;
int main()//a+b+c=r   
{
	ll n,k;cin>>n>>k;ll r=min(n,k);
	q.resize(n+1);
	for(ll i=0;i<n;i++) scanf("%lld",&q[i]);
	ll mx=0;
	for(ll a=0;a<=r;a++)
	{
		for(ll b=0;b<=r-a;b++)
		{
			if(2*(a+b)<r)
			continue;
			//else if((a+b)>r) continue;
			else 
			{
				ll c=k-(a+b);
				ll ans=0;
				vector<ll> v(a+b);
				for(ll i=0;i<a;i++)
					v.push_back(q[i]),ans+=q[i];
				for(ll i=n-1;i>=n-b;i--)
					v.push_back(q[i]),ans+=q[i];
				sort(v.begin(),v.end());
				for(ll i=0;i<min((ll)c,(ll)v.size());i++)
					if(v[i]<0)
						ans-=v[i];
				mx=max(mx,ans);
			}
		}
	}
	cout<<mx<<endl;
 } 

Measured memory_bytes: 256
function Main(input) {
  input = input.split(" ");

  var a = parseInt(input[0], 10);
  var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);

  if( a == b ) console.log( c );
  if( b == c ) console.log( a );
  if( a == c ) console.log( b );
 }

 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef unsigned long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, a[200005];
int to[200005][70] = {0};
ll K;
void init(){
    n = read();
    scanf("%llu", &K);
    for (int i = 1; i <= n; ++i)
        a[i] = read(), to[i][0] = a[i];
    for (int j = 1; j <= 64; ++j)
        for (int i = 1; i <= n; ++i)    
            to[i][j] = to[to[i][j - 1]][j - 1];
}
void solve(){
    ll tmp = 1;
    for (int i = 0; i < 63; ++i)
        tmp <<= 1;
    int cur = 63, ans = 1; 
    while (tmp > 0){
        if (K >= tmp)
            K -= tmp, ans = to[ans][cur];
        --cur, tmp >>= 1;
    }
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

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

using query = pair<int, int>;
using event = pair<int, query>;

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

  int N; cin >> N;
  int Q; cin >> Q;
  vector<event> E;
  for (int i = 0; i < N; i++) {
    int S; cin >> S;
    int T; cin >> T;
    int X; cin >> X;
    E.emplace_back(S - X, query(0, X));
    E.emplace_back(T - X, query(1, X));
  }
  for (int i = 0; i < Q; i++) {
    int D; cin >> D;
    E.emplace_back(D, query(2, i));
  }
  sort(E.begin(), E.end());

  vector<int> ans(Q, -1);
  multiset<int> st;
  for (auto e: E) {
    int t = e.first;
    int q = e.second.first;
    int p = e.second.second;
    if (q == 0) st.insert(p);
    else if (q == 1) st.erase(st.lower_bound(p));
    else if (!st.empty()) ans[p] = *(st.begin());
  }

  for (int i = 0; i < Q; i++) {
    std::cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 18536
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  REP(i,n){
    if ((i+1)%3!=0){
      if ((i+1)%5!=0)
        ans+=(i+1);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(1,int(math.sqrt(x))):
      if x % (i+1) == 0:
        return False
    return True

table=[0]*50001
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2 - 1]
  
for i in range(Q):
  print(ans[i])
  


Measured memory_bytes: 8208
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            int sum = 0;
            int x = i;
            while (x > 0) {
                sum += x % 10;
                x /= 10;
            }
            if (sum >= a && sum <= b) {
                count += i;
            }
        }
        System.out.println(count);
    }
}

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


int main()
{
    int n;  cin>>n;
    switch(n%10){
 case 2:
 case 4:
 case 5:
 case 7:
 case 9:
    cout<<"hon"<<endl;
    break;
 case 0:
 case 1:
 case 6:
 case 8:
    cout<<"pon"<<endl;
    break;
 case 3:
    cout<<"bon"<<endl;
    break;
    }
   return 0;
}


Measured memory_bytes: 3564
import copy
from functools import lru_cache
n, m, x = map(int, input().split())

books = []
for i in range(n):
    nums = list(map(int, input().split()))
    books.append((nums[0], nums[1:]))

mn = float('inf')
smart = [0] * m

def good():
    global x, smart

    for kn in smart:
        if kn < x:
            return False
    
    return True

@lru_cache(maxsize=None)
def solve(idx, n, sm):
    global mn, books, smart

    if idx == n:
        if good():
            #print(' '.join(list(map(str, smart))))
            mn = min(mn, sm)
        return

    #smart1 = copy.deepcopy(smart)

    cur_books = books[idx][1]
    cost = books[idx][0]
    for i in range(len(smart)):
        smart[i] += cur_books[i]

    solve(idx + 1, n, sm + cost)

    for i in range(len(smart)):
        smart[i] -= cur_books[i]

    solve(idx + 1, n, sm)


solve(0, n, 0)

print(mn if mn != float('inf') else -1)

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

int hantei(int y, int m, int d){
	int ret = 0;
	for(int i = 0; i<y;i++){
		if (i % 400 == 0) { ret += 366; }
		else if (i % 100 == 0) { ret += 365; }
		else if (i % 4 == 0) { ret += 366; }
		else { ret += 365; }
	}
	if (m > 1) { ret += 31; }
	if (m > 2) {
		if (y % 400 == 0) { ret += 29; }
		else if (y % 100 == 0) { ret += 28; }
		else if (y % 4 == 0) { ret += 29; }
		else { ret += 28; }
	}
	if (m > 3) { ret += 31; }
	if (m > 4) { ret += 30; }
	if (m > 5) { ret += 31; }
	if (m > 6) { ret += 30; }
	if (m > 7) { ret += 31; }
	if (m > 8) { ret += 31; }
	if (m > 9) { ret += 30; }
	if (m > 10) { ret += 31; }
	if (m > 11) { ret += 30; }
	ret += d;
	return ret;
}

int main(){
	int y, m, d, ans;
	while(cin >> y >> m >> d){
		ans = hantei(y, m, d);
		if(ans < 682525){
			cout << "pre-meiji" << endl;
		}
		else if(ans<698555){
			cout << "meiji " << y - 1867 << " " << m << " " << d << endl;
		}
		else if(ans<703816){
			cout << "taisho " << y - 1911 << " " << m << " " << d << endl;
		}
		else if(ans<726476){
			cout << "showa " << y - 1925 << " " << m << " " << d << endl;
		}
		else{
			cout << "heisei " << y - 1988 << " " << m << " " << d << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;

ll xs[] = {-1, 1, 0, 0};
ll ys[] = {0, 0, -1, 1};

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin >> st;
	ll ans = 0, q=0;
	for(ll i=0;st[i];i++){
		ans += st[i]-'0';
		q = q*10 + st[i]-'0';
	}
	if(q%ans == 0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

int main(void)
{
    int K;
    cin >> K;

    int a = K / 2;
    int b;
    if (K % 2 == 0)
        b = K / 2;
    else
        b = K / 2 + 1;

    int result = a * b;

    cout << result << endl;
}

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

int main(){
	string s;
  	cin >> s;
    
    //cout << (s[5] - '0') * 10 + (s[6] - '0') << endl;
  	if((s[5] - '0') * 10 + (s[6] - '0') >= 5){
      cout << "TBD" << endl;
    } else {
      if((s[8] - '0') * 10 + (s[9] - '0') <= 30){
			cout << "Heisei" << endl;
      }
      else {
        cout << "TBD" << endl;
      }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>

using namespace std;

typedef pair<int, int> P;

int N;

int main() {
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) { cin >> S[i]; }

	int A = 0, B = 0;//末尾にあるAの数、先頭にあるBの数
	int BA = 0;//両方含む数
	long long ans = 0;

	for (int i = 0; i < N; i++) {
		if (S[i][S[i].size() - 1] == 'A' && S[i][0] == 'B') { BA++; }
		else if (S[i][S[i].size() - 1] == 'A') { A++; }
		else if (S[i][0] == 'B') { B++; }
	}
	for (int i = 0; i < N; i++) {
		int len = S[i].size();
		for (int j = 0; j < len - 1; j++) {
			if (S[i][j] == 'A' && S[i][j + 1] == 'B') { ans++; }
		}
	}
	int mi = min(A, B);
	int ma = max(A, B);
	if(BA > 0){ ans += BA - 1; }
	if (mi > 0 && ma > 0 && BA > 0) { ans += 2; mi--; ma--; }
	else if (BA > 0 && ma > 0) { ans++; ma--; }
	ans += mi;
	cout << ans << endl;
}

Measured memory_bytes: 768
import sys
import itertools


def resolve(in_):
    N = int(next(in_))
    AB = (map(int, line.split()) for line in itertools.islice(in_, N))
    A = []
    B = []
    for a, b in AB:
        A.append(a)
        B.append(b)

    A.sort()
    B.sort()


    i = N // 2
    if N % 2:
        a_median = A[i]
        b_median = B[i]
        if a_median > b_median:
            a_median, b_median = b_median, a_median
        answer = len(range(a_median, b_median + 1))
    else:
        a_median2 = (A[i - 1] + A[i])  #  / 2
        b_median2 = (B[i - 1] + B[i])  # / 2
        if a_median2 > b_median2:
            a_median2, b_median2 = b_median2, a_median2
        answer = len(range(a_median2, b_median2 + 1))
            
    return answer


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25452
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll H = in(), W = in(), h = in(), w = in();
	cout << H * W - h * W - w * H + h * w << endl;
}

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

typedef long long ll;

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

    int n;
    cin>>n;
    int A[3];

    int dp[3];
    dp[0] = dp[1] = dp[2] = 0;

    for (int day = 1;day<=n;++day){
        for (int i=0;i<3;++i) cin>>A[i];

        int memo[3];
        memo[0] = memo[1] = memo[2] = 0;
        for (int i=0;i<3;++i){
            for (int j=0;j<3;++j){
                if (i!=j)
                    memo[j] = max(memo[j], dp[i] + A[j]);
            }
        }
        for (int i=0;i<3;++i) dp[i] = memo[i];
    }
    cout<<max(dp[0], max(dp[1], dp[2]))<<endl;
    
    return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll gcd,a,b,i;
    cin>>a>>b;
    gcd=__gcd(a,b);
    a=a*b;
    cout<<a/gcd<<endl;






    return 0;
}





Measured memory_bytes: 3560
function Main(input) {
 
    var N = new Number(input.split('\n')[0]);
    var v = input.split('\n')[1].split(' ');

    v = v.map(x => x - 0);

    v.sort(compareNumbers);

    var tmp;
    while (v.length > 1) {
        var a = v.shift() - 0.0;
        var b = v.shift() - 0.0;
        
        tmp = ((a + b) / 2.0);
        v.unshift(tmp);
    }

    console.log(v-0.0);
}

function compareNumbers(a, b) {
    return a - b;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long N;
  cin>>N;
  int a1,b1,c1,a2,b2,c2;
  a1=b1=c1=0;
  while(N--){
    int a,b,c;
    cin>>a>>b>>c;
    a2=a+max(b1,c1);
    b2=b+max(a1,c1);
    c2=c+max(b1,a1);
    a1=a2;b1=b2;c1=c2;
  }
  cout<<max(a1,max(b1,c1))<<'\n';
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	S, T := next(), next()

	min := 100000

	for i := 0; i <= len(S)-len(T); i++ {
		miss := 0
		for j := 0; j < len(T); j++ {
			if S[i+j] != T[j] {
				miss += 1
			}
		}
		if miss < min {
			min = miss
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 1812
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

const long long MOD = (long long)(1e9 + 7);

long long powerf(long long a, long long b) {
    long long res = 1;
    while(b > 0) {
        if((b%2 == 1)) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        b/=2;
    }
    return res;
}


int main() {
    int m = 3;
    int a[3][3];
    for(int i=0; i<m; i++) {
        for(int j=0; j<m; j++) 
            cin >> a[i][j];
    }
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i=0; i<n; i++) {
        int x;
        cin >> x;
        mp[x] = 1;
    }

    for(int i=0; i<m; i++) {
        for(int j=0; j<m; j++) {
            if(mp[a[i][j]] == 0) {
                goto th;
            }
        }
        cout << "Yes\n";
        return 0;
        th:
        ;
    }
    for(int i=0; i<m; i++) {
        for(int j=0; j<m; j++) {
            if(mp[a[j][i]] == 0) {
                goto th1;
            }
        }
        cout << "Yes\n";
        return 0;
        th1:
        ;
    }
    for(int i=0; i<m; i++) {
        if(mp[a[i][i]] == 0) {
                goto th2;
        }
    }
    cout << "Yes\n";
    return 0;
    th2:
    ;
    for(int i=0; i<m; i++) {
        if(mp[a[2-i][i]] == 0) {
                goto th3;
        }
    }
    cout << "Yes\n";
    return 0;
    th3:
    ;
    cout << "No\n";
    return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,m;
char a[2001][2001];
int l[2004][2004],r[2004][2004],u[2004][2004],d[2004][2004];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf(" %s",a[i]+1);
	for(int i=1;i<=n;i++){
		l[i][0]=1;
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#')l[i][j]=j+1;
			else l[i][j]=l[i][j-1];
		}
		r[i][m+1]=m;
		for(int j=m;j>=1;j--){
			if(a[i][j]=='#')r[i][j]=j-1;
			else r[i][j]=r[i][j+1];			
		}
	}

	for(int i=1;i<=m;i++){
		u[0][i]=1;
		d[n+1][i]=n;
		for(int j=1;j<=n;j++){
			if(a[j][i]=='#')u[j][i]=j+1;
			else u[j][i]=u[j-1][i];
		}
		for(int j=n;j>=1;j--){
			if(a[j][i]=='#')d[j][i]=j-1;
			else d[j][i]=d[j+1][i];
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='.'){
				ans=max(ans,-u[i][j]+d[i][j]+r[i][j]-l[i][j]+1);
				// cout<<i<<' '<<j<<'-'<<u[i][j]<<' '<<d[i][j]<<' '<<r[i][j]<<' '<<l[i][j]<<endl;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 66944
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let k: i32 = s.next().unwrap().parse().unwrap();
	let a: Vec<i32> = s.take(n).map(|a| a.parse().unwrap()).collect();
	let sum: i32 = a.iter().sum();
	let ans = divisors(sum).into_iter().fold(1, |r, x| {
		let mut sum = 0;
		let mut a: Vec<i32> = a.iter().map(|a| a % x).inspect(|a| sum += a).collect();
		let m = (sum / x) as usize;
		a.sort();
		let cnt: i32 = a[0..n - m].iter().sum();
		if cnt <= k {
			x
		} else {
			r
		}
	});
	println!("{}", ans);
}

pub fn divisors<T>(n: T) -> Vec<T>
where
	T: num::PrimInt,
{
	let n = if n < T::zero() { T::zero() - n } else { n };
	let mut d = T::one();
	let mut divs = vec![];
	while d * d <= n {
		if n % d == T::zero() {
			divs.push(d);
			if d != n / d {
				divs.push(n / d);
			}
		}
		d = d + T::one();
	}
	divs.sort();
	divs
}


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

using namespace std;

int main(int argc, char* argv[])
{
  string s, t;
  cin >> s >> t;
  
  int n = s.size();
  int m = t.size();
  vector< vector<int> > v(n+1);
  for (int i=0; i <= n; i++) v[i].resize(m+1, 0);
  
  for (int i=1; i <= n; i++) {
    for (int j=1; j <= m; j++) {
      int best = max(v[i-1][j], v[i][j-1]);
      if (s[i-1] == t[j-1]) {
        best = max(best, 1 + v[i-1][j-1]);
      }
      v[i][j] = best;
    }
  }
  /*
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      cout << v[i][j] << " ";
    }
    cout << "\n";
  }
  */
  string ans = "";
  int i = n;
  int j = m;
  while (i > 0 && j > 0) {
    if (v[i][j] == v[i-1][j]) {
      i--;
    } else if (v[i][j] == v[i][j-1]) {
      j--;
    } else {
      ans = s[i-1] + ans;
      i--;
      j--;
    } 
  }
  
  cout << ans << "\n";
  return 0;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    cin>>n;
    rep1(i,9,1){
        if(n%i==0){
            int t=n/i;
            if(t>=1&&t<=9) cout<<"Yes";
            else cout<<"No";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
	public static void main(String[] args){
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {
			int m = Integer.parseInt(br.readLine());
			pw.println(48 - m);
		} catch (IOException e) {
		}
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast_I_O ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9+7 , INF = 1e9 ,  mx = 100005 ;
main()
{
    fast_I_O;
    int i,j,n,m,x,y,sum=0,p=0,l,k;
    cin>>x>>y>>m;
    double z=((double)x/m);
    if(z<=double(y)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3620