akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
constexpr int MOD = 1000000007;
constexpr int MAX = 100010;
using ll = long long;
using namespace std;

ll inv(ll x) {
  ll res = 1;
  ll k = MOD - 2;
  ll y = x;
  while (k) {
    if (k & 1) res = (res * y) % MOD;
    y = (y * y) % MOD;
    k /= 2;
  }
  return res;
}

ll f[MAX];
ll h[MAX];
void init() {
  f[0] = 1;
  for (int i = 1; i < MAX; i++)
    f[i] = (f[i - 1] * i) % MOD;
  
  h[0] = 0;
  for (int i = 1; i < MAX; i++)
    h[i] = (h[i - 1] + inv(i)) % MOD;
}

int main() {
  init();
  int n;
  cin >> n;
  vector<ll> x(n);
  for (int i = 0; i < n; i++)
    cin >> x[i];
  
  vector<ll> d(n);
  d[0] = f[n - 1];
  for (int i = 1; i < n - 1; i++) {
    d[i] = f[n - 1] * h[i + 1];
    d[i] %= MOD;
  }
  
  ll total = 0;
  for (int i = 0; i < n - 1; i++) {
    total += d[i] * (x[i+1] - x[i]);
    total %= MOD;
  }
  
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++){
  	cin >> A[i];
  }
  sort(A,A+N);
  cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ int x,y;
  while(1){
  scanf("%d %d",&x,&y);
  if(x==0&&y==0)break;
  if(x<y){
  printf("%d %d\n",x,y);
} else {
  printf("%d %d\n",y,x);
}
}
return 0;
}


Measured memory_bytes: 1980
#include<stdio.h>

int main()
{
	long long n,m,l,i;
	long long c = 0;
	scanf("%lld", &n);
	for (i = 0; i < n; i++) {
		scanf("%lld %lld", &m, &l);
		c += l - m + 1;
	}
	printf("%lld", c);
    return 0;
}

