akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n, dr;

int main(){
	IOS
	cin >> n >> dr;
	if(n>=10){
		cout << dr << '\n';
	}
	else{
		cout << dr+(1000-100*n) << '\n';
	}
}

Measured memory_bytes: 3620
/* 
 * Author: aps
 * Time: 2020-06-22 17:53:39
**/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
 
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll gcd(ll x, ll y) { return x == 0 ? y : gcd(y % x, x); }
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, full_xor = 0; cin >> n;
    vi a(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
        full_xor ^= a[i];
    }
    for(int i=0; i<n; i++) {
        a[i] = full_xor ^ a[i];
        cout << a[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int n;
char a[15];
void DFS(int now,int lst,int maxx){
	if(now==n){
		cout<<a<<endl;
		return ;
	}
	for(int i='a';i<=now+'a'&&i<=maxx+1;i++)a[now]=i,DFS(now+1,i,max(maxx,i));
}
int main(){
	cin>>n;
	DFS(0,'a'+n-2,'a'-1);
}

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

string s;
int cnt = 0;

void solve(string t){
  if(t.size() == 3){
    int ret = s[0]-'0';
    for(int i = 0; i < 3; i++){
      if(t.at(i) == '+') ret += s[i+1]-'0';
      else ret -= s[i+1]-'0';
    }
    if(ret == 7 && cnt == 0){
      cnt++;
      for(int i = 0; i < 3; i++){
        cout << s[i] << t[i];
      }
      cout << s[3] << "=7" << endl;
    }
    return;
  }
  string res = t;
  solve(res + "+");
  solve(res + "-");
  return;
}

int main(){
  cin >> s;
  solve("");
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#define _USE_MATH_DEFINES
#define ln long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

int max(int *ary) {
	int max = 0;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int nmax(int *ary) {
	int max = 0, num;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) {
			max = ary[i];
			num = i;
		}
	return max, num;
}

int main() {
	int w, a, b, ans = 0;
	cin >> w >> a >> b;
	if (a < b)
		ans = b - (a + w);
	else if (a > b)
		ans = a - (b + w);
	if (ans < 0)
		ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#//include <ext/pb_ds/assoc_container.hpp>
#//include <ext/pb_ds/tree_policy.hpp>
#//include <ext/pb_ds/detail/standard_policies.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//insert(), find_by_order(), order_of_key()
typedef long long int ll;
typedef unsigned long long int llu;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define ref(i,n) for(int i=0;i<n;++i)
#define rer(i,n) for(int i=n;i>=0;--i)
#define refv(i,n,k) for (int i = k; i <= n; ++i) 
#define rerv(i,n,k) for (int i = k; i >= n; --i) 
#define fi first
#define priority_queue_2 priority_queue <int, vector<int>, greater<int> >
#define se second
#define fast1 ios_base::sync_with_stdio(false)
#define fast2 cin.tie(NULL)
inline void pin(int n) { printf("%d\n",n);}
#define onec(x) __builtin_popcount(x);
#define all(x) x.begin(),x.end()
double PI = acos(-1);
const int inf =  0x3f3f3f3f;
#define sv()  int t; scanf("%d",&t); while(t--)
#define MOD 1000000007
#define TRACE
#ifdef TRACE
#define trace1(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif
ll StoI(string &s){ll sum=0;for(ll i=0; i<s.size(); i++){s[i]-='0';sum=sum*10+s[i];}return sum;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
int main()
{
    ll a, p;
    cin >> a >> p;   
    ll m= a*3 + p;
    m/=2;
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(M);
  REP(i, M) cin >> A[i];
  sort(ALL(A), greater<>());

  vector<int> cnt = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  // i本だけ使って作れる最大の桁数
  vector<int> dp(N+1, -INF);
  dp[0] = 0;
  REP(i, N) for(int j : A){
    if(i+cnt[j] <= N) chmax(dp[i+cnt[j]], dp[i]+1);
  }

  while(N != 0) for(int j : A){
    if(N-cnt[j] >= 0) if(dp[N] == dp[N-cnt[j]]+1){
      N -= cnt[j];
      cout << j;
      break;
    }
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-

N,M = map(int, input().split())
load_num = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    load_num[a-1] += 1
    load_num[b-1] += 1

for i in range(N):
    print(load_num[i])

Measured memory_bytes: 9168
n = int(input())
a = [int(i) for i in input().split()]

mod = 10 ** 9 + 7
fac = [1]
inv = [1]
for i in range(1, n + 2) :
    fac.append(fac[-1] * i % mod)
    inv.append(pow(fac[-1], mod-2, mod))

visited = [-1] * (n + 1)
for i, aa in enumerate(a) :
    if visited[aa] < 0 :
        visited[aa] = i
    else :
        l, r = visited[aa], i
        break

def comb(n, r) :
    if n < r or r < 0 :
        return 0
        
    return fac[n] * inv[n-r] * inv[r] % mod

for i in range(1, n + 2) :
    print((comb(n+1, i)-comb(n+l-r, i-1))%mod)

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

void koch(int d, pair<double, double> p1, pair<double, double> p2);
double tri = M_PI * 60.0 / 180.0;

int main(){
    int n;
    cin >> n;
    pair<double, double> p1 = make_pair(0.0, 0.0);
    pair<double, double> p2 = make_pair(100.0, 0.0);
    printf("%.8f %.8f\n", p1.first, p1.second);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.first, p2.second);
}

void koch(int d, pair<double, double> p1, pair<double, double> p2){
    if(d == 0) return;

    // s,u,tを計算
    pair<double, double> s,u,t;
    s.first = (2.0 * p1.first + 1.0 * p2.first) / 3.0;
    s.second = (2.0 * p1.second + 1.0 * p2.second) / 3.0;

    t.first = (1.0 * p1.first + 2.0 * p2.first) / 3.0;
    t.second = (1.0 * p1.second + 2.0 * p2.second) / 3.0;

    u.first = (t.first - s.first) * cos(tri) - (t.second - s.second) * sin(tri) + s.first;
    u.second = (t.first - s.first) * sin(tri) + (t.second - s.second) * cos(tri) + s.second;

    koch(d-1, p1, s);
    printf("%.8f %.8f\n", s.first, s.second);

    koch(d-1, s, u);
    printf("%.8f %.8f\n", u.first, u.second);

    koch(d-1, u, t);
    printf("%.8f %.8f\n", t.first, t.second);

    koch(d-1, t, p2);

}


Measured memory_bytes: 3348
#include<stdio.h>
int main(void){
  int n,c;
  int a[100][100],b[100]={},d=0,e[100]={};
  int i,j;
  scanf("%d %d",&n,&c);
  for(i=0;i<n;i++){
    for(j=0;j<c;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<c;j++){
      printf("%d ",a[i][j]);
      b[i] += a[i][j];
    }
    printf("%d\n",b[i]); 
    d += b[i];
  }
  
  for(i=0;i<c;i++){
    for(j=0;j<n;j++){
      e[i] += a[j][i];
    }
    printf("%d ",e[i]);
  }
  
  printf("%d\n",d);
  return(0);
}

Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
void low(char &c){
c=tolower(c);
}
void primeFactors(int n)
{
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n/2;
    }

    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            cout << i << " ";
            n = n/i;
        }
    }

    if (n > 2)
        cout << n << " ";
}

#include <iostream>
using namespace std;
void fast();
int arr[100005];
map <string,int> M;
map <int,string> M1;
int main() {
fast();
int n,t;
string s;
cin >> n;
int mx=0;
for(int i=0;i<n;i++){
    cin >>s;
    M[s]++;
    mx = max(M[s],mx);
}
for (map<string,int>::iterator it=M.begin(); it!=M.end(); ++it){
    if( it->second == mx)
    cout << it->first <<'\n';
}


}





void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

}


Measured memory_bytes: 23808
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a==1&&b==2||a==2&&b==1) System.out.println(3);
    if(a==1&&b==3||a==3&&b==1) System.out.println(2);
    if(a==2&&b==3||a==3&&b==2) System.out.println(1);
  }
}


