akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a,b,n;
signed main()
{
    cin>>n>>a>>b;
    if(a>b)cout<<0,exit(0);
    if(n==1&&a!=b)cout<<0,exit(0);
    cout<<b*(n-1)+a-(a*(n-1)+b)+1;

}
/*
先考虑加一个点。这个点先排在根的位置，然后两个儿子可以枚举一波。
3422702
*/




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

int main()
{
    int sum = 0;
    string str;

    while( cin >> str )
    {
        string palindrome = "";
        for( int i = str.size() - 1; i >= 0; i-- )
            palindrome += str[i];
        if( str == palindrome )
            sum++;
    }
    cout << sum << endl;

    return 0;
}


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

using namespace std;

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

    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    int amax=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            amax=max(amax,abs(a[i]-a[j]));
        }
    }
    cout << amax << endl;
}

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

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

    string ans;
    if (N % 2 == 0) {
        ans = "0";
    }
    else if (N % 2 != 0) {
        ans = "1";
        N--;
    }

    int i = 1;
    while (N != 0) {
        int ni = pow((-2), i);
        int num = N / ni;

        if (num % 2 == 0) {
            ans.insert(ans.begin(), '0');
        }
        else if (num % 2 != 0) {
            N -= ni;
            ans.insert(ans.begin(), '1');
        }
        i++;
    }
  
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int[][] dp;
    static int[] yen = new int[]{6, 36, 216, 36 * 36, 36 * 36 * 6, 216*216, 9, 81, 729, 81 * 81, 81 * 729, 729* 729};

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        dp = new int[yen.length + 1][100001];

        for (int i = 0; i < dp[0].length; i++) {
            dp[0][i] = i;
        }

        for (int i = 0; i < yen.length; i++) {
            for (int j = 1; j < dp[0].length; j++) {
                if (j - yen[i] >= 0) {
                    dp[i + 1][j] = Math.min(dp[i + 1][j - yen[i]] + 1, dp[i][j]);
                }
                else {
                    dp[i + 1][j] = dp[i][j];
                }
            }
        }
        System.out.println(dp[dp.length - 1][n]);
    }
}

Measured memory_bytes: 28372
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
int main()
{
  int n; cin >> n;
  int k; cin >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  using pi = pair<int,int>;

  rep(i,k) {
    vector<int> b(n, 1);
    vector<pi> p;
    rep(j,n){
      p.push_back({j,2});
    }
    rep(j,n) {
      p.push_back({max(0, j-a[j]), 1});
      p.push_back({min(n, j+a[j]+1), -1});      
    }
    sort(p.begin(), p.end());
    int now = 0;
    rep(j,p.size()) {
      int id = p[j].second;
      if(id == 2) {
	b[p[j].first] = now;
      }
      else {
	now += id;
      }
    }
    bool f = true;
    a = b;
    for(auto val: a) if(val != n) f = false;
    if(f) break;
    
  }

  for(auto val: a) cout << val << " ";
  cout  << "\n";    


  return 0;
}


