akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	string S;  cin >> S;
	int N = S.size();
	
	int ans=0;
	FOR(i, 0, N-1) {
		if (S[i] != S[i+1]) ans++;
	}

	cout << ans << endl;
	return 0;
}


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

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

  int mx = max(a,c);
  int mn = min(b,d);

  cout << max(0, mn - mx) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

int main() {
  // vector<int> X(5);
  // int x1, x2, x3, x4, x5;
  int N, K;
  cin >> N >> K;

  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    P[i] = p;
  }

  sort(P.begin(), P.end());

  int result = 0;
  for (int i = 0; i < K; i++) {
    result += P[i];
  }

  cout << result << endl;

  return 0;
}


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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int h,w; cin >> h >> w;
    int c[10][10];
    int a[h][w];
    rep(i,10){rep(j,10){cin >> c[i][j];}}
    rep(i,h){rep(j,w){cin >> a[i][j];}}

    int ans=0;
    rep(k,10){rep(i,10){rep(j,10){chmin(c[i][j],c[i][k]+c[k][j]);}}}
    rep(i,h){
        rep(j,w){
            if(a[i][j]>=0){
                ans+=c[a[i][j]][1];
            }
        }
    }
    COUT(ans);
    
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define N 200100
struct edge {
    int to, rev, f, cap;
};
vector <edge> g[N];
int nodes = N, src, dst;
int d[N], Q[N], nowi[N];
void add(int s, int t, int cap) {
    edge a = {t, g[t].size(), 0, cap};
    edge b = {s, g[s].size(), 0, 0};
    g[s].push_back(a);
    g[t].push_back(b);
}
bool bfs() {
    fill(d, d + nodes, -1);
    d[src] = 0;
    int qt = 0;
    Q[qt ++] = src;
    for (int qh = 0; qh < qt; qh ++) {
        int u = Q[qh];
        for (auto &e : g[u]) {
            int v = e.to;
            if (d[v] < 0 && e.f < e.cap) {
                d[v] = d[u] + 1;
                Q[qt ++] = v;
            }
        }
    }
    return d[dst] >= 0;
}
int dfs(int u, int f) {
    if (u == dst) return f;
    int ret = 0;
    for (int &i = nowi[u]; i < (int)g[u].size(); i ++) {
        edge &e = g[u][i];
        if (e.cap <= e.f) continue;
        int v = e.to;
        if (d[v] == d[u] + 1) {
            int df = dfs(v, min(f, (int)(e.cap - e.f)));
            if (df > 0) {
                e.f += df;
                g[v][e.rev].f -= df;
                ret += df;
                f -= df;
                if (f == 0ll) return ret;
            }
        }
    }
    return ret;
}
const int inf = 1e9;
int maxf(int _src, int _dst) {
    src = _src, dst = _dst;
    int rtn = 0;
    while (bfs()) {
        fill(nowi, nowi + nodes, 0);
        rtn += dfs(src, inf);
    }
    return rtn;
}
int n, p[N], q[N];
int a[N], b[N], x, y;

bool vis[N];

void conv(int *p, int *a, int &x) {
    x = 0;
    for (int i = 0; i < n; i ++) vis[i] = 0;
    for (int i = 0; i < n; i ++) if (!vis[i]) {
        vis[i] = 1; x ++; a[i] = x;
        for (int j = p[i]; j != i; j = p[j]) a[j] = x, vis[j] = 1;
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i ++) scanf("%d", &p[i]);
    for (int i = 0; i < n; i ++) scanf("%d", &q[i]);
    conv(p, a, x), conv(q, b, y);
    int ans = n;
    for (int i = 0; i < n; i ++) {
        if (p[i] == i && q[i] == i) ans --;
        else if (p[i] == i) {
            add(0, x + b[i], 1);
        }
        else if (q[i] == i) {
            add(a[i], x + y + 1, 1);
        }
        else {
            add(a[i], x + b[i], 1);
            if (p[i] == q[i]) add(x + b[i], a[i], 1);
        }
    }
    ans -= maxf(0, x + y + 1);
    printf("%d\n", ans);
}


Measured memory_bytes: 20608
#define rep(i, n) for (int i=0; i<(int)(n); ++i)

#include<bits/stdc++.h>
using namespace std;