Measured memory_bytes: 19796
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
int i[1100000];
int y[1100000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=1,g=0;
  cin >>a;
  for(int n=0;n<a;n++) cin >>i[n];
  for(int n=0;n<a;n++) cin >>g,d+=g;
  for(int n=0;n<a-1;n++) cin >>y[n];
  e=i[0]+1;
  for(int n=1;n<a;n++){
    if(e==i[n]) d+=y[i[n]-2];
    e=i[n]+1;
  }
  cout <<d<<'\n';
  return (0);
}


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

using namespace std;

#define ll long long

signed main() {
	int t1, t2;
	ll a1, a2, b1, b2;
	cin >> t1 >> t2;
	cin >> a1 >> a2;
	cin >> b1 >> b2;

	// 青木君がずっと原点にいるとして考える.
	a1 -= b1; a2 -= b2;
	if (a1 * t1 + a2 * t2 == 0)
		cout << "infinity" << endl;
	else if (a1 < 0 && a2 < 0)
		cout << 0 << endl;
	else if (a1 > 0 && a2 > 0)
		cout << 0 << endl;
	else if (abs(a1 * t1) > abs(a2 * t2))
		cout << 0 << endl;
	else {
		// b戻ってf進む、を繰り返す(b < f)
		ll b = abs(a1 * t1);
		ll f = abs(a2 * t2);
		if (b % (f - b))
			cout << (2 * (b / (f - b)) + 1) << endl;
		else
			cout << (2 * (b / (f - b))) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static String solve(int N, int K, int[] a) {
        boolean[] win = new boolean[K + 1];
        for (int i = 0; i < K; i++) {
            if (win[i]) continue;

            for (int j = 0; j < N; j++) {
                int newAmount = i + a[j];
                if (newAmount <= K) win[newAmount] = true;
            }
        }
        return win[K] ? "First": "Second";
    }

    public static String run(Scanner scanner) {
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] a = new int[N];
        for (int i=0; i < N; i++) a[i] = scanner.nextInt();

        return solve(N, K, a);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, W;
ll w[100];
ll v[100];
ll dp[100][100005];

int main()
{
	cin >> n >> W;
	for (int i = 0;i < n;i++) {
		cin >> w[i] >> v[i];
	}
	dp[0][w[0]] = v[0];
	for (int i = 1;i < n;i++) {
		for (int j = 0;j <= W;j++) {
			if (j - w[i] >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	ll ans = 0;
	for (int i = 0;i <= W;i++) {
		ans = max(ans, dp[n - 1][i]);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 77568
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
char s[50];
int main()
{
	scanf("%s",s+1);int str=strlen(s+1);
	for(int i=1;i<=str-8;i++)
	{
		printf("%c",s[i]);
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    _  <- fst . fromJust . B.readInteger <$> B.getLine
    ns <- map (fst . fromJust . B.readInteger) . B.words <$> B.getLine
    let n = (\n -> n-1) . foldr lcm 1 $ ns
    print . sum . map (mod n) $ ns

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,L,num;
  cin>>N>>L;
  vector<string> vec(N);
  vector<int> order(N);
  for(int i=0;i<N;i++)
    cin>>vec.at(i);
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(vec.at(i)>vec.at(j))
        num++;
    }
    order.at(i)=num;
    num=0;
  }
  for(int i=0;i<N;i++){
   for(int j=0;j<N;j++){
     if(order.at(j)==i){
      cout<<vec.at(j);
     }
   }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int n,x;
    int a,b,c;
    int ans;

    while(1){
        scanf("%d %d", &n, &x); 
        if(n==0 && x==0){ 
            break;
        }
        ans = 0;
        
        for(a=1; a<=n; a++){ //どこからどこまでかが重要
            for(b=a+1; b<=n; b++){//どこからどこまでかが重要
                for(c=b+1; c<=n; c++){
                    if(x == a+b+c ) ans++;
                    //printf("%d %d %d %d %d\n",ans , a+b+c, a,b,c);
                }
            }
        }
        
        printf("%d\n",ans);
    }

    return 0;
}


Measured memory_bytes: 2096
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================
signed main() {
	ll n;
	cin >> n;
	VL v(n);
	cin >> v;


	ll ans = 0;
	FOR(i, 1, n - 1) {
		if ((v[i - 1] < v[i] && v[i] < v[i + 1]) ||
			(v[i + 1] < v[i] && v[i] < v[i - 1])) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> D;
  Vec(C,lli,26,0);
  rep(i,0,26)cin >> C[i];
  DV(A,lli,D,26,0);
  rep(i,0,D)rep(j,0,26)cin >> A[i][j];
  Vec(B,lli,D,0);
  rep(i,0,D)cin >> B[i];
  Vec(last,lli,26,-1);
  rep(i,0,D){
    sum+=A[i][B[i]-1];
    last[B[i]-1]=i;
    rep(j,0,26)sum-=C[j]*(i-last[j]);
    Out(sum);
  }
}


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

using namespace std;

namespace {

    typedef long long Long;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << "," << vs[i];
        return os << "]";
    }

    string s;
    void input() {
        cin >> s;
    }

    vector<string> ops; /* levelと演算子の対応. levelが大きいほど優先度が高い. */
    Long number(const string& s, int& index) {
        Long r = 0;
        while (index < s.size() && isdigit(s[index])) {
            r = r * 10 + (s[index] - '0');
            index++;
        }
        return r;
    }

    bool check(char op, int level) {
        // opが当該levelの演算子かどうかを返す
        for (int i = 0; i < ops[level].size(); i++) {
            if (op == ops[level][i]) return true;
        }
        return false;
    }

    Long calc(char op, Long a, Long b) {
        if (op == '+') return a + b;
        if (op == '-') return a - b;
        if (op == '*') return a * b;
        assert(0);
    }

    Long parse(const string& s, int& index, int level) {
        if (level == 3) {
            if (s[index] == '(') {
                index++;
                Long r = parse(s, index, 0);
                assert(s[index] == ')');
                index++;
                return r;
            }
            return number(s, index);
        }
        Long r = parse(s, index, level + 1);
        while (index < s.size() && check(s[index], level)) {
            char op = s[index];
            index++;
            Long a = parse(s, index, level + 1);
            r = calc(op, r, a);
        }
        return r;
    }

    const Long INF = LLONG_MIN;

    void solve() {
        // 各演算子のlevelに対して全探索.
        string t = "+-*";
        sort(t.begin(), t.end());
        Long ans = -INF;
        for (int a = 0; a < 3; a++) {
            for (int b = 0; b < 3; b++) {
                for (int c = 0; c < 3; c++) {
                    for (int i = 0; i < 4; i++) {
                        ops.clear(); ops.resize(3);
                        ops[a].push_back(t[0]);
                        ops[b].push_back(t[1]);
                        ops[c].push_back(t[2]);
                        int index = 0;
                        ans = max(ans, parse(s, index, 0));
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 1220
def main():
  n =int(input())
  A = list(map(int, input().split()))

  if 0 in A:
    print(0)
    return

  p = 1
  for a in A:
    p *= a
    if p > 10 ** 18:
      print(-1)
      return

  print(p)
main()

Measured memory_bytes: 21784
while True:
    m, f ,r = map(int,input().split())
    if m + f + r == -3:
        exit()
    res = ""
    p = m + f
    if (30 > p) or m == -1 or f == -1:
        res = "F"
    elif p >= 80:
        res = "A"
    elif 80 > p >= 65:
        res = "B"
    elif (65 > p >= 50) or ((50 > p >= 30) and r >= 50):
        res = "C"
    elif 50 > p >= 30:
        res = "D"

    print(res)


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

using namespace std;
typedef long long ll;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    ll a, b, t, n, m, k;
    cin >> n;
    vector<double> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    double dp[n][n];
    dp[0][0]=1-p[0];
    dp[0][1]=p[0];
    for(int i=1;i<n;i++){
        dp[i][0]=dp[i-1][0]*(1-p[i]);
        dp[i][i+1]=dp[i-1][i]*(p[i]);
        
        for(int j=1;j<=i;j++){
        dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*(p[i]);
        }
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n-1][i];
    }
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 70400
#B問題
N = int(input())
W = list(map(int,input().split()))
SUM = sum(W)
s = [0]
for i in range(N):
    s.append(s[-1]+W[i])
for j in range(N+1):
    s[j] = abs((SUM-s[j])-s[j])
print(min(s))

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

const ll mod = 1000000007;

const int MAX = 200000+1;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
    ll n, k;
    cin >> n >> k;

    COMinit();
    ll ans = 0;
    for(int i=0; i<=min(n, k); i++){
        // cout << COM(n, i) << " " << COM(2*n-i-1, n) << endl;
        ans += COM(n, i) * COM(n-1, i) % mod;
        ans %= mod;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a*b%2==0) {
        cout << "Even" << endl;
        return 0;
    } else {
        cout << "Odd" << endl;
        return 0;
    }
}

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

using namespace std;

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

int solve(string str){
  int res = 100000000;
  set<string> vis;
  string u, v;
  queue<string> q;
  vis.insert(str);
  q.push(str);
  while(!q.empty()){
    u = q.front(); q.pop();
    int cnt = 0;
    for(int i=0;i<20;i++){
      if(u[i] != '0') cnt++;
    }
    res = min(res, cnt);
    for(int i=0;i<5;i++){
      for(int j=0;j<4;j++){
        if(u[i*4+j] == '0') continue;
        for(int k=0;k<8;k++){
          int ny = i + dy[k];
          int nx = j + dx[k];
          if(ny < 0 || ny >= 5) continue;
          if(nx < 0 || nx >= 4) continue;
          if(u[i*4+j] != u[ny*4+nx]) continue;
          v = "";
          for(int l=0;l<20;l++){
            if(l == i*4+j || l == ny*4+nx) continue;
            v += u[l];
          }
          v += '0';
          v += '0';
          if(vis.find(v) == vis.end()){
            vis.insert(v);
            q.push(v);
          }
        }
      }
    }
  }
  return res;
}

main(){
  int T;
  cin >> T;
  while(T--){
    string str;
    for(int i=0;i<5;i++){
      for(int j=0;j<4;j++){
        char c;
        cin >> c;
        str += c;
      }
    }
    cout << solve(str) << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
ll calc(ll i,ll a){
  ll num = a;
  //cout<<num<<endl;
  ll hoge=num/(BITLE(i+1));
  // cout<<i<<" "<<num<<endl;
  if(num%BITLE(i+1) < BITLE(i)){}
  else{
    hoge+=num%(BITLE(i+1));
  }
  // cout<<i<<" "<<num<<endl;
  return hoge;
  //else return 0;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  ll ans=0;
  ll sum[64]={};
  ll bcnt=0;
  ll acnt=0;
  ll nb=b;
  while(nb>0){
    bcnt++;
    nb/=2;
  }
  ll na=a-1;
  while(na>0){
    acnt++;
    na/=2;
  }
  ll sumb=0;
  for(ll i=bcnt-1;i>=0;i--){
    if((BITLE(i))&(b)){
      for(ll j=0;j<i;j++){
	sum[j]+=BITLE(i-1);
      }
      sumb+=BITLE(i);
      sum[i]+=b-sumb+1;
    }
  }
  /* for(int i=0;i<60;i++)
    cout<<sum[i]<<" ";
    cout<<endl;*/
  ll suma=0;
  for(ll i=acnt-1;i>=0;i--){
    if(BITLE(i)&(a-1)){
      for(ll j=0;j<i;j++){
	sum[j]-=BITLE(i-1);
      }
      suma+=BITLE(i);
      sum[i]-=a-suma;
    }
  }
  for(ll i=0;i<60;i++)
    if(sum[i]%2)ans+=BITLE(i);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[5];

	scanf("%s", s);

	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {//1文字目と2文字目、3文字目と4文字目が同じ
		printf("Yes\n");
	}
	else if (s[0] == s[2] && s[2] != s[1] && s[1] == s[3]) {//1文字目と3文字目、2文字目と4文字目が同じ
		printf("Yes\n");
	}
	else if (s[0] == s[3] && s[3] != s[1] && s[1] == s[2]) {//1文字目と4文字目、2文字目と3文字目が同じ
		printf("Yes\n");
	}
	else {//条件に合わない
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	ll ans = 0;
	repn(i, 1, n) ans += min(b, a * (x[i] - x[i - 1]));
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/

Measured memory_bytes: 1024
r,c = map(int,input().split())
num = [list(map(int,input().split())) for _ in range(r)]

for i in range(r):
        num[i].append(sum(num[i]))

num2=[0]*(c+1)
for i in range(c+1):
    for j in range(r):
        num2[i]+=num[j][i]

for i in range(r):
    print(*num[i])
print(*num2)

        
        

    


    
    


Measured memory_bytes: 6228
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

int M;
int p[200001];
int now[200001];
int T[200001];
int f[200001];
int main(){
    cin>>M;
    REP(i,M){
       cin>>p[i];
       now[p[i]]=i;
    }
    T[M]=0;
    for(int i=M-1;i>=1;i--){

        if(T[i+1]==0){
           //cout<<i+1<<"aa "<<i<<endl;
           if(now[i+1]<now[i]){
              T[i]=1;
              f[i]=i+1;
           }else{
              T[i]=0;
              f[i]=i;
           }
        }else{
           //cout<<now[f[i+1]]<<" "<<now[i]<<" "<<now[i+1]<<endl;
           if((now[f[i+1]]<now[i]&&now[i]<now[i+1])||
              (now[i]<now[i+1]&&now[i+1]<now[f[i+1]])||
              (now[i+1]<now[f[i+1]]&&now[f[i+1]]<now[i])){
              T[i]=T[i+1];
              f[i]=f[i+1];
           }else{
              T[i]=T[i+1]+1;
              if(now[i]<now[i+1]){
                 f[i]=i+1;
              }else{
                 f[i]=i+1;
              }
           }
        }
        //cout<<now[f[i]]<<now[f[i+1]]<<endl;
    }
    
    
    cout<<T[1]<<endl;
    
    return(0);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,ans[8];
int main()
{
    cin >> n;
    if (n == 3){
        cout << "2 5 63";
    }
    else{
    if(n % 2 == 1)
        ans[0]=6,ans[1]=2,ans[2]=10,ans[3]=3,ans[4]=9,ans[5]=4,ans[6]=8,ans[7]=12;
    else
        ans[0]=2,ans[1]=10,ans[2]=3,ans[3]=9,ans[4]=4,ans[5]=8,ans[6]=6,ans[7]=12;
    for(int i = 0; i < min(8 , n); i++) cout << ans[i] << " ";
    for(int i = 8; i < n; i++) ans[i % 8] += 12 , cout << ans[i%8] << " ";
    return 0;}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

void solve() {
	int n, m;
	cin >> n >> m;
	vi a(m);
	ll sum = 0;
	for(int i = 0; i < m; i++) cin >> a[i], sum += a[i];
	
	if(sum > n) cout << -1 << endl; else cout << n - sum << endl;
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

int main(){
	int n; scanf("%d",&n);
	vector<int> x(n);
	rep(i,n) scanf("%d",&x[i]);

	mint ans=1;
	int m=1;
	x[0]=1;
	for(int i=1;i<n;i++){
		if(x[i-1]+2<=x[i]){
			x[i]=x[i-1]+2;
			m++;
		}
		else{
			x[i]=x[i-1];
			ans*=m+1;
		}
	}
	ans*=fact(m);
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 4028
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
  char X[4]={'A','C','G','T'};
  bool flag=false;char c;ll M=0,count=0;while(cin>>c){
    REP(i,4)if(c==X[i])flag=true;
    if(flag){
      count++;
      if(count>M)M=count;
    }else count=0;
    flag=false;
  }
  cout<<M;
  return 0;
}

Measured memory_bytes: 256
S = list(input())
N = 0
num = 0
answer = False

if S[0] == 'A':
    del S[0]
    for i in range(1, len(S)-1):
        if S[i] == 'C':
            num += 1
            N = i
    if num == 1:
        del S[N]
        SS = ''.join(S)
        answer = SS.islower()
        
if answer == True:
    print('AC')
elif answer == False:
    print('WA')

Measured memory_bytes: 3064
# dp[i][t_sum]: i番目までの品物で時間がt_sumを超えないように選んだときの、満足度の総和の最大値
N, T = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

dp1 = [[0 for t_sum in range(T+1)] for i in range(N+2)]
dp2 = [[0 for t_sum in range(T+1)] for i in range(N+2)]

for i in range(N):
    for t_sum in range(T+1):
        if t_sum-items[i][0] >= 0:
            dp1[i+1][t_sum] = max(dp1[i+1][t_sum], dp1[i]
                                  [t_sum-items[i][0]]+items[i][1])
        dp1[i+1][t_sum] = max(dp1[i+1][t_sum], dp1[i][t_sum])

    for t_sum in range(T+1):
        if t_sum-items[N-1-i][0] >= 0:
            dp2[N-1-i][t_sum] = max(dp2[N-1-i][t_sum], dp2[N-i]
                                    [t_sum-items[N-1-i][0]]+items[N-1-i][1])
        dp2[N-1-i][t_sum] = max(dp2[N-1-i][t_sum], dp2[N-i][t_sum])


ans = 0
for i in range(N):
    for t in range(T):
        ans = max(ans, dp1[i][t]+dp2[i+1][T-1-t]+items[i][1])
print(ans)


Measured memory_bytes: 195844
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int dp[n+1][3];
   int a[n+1][3];
   for(int i=1;i<=n;i++)
   {cin>>a[i][0]>>a[i][1]>>a[i][2];}
   dp[1][0]=a[1][0];
   dp[1][1]=a[1][1];
   dp[1][2]=a[1][2];
   for(int i=2;i<=n;i++)
   {
       dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
   }
   cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}


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

#define EB emplace_back
#define int long long
#define F first
#define S second
//#define N 500005a
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

bool is_prime(int x){
  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }
  return true;
}
const int N = 1e6 + 10;
int mp[N] = {};

int32_t main(){
  IOS;
  int tt = 1; 
  //cin >> tt;
  while(tt--){
    int n; cin >> n;
    int A[n];
    
    vector < int > primes;
    for(int i = 2; i < 1100; i++){
      if(is_prime(i)) primes.EB(i);
    }
   
    int g = 0;
    for(int i = 0; i < n; i++) {
      cin >> A[i];
      g = __gcd(A[i], g);
      if(A[i] == 1) continue;
      bool ok = true;
      for(auto x : primes){
        if(A[i] % x == 0){
          ok = false;
          mp[x]++;
          if(A[i] / x != x && x != A[i]){
            mp[A[i] / x]++;
          }
        }
      }
      if(ok) mp[A[i]]++;
      
    }
    bool flag = true;
    
    for(auto x : mp){
      if(x > 1){
        flag = 0;
        break;
      }
    }
    
    if(flag) {
      cout << "pairwise coprime" << endl;
      break;
    }
    
    if(g == 1) {
      cout << "setwise coprime" << endl;
      break;
    }
    
    cout << "not coprime";
  
  }
  return 0;
}


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


void solve(long long N, std::vector<long long> A){
    sort(A.begin(), A.end());
    __float128 ans = 1;
    for (auto a: A) {
        ans *= a;
        if (ans > (__float128)1e18L) {
            cout << -1 << endl;
            return;
        }
    }
    cout << (long long)ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4076
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6 + 1];
		array[0] = 0;
		for (int i = 1; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		int q = scan.nextInt();
		Dice dice = new Dice(array);
		int part1; int part2;
		for (int i = 0; i < q; i++) {
			part1 = scan.nextInt();
			part2 = scan.nextInt();
			System.out.println(dice.check(part1, part2));
		}
		scan.close();
	}
}
	

class Dice {
	private int[] num = new int[6 + 1];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(String order) {
		int now_1 = 1;	int now_2 = 2;	int now_3 = 3;	int tmp;
		int[] array = getNum();
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 7 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 7 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 7 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 7 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[1] = array[now_1]; cp_array[2] = array[now_2];
		cp_array[3] = array[now_3]; cp_array[4] = array[7 - now_3];
		cp_array[5] = array[7 - now_2]; cp_array[6] = array[7 -now_1];
		return cp_array;
	}
	
	// 1?????????????????????????¨?????????????????????????
	public int[] turn(int[] array) {
		int tmp;
		tmp = array[2];
		array[2] = array[3];
		array[3] = array[5];
		array[5] = array[4];
		array[4] = tmp;
		
		return array;
	}
	
	// 3?????¨?????????????????????
	public int check(int part1, int part2) {
		String[] str = {"null", "N", "NN", "S", "W", "E"};
		int sum = 0;
		int[] array = new int[num.length];
		for (int i = 0; i < num.length; i++) {
			array[i] = num[i];
		}
		boolean decision = false;
		for (int i = 0; i < str.length; i++) {
			array = this.roll(str[i]);
			for (int j = 0; j < 4; j++) {
				if (array[1] == part1)
					if (array[2] == part2) {
						sum = array[3];
						decision = true;
						break;
					} else {
						array = this.turn(array);
					}
			}
			if (decision) break;
		}
		

		return sum;
	}
}

Measured memory_bytes: 26180
#include <math.h>
#include <stdio.h>

#include <iostream>
#include <numeric>
#include <string>

using namespace std;

int main() {
    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;
        double p[1000] = {};
        for (int i = 0; i < n; i++) {
            cin >> p[i];
        }
        double ave;
        ave = accumulate(begin(p), end(p), 0.0) / n;

        double x_d[1000] = {};
        for (int i = 0; i < n; i++) {
            x_d[i] += pow(p[i] - ave, 2);
        }
        double s;
        s = sqrt(accumulate(begin(x_d), end(x_d), 0.0) / n);

        cout << s << endl;
    }
}


Measured memory_bytes: 3296
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long AlphaNum = 27;




int main()
{
  string s, t;
  cin >> s;
  cin >> t;
  // pair<string, string> st = make_pair(s, t);


  // for (int i = 0; i < s.size(); ++i) {
  //   if (s[i] == t[i]) {
  //     s.erase(i , 1);
  //     t.erase(i, 1);
  //     i--;
  //   }
  // }

  // cerr << s << endl;
  // cerr << t << endl;

  vector<int> c_s(27, 0);
  vector<int> c_t(27, 0);

  for (int i = 0; i < s.size(); ++i) {
    c_s[ s[i] - 'a' ]++;
    c_t[ t[i] - 'a' ]++;
  }

  //それぞれの文字をカウントが多い順に並び替え
  sort(c_s.begin(),c_s.end(), greater<int>());
  sort(c_t.begin(),c_t.end(), greater<int>());

  

  //多い順の文字の出現回数が同じならoK
  bool ans = true;
  for (int i = 0; i < c_s.size(); ++i){
    if (c_s[i] != c_t[i])ans=false;
  }


  cout << (ans ? "Yes" : "No");



  return 0;
}



























Measured memory_bytes: 776