Measured memory_bytes: 17668
#include<cstdio>
int main(void){
int a[4][13];
char c[10];
int x;
int n;
scanf("%d",&n);
for(int i=0;i<4;i++){
for(int j=0;j<13;j++)a[i][j]=0;
}
for(int i=0;i<n;i++){
scanf("%s %d",c,&x);
if(c[0]=='S')a[0][x-1]=1;
if(c[0]=='H')a[1][x-1]=1;
if(c[0]=='C')a[2][x-1]=1;
if(c[0]=='D')a[3][x-1]=1;
}
for(int i=0;i<13;i++){
if(a[0][i]==0)printf("S %d\n",i+1);
}
for(int i=0;i<13;i++){
if(a[1][i]==0)printf("H %d\n",i+1);
}
for(int i=0;i<13;i++){
if(a[2][i]==0)printf("C %d\n",i+1);
}
for(int i=0;i<13;i++){
if(a[3][i]==0)printf("D %d\n",i+1);
}
return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0,A+B-N) << endl;
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> a(n);
    rep(i, n) cin >> a[i].first >> a[i].second;

    sort(ALL(a));

    ll cnt = 0;
    rep(i, n)
    {
        cnt += a[i].second;
        if (cnt >= k)
        {
            OP(a[i].first);
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
[n,k]=list(map(int,input().split()))
akarusa=list(map(int,input().split()))


for i in range(k):
    imos=[0]*n
    for j in range(n):
        kagen=max(j-akarusa[j],0)
        jogen=min(j+akarusa[j],n-1)
        imos[kagen]+=1
        if jogen+1<n:
            imos[jogen+1]-=1
    akarusanext=imos
    for j in range(1,n):
        akarusanext[j]+=akarusanext[j-1]
    
    if akarusa==akarusanext:
        break
    else:
        akarusa=akarusanext

for i in range(n):
    print(akarusa[i], end=" ")


Measured memory_bytes: 145344
s = input()

count = [0,0,0,0]
for i in range(len(s)):
  for j in range(len(s)):
    if s[i] == s[j]:
      count[i] += 1

if (count[0] == count[1] == count[2] == count[3] == 2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        StringBuilder res = new StringBuilder();
        String s = "";
        for (int i = 0; i <= 25; i++) {
            s += (char)('a' + i);
        }

        while (n > 0) {
            int index = (int)((n-1) % 26);
            res.append(s.charAt(index));
            n = (n-1) / 26;
        }
        res = res.reverse();

        System.out.println(res.toString());
    }
}


Measured memory_bytes: 39296
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author win11905
 */

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define long long long
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};


class TaskC {
private:
	int n;
	vector<int> vec;
	char inp[20];
	void check() {
	    int num; sscanf(inp, "%d", &num);
	    int bit = 0;
	    for(int i = 0; inp[i]; ++i) {
	        if(inp[i] == '3') bit |= 1;
	        if(inp[i] == '5') bit |= 2;
	        if(inp[i] == '7') bit |= 4;
	    }
	    if(bit == 7) vec.emplace_back(num);
    }
	void rec(int pos) {
	    inp[pos] = '\0';
	    if(pos) check();
	    if(pos == 9) return;
        inp[pos] = '3';
        rec(pos+1);
        inp[pos] = '5';
        rec(pos+1);
        inp[pos] = '7';
        rec(pos+1);
	}
public:
	void solve(istream& cin, ostream& cout) {
		cin >> n;
		rec(0);
		int sum = 0;
        for(int x : vec) if(x <= n) sum++;
        cout << sum << endl;
	}
};

