akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
  string s1,s2;
  int dp[1001][1001];
  cin >> s1 >> s2;
  for(int i=0;i<=s1.size();i++) dp[i][0]=i;
  for(int i=0;i<=s2.size();i++) dp[0][i]=i;
  for(int i=1;i<=s1.size();i++){
    for(int j=1;j<=s2.size();j++){
      int key=1;
      if(s2[j-1]==s1[i-1]) key=0;
      dp[i][j]=min(min(dp[i-1][j-1]+key,dp[i][j-1]+1),dp[i-1][j]+1);
    }
  }
  cout << dp[s1.size()][s2.size()] << endl;
}



Measured memory_bytes: 7076
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,q,x,cnt1=1,cnt2=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> q >> x;
    if(q==1) {
      cnt1*=x;
      cnt2*=x;
    }
    else if(q==2) {
      cnt2+=x;
    }
    else {
      cnt2-=x;
    }
  }
  cout << -cnt2 << " " << cnt1 << endl;
}


Measured memory_bytes: 3120
n = int(input())
A = list(map(int, input().split()))


A.sort(reverse=True)
ans = A[0]
current_a = 1
cnt = 0
for i in range(n-2):
  cnt += 1
  ans += A[current_a]
  if cnt == 2:
    cnt = 0
    current_a += 1
print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    bool a = true;
    if(s.length() < 4) a = false;
    else
    {
        if(s.at(0) != 'Y') a = false;
        if(s.at(1) != 'A') a = false;
        if(s.at(2) != 'K') a = false;
        if(s.at(3) != 'I') a = false;
    }
    if(a)cout << "Yes";
    else cout << "No" ;
}

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