Measured memory_bytes: 128
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
const int INF = 1001001001;
int main(){
  int n;cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());
  long long ans=0;
  for(int i=n-1;i>1;i--){  
    for(int left=0;left<i-1;left++){ 
      int right=left+1;
      while(l[left]+l[right]<=l.at(i)){
        right++;
      }
      if(l[left]+l[right]>l[i]){
        ans+=i-right;
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >>n;
    long max;
    long min;
    long sum;
    int x;
    for (int i =1; i<=n ; i++){
        cin >> x;
        if ( i == 1){
            min = x;
            max = x;
            sum = x;
        }else{
            if(min > x){
                min = x;
            }if(max < x){
                max = x;
            }
            sum = sum + x;
        }
    }cout << min << " " << max << " " << sum <<endl;
    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

//a_l + a_l+1 + ... + a_r <= x ???????????? (l, r) ????????° 
int number_of_windows(const vector<int> &a, int x) {
	int n = a.size(), l = 0, r = 0;
	int num = 0;
	int sum = 0;
	while (l < n) {
		if (r == n || sum + a[r] > x) {
			if (l == r) {
				l++, r++;
			}
			else {
				num += r - l;
				sum -= a[l];
				l++;
			}
		}
		else {
			sum += a[r];
			r++;
		}
	}
	return num;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
	rep(i, 0, Q) {
		int x; cin >> x;
		dump(x);
		cout << number_of_windows(a, x) << endl;
	}
	return 0;
}

Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	string a, b, c;
	cin >> a >> b >> c;
	
	if(a.back() == b[0] && b.back() == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<long long> x(n), y(n);
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	long long ans = LLONG_MAX;
	for (int xt = 0; xt < n; xt++)
		for (int xu = 0; xu < n; xu++)
			for (int yl = 0; yl < n; yl++)
				for (int yr = 0; yr < n; yr++)
				{
					int cnt = 0;
					for (int i = 0; i < n; i++)
						if (x[xu] <= x[i] && x[i] <= x[xt] && y[yl] <= y[i] && y[i] <= y[yr])
							cnt++;
					if (k <= cnt)
						ans = min(ans, abs(x[xt] - x[xu]) * abs(y[yr] - y[yl]));
				}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

int a[20], b[20];
pair<int, bool> p[20];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, n)
		cin >> b[i];
	int ans = INF;
	FOR(mask, 0, 1 << n)
	{
		FOR(i, 0, n)
		{
			bool is = (mask >> i) & 1;
			p[i] = MP(is ? b[i] : a[i], (i + is) & 1);
		}
		int cur = 0;
		FOR(i, 0, n)
		{
			int mn = INF;
			int idx = -1;
			FOR(j, i, n)
			{
				mn = min(mn, p[j].first);
				if(p[j].second == (i & 1) && (idx == -1 || p[j].first < p[idx].first))
					idx = j;
			}
			if(idx == -1 || p[idx].first != mn)
			{
				cur = INF;
				break;
			}
			RFOR(j, idx, i)
				swap(p[j], p[j + 1]);
			cur += idx - i;
		}
		ans = min(ans, cur);
	}
	cout << (ans == INF ? -1 : ans) << "\n";
	return 0;
}


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

void solver() {
  long long n;
  cin >> n;

  vector<long long> as(n);
  for (int i = 1; i < n; i++) {
    long long a;
    cin >> a;
    as[a-1]++;
  }

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

int main() {
  solver();
  return 0;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,ans,lenth;
int tree[N],tot[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>tree[i];
		lenth=max(lenth,tree[i]);
		tot[tree[i]]++;
	}
	if(lenth%2==1)
	{
		if(tot[lenth/2+1]!=2)
		{
			cout<<"Impossible";
			return 0;
		}
		for(int i=1;i<lenth/2+1;i++)
		{
			if(tot[i])
			{cout<<"Impossible";
			return 0;
			}
		}
		for(int i=lenth;i>lenth/2+1;i--)
		{
			if(tot[i]<2)
			{
				cout<<"Impossible";
				return 0;
			}
		}
		cout<<"Possible";
		return 0;
	}
	else
	{
		if(tot[lenth/2]!=1)
		{
			cout<<"Impossible";
			return 0;
		}
		for(int i=1;i<lenth/2;i++)
		{
			if(tot[i])
			{
				cout<<"Impossible";
				return 0;
			}
		}
		for(int i=lenth;i>lenth/2;i--)
		{
			if(tot[i]<2)
			{
				cout<<"Impossible";
				return 0;
			}
		}
		cout<<"Possible";
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define inrep(t) int t;cin>>t; while(t--)
#define pb push_back
#define mp make_pair 
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi; 
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const int up= int(1e5)+5; 
vpii adj[up];
bool visited[up];   
int n,m;
int root; 
bool pos=1; 
vll x(up,-INFL); 
void dfs(int u, int p){
	//cerr<<u<<" "<<p<<endl; 
	if(pos==0) return; 
	visited[u]=1;
	reu(i,0,adj[u].size()){
		int v=adj[u][i].first; 
		ll d=adj[u][i].second; 
		if(v==p) continue; 
		
		if(x[v]==-INFL) { x[v]=x[u]+d; }
		else if((x[v]-x[u])!=d){
			pos=0; return; 
		}
		if(!visited[v]){
		dfs(v,u); 
		}
	} 

}
int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL); 
	cin>>n>>m; 
	reu(i,0,m){
		int u,v,d; cin>>u>>v>>d; 
		adj[u].pb(mp(v,d));
		adj[v].pb(mp(u,-d));  
	}
	reu(i,1,n+1) {
		if(!visited[i]){
			x[i]=0; 
			dfs(i,0); 
		}
		if(!pos) break; 
	}
	if(pos) cout<<"Yes"; 
	else cout<<"No"; 

}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	map<int,bool> used;
	for(int i=0; i<110; i++){
		used[i]=false;
	}
	vector<int> d(n);
	int cnt=0;
	for(int i=0; i<n; i++)cin>>d[i];
	for(int i=0; i<n; i++){
		if(!used[d[i]]){
			used[d[i]]=true;
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  vector<vii> dp(n + 1, vii(n + 1, vi(k + 1, -inf)));
  rep (i, n + 1) {
    dp[i][i][0] = 0;
    if (i != n) {
      dp[i][i + 1][0] = 1;
    }
  }
  rep (len, n) {
    rep (l, n) {
      int r = l + len;
      if (r > n) break;
      rep (i, k + 1) {
        if (r != n) {
          chmax(dp[l][r + 1][i], dp[l][r][i]);
        }
        if (l != 0) {
          chmax(dp[l - 1][r][i], dp[l][r][i]);
        }
        if (l != 0 && r != n) {
          if (s[l - 1] == s[r]) {
            chmax(dp[l - 1][r + 1][i], dp[l][r][i] + 2);
          }
          else {
            if (i != k) {
              chmax(dp[l - 1][r + 1][i + 1], dp[l][r][i] + 2);
            }
          }
        }
      }
    }
  }
  int ans = -inf;
  rep (i, n + 1) {
    rep (j, n + 1) {
      rep (l, k + 1) {
        chmax(ans, dp[i][j][l]);
      }
    }
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 110336
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

K, n = na()
a = na()

md = 0
for i in range(n-1):
    md = max(md, a[i+1] - a[i])
md = max(md, a[0] + K - a[-1])
print(K - md)


Measured memory_bytes: 73164
// 0000000000D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000I0000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000M0000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A0000000000000
#include <bits/stdc++.h>
#define ld long double
#define mod 1000000007
#define ll_inf 1000000000000000000
#define int_inf 1000000000
#define pb push_back
#define ll long long int
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define fi first
#define se second
#define prout(x) cout.precision(x)
using namespace std;
ll a[200010];
ll sm;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sm+=a[i];
    }
    ll dif=1e18, tmp=0;
    for(int i=0;i<n-1;i++){
        tmp+=a[i];
        ll z=sm-tmp;
        dif=min(dif, abs(z-tmp));
    }
    cout<<dif<<endl;
}
// 0000000000D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000I0000000000000000000000000000000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000M0000000000000000000000000000000000000000000
// 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A0000000000000


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define fi first
#define se second 
#define in insert
#define er erase
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int mx=1e5+10;
int a[mx];
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;cin>>n;
	string s;cin>>s;
	for(int i=0;i<4;i++){
		a[0]=i/2,a[1]=i%2;
		for(int j=2;j<n;j++){
			int t=(s[j-1]=='x');
			a[j]=a[j-1]^t^a[j-2];
		}
//		for(int j=0;j<n;j++) cout<<a[j]<<" ";
//		cout<<endl;
		int t0=(s[0]=='x'),tn=(s[n-1]=='x');
		if((a[1]^t0^a[0])==a[n-1] && (a[n-1]^a[n-2]^tn)==a[0]){
			for(int i=0;i<n;i++) cout<<(a[i]?'W':'S');
			return 0;
		}
	}
	cout<<-1;
}


Measured memory_bytes: 976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder answer = new StringBuilder();
		int n = sc.nextInt();
		int i = 1;

		if (n >= 3 && n <= 10000) {
			while (i <= n) {
				if (i % 3 == 0) {
					answer.append(" ").append(String.valueOf(i));
				} else {
					int x;
					x = i;
					while (x != 0) {
						if (x % 10 == 3) {
							answer.append(" ").append(String.valueOf(i));
							break;
						}
						x = x / 10;
					}
				}

				i++;
			}
		}
		System.out.println(answer.toString());

	}

}

Measured memory_bytes: 27960
import kotlin.math.pow

fun main(){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    val array = List(n+1){ i -> i.toLong() }
    val sumList = mutableListOf<Long>()
    sumList.add(array[0])
    for (i in 1..n){
        sumList.add(sumList[i-1] + array[i])
    }
    val arrayR = array.asReversed()
    val sumListR = mutableListOf<Long>()
    sumListR.add(arrayR[0])
    for (i in 1..n){
        sumListR.add(sumListR[i-1] + arrayR[i])
    }

    var ans = 1L
    for(i in k until  n+1){
        val min = sumList[i-1]
        val max = sumListR[i-1]
        ans += (max - min + 1) % (10.toDouble().pow(9).toLong() + 7)
    }
    println(ans % (10.toDouble().pow(9).toLong() + 7))
}

Measured memory_bytes: 65116
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

c = input()
o = ord(c)
print(chr(o + 1))


Measured memory_bytes: 74776
#include<iostream>
using namespace std;
int n,s,o;
void rec(int d,int k,int x){
  if(d>n) return;
  else if(d==n){
    if(x==s) o++;
  }else{
    for(int i=k+1;i<=9;i++){
      rec(d+1,i,x+i);
    }
  }
}
int main(){
  cin >> n >> s;
  while(n!=0){
    o=0;
    rec(0,-1,0);
    cout << o << endl;cin >> n >> s;
  }
}


Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int n, t;
	cin >> n >> t;
	
	int ans = 9999999;

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b <= t)ans = min(ans, a);

	}
	if (ans == 9999999)cout << "TLE" << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import combinations

