akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#define MAXN 5005
#define INF 0x3f3f3f3f3f3f3f3f
using namespace std;

int n;
long long dp[MAXN][MAXN][2];
pair<int, int> v[MAXN];

bool Comp(pair<int, int> a, pair<int, int> b) {
    return a.first + a.second > b.first + b.second;
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d %d", &v[i].first, &v[i].second);
    }

    sort(v + 1, v + n + 1, Comp);

    for(int l = 0; l <= n; ++l) {
        for(int r = 0; l + r <= n; ++r) {
            for(int c = 0; c <= 1 && l + r + c <= n; ++c) {
                if(l == 0 && r == 0 && c == 0) continue;

                int L = v[l + r + c].first;
                int R = v[l + r + c].second;
                int X = L + R;

                dp[l][r][c] = INF;
                if(l > 0)
                    dp[l][r][c] = min(dp[l][r][c], dp[l - 1][r][c] + R + 1LL * (l - 1) * X);
                if(r > 0)
                    dp[l][r][c] = min(dp[l][r][c], dp[l][r - 1][c] + L + 1LL * (r - 1) * X);
                if(c > 0)
                    dp[l][r][c] = min(dp[l][r][c], dp[l][r][c - 1] + 1LL * n / 2 * X);
            }
        }
    }


    printf("%lld\n", ((n % 2) ? dp[n / 2][n / 2][1] : dp[n / 2][n / 2][0]));

    return 0;
}

Measured memory_bytes: 215296
<?php
fscanf(STDIN, "%s", $s );
$ans = 0;

if(substr($s, 0, 1)== "A"){
  
  if(substr_count($s, "C")==1){
  if(strpos($s, "C") >= "2" && strpos($s, "C")+1 < strlen($s)){
    
    $srep = str_replace("A", "", $s);
    $srep = str_replace("C", "", $srep);
    
    if(ctype_lower($srep)==true){
    $ans =1;
    }
  }}
}

if($ans==1) echo "AC";
else echo "WA";
 ?>

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

ll f(ll s, ll acc, ll sum,vector<ll>&ds) {
  if(s==ds.size()-1) {
    return 10*acc+ds[s]+sum;
  }
  return f(s+1,0,sum+10*acc+ds[s],ds)+f(s+1,10*acc+ds[s],sum,ds);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  vector<ll> ds(s.size());
  rep(i,s.size()) {
    ds[i] = static_cast<ll>(s[i]-'0');
  }
  cout << f(0,0,0,ds) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
signed main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll n, c; cin >> n >> c;
  vector<ll> a(n), b(n);
  for(ll i=0;i<n;++i) {
    cin >> a[i];
  }
  for(ll i=0;i<n;++i) {
    cin >> b[i];
  }
  vector<vector<ll>> pow(401, vector<ll>(401, 0));
  for(ll i=1;i<=400;++i) {
    ll now = 1;
    for(ll j=0;j<=400;++j) {
      pow[i][j] = now;
      now *= i;
      now %= MOD;
    }
  }
  vector<vector<ll>> su(401, vector<ll>(401, 0));
  for(ll j=0;j<=400;++j) {
    for(ll i=1;i<=400;++i) {
      su[i][j] = su[i-1][j] + pow[i][j];
      su[i][j] %= MOD;
    }
  }
  vector<vector<ll>> dp(n+1, vector<ll>(401));
  dp[0][0] = 1;
  for(ll i=0;i<n;++i) {
    for(ll j=0;j<=400;++j) {
      for(ll k=j;k>=0;--k) {
        dp[i+1][j] += dp[i][j-k] * (((su[b[i]][k] - su[a[i]-1][k]) + 2 * MOD) % MOD) % MOD;
        dp[i+1][j] %= MOD;
      }
    }
  }
  cout << dp[n][c] << endl;
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;

class A2{
  public static void Main(){
    int max = -1,A_int;
    string A;
    Stack<string> stack = new Stack<string>();
    string[] str = Console.ReadLine().Split(' ');
    for(int i = 0;i < str.Length;i++){
      if(str[i] == "+"){
        A_int = int.Parse(stack.Pop()) + int.Parse(stack.Pop());
        A = A_int.ToString();
        stack.Push(A);
      }
      else if(str[i] == "-"){
        A_int = (-1) * int.Parse(stack.Pop()) + int.Parse(stack.Pop());
        A = A_int.ToString();
        stack.Push(A);
      }
      else if(str[i] == "*"){

        A_int = int.Parse(stack.Pop()) * int.Parse(stack.Pop());
        A = A_int.ToString();
        stack.Push(A);
      }
      else{
      stack.Push(str[i]);
      max++;
      }
    }
      Console.WriteLine(stack.Pop());
  }
}



Measured memory_bytes: 10072
n,m = map(int,input().split())
A=[[] for i in range(n)]
for i in range(n):
    A[i] = list(map(int,input().split()))
b = []
c = list(map(int,'0'*n))
for i in range(m):
    b.append(int(input())) 
for i in range(n):
    for j in range(m):
        c[i] += A[i][j]*b[j]
for i in range(n):      
    print(c[i])


Measured memory_bytes: 6020
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		System.out.println(Math.max(Math.max(a*c, b*c), Math.max(a*d, b*d)));

		sc.close();
	}
}