int main(){
    int X;
    cin >> X;

    int a,b,c;

    a = X / 500;
    b = (X % 500) / 5;

    cout << a * 1000 + b * 5 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, x, y; cin >> n >> x >> y;
    x--, y--;
    if (x > y) swap(x, y);

    vll ans(n);
    V< V<int> > used(n, V<int>(n, -1));
    for (ll k = 1; k < n; k++) {
        int tmp = 0;
        for (ll left = 0; left < n - k; left++) {
            if (left + k <= x) {
                if (used[left][left + k] == -1) used[left][left + k] = k;
            } else if (left >= y) {
                if (used[left][left + k] == -1) used[left][left + k] = k;
            } else if (left < x) {
                ll diffx = x - left;
                if (k - diffx > 0 && left < y - (k - diffx - 1) && used[left][y - (k - diffx - 1)] == -1) used[left][y - (k - diffx - 1)] = k;
                if (k - diffx > 0 && y + (k - diffx - 1) < n && used[left][y + (k - diffx - 1)] == -1) used[left][y + (k - diffx - 1)] = k;
                if (used[left][left + k] == -1) used[left][left + k] = k;
            } else {
                ll diffx = left - x;
                if (k - diffx > 0 && left < y - (k - diffx - 1) && used[left][y - (k - diffx - 1)] == -1) used[left][y - (k - diffx - 1)] = k;
                if (k - diffx > 0 && y + (k - diffx - 1) < n && used[left][y + (k - diffx - 1)] == -1) used[left][y + (k - diffx - 1)] = k;
                if (used[left][left + k] == -1) used[left][left + k] = k;
            }
        }
    }

    // for (ll i = 0; i < n; i++) DEBUG_VLL(used[i])

    for (ll i = 0; i < n; i++) {
        for (ll j = i + 1; j < n; j++) {
            if (used[i][j] != -1) ans[used[i][j]]++;
        }
    }

    for (int i = 1; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 16000
#include<cstdio>
#include<algorithm>
using namespace std;
int tate[1005][1005];
int yoko[1005][1005];
int dp[1005][1005];
char c[1005][1005];
int main(){
  int n;
  while(scanf("%d",&n),n!=0){
    for(int i=1;i<=n;i++) scanf("%s",c[i]+1);
    
    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	tate[i][j] = 0;
	yoko[i][j] = 0;
	dp[i][j] = 0;
      }
    }
    
    int ans = 0;
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	if(c[i][j] == '.'){
	  tate[i][j] = tate[i-1][j]+1;
	  yoko[i][j] = yoko[i][j-1]+1;
	  dp[i][j] = min(tate[i][j],yoko[i][j]);
	  dp[i][j] = min(dp[i][j],dp[i-1][j-1]+1);
	  ans = max(ans,dp[i][j]);
	}
      }
    }
    printf("%d\n",ans);
  }
  return(0);
}



Measured memory_bytes: 15464
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	int b[n+1];
	int j=0;
	a[0]=0;
	b[0]=0;
	int f=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=0)
		{
			j=i;
			break;
		}
		else
		a[i]*=(-1);
		if(i==n)
		{
			j=n;
			f=1;
		}
	}
	
	b[1]=a[j];
	int s=2;
	for(int i=j+1;i<=n;i++)
	{
		cin>>b[s];
		s++;
	}
	s--;
	if(f==0)
	j--;
	long long t=9999999999;
	sort(a+1,a+1+j);
	for(int i=max(0,k-s);i<=min(k,j);i++)
	{
		int p=0;
		p+=a[i];
		p+=b[k-i];
		p+=min(a[i],b[k-i]);
		if(p<t)
		{
			t=p;
		}
		
	}
	cout<<t;
 } 

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

vector<int> cnt[26];

int main(){
	string s;
	cin >> s;
	int l=s.length();

	int ansl=-1, ansr=-1;
	for(int i=0; i+1<l; i++){
		if(s[i]==s[i+1]){
			ansl=i+1;
			ansr=i+2;
		}
	}
	for(int i=0; i+2<l; i++){
		if(s[i]==s[i+2]){
			ansl=i+1;
			ansr=i+3;
		}
	}
	cout << ansl << " " << ansr << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(3*n);
  ll f=0;
  ll s=0;
  PQ ss;
  PQR ff;
  rep(i,3*n){
    cin>>a[i];
    if(i<n){
      f+=a[i];
      ff.pu(a[i]);
    }
    if(i>2*n-1){
      s+=a[i];
      ss.pu(a[i]);
    }
  }
  vll fff(n+1);
  rep(i,n+1){
    fff[i]=f;
    ff.pu(a[i+n]);
    f+=a[i+n];
    f-=ff.top();
    ff.pop();
  }
  vll sss(n+1);
  rep(i,n+1){
    sss[n-i]=s;
    ss.pu(a[2*n-1-i]);
    s+=a[2*n-1-i];
    s-=ss.top();
    ss.pop();
  }
  ll ans=-INF;
  rep(i,n+1){
    ans=max(ans,fff[i]-sss[i]);
  }
  COUT(ans);
}

Measured memory_bytes: 5876
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String K = sc.nextLine();

		String[] k = K.split("");
		
		if(k[0].equals("7")) {
			System.out.println("Yes");
			return;
		}
		
		if(k[1].equals("7")) {
			System.out.println("Yes");
			return;
		}
		
		if(k[2].equals("7")) {
			System.out.println("Yes");
			return;
		}
		

		System.out.println("No");
		sc.close();

	}
}

Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, l = INT_MAX;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    
    for(int i = 0; i <= n - k;i++) {
        l = min(l, h[i + k - 1] - h[i]);
    }
    cout << l << endl;

    return 0;
}

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

int main() {
    ll N, X, M;
    cin >> N >> X >> M;
    vector<ll> A(2 * M + 20);
    set<ll> S;
    S.insert(X);
    A[0] = X;
    ll l = 0, r = 0;
    for (ll i = 1; ; i++) {
        A[i] = ((A[i - 1] % M) * (A[i - 1] % M)) % M;
        if (S.find(A[i]) != S.end()) {
            for (ll j = 0; ; j++) {
                if (A[i] == A[j]) {
                    l = j;
                    r = i;
                    break;
                }
            }
        }
        if (r != 0) break;
        S.insert(A[i]);
    }
    ll w = r - l;
    ll s = 0;
    for (ll i = l; i < r; i++) s += A[i];
    ll ans = 0;
    ll n = 0;
    for (ll i = 0; i < l && n < N; i++) {
        ans += A[i];
        n++;
    }
    ans += s * ((N - n) / w);
    n += w * ((N - n) / w);
    for (ll i = l; n < N; i++) {
        ans += A[i];
        n++;
    }
    cout << ans << endl;
    return 0;
}


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