int main(){
	for(int n,p;cin>>n>>p,p;){
		int have[50]={0};
		int cup=p;
		int turn=0;
		for(int i=0;1;){
			if(cup==0)swap(cup,have[i]);
			else{
				cup--;
				have[i]++;
			}
			if(have[i]==p){
				cout<<i<<endl;
				break;
			}
			i=(i+1)%n;
		}
		
		
	}
	return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	int64_t ans=t,ftmp,tmp;
	cin>>ftmp;
	for(int i=1;i<n;++i){
		ans+=t;
		cin>>tmp;
		if(tmp-ftmp<t)ans-=t-(tmp-ftmp);
		ftmp=tmp;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if (A+B>C+D) {
    cout<<"Left"<<endl;
  } else if(A+B<C+D) {
    cout<<"Right"<<endl;
  } else {
    cout<<"Balanced"<<endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int a, b;
	cin >> a >> b;

	int res = 0;
	for (int i = a; i <= b; i++)
	{
		string s = to_string(i);
		string t = s;
		reverse(all(t));

		if (s == t)
		{
			res++;
		}
	}
	println(res);
}


Measured memory_bytes: 256
import sys
import heapq

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

A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)

for _ in range(M):
    mx = heapq.heappop(A)
    heapq.heappush(A, mx // 2 if mx % 2 == 0 else mx // 2 + 1)

print(sum(A) * (-1))

Measured memory_bytes: 14200
n = int(input())
d,x = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = int(input())

cnt = 0

for i in range(n):
    day = 1
    c = 0
    
    while day <= d:
        c += 1
        day += a[i]
    cnt += c
print(cnt+x)

Measured memory_bytes: 38768
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

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

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#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)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int A,B,C;
	cin>>A>>B>>C;
	cout <<(A+B>=C?"Yes":"No") << 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
#include<stdio.h>
int main(void)
{
	int n,a;
	scanf("%d",&n);
	while(n!=0){
		a=0;
		while(n!=1){
			if(n%2==0)  n=n/2;
			else  n=n*3+1;
			a++;
		}
		printf("%d\n",a);
		scanf("%d",&n);
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
  long long N, M; cin>>N>>M;
  
  if (N == 1 && M == 1){
    cout << 1 << "\n";
  }else if(N == 1) {
    cout << M - 2 << "\n";
  } else if (M == 1) {
    cout << N - 2 << "\n";
  } else {
    cout << (N - 2) * (M - 2) << "\n";
  }

  return 0;
}


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

int main() {
  int n, c;
  std::cin >> n >> c;
  std::vector<std::vector<int>> d(c, std::vector<int>(c));
  for (int i = 0; i < c; ++i) {
    for (int j = 0; j < c; ++j) std::cin >> d[i][j];
  }
  std::vector<int> total[3];
  for (int m = 0; m < 3; ++m) total[m].resize(c, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int before;
      std::cin >> before;
      --before;
      for (int after = 0; after < c; ++after) {
        total[(i + j) % 3][after] += d[before][after];
      }
    }
  }
  int ans = 1e9;
  for (int x = 0; x < c; ++x) {
    for (int y = 0; y < c; ++y) {
      if (x == y) continue;
      for (int z = 0; z < c; ++z) {
        if (z == x or z == y) continue;
        ans = std::min(ans, total[0][x] + total[1][y] + total[2][z]);
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val S = next()
    var k = 0
    for(n in 0 until N - 1){
        if(S[n] == S[n + 1]) k++
    }
    var ans = Math.min(N - 1, k + 2 * K)
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

int N, A, B, C;
vec l;
ll rec(int n, int a, int b, int c){
    if(n == N){
        if(min(a, min(b, c)) == 0) return INF;
        else return (abs(A-a) + abs(B-b) + abs(C-c) - 30);
    }

    ll ret1 = rec(n+1, a, b, c);
    ll ret2 = rec(n+1, a+l[n], b, c) + 10;
    ll ret3 = rec(n+1, a, b+l[n], c) + 10;
    ll ret4 = rec(n+1, a, b, c+l[n]) + 10;

    return min(ret1, min(ret2, min(ret3, ret4)));
}

void solve() {
    cin >> N >> A >> B >> C;
    l.resize(N);
    rep(i, N) cin >> l[i];

    cout << rec(0, 0, 0, 0) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
n, m = map(int, input().split())
def check_ans(list_pairs):
  dict_people = {i: i for i in range(1, n+1)}
  for i in range(n):
    for k in range(m):
      val1 = dict_people[list_pairs[k][0]]
      val2 = dict_people[list_pairs[k][1]]
      if val1>val2:
        print(val2, val1, end=" / ")
      else:
        print(val1, val2, end=" / ")
    print("")
    for j in range(1, n+1):
      dict_people[j] = (dict_people[j]+1)%n
      if dict_people[j] == 0: dict_people[j] = n
ans = list()
if n%2 == 1:
  for i in range(m):
    node1 = (1-i)%n
    if node1 == 0: node1 = n
    node2 = 2+i
    ans.append((node1, node2))
else:
  distance = -1
  node2 = 1
  for i in range(m):
    node1 = (1-i)%n
    if node1 == 0: node1 = n
    node2 = node2+1
    distance += 2
    if distance == n//2 or distance == n//2 + 1:
      node2 += 1
    ans.append((node1, node2))
[print(str(values[0])+" "+str(values[1])) for values in ans]
# check_ans(ans)

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

#define MAX 2000001
#define VMAX 10000

int A[MAX],B[MAX];

int main(){
  int C[VMAX+1];
  int n, i, j,k;
  scanf("%d", &n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
  }
  k=A[1];
  for(i=1;i<n+1;i++){
    if(k<A[i]){
      k=A[i];
    }
  }
  for(i=0;i<=k;i++){
    C[i]=0;
    
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
 for(i=1;i<=n;i++){
      if(i<n)
      printf("%d ",B[i]);
      else printf("%d",B[i]);
      }
 
  printf("\n");
 return 0;
}



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

vector<int> G[MAX];
vector<ll> cnt(MAX, 0);
void dfs(int v, int p = -1)
{
	for (auto u : G[v])
	{
		if (u == p) continue;
		cnt[u] += cnt[v];
		dfs(u, v);
	}
}

signed main(void)
{
	int n, q;
	cin >> n >> q;
	rep(i, n - 1)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, q)
	{
		int p, x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	dfs(0);
	rep(i, n) printf("%lld%c", cnt[i], i==n-1?'\n':' ');
	return 0;
}


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

int main(){

    ll n;
    cin >> n ;
    
    if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
        cout << "hon" << endl;
    }else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }


    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b; cin >> a >> b;
	if(a<10&&b<10){
		cout << a*b << endl;
	}
	else{

		cout << -1 << endl;
	}
}

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

int main() {
  int N;
  int L[2005];
  int i, j, k;
  int cnt = 0;
  cin >> N;
  for (i = 0; i < N; i++)
    cin >> L[i];
  sort(L, L+N);
  for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
      for (k = j+1; k < N; k++) {
        if (L[k] < L[i]+L[j])
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;

set<char> se;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        char s; cin >> s;
        se.insert(s);
    }
    
}

string count_s(int n){
    if(n==3) return "Three";
    else return "Four";
}

int solve(){
    cout << count_s(se.size()) << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define LEN 100
#define INF 100000000

int  Q[LEN];
int G[LEN][LEN];
int head,tail;
int d[LEN];
int n;

void enqueue(int x){
  Q[tail] = x;
  tail = (tail+1) % LEN;
}
int dequeue(){
  int  x = Q[head];
  head = (head+1)%LEN;
  return x;
}

int enpty(){
  if(tail == head)return 1;
  else return 0;
}

void bfs(int s){
  int i;
  int u,v;
  enqueue(s);

  for(i=0;i<n;i++){
    d[i] = INF;
  }

  d[s] = 0;

  while(!enpty()){
    u = dequeue();
    for(v=0;v<n;v++){
      if(G[u][v] == 0)continue;
      if(d[v] != INF)continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,((d[i] == INF)? -1 : d[i]));
  }
}

int main(){
  int k,u,v;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 2140
def vacation():
    n = int(input())
    dp = [[]]*n
    for i in range(n):
        a, b, c = map(int, input().split())
        if i == 0:
            dp[i] = [a, b, c]
        else:
            dp[i] = [a + max(dp[i-1][1], dp[i-1][2]), b + max(dp[i-1][0], dp[i-1][2]), c + max(dp[i-1][0], dp[i-1][1])]
    print(max(dp[-1]))


if __name__ == '__main__':
    vacation()


Measured memory_bytes: 22796
#include<stdio.h>

int main(void)
{
    int n[1024], x[1024], data=0, i, j, k, l, count[1024]={0};
    
    while(1){
        scanf("%d %d", &n[data], &x[data]);
        if(n[data]==0 && x[data]==0) break;
        data++;
    }
    
    for(i=0; i<data; i++){
        for(j=0; j<n[i]-2; j++){
            for(k=j+1; k<n[i]-1; k++){
                for(l=k+1; l<n[i]; l++){
                    if(j+k+l+3==x[i]) count[i]++;
                }
            }
        }
    }
    
    for(i=0; i<data; i++){
        printf("%d\n", count[i]);
    }
    
    return 0;
}


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

// author: Seong Yong-ju ( @sei40kr )

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#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)

#define ALL(a) (a).begin(), (a).end()

#define P pair<int, int>

using namespace std;

const double pi = 4 * atan((double) 1.0);

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

  P start, dest;
  int n;
  cin >> start.first >> start.second >> dest.first >> dest.second >> n;
  bool invert = false;
  if (dest.first < start.first) {
    swap(start, dest);
  }
  if (dest.second < start.second) {
    invert = true;
    start.second *= -1;
    dest.second *= -1;
  }
  set<pair<int, int>> ps;
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    if (invert) {
      y *= -1;
    }
    if (start.first <= x && x <= dest.first && start.second <= y && y <= dest.second) {
      ps.emplace(x, y);
    }
  }

  P vec = make_pair(dest.first - start.first, dest.second - start.second);

  size_t l = ps.size();
  int dp[l];
  fill(dp, dp + l, INT_MAX);
  for_each(ps.begin(), ps.end(), [l, &dp](const auto &p) {
    *lower_bound(dp, dp + l, p.second) = p.second;
  });
  long k = lower_bound(dp, dp + l, INT_MAX) - dp;

  double ans = (double) 100 * (vec.first + vec.second) + (5 * M_PI - 20) * k;
  if (min(vec.first, vec.second) < k) {
    ans += 5 * M_PI;
  }

  cout << fixed << setprecision(19) << ans << endl;
}


Measured memory_bytes: 10368
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>

typedef long long int ll;
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) for(int i=0;i<signed(n);i++)
#define EREP(i, n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int, int> P;
struct edge {
    int to, cost;
};
#define VMAX 100000+10

ll N, H;
ll A[VMAX], B[VMAX];
ll ans;


int main() {
    std::ios_base::sync_with_stdio(false);
    cin >> N >> H;
    REP(i, N) {
        cin >> A[i] >> B[i];
    }
    std::sort(A, A + N);
    std::sort(B, B + N);
    REP(i, N) {
        H -= max(A[N - 1], B[N - 1 - i]);
        ans++;
        if (H <= 0) {
            cout << ans << endl;
            return 0;
        }
    }
    DEB(ans)
    ans += (H % A[N - 1] == 0 ? H / A[N - 1] : H / A[N - 1] + 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;

int main() {
  int N;
  double T, A;
  cin >> N;
  cin >> T >> A;
  vector<double> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  int ans = 1;
  double ans_t = T - H[0] * 0.006;

  for (int i = 0; i < N; i++) {
    double curr = T - H[i] * 0.006;
    if (abs(A - curr) < abs(A - ans_t)) {
      ans_t = curr;
      ans = i + 1;
    }
  }

  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++)
#define ll long long
int main(){
  int h,w;
  cin >> h >> w;
  char c[h][w];
  rep(i,h){
    rep(j,w){
      cin >> c[i][j];
    }
  }
  string ans="Yes";
  int x[4]={1,0,-1,0};
  int y[4]={0,1,0,-1};
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='#'){
        bool is=false;
        rep(k,4){
          int xx=x[k]+i;
          int yy=y[k]+j;
          if(xx>=h || xx<0 || yy>=w || yy<0){
            continue;
          }
          if(c[xx][yy]=='#'){
            is=true;
          }
        }
        if(!is){
          ans="No";
        }
      }
    }
  }
   cout << ans;
}
    
    
      

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

  vector<int>num(3);
  cin>>num[0]>>num[1]>>num[2];
  sort(num.begin(),num.end());
  int time=0;
  while(num[0]<=num[2]-2){
  
    num[0]+=2;
    time++;
  }
  while(num[1]<=num[2]-2){
  
    num[1]+=2;
    time++;
  }
  if(num[0]==num[1]){
  
    if(num[1]==num[2])time;
    else time++;
  }
  else{
  
    time+=2;
  }
  cout<<time;
  return 0;
}

Measured memory_bytes: 3620
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int n, x[110];
signed main() {
	cin >> n;
	rep(i, n)cin >> x[i];
	int ans = INF;
	REP(i,100){
		int cnt = 0;
		rep(j, n)cnt += (x[j] - i) * (x[j] - i);
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int N;
    std::cin >> N;
    int result;
    if (N >= 64) {
        result = 64;
    } else if (N >= 32) {
        result = 32;
    } else if (N >= 16) {
        result = 16;
    } else if (N >= 8) {
        result = 8;
    } else if (N >= 4) {
        result = 4;
    } else if (N >= 2) {
        result = 2;
    } else {
        result = 1;
    }
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		Card[] src = new Card[n];
		Card[] cards = new Card[n];
		
    	for (int i = 0; i < n; i++) {
    		src[i] = new Card(sc.next());
    		cards[i] = src[i];
    	}
    	
    	// Bubble Sort
    	for (int i = 0; i < n; i++) {
    		for (int j = n - 1; j > i; j--) {
    			if (cards[j].rank < cards[j - 1].rank) {
    				Card temp = cards[j];
    				cards[j] = cards[j - 1];
    				cards[j - 1] = temp;
    			}
    		}
    	}
//    	printData(src);
    	printData(cards);
    	if (checkStable(src, cards)) {
    		System.out.println("Stable");
    	} else {
    		System.out.println("Not stable");
    	}

    	for (int i = 0; i < n; i++) {
    		cards[i] = src[i];
    	}
//    	printData(src);
//    	printData(cards);

    	// SelectionSort
    	for (int i = 0; i < n; i++) {
    		int mini = i;
    		for (int j = i; j < n; j++) {
    			if (cards[j].rank < cards[mini].rank) {
    				mini = j;
    			}
    		}
    		if (mini != i) {
    			Card temp = cards[i];
    			cards[i] = cards[mini];
    			cards[mini] = temp;
    		}
    	}
//    	printData(src);
    	printData(cards);
    	if (checkStable(src, cards)) {
    		System.out.println("Stable");
    	} else {
    		System.out.println("Not stable");
    	}

    	sc.close();
	}
	
	private static boolean checkStable(Card[] src, Card[] result) {
		for (int i = 1; i < result.length; i++) {
			if (result[i - 1].rank == result[i].rank) {
				if (seekCard(src, result[i - 1].data) > seekCard(src, result[i].data)) {
					return false;
				}
			}
		}
		return true;
	}
	
	private static int seekCard(Card[] src, String key) {
		for (int i = 0; i < src.length; i++) {
			if (src[i].data.equals(key)) {
				return i;
			}
		}
		
		return -1;
	}

	private static void printData(Card[] data) {
		StringBuffer printData = new StringBuffer();
		for (int i = 0; i < data.length; i++) {
			printData.append(data[i].data);
			printData.append(" ");
		}
		printData.delete(printData.length() - 1, printData.length());
		System.out.println(printData);
	}
}

class Card {
	public String data;
	public int rank;
	public char suit;
	
	public Card(String str) {
		data = str;
		suit = str.charAt(0);
		rank = str.charAt(1) - '0';
	}
}

Measured memory_bytes: 17368
M,D = (int(i) for i in input().split()) 
cnt=0
d10=0
d1=0
for i in range(1,M+1):
    for j in range(1,D+1):
        d10=int(j/10)
        d1=j%10
        if d10>=2 and d1>=2 and i==d10*d1:
            cnt=cnt+1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int c=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
            c++;
    }
    cout<<c;
    return 0;
}



Measured memory_bytes: 3792
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
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; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long MOD = 1'000'000'007LL;
const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

//MAXを絶対check!!!!!!!

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	COMinit();
	ll n, k; cin >> n >> k;
	cout << COM(k, n) * fac[n] % MOD << endl;

	return 0;
}