Measured memory_bytes: 27080
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
	int l;
	std::vector<int> t;
	long p, last, buf;
	last = 0;
	buf = 10;
	for (int i = 0; i < 5; i++)
	{
		std::cin >> l;
		t.push_back(l);
		if (buf > l % 10 && l % 10 != 0)
		{
			buf = l % 10;
			last = i;
		}
	}
	long result = 0;
	for (int i = 0; i < 5; i++)
	{
		if (i != last && t[i] % 10 != 0)
		{
			t[i] = (t[i] + 10) / 10 * 10;
		}
		result += t[i];
	}
	std::cout << result << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<string>
#include<cmath>
#include<stack>

using namespace std;

vector<vector<int>> graph;

bool dfs(int source, int dest, int prev, int cur)
{
	int i;
	

	for (i = 0; i < graph[cur].size(); i++)
	{
		if (graph[cur][i] == prev)
		{
			continue;
		}

		if (graph[cur][i] == dest)
		{
			return false;
		}

		if (graph[cur][i] == source)
		{
			return true;
		}

		return dfs(source, dest, cur, graph[cur][i]);
	}
}

int main()
{
	int n, m;
	int deg[100001] = { 0, };
	int u, v;
	vector<pair<int, int>> arr;
	int res = 0;
	int f1 = -1, f2 = -1;
	int lmax = 0;
	vector<int> emp;
	bool valid=false;

	int i;

	//freopen("input.txt", "r", stdin);

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

	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &u, &v);

		arr.push_back(pair<int, int>(u, v));

		deg[u]++;
		deg[v]++;
	}
	
	for (i = 1; i <= n; i++)
	{
		if (deg[i] % 2)
		{
			printf("No\n");

			return 0;
		}

		res += deg[i] / 2 - 1;

		/*
		if (res > 2)
		{
			printf("No\n");

			return 0;
		}
		*/
	}

	if (res >= 3)
	{
		printf("Yes\n");
	}

	else if (res == 2)
	{
		for (i = 1; i <= n; i++)
		{
			if (deg[i] > lmax)
			{
				lmax = deg[i];
			}

			if (deg[i] == 4)
			{
				if (f1 == -1)
				{
					f1 = i;
				}

				else
				{
					f2 = i;
				}
			}
		}

		if (lmax == 6)
		{
			printf("Yes\n");
		}

		else
		{
			for (i = 0; i <= n; i++)
			{
				graph.push_back(emp);
			}

			for (i = 0; i < m; i++)
			{
				graph[arr[i].first].push_back(arr[i].second);
				graph[arr[i].second].push_back(arr[i].first);
			}

			for (i = 0; i < 4; i++)
			{
				valid = valid || dfs(f1, f2, f1, graph[f1][i]);
			}

			if (valid)
			{
				printf("Yes\n");
			}

			else
			{
				printf("No\n");
			}
		}
	}

	else
	{
		printf("No\n");
	}

	return 0;
}

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

int main()
{
    int N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    
    long ans1 = a[0];
    
    long ans2 = a[1];
    
    long temp = LONG_MAX;
    
    if(a[0] %2 == 1)
    {
        long ref1 = a[0]/2;
        long ref2 = a[0]/2+1;
        for(int i = 1;i<N;i++)
        {
            if(min(abs(a[i]-ref1),abs(a[i]-ref2)) < temp)
            {
                temp = min(abs(a[i]-ref1),abs(a[i]-ref2));
                ans2 = a[i];
            }
            else
            {
                break;
            }
        }
    }
    else
    {
        long ref = a[0]/2;
        for(int i=1;i<N;i++)
        {
        if(abs(a[i]-ref) < temp)
        {
            temp = abs(a[i]-ref);
            ans2 = a[i];
        }
        else
        {
            break;
        }
        }
    }
    
    cout << ans1 << " " << ans2 << endl;
    return 0;
    
}


 

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