long long a[62];
long long b[62];
long long c[62];
typedef __int128 ll;
const long long mod = 1e9 + 7;

template<class T>
inline void read(T &x){
    x=0;T flag=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') flag=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-48;c=getchar();}
    x*=flag;
}


void print(__int128 x)  
{  
    if(!x)  
    {  
        puts("0");  
        return ;  
    }  
    string ret="";  
    while(x)  
    {  
        ret+=x%10+'0';  
        x/=10;  
    }  
    reverse(ret.begin(),ret.end());  
    cout<<ret<<endl;  
}  

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;++i){
        ll x;
        read(x);
        int cnt = 0;
        for(int i = 0;i < 62;++i){
            if(x & 1) a[cnt]++;
            else b[cnt]++;
            x>>=1;
            cnt++; 
        }
    }
    for(int i = 0;i < 62;++i){
        c[i] = a[i] * b[i];
    }
    ll all = 0;
    for(int i =0;i < 62;++i){
        all = (all + c[i]*((ll)1<<i)) % mod;
    }
    print(all);

    return 0;
}

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

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

    vector<int> x(M), y(M);
    for (int i = 0; i < M; i++)
    {
        int x_in, y_in;
        cin >> x_in >> y_in;
        x[i] = x_in - 1;
        y[i] = y_in - 1;
    }

    vector<int> all(N,1);
    vector<int> red(N,0);
    red[0] = 1;

    for (int i = 0; i < M; i++)
    {
        int from = x[i];
        int to = y[i];

        if(red[from] != 0){
            red[to] = 1;
        }

        all[from]--;
        all[to]++;
        if(all[from] == 0) {
            red[from] = 0;
        }
    }
    
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if(red[i] > 0) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 4680
import queue

h,w = map(int,input().split())
maze = []

for i in range(h):
	mazeRow = list(input())
	maze.append(mazeRow)
	
maxRootCnt = 0
#スタート→ゴール全探索（ま？）
for roop_h in range(h):
	for roop_w in range(w):
		if maze[roop_h][roop_w] == '#':
			continue

		isSearched =  [[0] * w for i in range(h)]
		isLevel =  [[0] * w for i in range(h)]
		nowTansakuCnt = 0

		q = queue.Queue()
		q.put([roop_h,roop_w])

		# 探索済マスセット
		isSearched[roop_h][roop_w] = 1
		isLevel[roop_h][roop_w] = 0
		while not q.empty():
			n= q.get()
			nowLevel = isLevel[n[0]][n[1]]
			if nowLevel > maxRootCnt:
				maxRootCnt = nowLevel
			#北
			if n[0] != 0:
				if maze[n[0] -1][n[1]] == '.' and isSearched[n[0] -1][n[1]] == 0:
					q.put([n[0]-1,n[1]])
					isSearched[n[0] -1][n[1]] = 1
					isLevel[n[0] -1][n[1]] = nowLevel + 1
			#南
			if n[0] != h-1:
				if maze[n[0] +1][n[1]] == '.' and isSearched[n[0]+1][n[1]] == 0:
					q.put([n[0]+1,n[1]])
					isSearched[n[0] +1][n[1]] = 1
					isLevel[n[0] +1][n[1]] = nowLevel + 1
				
			#西
			if n[1] != 0:
				if maze[n[0]][n[1]-1] == '.' and isSearched[n[0]][n[1]-1] == 0:
					q.put([n[0],n[1]-1])
					isSearched[n[0]][n[1]-1] = 1
					isLevel[n[0]][n[1]-1] = nowLevel + 1

			#東            
			if n[1] != w-1:
				if maze[n[0]][n[1]+1] == '.' and isSearched[n[0]][n[1]+1] == 0:
					q.put([n[0],n[1]+1])
					isSearched[n[0]][n[1]+1] = 1
					isLevel[n[0]][n[1]+1] = nowLevel + 1
				                    
print(maxRootCnt)


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

int main() {
    constexpr ll H = 2, W = 3;
    vector<vector<char>> C(H, vector<char>(W));
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            cin >> C[i][j];
        }
    }

    bool ok = true;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if (C[i][j] != C[H - 1 - i][W - 1 - j]) {
                ok = false;
            }
        }
    }

    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    int N;
    string S;
    cin>>N>>S;
    map<char,int> dic;
    for(int i=0;i<N;i++){
        dic[S[i]]+=1;
    }
    long long ans=1;
    for(auto itr=dic.begin();itr!=dic.end();++itr){
        ans=(ans*(itr->second+1))%1000000007;
    }

    cout<<(ans+1000000006)%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
