akhauriyash/Code-Regression huggingface dataset:
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	string s;
	cin>>s;
	set<char>st;
	for (int i = 0; i < 4; i++){
		st.insert(s[i]);
	}
	if(st.size() == 2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3628
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int n, vector<string> const &strs) {
  using Freq = std::array<int, 26>;
  multiset<Freq> freq;
  REP(i, n) {
    Freq f;
    f.fill(0);
    for (auto &&c: strs[i]) { ++f[c-'a']; }
    freq.insert(f);
  }
  lli cnt = 0;
  for (auto each = begin(freq); each != end(freq); each = freq.upper_bound(*each)) {
    lli m = freq.count(*each);
    cnt += m * (m - 1) / 2;
  }
  cout << cnt << endl;
}

int main() {
  // cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<string> strs;
  REP(i, N) {
    string S; cin >> S;
    strs.push_back(S);
  }
  solve(N, strs);
  return 0;
}


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

int main()
{
    int s;
    cin >> s;
    if(s==1){ cout<<4<<endl; return 0;}
    if(s==2){ cout<<4<<endl; return 0;}
    for(int i=1; true; i++){
        if(s==4){
            cout<< (i + 3) <<endl;
            return 0;
        }
        if(s % 2 == 0) s /= 2;
        else           s = 3 * s + 1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 205;

int i, j, ok, res, n, D[N][N];
char t[N];
VI graf[N];

//n - liczba wierzchołków (0...n-1), D[][] - tablica wynikowa
void FloydWarshall (int n) {
    int i,j,k;
    for (i=0;i<n;i++) {
        for (j=0;j<n;j++) D[i][j]=INF;
        D[i][i]=0;
    }
    for (i=0;i<n;i++) for (j=0;j<graf[i].size();j++) D[i][graf[i][j]]=min(D[i][graf[i][j]],1);
    for (i=0;i<n;i++) for (j=0;j<n;j++) if (D[j][i]!=INF) for (k=0;k<n;k++) if (D[i][k]!=INF) D[j][k]=min(D[j][k],D[j][i]+D[i][k]);
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<n;j++) if (t[j] == '1') graf[i].pb(j);
}
FloydWarshall(n);
res = -1;
for (i=0;i<n;i++) {
	ok = 1;
	for (j=0;j<n;j++) for(auto& w : graf[j]) if (abs(D[i][j] - D[i][w]) != 1) ok = 0;
	if (ok) for (j=0;j<n;j++) res = max(res, D[i][j] + 1);
}
printf("%d\n", res);
return 0;
}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>

std::vector<std::vector<int>> pikas;
std::vector<int> pika_num;
std::array<int,10> pikapika;