int main() {
    int a,b[100010]={0},c[110],ans =0;
   
    cin >> a ;
    for(int i=1;i<=a;i++) cin >> b[i];
  
  for(int i=0;i<=a+1;i++){
    ans += abs(b[i]-b[i+1]);
      
}
  
  for(int i=1;i<=a;i++){
    cout << ans + abs(b[i-1]-b[i+1]) -abs(b[i-1]-b[i]) -abs(b[i]-b[i+1]) << endl;
  }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n,w;

	cin >> n >> w;

	vector<vll> dp(n+1,vll (100001,INF));

	ll a[n+1],h[n+1];

	for (int i = 1; i <= n; ++i){
		cin >> h[i] >> a[i];
	}

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

	for (int i = 1; i < 100001; ++i){
		for (int j = 1; j < n+1; ++j){
			if(i-a[j] < 0) dp[j][i] = dp[j-1][i];
			else dp[j][i] = min(dp[j-1][i-a[j]] + h[j],dp[j-1][i]);
		}
	}

	for(int i = 100000; i >= 0; i--){
		if(dp[n][i] <= w){
			cout << i << '\n';
			break;
		}
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----


----解説ここまで---- */


int main() {

	string s; cin >> s;
	int N = SZ(s)-2;

	cout << s.front() << N << s.back() << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main(){

   int n, m;

   cin >> n >> m;

   int a[n][m] = {{0}}, b[m][1] = {{0}}, c[n][1] = {{0}};

   rep(i, n){
      rep(j, m){
         cin >> a[i][j];
      }
   }

   rep(i, m){
      cin >> b[i][0];
   }

   rep(i, n){
      rep(j, m){
         c[i][0] += a[i][j] * b[j][0];
      }
   }

   rep(i, n){
      cout << c[i][0] << endl;
   }

   return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<int> edge[100000];
  for (int i=0; i<m; i++){
    cin >> a >> b;
    a-=1; b-=1;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  int ar[100000];
  for(int i=0; i<n; i++) ar[i] = -1;
  queue<int> li;
  li.push(0);
  while(!li.empty()){
    a=li.front();
    li.pop();
    for (auto jt=edge[a].begin(); jt!=edge[a].end(); jt++){
      b=*jt;
      if (ar[b]==-1){
        ar[b] = a;
        li.push(b);
      }
    }
  }

  cout << "Yes" << endl;
  for (int i=1; i<n; i++){
    cout << ar[i]+1 << endl;
  }
  return 0;
}


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

long long pow(long long a,long long b) {
  if(b == 0)return 1;
  else return pow(a*a%998244353,b/2)*(b%2==0?1:a)%998244353;
}

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  vector<long long> f(N),invf(N);
  f[0] = 1;
  int i;
  for(i=1;i<N;i++)f[i] = (f[i-1]*i)%998244353;
  for(i=0;i<N;i++)invf[i] = pow(f[i],998244351);
  long long m_1 = f[N-1]*(M*pow(M-1,N-K-1)%998244353)%998244353;
  long long ans = 0;
  for(i=K;i>=0;i--) {
    ans = (ans + m_1*(invf[N-i-1]*invf[i]%998244353)%998244353)%998244353;
    m_1 = (m_1*(M-1))%998244353;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6332
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly int WHITE = 0;
        static readonly int GRAY = 1;
        static readonly int BLACK = 2;

        static long[] dijkstra(long n, List<KeyValuePair<long, long>>[] M)
        {
            long minv = 0;
            var d = new long[n];
            var color = new long[n];
            for (var i = 0; i < n; ++i)
            {
                d[i] = long.MaxValue;
                color[i] = WHITE;
            }
            d[0] = 0;
            color[0] = GRAY;
            while (true)
            {
                minv = long.MaxValue;
                long u = -1;
                for(var i=0;i<n;++i)
                {
                    if(d[i]<minv && color[i]!=BLACK)
                    {
                        u = i;
                        minv = d[i];
                    }
                }
                if (-1 == u) break;
                color[u] = BLACK;
                foreach (var kv in M[u])
                {
                    var k = kv.Key;
                    var v = kv.Value;
                    if (color[k] != BLACK)
                    {
                        if (d[u] + v < d[k])
                        {
                            d[k] = d[u] + v;
                        }
                    }
                }
            }
            return d;
        }

        static void Main(string[] args)
        {
            var N = Sarray()[0];

            var M = new List<KeyValuePair<long, long>>[N];
            for (var i = 0; i < N; ++i)
            {
                M[i] = new List<KeyValuePair<long, long>>();
                var line = Sarray();
                for (var j = 2; j < line.Length; j += 2)
                { M[i].Add(new KeyValuePair<long, long>(line[j], line[j + 1])); }
            }
            var dst = dijkstra(N, M); 
            for(var i=0;i<N;++i)
            {
                WriteLine($"{i} {dst[i]}");
            }
        }
    }
}


Measured memory_bytes: 18416
import itertools

N = int(input())

d = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}

for i in range(N):
    s = input()
    if s[0] in d:
        d[s[0]] += 1

c = itertools.combinations('MARCH', 3)

ans = 0

for i, j, k in c:
    ans += d[i]*d[j]*d[k]

print(ans)



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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
long long ans;
long long res = inf;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for(int i = a[1]; i <= a[n]; i ++, ans = 0){
        for(int j = 1; j <= n; j ++){
            ans += (a[j] - i) * (a[j] - i);
        }
        res = min(res, ans);
    }
    cout << res << "\n";
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [a,b] = lines[0].split(" ").map(v=>v);
    console.log(Math.pow(b-1,a-1)*b);
});