intt lcm(intt a, intt b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = ((res%mod) * (a%mod))%mod;
      a = ((a%mod) * (a%mod))%mod;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
///////////U L R D
int dx[4]={0,-1,1,0};
int dy[4]={1,0,0,-1};

template <typename T1, typename T2>
struct less_second {
    typedef pair<T1, T2> type;
    bool operator ()(type const& a, type const& b) const {
        return a.second > b.second;
    }
};

void solve(vector<vector<int>> v,int &ans)
{
  int n=v.size();
  vector<vector<int>> dp(n,vector<int>(3,INT_MIN));
  
  for(int i=0;i<3;i++)
  {
    dp[0][i]=v[0][i];
  }
  for(int i=1;i<n;i++)
  {
    for0(j,3)
    {
        for(int k=0;k<3;k++)
        {
          if(k==j)
            continue;
          dp[i][j]=max(v[i][j]+dp[i-1][k],dp[i][j]);
        }
    }
  }
  ans=INT_MIN;
  for(int i=0;i<3;i++)
  {
    ans=max(ans,dp[n-1][i]);
  }


  
}

int main()
{
  go();
  fast_io
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(3));
  for0(i,n)
  {
    for0(j,3)
    {
      cin>>vec[i][j];
    }
  }
  int ans=INT_MIN;
  solve(vec,ans);
  cout << ans <<"\n";
}
























Measured memory_bytes: 19552
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s;
    int k;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
        cout<<s<<endl;
    else
    {for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"..."<<endl;}

    return 0;
}


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

string s, ans;

void solve(int i, string x, int sum)
{
	if (i == 4) 
	{
		if (sum == 7) ans = x;
		return;
	}
	solve(i+1, x+"+"+s[i], sum+s[i]-48);
	solve(i+1, x+"-"+s[i], sum-s[i]+48);
}

int main()
{
	cin >> s;
	solve(1, "", s[0]-48);
	cout << s[0] << ans << "=7" << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second

using namespace std;
typedef long long ll;

ll cnt[5005];
ll f(int backs, int len){

}
int main()
{
    string s;
    cin >> s;
    string s2 = "keyence";
    if(s == s2){
        cout << "YES" << endl;
        return 0;
    }
    fr(i, 0, s.size()){
        fr(j, i, s.size()){
            string s3 = s.substr(0, i);
            s3 += s.substr(j + 1, s.size() - j - 1);
            if(s2 == s3){
                cout << "YES" << endl;
                return 0;

            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int main(){
  double v,y;
  int N;
  while(scanf("%lf",&v)!=EOF){
    y=v*v/2/9.8;
    N=(y+5)/5+1;
    printf("%d\n",N);
  }
  return 0;
}


Measured memory_bytes: 2028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int D = int.Parse(str[3]);
            Console.WriteLine(A * B > C * D ? A * B : C * D);

        }
    }
}


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

int n;
long long k;
map<int,long long> m;

int main(){
  scanf("%d%lld",&n,&k);
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    m[a]+=b;
  }
  for(auto it: m){
    k-=it.second;
    if(k<=0){
      printf("%d",it.first);
      break;
    }
  }
}

Measured memory_bytes: 4224
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong(),b = sc.nextLong(),n = sc.nextLong();
    long x = 0;
    if(b-1>n){
      x=n;
    }else{
      x=b-1;
    }
    long ans = (long)(a*x)/b - a*(long)(x/b);
    pl(ans+"");
  }

  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
}


Measured memory_bytes: 38888
#include <stdio.h>
 
#define MAX 101
#define INF 10000000
#define NIL -1
 
#define WHITE 0
#define BLACK 1 
 
int n;
int Graph[MAX][MAX];
 
void prim(void);
 
int main(){
 
  int i, j, k, u, v, w;
 
  scanf("%d", &n);
 
  for(i = 0; i < n; i++){
 
    for(j = 0; j < n; j++){
 
      Graph[i][j] = INF;
 
    }
 
  }
 
  for(i = 0; i < n; i++){
     
    scanf("%d %d", &u, &k);
 
    for(j = 0; j < k; j++){
 
      scanf("%d %d", &v, &w);
 
      Graph[u][v] = w;
 
    }
 
  }
 
  prim();
 
  return 0;
 
}
 
void prim(){
 
  int u, v, mincost, i, sum;
  int d[MAX];
  int pi[MAX];
  int color[MAX];
 
  sum = 0;
 
  for(u = 0; u < n; u++){
 
    d[u] = INF;
     
    pi[u] = NIL;
 
    color[u] = WHITE;
 
  }
 
  d[0] = 0;
 
  while(1){
 
    mincost = INF;
 
    for(i = 0; i < n; i++){
 
      if((color[i] != BLACK) && (d[i] < mincost)){
 
    mincost = d[i];
 
    u = i;
 
      }
 
    }
 
    if(mincost == INF)
      break;
 
    color[u] = BLACK;
 
    for(v = 0; v < n; v++){
 
      if(d[v] > d[u] + Graph[u][v]){
 
    d[v] = d[u] + Graph[u][v];
 
    pi[v] = u;
 
      }
 
    }
 
  }
 
  for(i = 0; i < n; i++){
 
    printf("%d %d\n", i, d[i]);
 
  }
 
}

Measured memory_bytes: 640
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var d = int.Parse(Console.ReadLine());

            if(d == 25){
                Console.WriteLine("Christmas");
            }

            if(d == 24){
                Console.WriteLine("Christmas Eve");
            }

            if(d == 23){
                Console.WriteLine("Christmas Eve Eve");
            }

            if(d == 22){
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }
    }
}


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