class Solver {
public:
	void solve(std::istream& in, std::ostream& out) {
		TaskC *obj = new TaskC();
		obj->solve(in, out);
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	Solver solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;

int main(){
  long long int n, h, d, hp, maxhp, damage = 0, ans = 0;
  deque<pair<long long int, long long int> > izumi;
  scanf("%lld%lld", &n, &hp);
  maxhp = hp;
  for(int i = 0;i < n - 1;i++){
    scanf("%lld%lld", &d, &h);
    while(!izumi.empty() && izumi.back().first < h){
      izumi.pop_back();
    }
    izumi.push_back(make_pair(h, damage));
    damage += d;
    while(hp <= damage){
      long long int tmphp = hp ;
      while(!izumi.empty() && tmphp + izumi.front().first - izumi.front().second > maxhp){
	hp = max(hp, izumi.front().second + maxhp);
	izumi.pop_front();
      }
      if(!izumi.empty()){
	hp = max(hp, tmphp + izumi.front().first);
	int tmp = max(0ll, min((damage - hp) / izumi.front().first, (izumi.front().second + maxhp - hp) / izumi.front().first));
	ans += tmp;
	hp += tmp * izumi.front().first;
      }
      ans++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1052
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  ll ind = 0;
  FOR(i,1,n+1){
    ll t = 1LL * i * i;
    if(t <= n)
      ind = t;
  }
  COUT(ind);


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


signed main() {
	ios::sync_with_stdio(false);
	vvi grid(3, vector<int>(3));
	int i, j;
	rep(i, 3) {
		rep(j, 3)
			cin >> grid[i][j];
	}
	vector<int> a(3, 0);
	vector<int> b(3, 0);
	int n = 3;
	vvi sum(3, vector<int>(3, 0));
	rep(i, n) {
		a[i] = grid[0][i];
	}
	rep(i, n) {
		b[i] = grid[i][0] - a[0];
	}
	rep(i, n) {
		rep(j, n) {
			sum[i][j] = a[j] + b[i];
		}
	}
	bool ans = true;
	rep(i, n) {
		rep(j, n) {
			if (grid[i][j] != sum[i][j]) {
				ans = false;
			}
		}
	}
	if (ans)
		cout << "Yes" << '\n';
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n;
    cin >> n ;
    vector <int> a(n);
    int ma = 0;
    rep(i,0,n) {
        cin >>a[i];
        ma = max (ma,a[i]);
    }
    int count =0;
    rep(i,0,n) {
        if(a[i] == ma) count++;
    }
    int b =0;
    rep(i,0,n) {
        if (!(a[i] == ma)) {
            b += a[i];
        }
    }
    b += ma * (count-1);
    if (ma < b) {
        yes
    } else {
        no
    }
}

Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];
    
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;
    
    while (1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (color[i] != BLACK && d[i] < minv) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e; std::cin >> e;
            M[i][j] = (e != -1) ? e : INFTY;
        }
    }
    
    printf("%d\n", prim());
    
    return 0;
}



Measured memory_bytes: 3248
MOD =  1000000007

H, W, K = map(int, input().split())

cand = []
for bits in range(1 << (W-1)):
  s = "{:b}".format(bits) 
  if s.count('11') > 0: continue
  while len(s) < W-1:
    s = '0' + s
  cand.append(s)

dp = [0] * W
dp[0] = 1

for _ in range(H):
  ndp = [0] * W
  for c in cand:
    for i in range(W):
      if i+1 < W and c[i] == '1':
        ndp[i+1] += dp[i]
      elif i-1 >= 0 and c[i-1] == '1':
        ndp[i-1] += dp[i]
      else:
        ndp[i] += dp[i]
  dp = ndp
  for i in range(W):
    dp[i] %= MOD
print(dp[K-1])




Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<vector<int>> A(a,vector<int>(b,0));

    for (int c = 0; c < a; ++c) {
        for (int d = 0; d < b; ++d) {
            cin >> A.at(c).at(d);
        }
    }

    vector<int> B(b,0);
    for (int e = 0; e < b; ++e) {
        cin >> B.at(e);
    }

    vector<int> Result(a,0);
    for (int f = 0; f < a; ++f) {
        int temp = 0;
        for (int g = 0; g < b; ++g) {
            temp += A.at(f).at(g) * B.at(g);
        }
        Result.at(f) = temp;
    }

    for (int i = 0; i < a; ++i) {
        cout << Result.at(i);
        if(i != a)
            cout << endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  rep(i, n - 2) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++ans;
  }

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


Measured memory_bytes: 256
N,K = map(int,input().split())
high = [int(input()) for _ in range(N)]
s_high = sorted(high)
ans = 10**9
#print(s_high)
for i in range(N-K+1):
    j = s_high[i+K-1] - s_high[i]
    ans = min(ans,j)
print(ans)

Measured memory_bytes: 14056
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int maxn=6e6+5;
const ll inf=1e18;
int k;
int main(){
    cin>>k;
    for(int i=1;i<=k;i++)
        cout<<"ACL";
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define min(a, b) (a > b ? b : a)

int func(int a, int b, int c) {
    if (b == 0 && c == 0)
        return 0;
    else if (a & 1)
        return func(a >> 1, b >> 1, c >> 1);
    else if (b & 1)
        return func(c >> 1, b >> 1, a >> 1) + 1 + func(0, 0, (a | b | c) >> 1);
    else
        return func(a >> 1, b >> 1, c >> 1) + 2 +
               4 * func(0, (a | b | c) >> 1, 0);
}

int main() {
    int n, m, tray[3];
    while (std::cin >> n >> m && n && m) {
        rep(i, 3) {
            tray[i] = 0;
            int k, num;
            std::cin >> k;
            rep(j, k) {
                std::cin >> num;
                tray[i] |= 1 << (num - 1);
            }
        }

        int res = min(func(tray[0], tray[1], tray[2]),
                      func(tray[2], tray[1], tray[0]));
        std::cout << (res <= m ? res : -1) << std::endl;
    }
}

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

int main() {
  long double l;
  cin >> l;
  long double a = l/3;
  l -= a;
  long double b = l/2;
  l -= b;
  long double c = l;
  cout << fixed << setprecision(16) << double(a)*b*c << endl;
  return 0;
}


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

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, w, a, b);
    Cout(max(abs(a-b)-w, 0));
}


Measured memory_bytes: 256
(* O(n * log(n)) *)
let solve n m ab_s =
  let sorted_ab_s = List.sort (fun (a1, _) (a2, _) -> compare a1 a2) ab_s in
  let rec find money rest_m = function
  | [] -> money
  | (a, b) :: rest ->
    if rest_m <= 0 then
      money
    else
      find (money + a * min b rest_m) (rest_m - b) rest
  in
    find 0 m sorted_ab_s

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string
(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

let _ =
  match read_ints () with
  | [n; m] ->
    fold_int (fun acc _ ->
      match read_ints () with
      | [a; b] -> (a, b) :: acc
      | _ -> acc) [] n |> List.rev |> solve n m |> string_of_int |> print_endline
  | _ -> ()

Measured memory_bytes: 14976
#include<stdio.h>
int main(){
  while(1){
    int s,e,count=0;
  scanf("%d%d",&s,&e);
  if(s==0&&e==0)break;

  for(int i=1;i<=s;i++){
    for(int j=i;j<=s;j++){
      for(int k=j;k<=s;k++){
	if(i+j+k==e){
	  if(i==j||j==k||k==i)continue;
	  
	  count++;
	  
	  //printf("%d %d %d\n",i,j,k);
	}
      }
    }
  }//ireowari

  printf("%d\n",count);
  
  }
  return 0;
}


Measured memory_bytes: 2088
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = sorted(LI())
    if a == [1,4,7,9]:
        return 'YES'

    return 'NO'



print(main())




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

int main(){
  ll s,p;
  p=1000000007;
  cin >> s;
  vector<ll> a(2001);
  a.at(1)=0;
  a.at(2)=0;
  a.at(3)=1;
  ll i;
  for(i=4;i<=2000;i++){
    a.at(i)=(a.at(i-1)+a.at(i-3))%p;
  }
  
  cout << a.at(s) << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      ans = max(ans, abs(A[i] - A[j]));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;

	while(q--){
		int a,b,c;
		cin>>a>>b>>c;
		swap(a,b);
		swap(a,c);

		cout<<a<<" "<<b<<" "<<c<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 入力
        int n = sc.nextInt();
        int dt, dx, dy, dif;
        // 初期値
        boolean can = true;
        int t = 0;
        int x = 0;
        int y = 0;

        for (int i = 0; i < n; i++) {
            // 入力値
            dt = sc.nextInt();
            dx = sc.nextInt();
            dy = sc.nextInt();
            dif = dt - t - Math.abs(dx - x) - Math.abs(dy - y);
            can &= dif >= 0 && dif % 2 == 0;
            t = dt;
            x = dx;
            y = dy;
        }

        // 出力
        if (can) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 90172
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

bool ist[200] = {false};
bool use[200] = {false};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int(n);
    if(!n)break;
    rep(i, n){
      int(tmp);
      --tmp;
      ist[tmp] = true;
    }

    int now = -1;
    bool tturn = true;
    int tcnt = n, hcnt = n;
    for(;tcnt * hcnt;){
      if(now == -1){
        rep(i, n + n)if(ist[i] == tturn && !use[i]){
          use[i] = true;
          tturn ? --tcnt : --hcnt;
          now = i;
          break;
        }
      }else{
        rep(i, n + n)if(ist[i] == tturn && !use[i] && now < i){
          use[i] = true;
          tturn ? --tcnt : --hcnt;
          now = i;
          break;
        }
        if(i == n + n){
          now = -1;
        }
      }
      tturn = !tturn;
      //debug3(now + 1, tcnt, hcnt);
    }

    pri(hcnt);
    pri(tcnt);



//*/
  rep(i, 200){
    ist[i] = false;
    use[i] = false;
  }
//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  intl N;
  cin >>N;
  vi x(0);
  while(N != 0){
    if( N%26 == 0){x.pub(26); N -=26;}
    else{x.pub(N%26);}
    N /=26;
  }
  reverse(x.begin() , x.end());
  for (auto ch :x){
    char a = 'a';
    a += ch -1;
    cout << a;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define getl(s) getline(cin,s);



int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin>>n;
  ll dp[n+1];
  ll h[n+1];
  for(ll i=1;i<=n;i++){
    cin>>h[i];
  }
  dp[1]=dp[0] =0;
  dp[2]=abs(h[2]-h[1]);
  for(ll i =3;i<=n;i++){
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n];

  return 0;
}


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

int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int N,L;
  cin>>N>>L;
  string S[N];
  for (int i=0; i<N; i++) {
    cin>>S[i];
  }
  sort(S,S+N);
  string ans;
  for (int i=0; i<N; i++) {
    ans.append(S[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n = s.length();
    if(s[n-1]=='s')
    {
        s = s + "es";
    }
    else
    {
        s = s + "s";
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3632
package main

// ---------- template start ----------
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func maxInt(arr... int) int {
	max := -10000007
	for _, v := range arr {
		if max < v {
			max = v
		}
	}
	return max
}

func minInt(arr... int) int {
	min := 10000007
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	return min
}

type Merger func(a, b int) int

type BIT struct {
	n int
	data []int
	merge Merger
}

func (bit *BIT) update(k, w int) {
	for i:=k; i<=bit.n; i += i&-i {
		bit.data[i] = bit.merge(bit.data[i], w)
	}
}

func (bit *BIT) query(k int) int {
	ret := 0
	for i:=k; i>0; i -= i&-i {
		ret = bit.merge(ret, bit.data[i])
	}
	return ret
}

func initBIT(a []int, m Merger) *BIT {
	n := len(a)
	bit := &BIT{n : n, data : make([]int, n+1), merge : m}
	for i, v := range a {
		bit.update(i+1, v)
	}
	return bit
}

type UFTree struct {
	data []int
}

func (uft *UFTree) root(x int) int {
	if uft.data[x] == x {
		return x
	} else {
		uft.data[x] = uft.root(uft.data[x])
	}
	return uft.data[x]
}

func (uft *UFTree) same(x, y int) bool {
	return uft.root(x) == uft.root(y)
}

func (uft *UFTree) unite(x, y int) {
	x = uft.root(x)
	y = uft.root(y)
	if x == y {
		return
	}
	uft.data[x] = y
}

func initUFTree(n int) *UFTree {
	uft := &UFTree{data : make([]int, n)}
	for i:=0; i<n; i++ {
		uft.data[i] = i
	}
	return uft
}

// ---------- template end ----------


func main(){
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	var H, W, h, w int
	fmt.Scan(&H, &W)
	fmt.Scan(&h, &w)
	fmt.Println(H*W - (w*H + W*h - w*h))
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
//#include <chrono>
//#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <tuple>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;
int c[N];

int dp[N];

int bef[N], ind[N];

int main() {
	//mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 1; i <= n; i++) {
		int x = c[i];
		bef[i] = ind[x];
		ind[x] = i;
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (bef[i] != 0 && bef[i] != i - 1) {
			dp[i] += dp[bef[i]];
			dp[i] %= mod;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;
LL modd = 1000000007;

LL g[500][500], dp[500][500];
int n, c, a[500], b[500];
int main(){
	//g[i][j] = i**j
	REP(i,400){
		g[i][0] = 1;
		REP(j,400) g[i][j] = (g[i][j-1]*i)%modd;
	}
	//g[i][j] = sum_k=1^i k**j
	FOR(j,0,400) REP(i,400) g[i][j] = (g[i][j]+g[i-1][j])%modd;
	scanf("%d %d", &n, &c);
	REP(i,n) scanf("%d", &a[i]);
	REP(i,n) scanf("%d", &b[i]);
	dp[0][0] = 1;
	REP(i,n) FOR(j,0,c) FOR(k,0,j)
		dp[i][j] = (dp[i][j]+dp[i-1][k]*(g[b[i]][j-k]-g[a[i]-1][j-k])%modd+modd)%modd;
	cout << dp[n][c] << endl;
	return 0;
}


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

using namespace std;

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


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.*;
/**
 * Created by Aksenov239 on 24.09.2016.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException{
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }

    public void solve() throws IOException {
        String s = nextToken();
        out.println(s.substring(0, 4) + " " + s.substring(4, 12));
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solve();

            out.close();
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;

int mapData[10][10];

int image[3][5][5] = {
	/*Small*/
	{ { 0, 0, 1, 0, 0 },
	  { 0, 1, 1, 1, 0 },
	  { 0, 0, 1, 0, 0 } },
	//*midium*/
	{ { 0, 0, 1, 1, 1 },
	  { 0, 0, 1, 1, 1 },
	  { 0, 0, 1, 1, 1 } },
	/*large*/
	{ { 0, 0, 1, 0, 0 },
	  { 0, 1, 1, 1, 0 },
	  { 1, 1, 1, 1, 1 },
	  { 0, 1, 1, 1, 0 },
	  { 0, 0, 1, 0, 0 } },
};

bool checkImage(int y, int x, int num) {
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (mapData[y + i][x - 2 + j] - image[num][i][j] < 0) {
				return false;
			}
		}
	}
	return true;
}

void paint(int y, int x, int num) {
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			mapData[y + i][x - 2 + j] -= image[num][i][j];
		}
	}
}

void repaint(int y, int x, int num) {
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			mapData[y + i][x - 2 + j] += image[num][i][j];
		}
	}
}

bool solve(int y, int x, int n) {
	if (n < 0) {
		return false;
	}
	if (y == 10) {
		return n == 0;
	}

	if (mapData[y][x] == 0) {
		y = y + (x == 9);
		x = (x + 1) % 10;
		return solve(y, x, n);
	}

	for (int image = 0; image < 3; image++) {
		if (!checkImage(y, x, image)) {
			continue;
		}
		paint(y, x, image);
		if (solve(y, x, n - 1)) {
			cout << x + (image == 1) << " " << y + 1 + (image == 2) << " " << image + 1 << endl;
			return true;
		}
		repaint(y, x, image);
	}
	return false;
}

int main() {
	int N;

	cin >> N;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> mapData[i][j];
		}
	}
	solve(0, 0, N);

	return 0;
}


Measured memory_bytes: 3120
#include <stdio.h>


int main(void)
{
	int a[1010];
	int b[1010];
	int t[1010];
	int ans[1010];
	int i=0;
	int j=0;
	int n=0;
	a[0] = 1;
	
	for(;;)
	{
		scanf("%d",&t[j]);
		if(t[j]==0)
		{
			
			break;
			
		}
		j++;
	}
	
	
	
	
	
	a[1]=1;
	a[2]=2;
	a[3]=4;
	
	for(i=4;i<1010;i++)
	{
		
		a[i]=a[i-1]+a[i-2]+a[i-3];
		ans[i]=a[i]/3650;
	}
	
	int k,unk;
	
	
	for(k=0;k<j;k++)
	{
		printf("%d\n",ans[t[k]]+1);
	}

}

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

using namespace std;

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

	//int a[n+5];

	int dp[100005][3];
	int a[n+5],b[n+5],c[n+5];

	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	for(int i=1;i<n;i++)
	{	
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
	}

	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;

	return 0;	
}

Measured memory_bytes: 2560
#include<stdio.h>

int main() {
	int n, i, cnt;
	int a[200];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	cnt = 0;
	while (1) {
		for (i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
			}
			else {
				printf("%d", cnt);
				return 0;
			}
		}
		cnt++;
	}
}

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