min = (...a)=>{return a.reduce((a,b)=>a<b?a:b, a[0])};


Measured memory_bytes: 29848
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

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

	map<long,int> mp;
	rep(i,0,n){
		int a;
		cin >> a;
		mp[a]++;
	}
	
	long f = 0 , s = 0;
	
	for(auto itr = mp.begin() ; itr != mp.end() ; itr++ ){
		if(itr->second >= 2){
			if( itr->first > f ){
				s = f;
				f = itr->first;
			}
			else if( itr->first > s && itr->first != f )
				s = itr->first;
		}

	
	}
	
	if(mp[f] >= 4 ){
		s = f;
	}
	P(f*s);

	ret 0;
}

Measured memory_bytes: 6528
import numpy as np
n, m = map(int, input().split())
a = list(map(int, input().split()))
flag = False
c = []
for _ in range(m):
  x,y = map(int, input().split())
  c.append([x,y])
c = np.array(c)
e = c[np.argsort(c[:, 1])]
d = []
for x,y in reversed(e):
  for i in range(x):
    d.append(y)
    if len(d) == n:
      flag = True
      break
  if flag:
    break
f = sorted(a+d,reverse=True)
print(sum(f[:n]))

Measured memory_bytes: 47796
#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.at(i);
  }
  sort(A.begin(),A.end());
  bool match=false;
  for(int i=0;i<N-1;i++){
    if(A.at(i)==A.at(i+1)){
      match=true;
      break;
    }
  }
  cout<<(match?"NO":"YES")<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