Measured memory_bytes: 122644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
        int A,B,C;
      	A=sc.nextInt();
      	B=sc.nextInt();
      	C=sc.nextInt();
      	pl(A*B/2);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 21204
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a,b,c,d;
    cin >> a >> b >>  c >> d;
    if(a == 1 || a == 3 ||a == 5 || a == 7 || a == 8 || a == 10 || a ==12)
    {
        if (b == 31)
        {
           cout << 1;
           return 0;
        }
        else
        {
            cout << 0;
            return 0;
        }
    }
    if(a == 4 ||a == 6 || a == 9 || a == 11)
    {
        if (b == 30)
        {
           cout << 1;
           return 0;
        }
        else
        {
            cout << 0;
            return 0;
        }
    }
    if(a == 2)
    {
        if (b == 28)
        {
           cout << 1;
           return 0;
        }
        else
        {
            cout << 0;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush, heapify
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
  n = int(input())
  ans = 0
  for i in range(1,n+1):
    if i%3==0 or i%5==0:
      continue
    else:
      ans += i
  print(ans)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 37668
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int n;
#define Maxn 200010
int a[Maxn],b[Maxn];
struct Data{
	int id,val;
	bool operator <(const Data &z)const{return val<z.val;}
};
priority_queue<Data> Q;
int main(){
	scanf("%d",&n);
	for(register int i=0;i<n;++i)scanf("%d",&b[i]);
	for(register int i=0;i<n;++i){
	    scanf("%d",&a[i]);
	    if(a[i]<b[i]){
	    	puts("-1");
	    	return 0;
		} 
	}
	for(register int i=0;i<n;++i)
	if(a[i]!=b[i])Q.push((Data){i,a[i]});
	long long ans=0;
	while(!Q.empty()){
		int x=Q.top().id;
		Q.pop();
		int y1=(x-1+n)%n,y2=(x+1)%n;
	    int tmp=(a[x]-b[x])/(a[y1]+a[y2]);
	    ans+=tmp;
	    if(tmp==0&&a[x]!=b[x]){puts("-1");return 0;}
	    a[x]-=tmp*(a[y1]+a[y2]);
	    if(a[x]!=b[x])Q.push((Data){x,a[x]});
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3956
n,m = map(int,input().split())
p = []
s = []

ac = 0
wa = 0
yet =set()
count = {}
for i in range(m):
    tmp1,tmp2 = input().split()
    p.append(int(tmp1))
    s.append(tmp2)

for i in range(m):
    #初めてACを出した時、acにカウントを1足し、それまでにその問題で間違えた数をwaに足し、yetにACが出たことを記録
    if s[i] == "AC" and p[i] not in yet:
        ac +=1
        if p[i] in count.keys():
            wa +=count[p[i]]
        yet.add(p[i])
    elif s[i] == "WA" and p[i] not in yet:
        if p[i] in count.keys():
            count[p[i]] += 1
        else:
            count[p[i]] = 1
print(ac,wa)

Measured memory_bytes: 19520
def main():
    N, T = [int(x) for x in input().split()]
    price = [int(x) for x in input().split()]

    minprice = 1000000000;
    maxbenefit = 0
    dict = {}
    res = 0

    for i in range(len(price)):
        if (price[i] < minprice): minprice = price[i]
        if (maxbenefit < (price[i] - minprice)): maxbenefit = (price[i] - minprice)
        dict[price[i]] = i

    for i in range(len(price)):
        if price[i] + maxbenefit in dict:
            if (dict[price[i] + maxbenefit] > i): res += 1

    print(res)

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
  int A,B; cin>>A>>B;
  int num[5];
  int ans=0;
  for(int i=A;i<=B;i++){
    int temp=i;
    for(int j=0;j<5;j++){
      num[j]=temp%10;
      temp/=10;
    }
    bool check=true;
    for(int j=0;j<2;j++){
      if(num[j]!=num[4-j]){
        check=false; break;
      }
    }
    if(check){
      ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
w=[input() for i in range(n)]
check=True
for i in range(1,n):
  for j in range(i):
    if w[i]==w[j]:
      check=False
  if w[i-1][-1]!=w[i][0]:
    check=False
print("Yes" if check else "No")

Measured memory_bytes: 9176
using System;
using System.Linq;
namespace AtCoder_Begginer_Contest1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split();
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);           
            if(a > b)
            {
                b = a;
                ab[0] = ab[1];
            }
            string ans = ab[0];
            for (int i = 0; i < b-1; i++)
            {
                ans += ab[0];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a/b<<endl;
	cout<<a-(b*(a/b))<<endl;
	double c=((double)a)/b;
	cout<<fixed<<setprecision(10)<<c<<endl;
	return 0;
}

Measured memory_bytes: 1240
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main{
	static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
	
	static int findGCD(int a,int b,int c) 
    { 
        int result = a; 
        result = gcd(b,result);
        result = gcd(c,result);
        return result; 
    } 
	
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	int k = sc.nextInt();
        	int sum = 0;
        	for(int i=1;i<=k;i++) {
        		for(int j=1;j<=k;j++) {
        			for(int a=1;a<=k;a++) {
                		sum+=findGCD(i,j,a);
                	}
            	}
        	}
        	System.out.println(sum);
    }
}


Measured memory_bytes: 35764
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 1e18

const ll mod = 1000000000+7;
const int N = 450;

ll dp[N][N];
ll a[N];
ll pre[N];
int opt[N][N];

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,k;
	cin >> n;
	for(int i = 1; i<=n; i++)
	{
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}
	for(int i = 1; i<=n; i++)
	{
		opt[i][1] = i;
	}
	for(int i = 2 ; i<=n; i++)
	{
		for(int j = 1; j<=n-i+1; j++)
		{
			int optx = j;
			ll ans = INF;
			for(int k = opt[j][i-1]; k<=min(opt[j+1][i-1],i+j-2); k++)
			{
				ll tans = pre[j+i-1] - pre[j-1] + dp[j][k-j+1] + dp[k+1][j+i-k-1];
				if(tans<ans){
					ans = tans;
					optx = k;
				}
			}
			opt[j][i] = optx;
			dp[j][i] = ans;
		}
	}
	cout << dp[1][n] << endl;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

int S[1<<18];
bool made[1<<18];

int main(){
    int N;
    cin >> N;
    int m = 1<<N;
    for(int i = 0; i < m; i++){
        cin >> S[i];
    }
    sort(S, S+m);
    vector<int> v;
    v.push_back(S[m-1]);
    made[m-1] = true;
    for(int i = 0; i  < N; i++){
        int cur = 0;
        int s = v.size();
        
        for(int j = m-1; j >= 0; j--){
            if(!made[j]){
                if(v[cur] > S[j]){
                    v.push_back(S[j]);
                    made[j] = true;
                    cur++;
                }
                if(cur == s) break;
            }
            if(j == 0){
                cout << "No" << endl;
                return 0;
            }
        }
        sort(v.begin(), v.end(), greater<int>());
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 2676
#include<stdio.h>
#include<math.h>
int main()
{
	int n,d,i,s=0,j,k,c=0;

	scanf("%d%d",&n,&d);

	int x[n][d];

	for(i=0;i<n;i++)
		for(j=0;j<d;j++)
			scanf("%d",&x[i][j]);
	for(i=0;i<n-1;i++)
		for(j=i+1;j<n;j++){
			for(k=0;k<d;k++)
				s+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
			if(sqrt(s)==(int)sqrt(s))
				c++;
			s=0;
		}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128
s = input()[::-1]
num = 0
last = 0
d = 1
count={}
for k in range(2019):
    count[k] = 0
    
count[0] =1  # 割り切れるとき

for i in s:
    num = (int(i) * d + num)%2019
    
    d *= 10
    d %= 2019
    count[num] += 1
    
ans = 0
for j in range(2019):
    ans += count[j] * (count[j]-1) //2
print(ans)

Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int b[200001];
int c[200001];
int n;
int dp[200001][3][3][3];
 
int rec(int idx,int count1,int count2,int count3)
{
    if(dp[idx][count1][count2][count3]!=-1)
        return dp[idx][count1][count2][count3];
    if(idx==n) return 0;
    if(count1==1) return dp[idx][count1][count2][count3]=max((b[idx]+rec(idx+1,0,1,0)),(c[idx]+rec(idx+1,0,0,1)));
    if(count2==1) return dp[idx][count1][count2][count3]=max((c[idx]+rec(idx+1,0,0,1)),(a[idx]+rec(idx+1,1,0,0)));
    if(count3==1) return dp[idx][count1][count2][count3]=max((a[idx]+rec(idx+1,1,0,0)),(b[idx]+rec(idx+1,0,1,0)));
    return dp[idx][count1][count2][count3]=max((a[idx]+rec(idx+1,1,0,0)),max((b[idx]+rec(idx+1,0,1,0)),(c[idx]+rec(idx+1,0,0,1))));
 
}
 
 
int main()
{
    for(int i=0;i<200001;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                for(int y=0;y<3;y++)
                {
                 dp[i][j][k][y]=-1;
                }
            }
        }
    }
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i]>>c[i];
        
    }
    cout<<rec(0,0,0,0);
 
 
 
 
 
 
 
 
}

Measured memory_bytes: 30976
import numpy as np
N = int(input())
A1 = np.array([int(a) for a in input().split()])
A2 = np.array([int(a) for a in input().split()])

max_candy = 0
for i in range(N):
    candy = sum(A1[:(i+1)]) + sum(A2[i:])
    if candy > max_candy:
        max_candy = candy

print(max_candy)
        


Measured memory_bytes: 21644
#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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    string s;
    cin >> s;
    bool flag=false;
    int ans;
    REP(i,26){
        if(s.find(moji[i]) == -1){
            flag=true;
            ans=i;
            break;
        }
    }
    if(flag) cout << moji[ans];
    else cout << "None";
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> H(N,0);
  vector<ll> M(N,0);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  for(int i=1;i<N;i++){
    M[i]=M[i-1]+abs(H[i]-H[i-1]);
    for(int j=1;j<=min(K,i);j++){
      M[i]=min(M[i],M[i-j]+abs(H[i]-H[i-j]));
    }
  }
  cout << M[N-1] << endl;
}

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

using namespace std;

int main(void){
    long long X;
    cin>>X;
    long long result=100;
    long long year=0;
    while(result<X){
        result=result+result*0.01;
        year++;
    }
    cout<<year<<endl;
    return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = [None]*n
b = [None]*n
c = [None]*n
for i in range(n):
    a[i],b[i],c[i] = list(map(int,input().split(' ')))

dp = [[0]*n for i in range(3)]
dp[0][0], dp[1][0], dp[2][0] = a[0],b[0],c[0]
for i in range(1,n):

    for j in range(3):
        if j==0:
            dp[j][i] = max(dp[1][i-1]+a[i], dp[2][i-1]+a[i])
        elif j==1:
            dp[j][i] = max(dp[0][i-1]+b[i], dp[2][i-1]+b[i])
        elif j==2:
            dp[j][i] = max(dp[0][i-1]+c[i], dp[1][i-1]+c[i])
print(max(dp[0][-1], dp[1][-1], dp[2][-1]))

Measured memory_bytes: 32488
#include "bits/stdc++.h"
using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool dfs(vs& grid,int i,int j,int d,int rest,string& res)
{
	if(rest==1) return true;
	grid[i][j]='.';
	
	int h=grid.size(),w=grid[0].size();
	rep(k,4) if(k!=(d^1)){
		const int di[]={-1,1,0,0},dj[]={0,0,-1,1};
		for(int ni=i,nj=j;0<=ni && ni<h && 0<=nj && nj<w;ni+=di[k],nj+=dj[k])
			if(grid[ni][nj]=='o'){
				res.push_back("UDLR"[k]);
				if(dfs(grid,ni,nj,k,rest-1,res))
					return true;
				//res.pop_back();
				res.erase(res.size()-1);
				break;
			}
	}
	
	grid[i][j]='o';
	return false;
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];
		
		int cnt=0;
		rep(i,h) rep(j,w) cnt+=grid[i][j]!='.';
		rep(i,h) rep(j,w) if(isupper(grid[i][j])){
			int d=string("UDLR").find(grid[i][j]);
			grid[i][j]='o';
			string res;
			assert(dfs(grid,i,j,d,cnt,res));
			cout<<res<<endl;
		}
	}
}

Measured memory_bytes: 1216
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int d=n%10;
    if(d==2||d==4||d==5||d==7||d==9)
      System.out.println("hon");
    else if(d==0||d==1||d==6||d==8)
      System.out.println("pon");
    else
      System.out.println("bon");
    
    
  }
}