const int N = 2e5 + 5;
pair< int, int> p[N];
int indx[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &p[i].first);
        p[i].second = i;
    }
    sort(p + 1, p + 1 + n);
    for (int i = 1; i <= n; ++i) indx[p[i].second] = i;
    for (int i = 1; i <= n; ++i) {
        if (indx[i] <= n / 2) printf("%d\n", p[n / 2 + 1].first);
        else printf("%d\n", p[n / 2].first);
    }
}

Measured memory_bytes: 4480
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
  }
  
  macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
  
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
  }
  
  macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
  
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
  
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
  
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
  
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
  }

const MOD:i64 = 1000000007;

fn main() {
    input!{
        n: i64,
    };
    let ans = modpow(10, n) - (modpow(9, n) *2) % MOD + modpow(8, n);
    let ans = (ans + MOD)% MOD;
    println!("{}" ,ans);
}

fn modpow(v: i64, p: i64) -> i64 {
    let mut r = 1;
    for _ in 0..p {
        r = (r * v) % MOD;
    }
    r
}

Measured memory_bytes: 2160
s=list(input())
t=list(input())
t.sort(reverse=True)
tt=sorted(t)
t=''.join(t)
tt=''.join(tt)
s.sort()
s=''.join(s)
dic=[s,t]
dic.sort()
if dic[0]==s and tt!=s:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse=True)