void dfs();
void visit(int);
int A[101][101];
int Ans[101][2];
int color[101];
int n;
int time;
int main(){
    int i,j,num,d,x;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&num,&d);
        for(j=0;j<d;j++){
            scanf("%d",&x);
            A[num][x]=1;
            
        }
    }
  
    dfs();
    for(i=1;i<=n;i++){
        
      printf("%d %d %d\n",i,Ans[i][0],Ans[i][1]);
    }
    return 0;
}
void dfs(){
    int i;
    time=0;
    for(i=1;i<=n;i++){
   
        if(color[i]==WHITE){
        visit(i);
    }
    }
}
void visit(int u){
    int next,i;

    color[u]=GRAY;
    Ans[u][0]=++time;
    
for(i=0;i<=n;i++){
    if(A[u][i]!=0){
    if(color[i]==WHITE){
        visit(i);
        
    }
    }
}
    color[u]=BLACK;
    Ans[u][1]=++time;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll dp[101][5][5][5];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	dp[0][4][4][4]=1;
	
	FOR(i,N) {
		FOR(x,5) FOR(y,5) FOR(z,5) FOR(j,4) {
			if(y==0 && z==1 && j==2) continue;
			if(y==0 && z==2 && j==1) continue;
			if(y==1 && z==0 && j==2) continue;
			if(x==0 && y==1 && j==2) continue;
			if(x==0 && z==1 && j==2) continue;
			(dp[i+1][y][z][j]+=dp[i][x][y][z])%=mo;
		}
	}
	
	ll ret=0;
	FOR(x,5) FOR(y,5) FOR(z,5) ret+=dp[N][x][y][z];
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  int a[26] = {};
  for (int i = 0; i < (int)s.size(); i++) a[s[i]-'a']++;
  bool x = true;
  for (int i = 0; i < 26; i++) if (a[i] > 1) x = false;
  dump(x ? "yes" : "no");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 50 + 5;
map<ii, int> id;
map<int, ii> back;
vector<int> adj[MAX];
int n;

ll get_path(int u, const int v, ll cur_path = 0, int f = -1) {
    if (u == v) return cur_path;
    ll path = -1;
    for (auto &each : adj[u]) {
        if (each == f) continue;
        ii e = ii(min(u, each), max(u, each));
        ll ep = get_path(each, v, cur_path | (1LL << id[e]), u);
        if (ep != -1) path = ep;
    }
    return path;
}

void solve() {
    cin >> n;
    int cur_id = 0;
    fori (i, 0, n - 1) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        back[cur_id] = ii(min(u, v), max(u, v));
        id[ii(min(u, v), max(u, v))] = cur_id++;
    }
    int m;
    cin >> m;
    vector<ll> paths(m);
    fori (i, 0, m) {
        int u, v;
        cin >> u >> v;
        paths[i] = get_path(u, v);
    }
    ll ans = 0;
    fori (i, 0, 1 << m) {
        int mult = __builtin_popcount(i) % 2 == 0 ? 1 : -1;
        ll edges = 0;
        fori (j, 0, m) {
            if (i & (1 << j)) {
                edges |= paths[j];
            }
        }
        ans += mult * (1LL << (n - 1 - __builtin_popcountll(edges)));
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    return ~~(0^0);
}


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

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()
const int N = 2e5+5;

ll n , q , a[N] , seg[3][4*N] , lazy[3][4*N] , ans;

void probagate(int id , int node , int st , int en)
{
    if (lazy[id][node] != 1e9)
    {
        seg[id][node] = min(seg[id][node] , lazy[id][node]);
        if (st != en)
        {
            lazy[id][2*node] = min(lazy[id][node] , lazy[id][2*node]);
            lazy[id][2*node+1] = min(lazy[id][node] , lazy[id][2*node+1]);
        }
        lazy[id][node] = 1e9;
    }
}

void update(int id , int node , int st , int en , int l , int r , int val)
{
    probagate(id , node , st , en);

    if (st > en || st > r || en < l)
        return;

    if (st >= l && en <= r)
    {
        lazy[id][node] = min(lazy[id][node] , (ll)val);
        return probagate(id , node , st , en);
    }

    int mid = (st+en)/2;
    update(id , 2*node,st,mid,l,r,val);
    update(id , 2*node+1,mid+1,en,l,r,val);
    seg[id][node] = min(seg[id][2*node] , seg[id][2*node+1]);
}

int query(int id , int node , int st , int en , int l , int r)
{
    if (st > en || st > r || en < l) return 1e9;

    probagate(id , node , st , en);

    if (st >= l && en <= r)
    {
        return seg[id][node];
    }

    int mid = (st+en)/2;

    return min(query(id , 2*node , st , mid , l , r) , query(id , 2*node+1 , mid+1 , en , l , r));
}

void pre()
{
    for(int i=0; i<=4*n; i++)
    {
        lazy[0][i] = 1e9 , lazy[1][i] = 1e9;
        seg[0][i] = n , seg[1][i] = n;
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> q;

    ans = (n-2)*(n-2);

    pre();

    //0 for col , 1 for rows
    while(q--)
    {
        ll ty , x , tmp , tmp2 , tmp3 , en;
        cin >> ty >> x;
        if (ty==1) //we will update rows , but query on columns
        {
            tmp = query(0,1,1,n,x,x);
            en = tmp-1; //fron 1 to en rows will be affected
            ans -= (en-1);
            update(1,1,1,n,1,en,x);
        }
        else
        {
            tmp = query(1,1,1,n,x,x);
            en = tmp-1;
            ans -= (en-1);
            update(0,1,1,n,1,en,x);
        }
    }

    cout << ans << '\n';

    return 0;
}

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

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

using namespace std;

int main(){
	char s[100001];
	scanf("%s",s);
	int n=strlen(s);

	while(1){
		if     (n>=5 && strcmp(s+n-5,"dream"  )==0) n-=5, s[n]='\0';
		else if(n>=7 && strcmp(s+n-7,"dreamer")==0) n-=7, s[n]='\0';
		else if(n>=5 && strcmp(s+n-5,"erase"  )==0) n-=5, s[n]='\0';
		else if(n>=6 && strcmp(s+n-6,"eraser" )==0) n-=6, s[n]='\0';
		else break;
	}
	puts(n>0?"NO":"YES");

	return 0;
}


Measured memory_bytes: 384
N=int(input())
A=list(map(int, input().split()))
if N==2:
    print(abs(A[0]-A[1]))
    exit()
SUM=sum(A)
ans=float("INF")
now=0
for i in range(N-1):
    now+=A[i]
    ans=min(ans, abs(now-(SUM-now)))


print(ans)

Measured memory_bytes: 24932
program prob6
    implicit none
    integer(8)::N,x,i, tmp, ans
    integer(8),allocatable::a(:)
    read(*,*) N,x
    allocate(a(N))
    read(*,*) a

    ans = 0
    do i = 2, N
        tmp = a(i-1) + a(i)
        if(tmp > x) then
            if(tmp - x > a(i)) then
                a(i) = 0
            else
                a(i) = a(i) - (tmp - x)
            end if
            ans = ans + tmp - x
        end if
    end do

    write(*,*) ans

    stop
end program

Measured memory_bytes: 3832
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C, D, X, Y;
	string S, T;

	cin >> S;
	bool F = 1;
	int N = S.size();
	int i = 0;
	while (i < N) {
		if (S[i] == 'h'&&S[i + 1] == 'i') {

		}
		else F = false;
		i += 2;
	}
	if (N % 2)F = false;


	if (F)cout << "Yes" << endl;
	else cout << "No" << endl;








	return 0;
}



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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPE(i, n) for (int i = (int)(0); i <= (int)(n); ++i)
#define REPR(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define REPRE(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

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

	int n;cin >> n;n--;
	VI w;
	REPE(i,n){
		int a;cin>>a;
		w.push_back(a);
	}

	int ans = INT_MAX;
	REPE(i,n){
		int tmp1=0;
		int tmp2=0;
		REPE(j,i) tmp1+=w[j];
		for(int j=i+1;j<=n;j++) tmp2+=w[j];
		int tmp3=abs(tmp1-tmp2);
		
		// cout <<"tmp3"<< tmp3<<endl;
		if(ans>tmp3)ans=tmp3;
	}

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int x,y;
cin >> x >> y;
vector<int> a = {300000,200000,100000};
int ans = 0;
if(x <= 3)ans += a.at(x-1);
if(y <= 3)ans += a.at(y-1);
if(x == 1 && y == 1) ans += 400000;
cout << ans << endl;
}


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