N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 10 ** 12

for n in combinations(range(N), K):
    m = A[0]
    c = 0
    for i in range(1, N):
        if i in n:
            c += max(m + 1 - A[i], 0)
            m = max(m+1, A[i])
        else:
            m = max(m, A[i])
    ans = min(ans, c)

print(ans)

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

int main(){
    string S;
    cin >> S;
    string ans = "Yes";
    for(int i = 0; i < S.size(); i += 2){
        if(S[i] != 'h' or S[i+1] != 'i')ans = "No";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import permutations
from collections import Counter
def inpl(): return list(map(int, input().split()))
N, C = inpl()

D = [inpl() for _ in range(C)]

G = [Counter() for _ in range(3)]
for i in range(1, N+1):
    for j, c in enumerate(inpl(), start=1):
        G[(i+j)%3][c-1] += 1

ans = 10**9
for p, q, r in permutations(range(C), 3):
    tmp = 0
    for c in range(C):
        tmp += (D[c][p] * G[0][c]
              + D[c][q] * G[1][c]
              + D[c][r] * G[2][c])
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();

		int s = S%60;
		int m = (S/60)%60;
		int h = (S/60)/60;

		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26188
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b;
	while(~getII(a,b)){
		if((a+b)%2==0) printf("%d\n",(a+b)/2);
		else puts("IMPOSSIBLE");
	}
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int a, b, c;
	std::string res;
    std::cin >> a >> b >> c;
	if( (a*b==25 && c == 7) || (a*c==25 && b == 7)|| (b*c==25 && a == 7) ) {
      res = "YES";
    } else {
      res = "NO";
    }
    std::cout << res << std::endl;
}

Measured memory_bytes: 3572
a=list(input());b=list(input())
aa=[];bb=[]
for c in [chr(ord('a')+k)for k in range(26)]:
	aa.append([i for i,j in enumerate(a) if j==c])
	bb.append([i for i,j in enumerate(b) if j==c])
if sorted(aa)==sorted(bb):
	print("Yes")
else:print("No")

Measured memory_bytes: 22480
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	static ll v[100000];
	int main()
	{
		ll N,K,Q,A;
		cin>>N>>K>>Q;
		for(int i=1;i<=Q;i++){
			cin>>A;
			v[A]++;
		}
		for(int i=1;i<=N;i++) printf("%s\n",(K+v[i]-Q	>0)?"Yes":"No");
		
	}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string>

using namespace std;
 
int main()
{
    long a, b, c, k;
    cin >>a >> b >> c >>k;
    if(k%2==0){
        cout << a-b;
    }else{
        cout << b-a;
    }
    return 0;
}

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

int main(void){
    int r,d,x[10];
    cin >> r >> d >> x[0];

    for(int i=0; i < 10; i++){
        x[i+1] = r * x[i] - d;
    }

    for(int i=1; i < 11; i++) printf("%d\n",x[i]);//cout << x[i] << endl;        

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int b, d = 100, s = 0, t;
    cin >> b;
    for(int i = 0; i < b; i++)
    {
        cin >> t;
        if(d < t)
        {
            d = t;
        }
        s = s + t;
    }
    cout << s - d + d / 2;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;

public class Dish
{
    public int A;
    public int B;

    public Dish(int a, int b)
    {
        A = a;
        B = b;
    }
}

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var dishs = new Dish[n];
        for (int i = 0; i < n; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            dishs[i] = new Dish(vals[0], vals[1]);
        }
        dishs = dishs.OrderByDescending(d => d.A + d.B).ToArray();

        long diff = 0;
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0)
            {
                diff += dishs[i].A;
            }
            else
            {
                diff -= dishs[i].B;
            }
        }

        Console.WriteLine(diff);
    }
}