pairs = []

flag = True

for i in range(1, len(A)):
    if flag:
        if A[i] == A[i-1]:
            pairs.append(A[i])
            flag = False
    else:
        flag = True
        
if len(pairs) < 2:
    print(0)
else:
    print(pairs[0]*pairs[1])

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
        for ( int i = 0; i< N; i++ ) {
                for ( int j = N -1 ; j >= i + 1; j-- ) {
                        if ( A[j].value < A[j-1].value){
                                Card t = A[j]; A[j] = A[j-1]; A[j-1] = t; //std::swapがつかえない
                        }
                }
        }
}

void selection(struct Card A[], int N) {
        for ( int i = 0; i < N; i++ ) {
                int minj = i;
                for ( int j = i; j < N; j++ ) {
                        if ( A[j].value < A[minj].value ) minj = j;
                }
                Card t = A[i]; A[i] = A[minj]; A[minj] = t;
        }
}

void print (struct Card A[], int N){
        for ( int i = 0; i < N; i++) {
                if ( i > 0) cout << " ";
                cout << A[i].suit << A[i].value;
        }
        cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
        for ( int i = 0; i < N; i++ ) {
                if ( C1[i].suit != C2[i].suit ) return false;
        }
        return true;
}

int main () {
        Card C1[100], C2[100];
        int N;
        char ch;

        cin >> N;
        for ( int i = 0; i < N; i++ ) {
                cin >> C1[i].suit >> C1[i].value;
        }

        for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

        bubble(C1,N);
        selection(C2,N);

        print(C1,N);
        cout << "Stable" << endl;
        print(C2, N);
        if ( isStable(C1,C2,N)) {
                cout << "Stable" << endl;
        } else {
                cout << "Not stable" << endl;
        }
        return 0;
}



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

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

    int mul = a * b;
    if (mul % 2 == 1)
    {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

S = stdin.readline().rstrip()

lst = ['dream', 'dreamer', 'erase', 'eraser']

ans = True
while len(S) > 0:

    # print(S)

    if S[len(S) - 7:] == lst[1]:
        S = S[:len(S) - 7]
    elif S[len(S) - 6:] == lst[3]:
        S = S[:len(S) - 6]
    elif S[len(S) - 5:] == lst[0] or S[len(S) - 5:] == lst[2]:
        S = S[:len(S) - 5]
    else:
        ans = False
        break

if (ans):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =  sc.nextInt();
		long sum = 0;


		for(int i=0; i<=n;i++) {
			if(i%3==0 || i%5==0) {
			}
			else{
				sum += i;
			}
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1e9+7;
using namespace std;
typedef pair<int,int> pii;
int main(){
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(sc.nextLong());
        }
        long min = Collections.min(list);
        if(min >= n) {
            System.out.println(5);
        } else {
            long tmp = (n % min);
            long ans = 0;
            if(tmp != 0) {
                ans = (n / min) + 5;
            } else {
                ans = (n / min) + 4;
            }
            System.out.println(ans);
        }
    }
}

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