typedef long long ll;									//XD
#define int long long   
#define PB push_back 
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
//#define kill(x) {cout<<x; return;}
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);         
#endif
}

const int mod = 1e9+7;
const int maxn = 2e3+5;
int h[maxn]={};
void solve(){
	string a, b; cin>>a>>b;
	int ans=0;
	rep(i, 0, sz(a)){
		if(a[i] != b[i]) ans++;
	}
	cout<<ans;
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);// io();
    //cout<<setprecision(100);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif

    return 0;
}


Measured memory_bytes: 3744
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

d = []
for i in range(N):
    d.append(V[i]-C[i])

d = sorted(d,reverse=True)

ans = 0
for i in range(N):
    if d[i] < 0:
        break
    ans += d[i]
print(ans)


Measured memory_bytes: 39880
#include <iostream>

using namespace std;

int main(){
  int N, A, B, tmp;
  int c1 = 0, c2 = 0, c3 = 0;
  cin >> N >> A >> B;
  for (int i=0; i<N; i++){
    cin >> tmp;
    if (tmp <= A) c1++;
    else if(tmp <= B) c2++;
    else c3++;
  }
  cout << (c1 > c2 ? (c2 > c3 ? c3 : c2) : (c1 > c3 ? c3 : c1)) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static String toChange(String s) {
		boolean isM = (s.charAt(0) == '1')?true:false;
		Long integerPart = 0L;
		Long decimalPart = 0L;
		for(int i = 1; i < 24; i++) {
			if(s.charAt(i) == '1') {
				long tmp = 1;
				for(int j = 0; j < 24-i; j++) {
					tmp *= 2L;
				}
				integerPart += tmp;
			}
		}
		if(s.charAt(24) == '1') {
			integerPart += 1;
		}
		if(s.charAt(25) == '1') {
			decimalPart += 5000000;
		}
		if(s.charAt(26) == '1') {
			decimalPart += 2500000;
		}
		if(s.charAt(27) == '1') {
			decimalPart += 1250000;
		}
		if(s.charAt(28) == '1') {
			decimalPart += 625000;
		}
		if(s.charAt(29) == '1') {
			decimalPart += 312500;
		}
		if(s.charAt(30) == '1') {
			decimalPart += 156250;
		}
		if(s.charAt(31) == '1') {
			decimalPart += 78125;
		}
		int decLen = decimalPart.toString().length();
		if(decimalPart != 0) {
			
			while(true) {
				if((Long.toString(decimalPart).charAt(Long.toString(decimalPart).length()-1) == '0')) {
					decimalPart /= 10;
				}
				else {
					break;
				}
			}
		}
		String tmp0 = integerPart.toString();
		String tmp1 = decimalPart.toString();
		if(decimalPart != 0) {
			for(int i = decLen; i < 7; i++) {
				tmp1 = "0" + tmp1;
			}
		}
		if(isM) {
			tmp0 = "-" + tmp0;
		}
		
		String tmp2 = "." + tmp1;
		tmp0 += tmp2;
		
		return tmp0;
	}
	
	static String toBin(String s) {
		String ans = "";
		for(int i = 0; i < 8; i++) {
			char tmp = s.charAt(i);
			if(tmp == '0') {
				ans += "0000";
				continue;
			}
			if(tmp == '1') {
				ans += "0001";
				continue;
			}
			if(tmp == '2') {
				ans += "0010";
				continue;
			}
			if(tmp == '3') {
				ans += "0011";
				continue;
			}
			if(tmp == '4') {
				ans += "0100";
				continue;
			}
			if(tmp == '5') {
				ans += "0101";
				continue;
			}
			if(tmp == '6') {
				ans += "0110";
				continue;
			}
			if(tmp == '7') {
				ans += "0111";
				continue;
			}
			if(tmp == '8') {
				ans += "1000";
				continue;
			}
			if(tmp == '9') {
				ans += "1001";
				continue;
			}
			if(tmp == 'a') {
				ans += "1010";
				continue;
			}
			if(tmp == 'b') {
				ans += "1011";
				continue;
			}
			if(tmp == 'c') {
				ans += "1100";
				continue;
			}
			if(tmp == 'd') {
				ans += "1101";
				continue;
			}
			if(tmp == 'e') {
				ans += "1110";
				continue;
			}
			if(tmp == 'f') {
				ans += "1111";
				continue;
			}
			
			
		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int Q = stdIn.nextInt();
		for(int i = 0; i < Q; i++) {
			String s = stdIn.next();
			s = toBin(s);
			System.out.println(toChange(s));
		}
	}
}

Measured memory_bytes: 87232
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

wr,ht,n=map(int,input().split())
wl=0;hd=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        wl=max(wl,x)
    elif a==2:
        wr=min(wr,x)
    elif a==3:
        hd=max(hd,y)
    else:
        ht=min(ht,y)
print(max(0,wr-wl)*max(0,ht-hd))
# print(wr,wl,ht,hd)



Measured memory_bytes: 38384
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))

S = input()
N = len(S)
C = [0]*3
for i in range(N):
    C[ston(S[i])] += 1
judge(max(C)-min(C)<=1,['YES','NO'])