int main(void) {
	string str, cpy;
	
	while(cin >> str) {
		int a, b;
		
		while (str.length() != 1) {
			cpy = "";
			for(int i = 0; i < str.length() - 1; ++i) {
				a = str[i] - '0';
				b = str[i + 1] - '0';
				cpy += ((a + b) % 10) + '0';
			}
			str = cpy;
		}
		
		cout << str << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type* arr = new type[n];
#define forn(i, n) for (int i = 1; i <= n; i++)
#define me0(x) memset(x, 0, sizeof(x))
#define me1(x) memset(x, -1, sizeof(x))
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 2e5 + 2;
void run() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
vector<int> g[N];
multiset<int> s;
int n, a[N], dp[N];

void dfs(int u, int p = 0) {
    s.insert(a[u]);
    auto it = s.lower_bound(a[u]);
    it++;
    int removed = 0;
    if (it != s.end()) {
        removed = *it;
        s.erase(it);
    }
    dp[u] = s.size();
    for (int v : g[u]) {
    	if(v != p)   dfs(v, u);
    }
    if (removed) s.insert(removed);
    s.erase(s.find(a[u]));
}

void solve() {
    int u, v;
    cin >> n;
    forn(i, n) cin >> a[i];
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
}
int32_t main() {
    run();
    solve();
    forn(i, n) cout << dp[i] << "\n";
    return 0;
}

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

int main(){
    int N,Y;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N-i;j++){
            if(10000*i+5000*j+1000*(N-i-j)==Y){
                cout<<i<<" "<<j<<" "<<N-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
int d,g;
int p[20];
int c[20];
signed main(){
  int ans = INF;
  cin >> d >> g;
  REP(i,d) cin >> p[i] >> c[i];
  REP(i,pow(2,d)){
    int nscore = 0;
    int nans = 0;
    int k=i;
    int nban = 0;
    int nmon = 1000;
    REP(j,d){
      int now = k%2;
      k /= 2;
      if(now==1){
        nscore += (j+1)*p[j]*100 + c[j];
        nans += p[j];
      }
      else{
        nban = j+1;
        nmon = p[j];
      }
    }
    if(nscore >= g){
      ans = min(ans,nans);
      continue;
    }
    if(g > nscore + nban*(nmon-1)*100) continue;
    ans = min(ans,nans+((g-nscore)-1)/100/nban+1);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a, b, c, d, e;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    
    cout<< std::max({c, d, e});
    return 0;    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

string S;

const int N_MAX = 10e5;
int a, b, c;
int flg = 0;
string ans = "No";
int tmpa, tmpb;
int tmpaval, tmpbval;
int amax = 0;
int buse = 0;
int cCount = 0;
int main()
{
    cin >> a >> b;
    if (b < 10)
    {
        c = b + a * 10;
    }
    else if (b < 100)
    {
        c = b + a * 100;
    }
    else
    {
        c = b + a * 1000;
    }

    for (int i = 1; i < 1000; i++)
    {
        if (c / i == i && c % i == 0)
        {
            ans = "Yes";
            break;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
#define MAX 500000
ll fac[MAX], finv[MAX], inv[MAX];
ll p;
ll modpow(ll a, ll n, ll mod = p) {
    ll res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll n;
    string s;
    cin >> n >> p >> s;
    if(p == 5) {
        ll res = 0;
        for(int i = 0; i < n; i++) {
            if(s[i] == '0' || s[i] == '5') {
                res += i + 1;
            }
        }
        cout << res << endl;
        return 0;
    }
    if(p == 2) {
        ll res = 0;
        for(int i = 0; i < n; i++) {
            if((s[i] - '0') % 2 == 0) {
                res += i + 1;
            }
        }
        cout << res << endl;
        return 0;
    }
    reverse(all(s));
    vector<ll> rui(n + 1, 0);
    map<ll, ll> mp;
    mp[0]++;
    for(int i = 0; i < n; i++) {
        rui[i + 1] = rui[i] + (s[i] - '0') * modpow(10, i, p);
        rui[i + 1] %= p;
        mp[rui[i + 1]]++;
    }
    ll ans = 0;
    for(auto e : mp) {
        ans += (e.second * (e.second - 1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2564
h,w=map(int,input().split())
a,l=[list(input())for i in range(h)],[0]*26
for i in a:
 for j in i:l[ord(j)-97]+=1
o,t,f=(h//2)*(w//2),(h//2)*(w%2)+(w//2)*(h%2),(h%2)*(w%2)
for i in l:
 while o and i>3:o-=1;i-=4
 while t and i>1:t-=1;i-=2
 f-=i
print("Yes"if o==t==f==0else"No")


Measured memory_bytes: 66044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vector<P> ans;
ll n, k;

void f(ll r) {
  rep2(i, 1, n - 1) rep2(j, i + 1, n) {
    if(r == 0) return;
    ans.push_back({i, j});
    r--;
  }
}

int main() {
  cin >> n >> k;
  ll mx = (n - 1) * (n - 2) / 2;
  if(mx < k) {
    cout << -1 << endl;
    return 0;
  }
  rep(i, n - 1) ans.push_back({0, i + 1});
  ll r = mx - k;
  f(r);
  cout << ans.size() << '\n';
  for(auto p : ans) cout << p.first + 1 << ' ' << p.second + 1 << '\n';
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << i << " " << arr[i] << endl;} cout << endl << endl;}
const ll N = 1e7 + 2, mod = 1e9 + 7;
int numb[N];
void sieve(){
    for(int i = 0; i < N; i++) numb[i] = 1;
    for(int i = 2; i <= N; i++)
        for(int j = i; j <= N; j += i)
            numb[j]++;
}
int main()
{
    Hello
    sieve();
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++)
        ans += (1ll * i * numb[i]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 42684
n = input()
dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(26):
  if n.count(str(dic[i]))==1 or n.count(str(dic[i]))==3 or n.count(str(dic[i]))==4:
    print("No")
    exit()
print("Yes")

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

typedef long long lglg;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	string s; lglg r; cin >> s >> r;
	lglg n = s.size();
	lglg index = 1;
	while (index < n && s[index-1] == s[index]) ++index;
	if (index == n) cout << n*r/2;
	else {
		string loop, suffix;
		for (lglg i=index; i<n+index; ++i) loop += s[i%n];
		for (lglg i=index; i<n; ++i) suffix += s[i%n];
		lglg result = 0;
		lglg count = 1;
		for (lglg i=1; i<n; ++i) {
			if (loop[i-1] == loop[i]) ++count;
			else {
				result += count/2;
				count = 1;
			}
		}
		result += count/2;
		count = 1;
		result *= r-1;
		result += index/2;
		for (lglg i=1; i<n-index; ++i) {
			if (suffix[i-1] == suffix[i]) ++count;
			else {
				result += count/2;
				count = 1;
			}
		}
		result += count/2;
		cout << result;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) { cin >> H[i]; }
    int m = 0;
    for (int i = 1; i < N; i++) {
        int tmp = 0;
        while (H[i - 1] >= H[i] && i < N) {
            tmp++;
            i++;
        }
        m = max(tmp, m);
    }
    cout << m << endl;
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,w; cin >> n >> w;
    vl we(n),va(n);
    rep(i,n)cin >> we[i] >> va[i];
    vvl dp(100010,vl(110,0));
    rep(i,w+1){
        rep(j,n){
            chmax(dp[i][j+1],dp[i][j]);
            if(i-we[j] >= 0)chmax(dp[i][j+1],dp[i-we[j]][j]+va[j]);
        }
    }
    out(dp[w][n]);
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,r;
	cin >> n >> r;
	if(n>=10) cout << r << endl;
	else cout << r+100*(10-n) << endl;
	return 0;
}

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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(5);
  for(long long &i:A)
    cin >> i;
  
  long long b = *min_element(A.begin(), A.end());
  
  cout << (N + b - 1) / b + 4 << endl;
}

Measured memory_bytes: 768
using System;
using System.Linq;

namespace AtCoderTemplate {
    class ProgramD {
        static void Main() {
            var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = line[0], A = line[1], B = line[2];
            var list = Enumerable.Repeat(0, N).Select(_ => int.Parse(Console.ReadLine())).ToList();
            long left = 0, right = 1000000000;
            
            while (right - left > 1) {
                long mid = (left + right) / 2, damage = mid * B;

                if (mid >= list.Sum(x => x <= damage ? 0 : (x - damage - 1) / (A - B) + 1)) right = mid;
                else left = mid;
            }

            System.Console.WriteLine(right);
        }
    }
}


Measured memory_bytes: 17580
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<String> list = new ArrayList<>();
        String[] s = new String[N];
        for (int i = 0; i < N; i++) {
            s[i] = sc.next();
            list.add(s[i]);
        }

        int M = sc.nextInt();
        String[] t = new String[M];
        for (int i = 0; i < M; i++) {
            t[i] = sc.next();
            list.add(t[i]);
        }

        int max = 0;
        for (String card : list) {
            int cnt = 0;
            for (int i = 0; i < s.length; i++) {
                if (card.equals(s[i])) {
                    cnt++;
                }
            }
            for (int j = 0; j < t.length; j++) {
                if (card.equals(t[j])) {
                    cnt--;
                }
            }
            max = Math.max(max, cnt);
        }

        System.out.println(max);
        return;
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int H, W, INF = 10000;
char s[50][50];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
queue<P> que;

int bfs(){
	int dist[H][W];
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			dist[i][j] = INF;
		}
	}
	que.push({0, 0});
	dist[0][0] = 0;
	while(que.size()){
		P p = que.front();
		que.pop();
		if(p.first == H-1 && p.second == W-1){
			break;
		}
		for(int i=0; i<4; i++){
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(0<=nx && nx<H && 0<=ny && ny<W && dist[nx][ny] == INF && s[nx][ny] == '.'){
				que.push({nx, ny});
				dist[nx][ny] = dist[p.first][p.second] + 1;
			}
		}
	}
	return dist[H-1][W-1];
}

int main(){
	cin >> H >> W;
	int cnt = 0;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> s[i][j];
			if(s[i][j] == '#'){
				cnt++;
			}
		}
	}
	int ans = bfs();
	if(ans == INF){
		cout << -1 << endl;
		return 0;
	}
	cout << H*W - (ans + cnt + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
class ListOfTopThreeHills
{
	static void Main(string[] args)
	{
		do
		{
			string input = Console.ReadLine();
			if (string.IsNullOrEmpty(input))
			{
				break;
			}
			string[] inputArr = input.Split(' ');
			int a = int.Parse(inputArr[0]);
			int b = int.Parse(inputArr[1]);
			int sum = a + b;
			Console.WriteLine(sum.ToString().Length);
		} while (true);
	}
}

Measured memory_bytes: 5588