Measured memory_bytes: 26672
# coding: utf-8


II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    A, B = MI()
    c = [0, 0, 0]
    for p in MI():
        if p <= A: c[0] += 1
        elif p <= B: c[1] += 1
        else: c[2] += 1
    return min(c)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  cin >> s;
  rep(i,s.size()) {
    if(i%2==0) cout << s[i]; 
  }
  ln;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
    int N,A;
    
cin >> N;
    cin >> A;
    
    cout << (N*N) - A << endl;

    return 0;

}

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

string S;

int main() {
    cin >> S;

    string ans = "Good";
    for (int i = 0; i < S.size() - 1; i++) {
        // printf("%c %c\n", S[i], S[i + 1]);
        if (S[i] == S[i + 1]) {
            ans = "Bad";
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    string s,t; cin >> s >> t;
    vector<int> ok[50];
    rep(i,s.size()){
        int idx=s[i]-'a';
        ok[idx].pb(i);
    }
    int n=t.size();
    vector<int> v(n);
    rep(i,t.size()){
        int idx=t[i]-'a';
        if(ok[idx].size()==0){
            cout << -1 << endl;
            return 0;
        }
        if(i==0){
            v[i]=ok[idx][0];
        }else{
            int pl=v[i-1];
            int p=upper_bound(ALL(ok[idx]),pl)-ok[idx].begin();
            if(p==ok[idx].size()) v[i]=ok[idx][0];
            else v[i]=ok[idx][p];
        }
    }
    ll cnt=0;
    rep(i,n-1){
        if(v[i]>=v[i+1]) cnt++;
    }
    cout << (ll)(cnt*s.size())+(ll)v[n-1]+1LL << endl;
    
}


Measured memory_bytes: 1468
#include<iostream>
#include<vector>
#include<cmath>
#include<climits>
#include<algorithm>
#include<string>
#include<math.h>

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

	long long left= n;
	long long right= 1;

	long long sqN= sqrtl(n);

	for(int i=2; i<= sqN; i++){
		if(n % i == 0){
			left = i;
			right = n/i;
		}
	}

	std::cout<<(left-1) + (right-1)<<std::endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  // ll sum=0;
  ll n;cin>>n;
  bool flag=false;
  REP(i,n){
    ll a;cin>>a;
    if(a%2==1)flag=true;
  }
  if(flag){
    P("first");
  }else{
    P("second");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string S;


bool jdg(string s){
    int n = SZ(s);
    rep(i, 0, n/2) if(s[i] != s[n-i-1]) return false;
    return true;
}


signed main(){
    cin >> S;

    int n = SZ(S);
    string a = string(begin(S), begin(S)+(n-1)/2);
    string b = string(begin(S)+(n+3)/2-1, end(S));

    if(jdg(S) and jdg(a) and jdg(b)) Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;

    string S;
    cin >> S;

    ll cnt = 0;
    string bef="";
    rep(ni,N){
        stmp = S.substr(ni,1);
        if(bef!=stmp){
            bef = stmp;
            cnt++;
        }
    }
    cout << cnt << endl;

    

}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  str s;
  cin>>s;
  bool a=true;
  if(s[0]==s[1])a=false;
  if(s[1]==s[2])a=false;
  if(s[2]==s[3])a=false;
  out(a?"Good":"Bad");
  
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	string s;
	map<char,int> num;
	cin >> s;
	for (auto i : s) {
		if (num[i]) {
			cout << "no\n";
			return 0;
		}
		num[i]++;
	}
	cout << "yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    ll ans=0;
    rep(i,n-1){
        ans+=a[i]/2;
        a[i]-=(a[i]/2)*2;
        if(a[i]){
            if(a[i+1]){
                ans++;
                a[i+1]--;
            }
        }
    }
    if(a[n-1])ans+=a[n-1]/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
int lcm(int a,int b){//最小公倍数
  return (a*b)/gcd(a,b);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);    
    int a,b,c=0,d;
    int q[1000000];
    cin>>a>>b;
    for(int i=0;i<a;i++){
      cin>>q[i];
    }
    sort(q,q+a,greater<int>());
    for(int i=0;i<a;i++){
      if(i>=b) c+=q[i];
    }
    cout<<c<<"\n"; 
}


Measured memory_bytes: 3072
<?php
/*
    Problem URL : http://abc044.contest.atcoder.jp/tasks/abc044_a
    (12:12:00-)
    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $N, $T);
$A = explode(" ", trim(fgets(STDIN)));

$TTB = array();
$TTS = array();
$memo = array();
$maxProfit = 0;

$TTS[0] = 0;
// $TTB[$N-1] = PHP_INT_MAX;
$TTB[0] = $A[0];

$TTS[$N] = 0;

// for ($i = 1; $i < $N; $i++) {
//  $TTS[$i] = max($TTS[$i-1], $A[$i]);
//  // $TTB[$N-1-$i] = min($TTB[$N-$i], $A[$N-1-$i]);
//  $TTB[$i] = min($TTB[$i-1], $A[$i]);
// }

for ($i = $N-1; $i >= 0; $i--) {
    $TTS[$i] = max($TTS[$i+1], $A[$i]);
//  $TTS[$i] = max($TTS[$i-1], $A[$i]);
//  // $TTB[$N-1-$i] = min($TTB[$N-$i], $A[$N-1-$i]);
//  $TTB[$i] = min($TTB[$i-1], $A[$i]);
}

// var_dump($TTS);
// ksort($TTS);
// echo implode(" ", $TTS) . PHP_EOL;

for ($i = 0; $i < $N; $i++) {
    // echo $TTS[$i] - $A[$i] . PHP_EOL;
    $profit = $TTS[$i] - $A[$i];
    $memo[$profit][] = "1";
    $maxProfit = max($maxProfit, $profit);
}

echo count($memo[$maxProfit]) . PHP_EOL;


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[1005][1005];
int main() {
    //cout.precision(10);
    int h, w;
    cin >> h >> w;
    string field[1005];
    for(int i = 1; i <= h; i++){
        cin >> field[i];
        field[i] = "#" + field[i];
    }
    dp[1][1] = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(i == 1 && j == 1) continue;
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] = dp[i][j] % mod;
            if(field[i][j] == '#') dp[i][j] = 0;
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}


Measured memory_bytes: 9088
# coding: utf-8
# import sys
# input = sys.stdin.readline

def dp_happiness(N):
    yesterday_a, yesterday_b, yesterday_c = 0, 0, 0
    for _ in range(N):
        a, b, c = map(int, input().split())

        today_a = a + max(yesterday_b, yesterday_c)
        today_b = b + max(yesterday_c, yesterday_a)
        today_c = c + max(yesterday_a, yesterday_b)

        yesterday_a = today_a
        yesterday_b = today_b
        yesterday_c = today_c
    return max(today_a, today_b, today_c)

N = int(input())
print(dp_happiness(N))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=55;
int n,k;
ll s[nax],jew[nax];;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>k;
		rep(i,0,n) cin>>s[i];
		ll m=0;
		rep(i,0,min(n,k)+1) {
			rep(j,0,min(n,k)-i+1) {
				ll t=0;
				int ind=0;
				rep(l,0,i) {
					jew[ind]=s[l];
					t+=jew[ind];
					ind++;
//					cout<<jew[ind-1]<<' ';
				}
				rep(l,n-j,n) {
					jew[ind]=s[l];
					t+=jew[ind];
					ind++;
//					cout<<jew[ind-1]<<' ';
				}
//				cout<<'\n';
				sort(jew,jew+ind);
//				rep(l,0,ind) cout<<jew[l]<<' ';
//				cout<<'\n';
//				auto it=lower_bound(jew,jew+ind,0);
				for(int l=0;l<(k-i-j)&&l<ind;l++) {
					if(jew[l]>=0) break;
					t-=jew[l];
				}
				m=max(m,t);
//				cout<<t<<'\n';
			}
		}
		cout<<m;
		return 0;
}

Measured memory_bytes: 256
while True:
    l = input().split()
    H = int(l[0])
    W = int(l[1])

    if 0 == H == W:
        break

    f_and_l_str = ''
    mid_str = ''
    for i in range(W):
        f_and_l_str += '#'
        if i == 0 or i == (W - 1):
            mid_str += '#'
        else :
            mid_str += '.'
    
    for i in range(H):
        if i == 0 or i == (H - 1):
            print(f_and_l_str)
        else :
            print(mid_str)

    print()


Measured memory_bytes: 5608
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    int sum = a+b, sub = a-b, mul = a*b;
    int m = max(sum, sub);
    cout << max(m, mul); 
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;

signed main() {
	cin >> s;
	
	int hoge = 0;
	for (int i = 0; i < s.length(); i++) {
		hoge += s[i] - '0';
		hoge %= 9;
	}
	if (hoge % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
using LL=long long;

const int INF = 1'000'000'000;
const long long INFLL = 1'000'000'000'000'000'000;

using Weight=int;
struct Edge {
	int to; Weight cost;
	Edge(int _to, Weight _cost) :to(_to), cost(_cost) {}
};
bool operator>(const Edge& e1, const Edge& e2) { return e1.cost > e2.cost; }
struct Edge2 { int u, v; Weight cost; };
using Graph=vector<vector<Edge>>;


vector<int> TopologicalSort(const Graph& graph) {
	int V = graph.size();
	vector<bool> visited(V);
	vector<int> ret;
	function<void(int)> dfs = [&](int u) {
		if (visited[u])return;
		visited[u] = true;
		for (auto& i : graph[u])dfs(i.to);
		ret.push_back(u);
	};
	for (int i = 0; i < V; i++)dfs(i);
	reverse(ret.begin(), ret.end());
	return ret;
}


int main() {
	int v, e; cin >> v >> e;
	Graph g(v);
	for (int i = 0; i < e; i++) {
		int s, t; cin >> s >> t;
		g[s].emplace_back(t, 1);
	}
	for (auto aa : TopologicalSort(g))
		cout << aa << endl;
}


Measured memory_bytes: 3916
solve :: [Int] -> Int -> Int 
solve [] m = 0
solve (x:xs) m
    | x <= m = 1 + solve xs (min m x)
    | otherwise =  solve xs (min m x)
    
main = do
    n <- readLn :: IO Int
    xs <- map read . words <$> getLine :: IO [Int]
    print $ solve xs (head xs)

Measured memory_bytes: 57852
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b,min,flag=0;
  cin>>n;  
  for(int i=1;i<9999999;i++){
    if(n%i==0){
      if(min>i+(n/i) || flag==0){
	min=i+(n/i);
	flag=1;
      }
    }
  }
  cout<<min-2<<'\n';
  return(0);
}


Measured memory_bytes: 384
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int c = 0;
            for (int j = 1; j <= i; j += 2) {
                if (i % j == 0)
                    c++;
            }
            if (c == 8)
                ans++;
        }
        System.out.println(ans);
    }
}

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

typedef long long ll;
const int N=1010;
int n,k;
ll a[N],ans;
ll pre[N];
vector<ll>v,v1;

int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",a+i);
	for(int i=1;i<=n;i++){
		ans=0;
		for(int j=i;j<=n;j++){
			ans+=a[j];
			v.push_back(ans);
		}
	}
//	for(int i=0;i<v.size();i++) printf("%d ",v[i]);
//	puts("");
	ans=0;
	for(int i=60;i>=0;i--){
		for(int j=0;j<v.size();j++)
			if(v[j]>>i&1) v1.push_back(v[j]);
		if(v1.size()>=k){
			v=v1;
			ans+=1LL<<i;
		}
		v1.clear();
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 19196
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10, mod = 998244353;

ll ctr[10];

int main() {
	fast_cin();
	int n; string s;
	cin >> n >> s;
	map<char, int> mp = {{'R', 0}, {'G', 1}, {'B', 2}};
	for (auto &i : s) {
		i = mp[i];
	}
	ll ans = 1;
	for (int i = 0; i < 3 * n; ++i) {
		int o1 = (s[i] + 1) % 3;
		int o2 = (s[i] + 2) % 3;
		if (ctr[o1] and ctr[o2]) {
			ans *= min(ctr[o1], ctr[o2]);
			ans %= mod;
			--ctr[s[i]];
			--ctr[o1];
			--ctr[o2];
		} else if (ctr[o1] > ctr[s[i]]) {
			ans *= (ctr[o1] - ctr[s[i]]);
			ans %= mod;
		} else if (ctr[o2] > ctr[s[i]]) {
			ans *= (ctr[o2] - ctr[s[i]]);
			ans %= mod;
		}
		++ctr[s[i]];
	}
	for (int i = 1; i <= n; ++i) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 720
n=int(input())
t=[0]*n
for i in range(n):
    t[i] =input()[0]
t2=[t.count(i) for i in ["M","A","R","C","H"]]
ans=0
for i in range(5):
    for j in range(5):
        if j==i:break
        for k in range(5):
            if k==j:break
            ans += t2[i]*t2[j]*t2[k]
print(ans)

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

int main()
{
    int N, M;
    cin>>N>>M;
    vector<vector<int>> E(N);
    for (int i=0; i<M; i++)
    {
        int s, t;
        cin>>s>>t;
        E[s-1].push_back(t-1);
    }

    vector<double> T(N);
    T[N-1] = 0;
    for (int i=N-2; i>=0; i--)
    {
        for (int e: E[i])
            T[i] += T[e]+1;
        T[i] /= E[i].size();
    }

    vector<double> P(N);
    P[0] = 1.0;
    for (int i=0; i<N; i++)
        for (int e: E[i])
            P[e] += P[i]/E[i].size();

    double ans = T[0];
    for (int i=0; i<N; i++)
        if (E[i].size()>1)
        {
            double s = 0;
            double m = 0;
            for (int e: E[i])
            {
                s += T[e]+1;
                m = max(m, T[e]+1);
            }
            double t = T[i] - (s-m)/(E[i].size()-1);
            ans = min(ans, T[0]-t*P[i]);
        }

    printf("%.10f\n", ans);
}


Measured memory_bytes: 1408