Measured memory_bytes: 68056
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        int count = 0;

        for (char a : N.toCharArray()) {
            if (a == '7') {
                count += 1;
            }
        }
        if (count != 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 27004
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Seg = Tuple!(int, "l", int, "r");
alias Query = Tuple!(int, "s", int, "t", int, "idx");

void main() {
    int n, m, q;
    scan(n, m, q);

    auto lcnt = new int[](n + 1);
    auto rcnt = new int[](n + 1);
    auto ss = new Seg[](m);

    foreach (i ; 0 .. m) {
        int li, ri;
        scan(li, ri);
        lcnt[li]++;
        rcnt[ri]++;
        ss[i] = Seg(li, ri);
    }

    foreach_reverse (i ; 0 .. n) {
        lcnt[i] += lcnt[i+1];
    }
    foreach (i ; 1 .. n + 1) {
        rcnt[i] += rcnt[i-1];
    }

    auto del = new int[](n + 1);

    auto qs = new Query[](m);

    foreach (i ; 0 .. q) {
        int si, ti;
        scan(si, ti);
        qs[i] = Query(si, ti, i);
    }

    ss.sort!"a.r > b.r"();
    qs.sort!"a.t > b.t"();

    int[] ans = new int[](q);
    int rr = n;

    foreach (i ; 0 .. q) {
        while (ss.front.r > qs[i].t) {
            del[ss.front.l]++;
            ss.popFront();
        }
        
        int res = lcnt[qs[i].s];
        foreach (j ; qs[i].s .. n + 1) {
            res -= del[j];
        }
        ans[qs[i].idx] = res;
    }

    writefln("%(%s\n%)", ans);
}






















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 8188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m,max,i,wa=0;
  cin>>n>>m;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
    wa+=a[i];
  }
  sort(a,a+n);
  max=(wa-1)/(4*m);
  if(a[n-m]>max){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long x[15],y[15],i,j,k,l,o,p,jc[2000005],ny[2000005],sum,ans,flag;
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long C(long long u,long long v){
	return jc[u]*ny[v]%mo*ny[u-v]%mo;
}
long long D(long long u,long long v){
	return C(u+v,v);
}
int main(){
	jc[0]=1;
	for(i=1;i<=2000000;i++)
		jc[i]=jc[i-1]*i%mo;
	ny[2000000]=ksm(jc[2000000],mo-2);
	for(i=1999999;i>=0;i--)
		ny[i]=ny[i+1]*(i+1)%mo;
	for(i=1;i<=6;i++)
		x[i]=read();
	for(i=1;i<=6;i++)
		y[i]=read();
	x[1]--;
	y[1]--;
	x[6]++;
	y[6]++;
	for(i=1;i<=2;i++)
		for(j=1;j<=2;j++)
			for(k=5;k<=6;k++)
				for(l=5;l<=6;l++){
					flag=1;
					if(i!=j)
						flag=-flag;
					if(k!=l)
						flag=-flag;
					sum=0;
					for(o=y[3];o<=y[4];o++)
						sum=(sum-D(x[3]-1-x[i],o-y[j])*D(x[k]-x[3],y[l]-o)%mo*(x[3]+o))%mo;
					for(o=x[3];o<=x[4];o++)
						sum=(sum-D(o-x[i],y[3]-1-y[j])*D(x[k]-o,y[l]-y[3])%mo*(y[3]+o))%mo;
					for(o=y[3];o<=y[4];o++)
						sum=(sum+D(x[4]-x[i],o-y[j])*D(x[k]-x[4]-1,y[l]-o)%mo*(x[4]+o+1))%mo;
					for(o=x[3];o<=x[4];o++)
						sum=(sum+D(o-x[i],y[4]-y[j])*D(x[k]-o,y[l]-y[4]-1)%mo*(y[4]+o+1))%mo;
					ans=(ans+sum*flag)%mo;
					//x[i],y[j]~x[k],y[l]
				}
	ans=(ans+mo)%mo;
	pus(ans,2);
   	return 0;
}

Measured memory_bytes: 31616
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if ((i + 1) % 2 == 1 && A.at(i) % 2 == 1) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
import static java.util.Arrays.binarySearch;

import java.io.IOException;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		int n = nextInt();
		int m = nextInt();
		int[] xs = new int[n];
		int[] ys = new int[n];
		for (int i = 0; i < n; i++) {
			xs[i] = nextInt();
			ys[i] = nextInt();
		}

		TreeSet<Integer> xTreeSet = new TreeSet<Integer>();
		TreeSet<Integer> yTreeSet = new TreeSet<Integer>();

		for (int i = 0; i < n; i++) {
			xTreeSet.add(xs[i]);
			yTreeSet.add(ys[i]);
		}
		xTreeSet.add((int) Integer.MAX_VALUE);
		xTreeSet.add((int) Integer.MIN_VALUE);
		yTreeSet.add((int) Integer.MAX_VALUE);
		yTreeSet.add((int) Integer.MIN_VALUE);

		Integer[] xIntegers = xTreeSet.toArray(new Integer[0]);
		Integer[] yIntegers = yTreeSet.toArray(new Integer[0]);

		int w = xIntegers.length;
		int h = yIntegers.length;

		int[][] location = new int[h + 1][w + 1];

		for (int i = 0; i < n; i++) {
			int x = binarySearch(xIntegers, xs[i]);
			int y = binarySearch(yIntegers, ys[i]);
			location[y + 1][x + 1]++;
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				location[i + 1][j + 1] += location[i + 1][j] + location[i][j + 1] - location[i][j];
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < m; i++) {
			// TreeSet.ceiling(e)...e以上の1番小さい要素を返す
			// TreeSet.floor(e)...e以下の1番大きい要素を返す
			int x1 = binarySearch(xIntegers, xTreeSet.ceiling(nextInt()));
			int y1 = binarySearch(yIntegers, yTreeSet.ceiling(nextInt()));
			int x2 = binarySearch(xIntegers, xTreeSet.floor(nextInt())) + 1;
			int y2 = binarySearch(yIntegers, yTreeSet.floor(nextInt())) + 1;
			sb.append(location[y2][x2] - location[y1][x2] - location[y2][x1] + location[y1][x1]);
			sb.append('\n');
		}
		System.out.print(sb.toString());
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 211372
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,j,k;
	cin>>n;
	long long int dp[n+10][n+10][3];
	long long int a[n+10];
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<=n;i++)
	{
		dp[i][i][0]=a[i];
		dp[i][i][1]=0;
	}
	for(j=2;j<=n;j++)
	{
		i=1;
		k=j;
		while(i<n&&k<=n)
		{
			dp[i][k][0]=max(a[i]+dp[i+1][k][1],a[k]+dp[i][k-1][1]);
			dp[i][k][1]=min(dp[i+1][k][0],dp[i][k-1][0]);
			i+=1;
			k+=1;
		}
	}

	cout<<dp[1][n][0]-dp[1][n][1]<<endl;
}

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