int main(void){
	for(int i=0;i<10;i++){
		pikapika.at(i) = 0;
	}

	int N,M;
	std::cin>>N>>M;

	for(int i=0;i<M;i++){
		int K;
		std::vector<int> temp;
		std::cin>>K;
		for(int j=0;j<K;j++){
			int s;
			std::cin>>s;
			temp.push_back(s);
		}
		pikas.push_back(temp);
	}
	for(int i=0;i<M;i++){
		int p;
		std::cin>>p;
		pika_num.push_back(p);
	}


	int cnt = 0;
	for(int bit=0;bit<(1<<N);bit++){
		for(int i=0;i<10;i++){
			pikapika.at(i) = 0;
		}
		for(int i=0;i<N;i++){
			if(bit & (1<<i)){
				for(int j=0;j<M;j++){
					std::vector<int> temp = pikas.at(j);
					auto itr = std::find(temp.begin(),temp.end(),i+1);
					if(itr != temp.end()){
						pikapika.at(j) += 1;
					}
				}
			}
		}
//	for(int l=0;l<M;l++){
//		std::cout<<pikapika.at(l)<<std::endl;
//	}
//	std::cout<<"/////////////////////"<<std::endl;
		
		bool on = true;
		for(int k=0;k<M;k++){
			if(pikapika.at(k)%2 != pika_num.at(k)){
				on = false;
			}
		}
		if(on){
			cnt++;
		}
	}

	std::cout<<cnt<<std::endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

a, b = [int(x) for x in stdin.readline().rstrip().split()]

x1 = a / 0.08
x11 = (a + 1) / 0.08
x2 = b / 0.1
x22 = (b + 1) / 0.1

result = -1
if (x1 >= x2) and (x1 < x22):
    result = x1
if (x2 >= x1) and (x2 < x11):
    result = x2

print(math.ceil(result))

Measured memory_bytes: 3064
#include <stdio.h>

int main(){

int a,b;
int count = 0;

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


Measured memory_bytes: 2012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s;

int cou[3];

int main()
{
    cin >> s;


    rep(i,0,2)
    {
        for(int c : s)
        {
            if(c == 'a' + i) cou[i]++;
        }
    }

    /*
    aaを避ける->何か挟む
    aba...アウト
    abca..おkk
    abba...アウト
    ->abcabcabcabcが最適
    */

    sort(cou,cou + 3);

    if(cou[2] - cou[0] <= 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    a, b, c, x, y = [int(x) for x in input().split()]
    c *= 2
    ans = 0
    if c < a + b:
        z = min(x, y)
        ans += c * z
        x -= z
        y -= z
    if x:
        if c * x < a * x:
            ans += c * x
        else:
            ans += a * x
    if y:
        if c * y < b * y:
            ans += c * y
        else:
            ans += b * y
    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""


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

using namespace std;

int N,M;
const int MAXN = 1e5 + 5;

vector <int> adj[MAXN];
bool visitado[MAXN];
int dp[MAXN];

int solve(int u){
  
  visitado[u] = true;

  int ans = 0;

  for(auto &ele: adj[u]){
    if(!visitado[ele]){
      ans = max(ans,solve(ele) + 1);
    }else{
      ans = max(ans, dp[ele] + 1);
    }
  }

  return dp[u] = ans;
}

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

 while(M--){
   int x,y;
   cin >> x >> y;
   adj[x].push_back(y);
 }
  
 int ans = 0;

 for(int i = 1;i<=N;i++){
   if(!visitado[i])
    ans = max(ans,solve(i));
 }

 cout << ans << endl;

}

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

def main():
    M = int(input())
    count = 0
    wa = 0
    for _ in range(M):
        d, c = [int(x) for x in input().split()]
        count += c
        wa += d * c
    
    print(count - 1 + ((wa - 1) // 9))
    



if __name__ == '__main__':
    main()



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
i64 N, M;
vector<i64> G[MAX_N];
i64 dp[MAX_N];

void dfs(i64 u, vector<i64> &visited, vector<i64> &topo) {
    visited[u] = true;
    REP(i, G[u].size()) {
        if (visited[G[u][i]]) continue;
        dfs(G[u][i], visited, topo);
    }
    topo.pb(u);
}

int main() {
    cin >> N >> M;
    i64 u, v;
    REP(i, M) {
        cin >> u >> v;
        u--; v--;
        G[u].pb(v);
    }

    vector<i64> rtopo(N);
    vector<i64> visited(N);
    REP(u, N) {
        if (visited[u]) continue;
        dfs(u, visited, rtopo);
    }

    fill(dp, dp + N, 0);
    i64 maxl = 0;
    for (auto u : rtopo) {
        for (auto v : G[u]) {
            chmax(dp[u], dp[v] + 1);
        }
        chmax(maxl, dp[u]);
    }
    cout << maxl << endl;

    return 0;
}

Measured memory_bytes: 11632
#include<bits/stdc++.h>
#define rep(i, a, b) for(long long i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
long long n, k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n >> k;
    long long num=(n/k);
    long long xx=0;
    if(k%2==0) {
        xx=(n-k/2)/k;
        if(n>=k/2) ++xx;
    }
    long long ans=1ll*num*num*num+1ll*xx*xx*xx;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>

int main(){
	char s[233];
	scanf("%s",s+1);
	int l=strlen(s+1);
	if (s[1]!='A') puts("WA");else{
		int tot=0;
		if (s[2]=='C'||s[l]=='C'){
			puts("WA");
			return 0;
		}
		for (int i=3;i<l;i++) if (s[i]=='C') tot++;
		if (tot!=1){
			puts("WA");
			return 0;
		}
		for (int i=2;i<=l;i++) if (s[i]!='C'&&s[i]<='Z'){
			puts("WA");
			return 0;
		}
		puts("AC");
	}
}

Measured memory_bytes: 128
n, m = map(int, input().split())

if n ==1 and m == 1:
    print(1)
elif n == 1 or m==1:
    if n == 1:
        print(m-2)
    else:
        print(n-2)
else:
    print(n*m-2*n-2*m+4)

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

struct UnionFind {
  vector<int> par;//parent

  vector<int>nodes;

  UnionFind(int N): par(N), nodes(N)
  {
    for(int i = 0; i < N; i++){
      par[i] = i;
      nodes[i] = 1;
    }
  }

  int root(int x) {//find the root and path compression
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    nodes[ry] += nodes[rx];
    par[rx] = ry;
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }

};


int main(){
  long long n, m;
  cin >> n >> m;
  long long maxi = n*(n-1)/2;
  long long ans[100001] = {0};
  int a[100000][2] = {{0}};
  for(int i = 0 ; i < m; i++){
    cin >> a[i][0] >> a[i][1];

  }

  UnionFind uf = (n);

  for(int i = m-1; i >= 0 ; i--){
    if(uf.same(a[i][0]-1, a[i][1]-1)){
      ans[i] = ans[i+1];
    }
    else{
      ans[i] += ans[i+1] + uf.nodes[uf.root(a[i][0]-1)]*uf.nodes[uf.root(a[i][1]-1)];
      uf.unite(a[i][0]-1, a[i][1]-1);
    }
  }

  for(int i = 1 ; i <= m; i++){
    cout << maxi - ans[i] << endl;
  }

}

/*
int main(){
  vector< vector<int> > lands;
  long long n, m;
  cin >> n >> m;
  long long maxi = n*(n-1)/2;
  long long ans[100001];
  ans[100000] = 0;
  int a[100000][2];
  for(int i = 0 ; i < m; i++){
    cin >> a[i][0] >> a[i][1];
  }
  for(int i = m-1; i >= 0; i--){
    int f = -1;
    int s = -1;
    for(int j = 0; j < lands.size() ; j++){
      if(binary_search(lands[j].begin(), lands[j].end(), a[i][0])) f = j;
      if(binary_search(lands[j].begin(), lands[j].end(), a[i][1])) s = j;
    }
    if(f != -1 && s != -1 && f == s) ans[i] = ans[i+1];
    else if(f != -1 && s != -1){
      ans[i] = ans[i+1] + lands[f].size()*lands[s].size();
      if(lands[f].size() < lands[s].size()){
        int tmp = f;
        f = s;
        s = tmp;
      }
      for(int j = 0; j < lands[s].size() ; j++){
        lands[f].push_back(lands[s][j]);
      }
      sort(lands[f].begin(), lands[f].end());
      lands.erase(lands.begin()+s);
    }
    else if(f != -1){
      ans[i] = ans[i+1] + lands[f].size();
      lands[f].push_back(a[i][0]);
      sort(lands[f].begin(), lands[f].end());
    }
    else if(s != -1){
      ans[i] = ans[i+1] + lands[s].size();
      lands[s].push_back(a[i][1]);
      sort(lands[s].begin(), lands[s].end());
    }
    else{
      vector<int> land;
      land.push_back(a[i][0]);land.push_back(a[i][1]);
      lands.push_back(land);
      ans[i] = ans[i+1] + 1;
    }

  }


  for(int i = 1 ; i <= m; i++){
    cout << maxi - ans[i] << endl;
  }
}*/


Measured memory_bytes: 3712
tes = input()
for mak in range(int(input())) :
    ins = input().split()
    ins[1], ins[2] = int(ins[1]), int(ins[2])
    if ins[0] == 'replace' :
        tes = tes[ : (ins[1])] + ins[3] + tes[(ins[2] + 1) :]
    elif ins[0] == 'reverse' :
        tem = tes[ins[1] : ins[2] + 1]
        tem = tem[::-1]
        tes = tes.replace(tes[ins[1] : ins[2] + 1], tem)
    elif ins[0] == 'print' :
        print(tes[ins[1] : ins[2] + 1])

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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;

  while (1) {
    minv = INFTY;
    int u = -1;
    for (int i = 0; i < n; i++) {
      if (minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }

    if (u == -1) {
      break;
    }

    color[u] = BLACK;

    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > d[u] + M[u][v]) {
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i << " " << d[i] << endl;
  }
};

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

};






Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
signed main(){
    fast();
    int n;
    cin >> n;
    vector<int> a(n);
    int x = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        x ^= a[i];
    }
    // cout << x << endl;
    for(int i=0; i<n; i++){
        a[i] ^= x;
    }
    for(auto i: a)  cout << i << " ";
    cout << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

using namespace std;

int main() {
    int a,b,c,d;
    char c1, c2, c3, c4;
    int sum;
    cin >> c1 >> c2 >> c3 >> c4;
    a = c1 - '0';
    b = c2 - '0';
    c = c3 - '0';
    d = c4 - '0';
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 2; ++j)
            for (int k = 0; k < 2; ++k){
            int s1, s2, s3;
            if (i == 0) s1 = 1;
                else s1 = -1;
            if (j == 0) s2 = 1;
                else s2 = -1;
            if (k == 0) s3 = 1;
                else s3 = -1;
            sum = a + s1 * b + s2 * c + s3 * d;
            if (sum == 7) {
                cout << a;
                if (i == 0) cout << "+";
                    else cout <<"-";
                cout << b;
                 if (j == 0) cout << "+";
                    else cout <<"-";
                cout << c;
                 if (k == 0) cout << "+";
                    else cout <<"-";
                cout << d << "=7";
                return 0;
            }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

template <int MOD>
class mod_int {
public:
	mod_int() : val(0)
	{
	}

	mod_int(int value) : val(value) {
		assert(0 <= value);
		assert(value < MOD);
	}
	mod_int(const mod_int&) = default;
	mod_int& operator=(const mod_int&) = default;

	mod_int& operator+=(const mod_int& other) {
		val = (0LL + val + other.val) % MOD;
		return *this;
	}

	mod_int& operator-=(const mod_int& other) {
		val = (0LL + val + MOD - other.val) % MOD;
		return *this;
	}

	mod_int& operator*=(const mod_int& other) {
		val = (1LL * val * other.val) % MOD;
		return *this;
	}

	int value() const {
		return val;
	}

private:
	int val;
};

template <int MOD>
std::ostream& operator<<(std::ostream& os, mod_int<MOD> x)
{
	return os << x.value();
}

template <int MOD>
mod_int<MOD> operator+(mod_int<MOD> lhs, mod_int<MOD> rhs)
{
	return lhs += rhs;
}

template <int MOD>
mod_int<MOD> operator-(mod_int<MOD> lhs, mod_int<MOD> rhs)
{
	return lhs -= rhs;
}

template <int MOD>
mod_int<MOD> operator*(mod_int<MOD> lhs, mod_int<MOD> rhs)
{
	return lhs *= rhs;
}

const int MOD = 998244353;
using mint = mod_int<MOD>;

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

	vector<vector<mint>> dp(C + 1, vector<mint>(D + 1, 0));

	dp[A][B] = 1;
	for (int a = A; a <= C; ++a) {
		for (int b = B; b <= D; ++b) {
			if (a < C) {
				dp[a + 1][b] += dp[a][b] * mint(b);
			}
			if (b < D) {
				dp[a][b + 1] += dp[a][b] * mint(a);
			}
			if (a < C && b < D) {
				dp[a + 1][b + 1] -= dp[a][b] * mint(a) * mint(b);
			}
		}
	}

	cout << dp[C][D] << endl;
}


Measured memory_bytes: 38564
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL A[100001];
LL B[100001];
int main(){
	cin>>N;
	REP(i,N){
	   cin>>A[i]>>B[i];
	}
	LL ans=0;
        for(int i=N-1;i>=0;i--){
            LL temp=B[i]-((A[i]+ans)%B[i]);
            ans=ans+(temp%B[i]);
        }
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>

bool isTriangle(int a, int b, int c)
{
	if (a+b > c && c+a > b) return true;
	else return false;
}

int main()
{
	int N;
	std::cin >> N;
	int* L = new int[N];
	for (int i=0; i<N; i++) std::cin >> L[i];
	std::sort(L, L+N);
	int cnt = 0;
	for (int i=0; i<N-2; i++) {
		for (int j=i+1; j<N-1; j++) {
			if (L[i] == L[j]) continue;
			for (int k=j+1; k<N; k++) {
				if (L[j] == L[k]) continue;
				cnt += isTriangle(L[i], L[j], L[k]) ? 1 : 0;
			}
		}
	}
	std::cout << cnt << std::endl;
	delete[] L;
	return 0;
}


Measured memory_bytes: 3636
from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)

Measured memory_bytes: 29548
#include <iostream>

using namespace std;

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	if (n % x == 0) {
		cout << (n / x) * t << endl;
	}
	else {
		cout << ((n / x) + 1) * t << endl;
	}
	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int m,n,i,k=0;
    scanf("%lld %lld",&m,&n);
    long long int a[m+5],sum[m+5];
    for(i=0;i<m;i++)
    {
        scanf("%lld",&a[i]);
        if(n>m)
        {
            scanf("%lld",&a[i]);
        }
    }
    sort(a,a+m);
    for(i=0;;i++)
    {
        sum[k++]=a[n+i-1]-a[i];
        if((n+i)==m)
        {
            break;
        }
    }
    sort(sum,sum+k);
    printf("%lld\n",sum[0]);
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    int ans = 0;
    for(int i = 0; i < (1<<n); i++){
        int x = 0, y = 0;
        for(int j = 0; j < n; j++){
            if(i & (1<< j)){
                x += a[j];
                y += b[j];
            }
        }
        ans = max(ans, x - y);
    }
    cout << ans << endl;
}

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

int main()
{
    long long n;
    cin >> n;

    long long a, b;

    a = 0;
    b = 0;
    if (n >= 500)
    {
        a = n / 500;
        n = n % 500;
    }
    if (n > 5)
    {
        b = n / 5;
    }

    long long ans = (1000 * a) + (5 * b);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
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; }

int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;++i){
        int j=x-i;
        int leg=2*i+4*j;
        if(leg==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

#define endl '\n'
#define Int long long
#define Double long double
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define CLR(a, b) memset(a, b, sizeof a)
#define debug(x) cerr << #x << " " << x << endl;
#define MOD 1000000007
#define MAXN 2002

using namespace std;

int n, k;
int mark[MAXN];
int depth[2][MAXN];
vector<int> net[MAXN];

void dfs(int v, int d, int t) {
    mark[v] = 1;
    depth[t][d]++;

    for(int i = 0; i < SZ(net[v]); ++i) {
        if(!mark[net[v][i]])
            dfs(net[v][i], d + 1, t);
    }
}

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

    cin >> n >> k;
    for(int i = 0; i < n-1; ++i) {
        int u, v; cin >> u >> v;
        u--, v--;
        net[u].push_back(v);
        net[v].push_back(u);
    }
    int ans = INT_MAX;
    if(k%2 == 0) {
        for(int i = 0; i < n; ++i) {
            CLR(mark, 0);
            //CLR(depth, 0);
            for(int l = 0; l < n; ++l)
                depth[0][l] = 0;

            dfs(i, 0, 0);

            int res = 0;
            for(int i = k/2 + 1; i < n; ++i)
                res += depth[0][i];
            ans = min(res, ans);
        }
    } else {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < SZ(net[i]); ++j) {
                CLR(mark, 0);
                //CLR(depth, 0);
                for(int l = 0; l < n; ++l)
                    depth[0][l] = depth[1][l] = 0;

                mark[net[i][j]] = 1;
                dfs(i, 0, 0);

                dfs(net[i][j], 0, 1);

                int res = 0;
                for(int l = k/2 + 1; l < n; ++l) {
                    res += (depth[0][l] + depth[1][l]);
                }
                //res += min(depth[0][k/2 + 1], depth[1][k/2 + 1]);

                ans = min(ans, res);
            }
        }
        
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll N=105;
ll wt[N];
ll val[N];
ll dp[N][100005];
ll n,w;
int main()
{
	cin>>n>>w;
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	memset(dp,0,sizeof(dp));
	ll flag=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(j>=wt[i-1])
			{
				dp[flag][j]=max(dp[1-flag][j],val[i-1]+dp[1-flag][j-wt[i-1]]);
			}
			else
			dp[flag][j]=dp[1-flag][j];
		}
		flag=1-flag;
	}
	cout<<dp[1-flag][w]<<endl;
	
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int pre = sc.nextInt();
		long ans = pre;
		int now = pre;
		for (int i = 1; i < N-1; i++) {
			now = sc.nextInt();
			ans += Math.min(pre, now);
			pre = now;
		}
		ans += now;
		System.out.println(ans);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

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

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

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

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

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

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict
geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

def main():
    N = gete(int)
    p, q, r = 0,0,0
    for _ in range(N):
        a,b ,c = geta(int)
        p,q,r = a + max(q,r), b + max(r,p), c + max(p,q)

    print(max(p,q,r))

if __name__ == "__main__":
    main()

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

int main() {
   string S;
   cin >> S;
   for (int i=0; i<S.size(); i++) {
       if (S.at(i)!='?') cout << S.at(i);
       else cout << 'D';
   }
   cout << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    double R;
    cin >> R;
    cout << M_PI * R * 2 << endl;
    return 0;
}

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



int main() {
    int N, count=0, D[2];
    bool x=false;
    cin >> N;
    for(int i=0; i<N; ++i){
        cin >> D[0] >> D[1];
        if(D[0]==D[1]){
            ++count;
        }else{
            count=0;
        }
        if(count==3) x=true;
    }
    if(x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3628
h,w = map(int,input().split())
S = [input() for _ in range(h)]
B = [['0']*w for _ in range(h)]

def check(i,j):
    cnt = 0
    for i2 in [-1,0,1]:
        for j2 in [-1,0,1]:
            if (i2!=0 or j2!=0) and 0<=i+i2<h and 0<=j+j2<w:
                if S[i+i2][j+j2]=='#':
                    cnt+=1
    return cnt

for i in range(h):
    for j in range(w):
        if S[i][j]=='.':
            B[i][j]=str(check(i,j))
        else:
            B[i][j]='#'
[print(''.join(x)) for x in B]

Measured memory_bytes: 3188
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N;
    cin >> N;
    vecllong cost(N + 2, 0);

    FOR(i, N) {
        cin >> cost[i];
    }

    vecllong dp(N + 2, INF);
    dp[0] = 0;

    FOR(i, N + 1) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(cost[i] - cost[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(cost[i] - cost[i + 2]));
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define lli long long int
#define pb push_back
#define pob pop_back
#define rep(i,a,b) for(lli i=a;i<b;i++)
#define repv(a,b) for(int i=a;i>=b;i--)
#define itr vector<lli> :: iterator
#define maximum(a,b,c)  max(a,max(b,c))
#define minimum(a,b,c) min(a,min(b,c))
#define tim clock_t

inline void fast()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main()
{
	fast();
	double T,x,t;
	cin>>T>>x;
	t=T/x;
	printf("%.10lf",t);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    int n; cin >> n;

    int p[n];
    rep(i, n){
        cin >> p[i];
    }

    int dp[n+1] = {};
    rep(i, n){
        int pnow = p[i];

        dp[pnow] = dp[pnow - 1] + 1;
    }

    cout << n - *max_element(dp, dp+n+1) << endl;

    return 0;
}

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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int cnt = 0;
	int q; cin >> q;

	deque<char> que;
	for (auto c : s) que.push_back(c);

	rep(i, q) {
		int query; cin >> query;
		if (query == 1) {
			cnt++;
		} else {
			int f; char c; cin >> f >> c;
			if (cnt % 2 == 0) {
				if (f == 1) que.push_front(c);
				else que.push_back(c);
			} else {
				if (f == 1) que.push_back(c);
				else que.push_front(c);
			}
		}
	}

	string ans;
	for (auto c : que) ans += c;
	if (cnt % 2 != 0) {
		reverse(ans.begin(), ans.end());
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <utility>
#include <set>
//#include <map>
//#include <queue>
#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1ll<<61 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
	ll h,w ;
	cin >> h >> w ;
	ll sy,sx,gy,gx ;
	cin >> sy >> sx >> gy >> gx ;
	vvc g(h,vc(w)) ;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> g.at(i).at(j) ;
	vvll d(h,vll(w,INF)) ;
	deque<int> q ;
	auto check = [&](int y,int x,ll dis,int b){
		if(0<=y&&y<h&&0<=x&&x<w&&g.at(y).at(x)=='.'&&d.at(y).at(x)==INF){
			if(b==0){
				q.push_front(dis) ;
				q.push_front(x) ;
				q.push_front(y) ;
			}else{
				q.push_back(y) ;
				q.push_back(x) ;
				q.push_back(dis) ;
			}
		}
	} ;
	sy-- ; sx-- ;
	gy-- ; gx-- ;
	q.push_front(0) ; q.push_front(sx) ; q.push_front(sy) ;
	while(!q.empty()){
		int y = q.front() ; q.pop_front() ;
		int x = q.front() ; q.pop_front() ;
		ll dis = q.front() ; q.pop_front() ;
		if(dis>=d.at(y).at(x)) continue ;
		d.at(y).at(x) = dis ;
//		cout << y << " " << x << " " << dis << endl ;
		check(y-1,x,dis,0) ;
		check(y+1,x,dis,0) ;
		check(y,x-1,dis,0) ;
		check(y,x+1,dis,0) ;
		for(int i=-2;i<=2;i++) for(int j=-2;j<=2;j++) check(y+i,x+j,dis+1,1) ;
	}
	cout << (d.at(gy).at(gx)==INF?-1:d.at(gy).at(gx)) << endl ;
//	for(int i=0;i<h;i++){
//		for(int j=0;j<w;j++) cout << d.at(i).at(j) << (j==w-1?"\n":" ") ;
//	}
}


Measured memory_bytes: 13100
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let in_x: i32 = read();
    let a = in_x / 500;
    let b = (in_x % 500) / 5;

    println!("{}", a * 1000 + b * 5);
}


Measured memory_bytes: 4352
MOD = 10 ** 9 + 7

def func(N,A):
  result = 0
  S = sum(A) % MOD
  for x in A:
    S -= x
    S %= MOD
    result += x * S
    result %= MOD
  result %= MOD
  return result

if __name__ == "__main__":
  N = int(input())
  A = list(map(int, input().split()))
  print(func(N,A))

Measured memory_bytes: 31428
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int n,s[111111],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&s[i]);
	sort(s+1,s+1+2*n);
	for(int i=2*n-1;i>=1;i-=2) ans+=s[i];
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int>a(n+1),b(n+1),c(n+1),dpa(n+1),dpb(n+1),dpc(n+1);
    rep(i,1,n+1){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(i,0,n+1){
        dpa[i]=dpb[i]=dpc[i]=0;
    }
    rep(i,0,n){
        dpa[i+1]=max(dpb[i],dpc[i])+a[i+1];
        dpb[i+1]=max(dpa[i],dpc[i])+b[i+1];
        dpc[i+1]=max(dpb[i],dpa[i])+c[i+1];
    }
    cout<<max(dpc[n],max(dpa[n],dpb[n]));
}

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

int main(){
    string N;
    cin>>N;
    reverse(N.begin(),N.end());
    if(N.at(0)=='3'){
        cout<<"bon"<<endl;
        return 0;
    }
    if(N.at(0)=='6'||N.at(0)=='1'||N.at(0)=='0'||N.at(0)=='8'){
        cout<<"pon"<<endl;
        return 0;
    }else{
        cout<<"hon"<<endl;
        return 0;
    }

}

Measured memory_bytes: 3596
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC113 {
    class A {
        static void Main() => CustomMain();

        static void Solve() {
            var a = ReadIntArray();
            WriteAnswer(a[0] + a[1] / 2);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<endl
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e14
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll a,p; cin>>a>>p;
  	p+=a*3;
  	cout<<p/2<<'\n';
	
	return 0;
}


Measured memory_bytes: 256
// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;


int main() {
    int p, n;
    cin >> p >> n;
    vector<long long> h(n);
    long long dist = 0;
    cin >> h[0];
    for (int i=1; i<n; i++) {
        cin >> h[i];
        dist += h[i] - h[i-1];
    }
    sort(begin(h), end(h));
    for (int i=1; i<n; i++) {
        dist = min(dist, (p - (h[i] - h[i-1])));
    }
    cout << dist << endl;
}


Measured memory_bytes: 1792
import Data.Fixed

main = getContents >>= putStrLn.formatOut.calc.formatIn

formatIn :: String -> Pico
formatIn = read :: String -> Pico

formatOut :: [Pico] -> String
formatOut = unwords.map show

calc :: Pico -> [Pico]
calc r = [(r^2)*p, r*2*p]
    where p   = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 

Measured memory_bytes: 4132
n = int(input())

R = []
for _ in range(n):
    R.append(int(input()))

maxv = -2000000000
minv = R[0]

for i in range(1, n):
    maxv = max(maxv, R[i] - minv)
    minv = min(minv, R[i])

print(maxv)

Measured memory_bytes: 15628
// Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	for(int i=0; i<n; i++){
		prime[i] = false;
	}

	for(int i=0; 7*i<n; i++){
		if(7*i+1<n)
			prime[7*i+1] = true;
		if(7*i+6<n)
			prime[7*i+6] = true;
	}

	if(n>=2)
		prime[1] = false;

	for(int i=2; i*i<n; i++){
		if(!prime[i])
			continue;

		for(int j=i+i; j<n; j+=i){
			prime[j] = false;
		}
	}
}

int main()
{
	bool P[300000];
	eratos(P, 300000);
/*
	for(int i=0; i<100; i++)
		if(P[i])
			cout << i << endl;
*/
	while(true){
		int n;
		cin >> n;

		if(n==1)
			break;

		cout << n << ':';

		for(int i=2; i<=n; i++){
			if(!P[i])
				continue;

			if(n%i!=0)
				continue;

			if(n/i%7==1||n/i%7==6)
				cout << ' ' << i;
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

struct unionfind {
    vector<int> parent; // 各要素の親のindex(根の場合は-1)
    vector<int> diff_weight; // 各要素の親要素との重さの差分(根の場合は0)
    unionfind(int n) {
        parent.resize(n, -1);
        diff_weight.resize(n, 0);
    }
    int root(int x) { // 要素xの属する集合の根のindex(要素xが根の場合はx)
        if (parent[x] < 0) return x;
        int r = root(parent[x]);
        diff_weight[x] += diff_weight[parent[x]];
        return parent[x] = r;
    }
    int weight(int x) { // 要素xとその親要素との重さの差分
        root(x);
        return diff_weight[x];
    }
    void merge(int x, int y) { // 要素xとyを共通の集合に結合
        x = root(x), y = root(y);
        if (x == y) return;
        if (parent[x] > parent[y]) {
            swap(x, y);
        }
        parent[x] += parent[y];
        parent[y] = x;
    }
    void merge(int x, int y, int w) { // 要素xとyを共通の集合に結合
        w += weight(x), w -= weight(y);
        x = root(x), y = root(y);
        if (x == y) return;
        if (parent[x] > parent[y]) {
            swap(x, y);
            w *= -1;
        }
        parent[x] += parent[y];
        parent[y] = x;
        diff_weight[y] = w;
    }
    bool common(int x, int y) { // 要素xとyが共通の集合に属するか
        return root(x) == root(y);
    }
    int size(int x) { // 要素xの属する集合の大きさ
        return -parent[root(x)];
    }
    int diff(int x, int y) { // 要素xとyの重さの差分
        return weight(y) - weight(x);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    unionfind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.merge(a, b);
    }
    set<int> s;
    rep(i, n) {
        s.insert(uf.root(i));
    }
    int ans = (int)s.size() - 1;
    cout << ans << endl;
}

Measured memory_bytes: 7948
#include<iostream>
using namespace std;
const int N=100005;
int mayRed[N];
int bucket[N];
int main(){
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		mayRed[i]=0;
		bucket[i]=1;
	}
	mayRed[1]=1;
	int a,b;
	while(m--){
		cin>>a>>b;
		bucket[a]--;
		bucket[b]++;
		if(mayRed[a])
			mayRed[b]=1;
		if(bucket[a]==0)
			mayRed[a]=0;
	}
	for(int i=1;i<=n;i++)
	{
		if(mayRed[i])
			ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024