const char NL = '\n';
const int MOD = 1e9 + 7;

void solve()
{
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> dp(n);
    dp[1] = abs(v[0] - v[1]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2])); 
    }
    cout << dp[n - 1] << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=1e5+5,U=1e9;
bool ok;
struct BING
{
int n,last[N],lastv[N];
int fa[N];s64 d[N],mn[N];
void init(int r,int c)
{
	n=r;
	rep(i,1,c)last[i]=0;
	rep(i,1,r){fa[i]=i;d[i]=0;mn[i]=0;}
}
void find(int x)
{
	if(fa[x]==x)return ;
	find(fa[x]);
	d[x]+=d[fa[x]];
	fa[x]=fa[fa[x]];
}
void merge(int x,int y,s64 dx)
{
	find(x);find(y);
	dx=dx-d[x]+d[y];
/*	if(!(d[x]>=-U&&d[x]<=U))
	{
		cerr<<"d[x]="<<d[x]<<endl;
		exit(0);
	}
	if(!(dx>=-U&&dx<=U))
	{
		cerr<<"dx="<<dx<<endl;
		exit(0);
	}*/
	x=fa[x];y=fa[y];
	//cerr<<x<<" "<<y<<" "<<dx<<endl;
	if(x==y){ok&=dx==0;return ;}
	fa[x]=y;d[x]=dx;
}
void ins(int x,int y,int a)
{
	//assert(a==0||a==U);
	if(!last[y])
	{
		last[y]=x;lastv[y]=a;
		return ;
	}
	merge(x,last[y],a-lastv[y]);
}
void init_mn()
{
	rep(i,1,n)
	{
		find(i);
		chmin(mn[fa[i]],d[i]);
	}
}
s64 get_mn(int x)
{
	return -d[x]+mn[fa[x]];
}
};
BING b[2];
struct Point
{
	int x,y,a;
};
Point p[N];

int main()
{
#ifdef kcz
	freopen("1.in","r",stdin);
#endif
	int tt=1;
//	cin>>tt;
	while(tt--)
	{
		ok=1;
		int r,c,n;
		scanf("%d%d%d",&r,&c,&n);
		b[0].init(r,c);
		b[1].init(c,r);
		rep(i,1,n)
		{
			int x,y,a;
			scanf("%d%d%d",&x,&y,&a);
			p[i]=(Point){x,y,a};
			b[0].ins(x,y,a);
			b[1].ins(y,x,a);
		}
		b[0].init_mn();
		b[1].init_mn();
		rep(i,1,n)
		{
		//	cerr<<p[i].a+b[0].get_mn(p[i].x)+b[1].get_mn(p[i].y)<<endl;
			ok&=p[i].a+b[0].get_mn(p[i].x)+b[1].get_mn(p[i].y)>=0;
		}
		puts(ok?"Yes":"No");
	}
}

Measured memory_bytes: 6912