Measured memory_bytes: 27028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,sta,end) for(ll i=sta;i<end;i++)
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define vvl vector<vector<ll>>
#define vl  vector<ll>
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||

signed main(){
	acc_io;
	ll k,a,b;
	cin>>k>>a>>b;
	rep(i,a,b+1){
		if(i%k==0){ cout<<"OK"<<endl;return 0;}
	}
	cout<<"NG"<<endl;
	return 0;
}


Measured memory_bytes: 3648
A, B, C, D = map(int, list(input()))

def create_ops():
    """
    create operations.
    """
    pn = (-1, 1)
    ops = [(op_1, op_2, op_3) \
            for op_1 in pn \
            for op_2 in pn \
            for op_3 in pn]
    return ops

def sign(num):
    """
    get signed string of number.
    """
    return "+" + str(num) if num >= 0 else str(num)

def ans(a, b, c, d):
    """
    answer.
    """
    print("{0}{1}{2}{3}=7".format(a, sign(b), sign(c), sign(d)))

def main():
    """
    main.
    """
    a = A
    expected = 7 - a

    nums = (B, C, D)
    ops = create_ops()
    is_found = False

    for op in ops:
        els = [(n, pn) for n, pn in zip(nums, op)]
        els_map = map(lambda el: el[0] * el[1], els)
        els_list = list(els_map)
        total = sum(els_list)
        if total == expected:
            is_found = True
            break

    if is_found:
        b, c, d = els_list
        ans(a, b, c, d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int W, H, N, A, B;
    cin >> W >> H >> N;
    int x_min = 0, x_max = W, y_min = 0, y_max = H;
    vector<int> x(N), y(N), a(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i];
    }
    for(int i = 0; i < N; i++){
        if(a[i] == 1 && x_min < x[i]) x_min = x[i];
        if(a[i] == 2 && x_max > x[i]) x_max = x[i];
        if(a[i] == 3 && y_min < y[i]) y_min = y[i];
        if(a[i] == 4 && y_max > y[i]) y_max = y[i];
    }
    A = x_max - x_min;
    B = y_max - y_min;
    if(A < 0) A = 0;
    if(B < 0) B = 0;
    cout << A * B << endl;
}

Measured memory_bytes: 3628