int main(){
	int n;
	int previous;
	int present;
	int count=0;
	int max=0;
	cin>>n;
	vector<int>h(n);
	rep(i,n){
		cin>>h[i];
	}
	previous=h[0];
	present=h[0];
	for(int i=1;i<n;++i){
		previous=present;
		present=h[i];
		if(present<=previous){
			count++;
		}
		else{
			if(max<count)max=count;
			count=0;
		}
	}
	if(max<count)max=count;
	cout<<max<<endl;
	
	return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int inf=1e9+7;
const int mod=1e9+7;

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	string str;
	while(cin>>str)
	{
	
		ll int ans=0;
		
		ll int pre=0;
		
		for(int i=str.size()-1;i>=0;i--)
		{
			int now=(str[i]-'0');
			
			if(now<5)
			{
				ans+=now;
			}
			else if(now>5)
			{	
			//	if(10-now<0)
			//		cout<<"hehe"<<endl;
	
				ans+=(10-now);
				
				int to=i-1;
				
				if(to>=0)
					str[to]++;
				else
					pre++;
				
				while(to>0&&str[to]>'9')
				{
					str[to]-=10;
					str[to-1]++;
					to--;
				}
				
				if(to==0&&str[to]>'9')
				{
					str[to]-=10;
					pre++;
				}
			}
			else if(now==5)
			{
				if(i>0&&str[i-1]>='5')
				{
					ans+=(10-now);
				
					int to=i-1;
					
					if(to>=0)
						str[to]++;
					else
						pre++;
					
					while(to>0&&str[to]>'9')
					{
						str[to]-=10;
						str[to-1]++;
						to--;
					}
					
					if(to==0&&str[to]>'9')
					{
						str[to]-=10;
						pre++;
					}
				}
				else
				{
					ans+=now;
				}
			}
		}
		
		ans+=pre;
		
		cout<<ans<<endl;
		
	}
	
	return 0;
}

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

c11,c12,c13 = list(map(int,input().split()))
c21,c22,c23 = list(map(int,input().split()))
c31,c32,c33 = list(map(int,input().split()))

for a1 in range(0,101):
    b1 = c11-a1
    b2 = c12-a1
    b3 = c13-a1
    a2 = c21-b1
    a3 = c31-b1
    if a2+b2 == c22 and a3+b2 == c32 and a2+b3 == c23 and a3+b3 == c33:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

vector<pair<int,int>> to[2510];

int main(){
    ll N,M,P; cin>>N>>M>>P;
    //int a,b,c;
    vector<ll> a(M),b(M),c(M);
    for (int i = 0; i <M ; ++i) {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--; b[i]--;
        c[i]*=-1;
        c[i]+=P;
        //to[a].push_back(make_pair(b,c));
    }

    vector<ll> gain(N,1e18);
    gain[0]=0ll;
    ll loopcheck=0ll;

    for (int i = 0; i <=2*N; ++i) {
        for (int j = 0; j < M; ++j) {
            gain[b[j]]=min(gain[b[j]],gain[a[j]]+c[j]);
        }
        if(i==N-1) loopcheck=gain[N-1];
    }

    if(gain[N-1]!=loopcheck) cout<<-1<<endl;
    else cout<<max(0ll,-1ll*gain[N-1])<<endl;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	for (int i = 1; i <= 10000000; i++)
		if (a * i % b == c)
		{
			cout << "YES" << endl;
			return 0;
		}
	cout << "NO" << endl;
	return 0;
}

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

int q,h,s,d,n;

void work()
{
	scanf("%d %d %d %d %d",&q,&h,&s,&d,&n);
	h=min(h,2*q),s=min(s,2*h),d=min(d,2*s);
	printf("%lld",1LL*n/2*d+(n&1)*s);
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>

using namespace std;
const int inf = 1e9;
const int maxn = 1e5 + 10;

int mod[2020];

int main()
{
	string s;
	cin >> s;
	int p = 1;
	int now = 0;
	int ans = 0;
	mod[0] = 1;
	for (int i = s.length() - 1; i >= 0; i--)
	{
		now = (now + (s[i] - '0') * p) % 2019;
		ans += mod[now]++;
		p = (p * 10) % 2019;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(int i = 0; i < n; ++i){
        cin >> h.at(i);
    }
    vector<ll> cost(n);
    cost.at(n - 1) = 0;
    cost.at(n - 2) = abs(h.at(n - 2) - h.at(n - 1));
    for(int i = n - 3; i >= 0; --i){
        cost.at(i) = min(
            abs(h.at(i) - h.at(i + 1)) + cost.at(i + 1),
            abs(h.at(i) - h.at(i + 2)) + cost.at(i + 2)
        );
    }
    cout << cost.at(0) << endl;
    return 0;
}

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

int main() {
	int n = 0;
	int m = 0;
	int l = 0;
	scanf("%d %d %d", &n, &m, &l);

	int a[100][100] = { 0 };
	int b[100][100] = { 0 };

	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			scanf("%d", &a[x][y]);			
		}
	}
	for (int x = 0; x < m; x++) {
		for (int y = 0; y < l; y++) {
			scanf("%d", &b[x][y]);
		}
	}

	long int c[100][100] = { 0 };
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < l; y++) {
			for (int z = 0; z < m; z++) {
				c[x][y] += a[x][z] * b[z][y];
			}
		}
	}

	for (int x = 0; x < n; x++) {
		for (int y = 0; y < l; y++) {
			printf("%ld", c[x][y]);
			
			if (y == l - 1) {
				printf("\n");
			}
			else {
				printf(" ");
			}
		}
		
	}

	return 0;
}

Measured memory_bytes: 1952
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]); lines.shift();
    var D = lines.map(i => Number(i));

    D = D.filter((value, index, array) => {
        return (array.indexOf(value) === index)
    })

    console.log(D.length)

});

Measured memory_bytes: 21320
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    int point[3];cin>>point[1]>>point[2]>>point[0];
    char kumi[3]={'r','s','p'};
    string t;cin>>t;
    int score[t.size()];
    for(int i=0;i<t.size();i++){
        char c=t[i];
        int P=0;
        
        for(int j=0;j<3;j++){
            if(c==kumi[j])P=point[j];
            //if(i==0)cout<<c<<P<<endl;
        }
        
        if(i<k){
            score[i]=P;
            continue;
        }
        if(c==t[i-k]&&score[i-k]>0){
            score[i]=0;
            continue;
        }
        score[i]=P;
    }
    long long res=0;
    for(int i=0;i<t.size();i++){
        res+=score[i];
        //cout<<score[i]<<endl;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
	int n,k;	cin >> n >> k;
	double ans=0;
	for(int i=1;i<=n;i++){
		double p = 1.0/n;
		int now = i;
		while(now<k){
			now *= 2;
			p *= 0.5;
		}
		ans += p;
	}
	cout.precision(10); cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int k=1,n=0;
  char let[1200];
  int a[27];
  for(k=1;k<=26;k++) a[k]=0; //a[k]???0??§?????????
  while(scanf("%c",&let[k]) != EOF){
    if(0x61<=let[k] && let[k]<=0x7a){ //?°??????????????????????
      n = let[k]-0x60;
      a[n]++;
    }else if(0x41<=let[k] && let[k]<=0x5a){ //??§?????????????????????
      n = let[k]-0x40;
      a[n]++;
    }
    k++;
  }
  for(k=1;k<=26;k++){
    printf("%c : %d\n",0x60+k,a[k]);
  }
  return 0;
}

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

int N, M, D[1010][1010]; char S[1010][1010];
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	queue<pair<int, int>> Q;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (S[i][j] == '#') {
				Q.push({ i,j });
			}
		}
	}

	int ans = 0;
	while (!Q.empty()) {
		int x = Q.front().first, y = Q.front().second;
		Q.pop();
		int d = D[x][y];
		ans = d;
		for (int k = 0; k < 4; k++) {
			int px = x + dx[k];
			int py = y + dy[k];
			if (px < 0 || px >= N || py < 0 || py >= M) continue;
			if (S[px][py] == '.') {
				Q.push({ px,py });
				S[px][py] = '#';
				D[px][py] = d + 1;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 10112
n = int(input())
for i in range(n):
    S,T = input().split()
    ans = [0,0,0,0]
    for s in range(len(S)):
        if S[s] in "mcxi":
            if s!=0 and not(S[s-1] in "mcxi"):
                ans["mcxi".find(S[s])] = int(S[s-1])
            else:
                ans["mcxi".find(S[s])] = 1
    for t in range(len(T)):
        if T[t] in "mcxi":
            if t!=0 and not(T[t-1] in "mcxi"):
                ans["mcxi".find(T[t])] += int(T[t-1])
            else:
                ans["mcxi".find(T[t])] += 1
    ans = ans[::-1]
    anstr = ""
    for i in range(4):
        if i<3 and ans[i]>=10:
            ans[i] = ans[i]%10
            ans[i+1] += 1
        if ans[i] > 0:
            anstr = "ixcm"[i] + anstr
            if ans[i]>1:
                anstr = str(ans[i]) + anstr
    print(anstr)


Measured memory_bytes: 5624