akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	string s;
	cin >> s;
	int flag = 1;
	for (int i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
			{
				flag = 0;
				break;
			}
		}
		else if (i % 2 == 1)
		{
			if (s[i] == 'R')
			{
				flag = 0;
				break;
			}
		}
	}
	if (flag)
	{
		printf("Yes");
	}
	else 
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 256
[n,m,l] = map(int, input().split())
a = []
b = []
c = [[0 for k in range(l)] for i in range(n)]
for i in range(n):
    a.append(list(map(int, input().split())))

for j in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    for k in range(l):
        s = 0
        for j in range(m):
            s += a[i][j] * b[j][k]
        c[i][k] = s

for i in range(n):
    for k in range(l):
        print(c[i][k],end='')
        if k!= l-1:    
            print(' ',end='')
        else:
            print()

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  cout<< 1*min(a,k)+(-1)*max(0,k-a-b) <<endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

ll w[4000];
ll  dp[4000][4000];
ll  cut[4000][4000];
ll  sum[4001];

int main() {
  int n;
  cin >> n;
  REP(i,n) cin >> w[i];
  sum[0] = 0;
  REP(i,n) sum[i+1] = sum[i] + w[i];
  REP(i,n)REP(j,n)dp[i][j] = 1LL<<62;
  REP(i,n) {
    REP(j,n-i) {
      int a = j;
      int b = i+j;
      if (i == 0) {
        cut[a][b] = a;
        dp[a][b] = 0;
      } else {
        ll s = sum[b+1] - sum[a];
        for (int k=cut[a][b-1]; k<=min((ll)b-1,cut[a+1][b]); ++k) {
          ll t = s + dp[a][k] + dp[k+1][b];
          if (t < dp[a][b]) {
            cut[a][b] = k;
            dp[a][b] = t;
          }
        }
      }
    }
  }
  // REP(i,n){ REP(j,n) cout << dp[i][j] << " ";
  //   cout << endl;
  // }
  // cout << endl;
  // REP(i,n){ REP(j,n) cout << cut[i][j] << " ";
  //   cout << endl;
  // }
  cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 198000
N = int(input())
SP = [list(input().split()) for _ in range(N)]

for i in range(N):
    SP[i] = [SP[i][0], int(SP[i][1]) * (-1), i+1]
SP.sort(key=lambda x: x[1])
SP.sort()

for i in range(N):
    print(SP[i][2])

Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))

ans = 0

for i in range(n - 2):
    a, b, c = p[i], p[i + 1], p[i + 2]
    s = sorted([a, b, c])
    if s[1] == b:
        ans += 1

print(ans)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
ll qpow(ll a, ll b,ll mod)
{
	ll res = 1, base = a;
	while (b > 0)
	{
		if (b % 2 == 1) { res = (res * base) % mod; }
		base = (base * base) % mod;
		b >>= 1;
	}
	return res;
}
ll comp(ll a, ll b, int p)//composite num C(a,b)%p
{
	if (a < b)return 0;
	if (a == b)return 1;
	if (b > a - b)b = a - b;
	int ans = 1, ca = 1, cb = 1;
	for (ll i = 0; i < b; i++)
	{
		ca = (ca * (a - i)) % p;
		cb = (cb * (b - i)) % p;
	}
	ans = (ca * qpow(cb, p - 2, p)) % p;
	return ans;
}
int main()
{
	ll n, a, b;
	cin >> n >> a >> b;
	if (n == 2)cout << "0";
	else
	{
		ll sum =qpow(2,n,mod)-1;
		ll sum1 = comp(n, a, mod), sum2 = comp(n, b, mod);
		sum = (sum - sum1 + mod) % mod;
		sum = (sum - sum2 + mod) % mod;
		cout << sum ;
	}

}


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

const int inf = 1e9;
const ll linf = 1e18;

const int d[3] = {-1, 0, 1};

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

    int h, w; cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            int num = 0;
            for (auto &dy: d) for (auto &dx: d) {
                if (dy == 0 && dx == 0) continue;
                int ny = i + dy, nx = j + dx;
                if (ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                if (s[ny][nx] == '#') num++;
            }
            s[i][j] = (char)('0' + num);
        }
    }
    for (int i = 0; i < h; i++) cout << s[i] << endl;
    return 0;
}

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

a,b,c,d = inpm()

while True:
    c -= b
    if c <= 0:
        ans = 'Yes'
        break
    a -= d
    if a <= 0:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 31116
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
const int maxn=1e5+1;
int main()
{
    int val[maxn];
    int n;
    long long cost;
    while(~scanf("%d",&n)){
        memset(val,0,sizeof(val));
        cost=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&val[i]);
            //cout<<'#'<<val[i]<<'#'<<endl;
            if(i==n) cost+=fabs(val[i]);
            cost+=fabs(val[i]-val[i-1]);
            //cout<<'@'<<cost<<'@'<<endl;
        }
        long long out;
        for(int i=1;i<=n;i++){
            if(i==n) out=cost-fabs(val[i])+fabs(val[i-1])-fabs(val[i]-val[i+1]);
            out=cost-fabs(val[i]-val[i-1])-fabs(val[i+1]-val[i])+fabs(val[i+1]-val[i-1]);
            printf("%lld\n",out);
        }
    }
}

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

int main() {
  int N,X;
  cin>>N>>X;
  
  int m[N];
  for(int i=0;i<N;++i){
    cin>>m[i];
  }
  
  int min=100000;
  int sum=0;
  
  for(int i=0;i<N;++i){
    sum=sum+m[i];
    if(min>m[i])
      min=m[i];
  }
  
  int ans=N+(X-sum)/min;
  cout<<ans<<endl;
  
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            string s = ReadLine();
            string t = ReadLine();

            var arr_start = Enumerable.Repeat(-1, 26).ToArray();
            var arr_end = Enumerable.Repeat(-1, 26).ToArray();

            for (int i = 0; i < s.Length; i++)
            {
                int a = s[i] - 'a';
                int b = t[i] - 'a';

                if (arr_start[a] != -1 || arr_end[b] != -1)
                {
                    if (arr_start[a] != b || arr_end[b] != a)
                    {
                        WriteLine("No");
                        return;
                    }
                }
                arr_start[a] = b;
                arr_end[b] = a;
            }
            WriteLine("Yes");
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19240
#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;
typedef vector<int> VI;
#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));

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N;
	cin>>N;
	ll Bco=0;
	VI A(N);
	REP(i,N){
		int a,b;
		cin>>a>>b;
		Bco+=b;
		A[i]=a+b;
	}
	ll Aco=0;
	rSORT(A);
	REP(i,N)
		if(i%2==0)Aco+=A[i];
	
	cout<<Aco-Bco<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define llu unsigned long long int
int main()
{
    llu n,k;
    cin>>n>>k;
    llu i,a[n],x=1,y;
    
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
  // cout<<x<<endl;
    for(i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 100001;
vector<vector<int>> graph;
int V,E;
int x, y;
int step[MAX];
bool visited[MAX];
int re;
void DFS(int u)
{
	visited[u] = 1;
	for (int i = 0; i < graph[u].size(); i++)
	{
		int t = graph[u][i];
		if (!visited[t])
			DFS(t);
		step[u] = max(step[u], step[t] + 1);
	}
	if (graph[u].empty())	step[u] = 1;
	return;
}


int main()
{
	cin >> V >> E;
	graph.resize(V + 1);
	for (int i = 0; i < E; i++)
	{
		cin >> x >> y;
		graph[x].push_back(y);
	}

	for (int i = 1; i <= V; i++)
		if (!visited[i]) DFS(i);
	for (int i = 0; i < MAX; i++)
		re = max(re, step[i]);
	cout << re-1;
	
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int F(ll A,ll B){
  A = max(A,B);
  int ans = 0;
  while(A){
    ans++;
    A /= 10;
  }
  return ans;
}

int main(){
  int ans = INF;
  ll N;
  cin >> N;
  FOR(i,1,100001){
    if(N%i == 0){
      ans = min(ans,F(i,N/i));
      cerr << N/i << ":" << F(i,N/i) << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

string s[100001];
bool flag[600001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>s[i];
    FOR(i,1,5){
        rep(j,n){
            rep(k,(int)s[j].size()+1-i){
                int h=0;
                rep(l,i){
                    h=27*h+1+s[j][k+l]-'a';
                }
                flag[h]=true;
            }
        }
    }
    string ans;
    FOR(i,1,600000){
        if(!flag[i]){
            ans.clear();
            int t=i;
            bool f=true;
            while(t){
                if(t%27==0){
                    f=false;
                    break;
                } 
                char c=(char)((t%27)-1+'a');
                ans=c+ans;
                t/=27;
            }
            if(f){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong X, Y, A, B, C;
  vector<llong> p, q, r;

  cin >> X >> Y >> A >> B >> C;
  p.resize(A);
  q.resize(B);
  r.resize(C);
  for (auto &in: p) {
    cin >> in;
  }
  for (auto &in: q) {
    cin >> in;
  }
  for (auto &in: r) {
    cin >> in;
  }
  sort(ALL(p), greater<>());
  sort(ALL(q), greater<>());
  sort(ALL(r), greater<>());

  priority_queue<llong, vector<llong>, greater<llong>> pp, qq;
  for (int i = 0; i < X; ++i) {
    pp.push(p[i]);
  }
  for (int i = 0; i < Y; ++i) {
    qq.push(q[i]);
  }

  for (auto rr: r) {
    if (pp.top() < qq.top()) {
      if (pp.top() < rr) {
        pp.pop();
        pp.push(rr);
      }
    }
    else {
      if (qq.top() < rr) {
        qq.pop();
        qq.push(rr);
      }
    }
  }

  llong ans = 0;
  while (pp.size()) {
    ans += pp.top();
    pp.pop();
  }
  while (qq.size()) {
    ans += qq.top();
    qq.pop();
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4852
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> numSet = new HashSet<>();
        for (int i = 0; i < n; i++) {
            numSet.add(sc.nextInt());
        }
        System.out.println(numSet.size());
    }
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            List<long> A = Console.ReadLine().Split().Select(i => long.Parse(i)).ToList();
            List<double> DivA = A.Select(i => 1.0 / i).ToList();
            DivA.Sort();
            double sum = 0.0;
            for (var i = DivA.Count - 1; i >= 0; i--)
            {
                sum += DivA[i];
            }
            double ans = 1 / sum;
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> ene(n+1);
  vector<ll> can(n);
  rep(i,n+1)cin >> ene.at(i);
  rep(i,n)cin >> can.at(i);
  
  ll count=0;
  rep(i,n){
    if(ene.at(i)>=can.at(i))count+=can.at(i);
    else if(ene.at(i)+ene.at(i+1)>=can.at(i)){
      count+=can.at(i);
      ene.at(i+1)-=(can.at(i)-ene.at(i));
    }
    else{
      count+=(ene.at(i)+ene.at(i+1));
      ene.at(i+1)=0;
    }
    //cout << 1 << endl;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> H(N);
    for(int i=0; i<N; i++) scanf(" %d", &H[i]);

    std::vector<int> count(N, 0);
    for(int i=1; i<N; i++){
        if(H[i-1] < H[i]) count[i] = 0;
        else count[i] = count[i-1] + 1;
    }

    std::cout << *max_element(count.begin(), count.end()) << std::endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	int n;
	cin >> n;
	string s,t;
	cout << 0<<endl;
	cin >> s;
	if(s=="Vacant") return 0;

	
	int p=1;
	int q=n-1;
	cout << p<<endl;
	cin >> s;
	if(s=="Vacant") return 0;
	cout << q<<endl;
	cin >> t;
	if(t=="Vacant") return 0;
	int mid;
	string aux;
	int i=0;
	while(i++<25){
		mid=p+(q-p)/2;
		cout <<  mid << endl;
		cin >> aux;
		if(aux=="Vacant") return 0;
		if(mid%2==p%2){
			if(aux==s) {
				p=mid+1;
				s=(aux=="Male")? "Female": "Male";
			}
			else{
				q=mid-1;
				t=(aux=="Male")?"Female":"Male";	
			} 
		}
		else{
			if(aux==s){
				q=mid-1;
				t=(aux=="Male")? "Female":"Male";
			}
			else{
				p=mid+1;
				s=(aux=="Male")? "Female": "Male";				
			}
		}
		//error(p,q,mid,aux);
	}

	return 0;
}

Measured memory_bytes: 3820
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = 10**9 + 7
if N == K:
    result = 1
    for i in range(K):
        result = result * A[i] % M
    print(result)
    exit()
minus = [i for i in A if i <= 0]
l_minus = len(minus)
plus = [i for i in A if i > 0]
l_plus = len(plus)
plus.sort(reverse=1)
minus.sort()
if len(plus) == 0 and K % 2 == 1:
    result = 1
    for i in range(K):
        result = result * minus[-i-1] % M
    print(result)
    exit()

array = []
if K%2 == 1:
    array.append(plus.pop(0))
    l_plus -= 1
    K -= 1
m_x = 0
p_x = 0
max_mm = -1
if (m_x+1) * 2 <= l_minus:
    max_mm = minus[m_x * 2] * minus[m_x * 2 + 1]
max_pp = -1
if (p_x+1) * 2 <= l_plus:
    max_pp = plus[p_x * 2] * plus[p_x * 2 + 1]
counter = 0
\
while counter * 2 + 1 < K:
    if max_pp > max_mm:
        array.append(plus[p_x * 2])
        array.append(plus[p_x * 2 + 1])
        p_x += 1
        if (p_x+1) * 2 <= l_plus:
            max_pp = plus[p_x * 2] * plus[p_x * 2 + 1]
        else:
            max_pp = -1
 
    else:
        array.append(minus[m_x * 2])
        array.append(minus[m_x * 2 + 1])
        m_x += 1
        if (m_x+1) * 2 <= l_minus:
            max_mm = minus[m_x * 2] * minus[m_x * 2 + 1]
        else:
            max_mm = -1
    counter += 1

result = 1
for each in array:
    result = result * each % M
print(result)

Measured memory_bytes: 118080
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println(H * W - (H * w) - (W * h) + h * w);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  
  vl delta(n+1);
  delta[0] = a[0]-0;
  rep(i, n-1) delta[i+1] = a[i+1]-a[i];
  delta[n] = 0-a[n-1];
  
  ll distance = 0;
  rep(i, n+1) distance += abs(delta[i]);
  
  rep(i, n) {
    ll decrement = 0;
    if(delta[i]*delta[i+1]<0) decrement = 2 * min(abs(delta[i]),abs(delta[i+1]));
    cout << distance - decrement << newl;
  }
  return 0;
}

Measured memory_bytes: 4776
def main():
    def reviewSum(n):
      sum = 0
      while n > 0:
          sum += n % 10
          n = n // 10
      return sum
    
    N, A, B = map(int, input().split())
    total = 0
    for i in range(N + 1):
        sum = reviewSum(i)
        if sum >= A and sum <= B:
          total += i
    print(total)
main()

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

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	string s;
	cin >> s;
	
	if(s.back() == 's')s += "es";
	else s += 's';
	
	cout << s;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3652
//***No one wants to die...yet death is the destiation we all share***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
    ll a;
    cin>>a;
    cout<<(a+a*a+a*a*a);
}

Measured memory_bytes: 3612
# https://atcoder.jp/contests/abc109/tasks/abc109_b

N = int(input())

words = {}
last_w = ""

for _ in range(N):
    w = input()
    if w in words:
        print("No")
        exit()
    else:
        if len(last_w) == 0 or last_w == w[0]:
            words[w] = True
            last_w = w[-1]
        else:
            print("No")
            exit()

print("Yes")



Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n+1)
	as[0], as[1] = 2, 1
	for i := 2; i <= n; i++ {
		as[i] = as[i-1] + as[i-2]
	}

	fmt.Println(as[n])
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    double r,a,b;
    cin>>r;
    a=r*r*3.141592653589;
    b=2*r*3.141592653589;
    printf("%f %f\n",a,b );
}


Measured memory_bytes: 3148
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}

	return gcd(b, a%b)
}

func main() {
	sc.Split(bufio.ScanWords)
	var slice []int

	a, b, k := read(), read(), read()
	var aint, bint, kint int
	aint, _ = strconv.Atoi(a) //文字列から１０進整数への変換
	bint, _ = strconv.Atoi(b)
	kint, _ = strconv.Atoi(k)

	num := gcd(aint, bint) //最大公約数

	for i := 1; i <= num; i++ {
		if num%i == 0 {
			slice = append(slice, i)
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(slice)))

	// fmt.Println(slice)
	// fmt.Println(gcd(aint, bint))
	fmt.Println(slice[kint-1])

}


Measured memory_bytes: 640
package main

import (
    "fmt"
    "os"
    "sort"
)

func main() {

    var N int
    fmt.Fscanf(os.Stdin, "%d\n", &N)
    vals := make([]int, N)
    for i := 0; i < N; i++ {
        var v int
        fmt.Fscanf(os.Stdin, "%d", &v)
        vals[i] = v
    }

    sort.Ints(vals)
    alice := 0
    bob := 0
    for i := 0; i < N; i++ {
        idx := N - 1 - i
        if i%2 == 0 {
            alice += vals[idx]
        } else {
            bob += vals[idx]
        }
    }
    fmt.Printf("%d\n", alice-bob)
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define lint long long

using namespace std;

lint f(lint b, lint n) {
	if (n < b) {
		return n;
	} else {
		return n % b + f(b, n / b);
	}
}

int main()
{
	lint n, s;
	cin >> n >> s;
	if (n == s) {
		cout << n + 1 << endl;
	} else {
		lint minb = 99999999999999;
		for (lint i = 2; i <= sqrt(n); i++) {
			if (f(i, n) == s) {
				minb = min(minb, i);
			}
		}
		for (int i = 1; i < sqrt(n); i++) {
			lint b = (n - s) / i + 1;
			if (b >= 2 && f(b, n) == s) {
				minb = min(minb, b);
			}
		}
		if (minb != 99999999999999)
			cout << minb << endl;
		else
			cout << -1 << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
  
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
  
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
  
int F()
{
    char ch;
    int x, a;
    while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
    if (ch == '-') ch = getchar(), a = -1;
    else a = 1;
    x = ch - '0';
    while (ch = getchar(), ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + ch - '0';
    return a * x;
}
  
const int N = 5e5 + 10;
  
int n, k, p[N], q[N];
  
int t[N << 2], cnt;
  
int get(int x, int y)
{
    if (!x) return y;
    if (!y) return x;
    return min(x, y);
}
  
void modify(int x, int v)
{
    t[x += cnt] = v;
    for (x >>= 1; x; x >>= 1)
        t[x] = get(t[x << 1], t[x << 1 | 1]);
}
  
int query(int l, int r)
{
    int ans = 0;
    l = max(l, 1);
    r = min(r, n);
    if (l > r) return 0;
    for (l += cnt - 1, r += cnt + 1; l ^ r ^ 1; l >>= 1, r >>= 1)
    {
        if (~l & 1) ans = get(ans, t[l ^ 1]);
        if ( r & 1) ans = get(ans, t[r ^ 1]);
    }
    return ans;
}
  
vector<int> edge[N];
  
int deg[N];
  
priority_queue<int> pq;
  
int ans[N];
  
int main()
{
    gii(n, k);
    for (int i = 1; i <= n; ++i) gi(p[i]), q[p[i]] = i;
    for (cnt = 1; cnt < n + 2; cnt <<= 1); --cnt;
    for (int i = n; i; --i)
    {
        int x = q[query(q[i] - k + 1, q[i] - 1)];
        if (x) edge[q[i]].pb(x), ++deg[x];
        x = q[query(q[i] + 1, q[i] + k - 1)];
        if (x) edge[q[i]].pb(x), ++deg[x];
        modify(q[i], i);
    }
    for (int i = 1; i <= n; ++i)
        if (!deg[i]) pq.push(-i);
    int cur = 0;
    while (!pq.empty())
    {
        int u = -pq.top(); pq.pop();
        ans[u] = ++cur;
        for (auto v : edge[u])
        {
            --deg[v];
            if (!deg[v])
                pq.push(-v);
        }
    }
    for (int i = 1; i <= n; ++i)
        printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 44416
using System;

namespace ALDS1_3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            long[] list = new long[101];
            long val1 = 0;
            long val2 = 0;
            long top = 0;

            for (int i=0; i<str.Length; i++) 
            {
                if (str[i] == "+")
                {
                    pop(ref top, ref val1, list);
                    pop(ref top, ref val2, list);
                    top = push(val2+val1, top, list);
                }
                else if (str[i] == "-")
                {
                    pop(ref top, ref val1, list);
                    pop(ref top, ref val2, list);
                    top = push(val2-val1,top, list);
                }
                else if (str[i] == "*")
                {
                    pop(ref top, ref val1, list);
                    pop(ref top, ref val2, list);
                    top = push(val2*val1, top, list);
                }
                else
                {
                    top = push(long.Parse(str[i]), top, list);
                }
            }
            Console.WriteLine(list[1]);
        }

        static long push(long value, long top, long[] list)
        {
            top++;
            list[top] = value;
            return top;
        }

        static void pop(ref long top, ref long value, long[] list)
        {
            top--;
            value = list[top+1];
        }
    }
}

Measured memory_bytes: 9212
def main():
    while True:
        try:
            inputList = input().split()
            firstChar = inputList[0]
            secondChar = inputList[1]
            firstNum = ord(firstChar)
            secondNum = ord(secondChar)
            if(firstNum > secondNum):
                print(">")
            elif(firstNum < secondNum):
                print("<")
            elif(firstNum == secondNum):
                print("=")
        except:
            break
main()

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (a1, a2, a3) = readLine()!!.split(' ').map(String::toInt)
    var min = 10000
    min = Math.min(min, Math.abs(a2 - a1) + Math.abs(a3 - a2))
    min = Math.min(min, Math.abs(a3 - a1) + Math.abs(a2 - a3))
    min = Math.min(min, Math.abs(a1 - a2) + Math.abs(a3 - a1))
    min = Math.min(min, Math.abs(a3 - a2) + Math.abs(a1 - a3))
    min = Math.min(min, Math.abs(a1 - a3) + Math.abs(a2 - a1))
    min = Math.min(min, Math.abs(a2 - a3) + Math.abs(a1 - a2))
    println(min)
}

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

string* bubbleSort(string a[], int n) {

	for (int i = 0; i < n; i++)
	{
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j][1] < a[j - 1][1]) {
				string temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
		
			}
		}
	}

	return a;
}
string* selectSort(string a[], int n) {
	int mini;
	string	temp;

	for (int i = 0; i < n; i++) {
		mini = i;
		for (int j = i; j < n; j++) {
			if (a[j][1] < a[mini][1])
				mini = j;
		}
		
			temp = a[mini];
			a[mini] = a[i];
			a[i] = temp;

	}

	return a;
}
bool compareStable(string a[], string b[],int n) {
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i])
			return false;
	}
	return true;
}
void print(string a[], int n) {
	for (int i = 0; i < n-1; i++)
		cout << a[i]<<" ";
	cout << a[n - 1] << endl;
}
int main()
{
	int n;
	string a[150],d[150];
	while (cin >> n) {
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int i = 0; i < n; i++) {
			d[i] = a[i];
		}
		string *b = bubbleSort(a, n);
		string *c = selectSort(d, n);
		print(b, n);
		cout << "Stable"<<endl;
		print(c, n);
		if (compareStable(b, c, n))
			cout << "Stable" << endl;
		else
			cout << "Not stable" << endl;

	}

    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> b(n+1, 0), w(n+1, 0);
    rep (i, n) {
        if (s[i] == '#') {
            b[i+1]++;
        } else {
            w[i+1]++;
        }
        b[i+1] += b[i];
        w[i+1] += w[i];
    }
    int ans = 1e9 + 7;
    rep (i, n + 1) {
        chmin(ans, b[i] + w[n] - w[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
#define ll long long
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
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; }
using namespace std;
ll a,b,c,k,r;
int main() {
    cin >> a >> b >> c >> k;
    if(a >= k) {
        r = k;
    } else {
        r = a;
        k -= a;
        if(b < k) {
            k -= b;
            r -= k;
        }
    }
    cout << fixed << r;
}

Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int k = sc.nextInt();
  
        int array[] = new int[n + 1];
 
        for (int i = 0; i < n; i++) {
            array[sc.nextInt()]++;
        }

        List<Integer> list = new ArrayList<Integer>();
 
        for (int i = 0; i < n + 1; i++) {
            if (array[i] != 0) {
                list.add(array[i]);
            }
        }

        Collections.sort(list);

        long ans = 0;

        for (int i = 0; i < list.size() - k; i++) {
            ans += list.get(i);
        }
 
        System.out.println(ans);
 
        sc.close();
 
        }
 
    }

Measured memory_bytes: 60104
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class Main {
    public static void main(String[] args)throws Exception {
        StringBuilder sb = new StringBuilder();
        FastReader in = new FastReader(System.in);
        int i, j;
        char arr[]=in.next().toCharArray();
        int n=arr.length;
        if(n<=3){
            System.out.println(0);
            System.exit(0);
        }
        long ans=0;
        HashMap<Integer,Integer> map=new HashMap<>();
        map.put(0,1);
        int pow=1,val=0;
        for(i=n-1;i>=0;i--){
            int x=arr[i]-'0';
            val=(val+pow*x)%2019;
            pow=(pow*10)%2019;
            int z=map.getOrDefault(val,0);
            ans=(ans+z);
            map.put(val,z+1);
        }
        System.out.println(ans);


    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}





Measured memory_bytes: 43212
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] in = sc.next().split("");
		String last = in[in.length - 1];
		List<String> hons = Arrays.asList("2", "4", "5", "7", "9");
		List<String> pons = Arrays.asList("0", "1", "6", "8");
		if (hons.contains(last)) {
			System.out.println("hon");
		} else if (pons.contains(last)) {
			System.out.println("pon");
		} else {
			System.out.println("bon");
		}
	}
}


Measured memory_bytes: 27016
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
int dp[3001][3001],ans;
string a,b,st;
void solve(ll x,ll y,ll k){
    for(int i=x; i>=0; i--){
        for(int j=y; j>=0; j--){
            int pp = 0;
            if(i && j)pp = dp[i - 1][j - 1];
            if(a[i] == b[j] && pp == k - 1){
                st += a[i];
                if(k > 1)
                solve(i - 1 , j - 1 , k - 1);
                return;
            }
        }
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin >> a >> b;
    for(int i=0; i<a.size(); i++){
        int mx = 0;
        for(int j=0; j<b.size(); j++){
            if(i)dp[i][j] = max(dp[i][j] , dp[i - 1][j]);
            if(j)dp[i][j] = max(dp[i][j] , dp[i][j - 1]);
            if(a[i] == b[j]){
                if(i && j)mx = max(mx , dp[i - 1][j - 1] + 1);
                else mx = max(mx , 1);
            }
            dp[i][j] = max(dp[i][j] , mx);
            ans = max(ans , dp[i][j]);
        }
    }
    if(ans)
    solve((int)a.size() - 1 , (int)b.size() - 1 , ans);
    reverse(st.begin() , st.end());
    
    cout << st << '\n';
    
    
    return 0;
}


Measured memory_bytes: 35456
#include<cstdio>
#include<algorithm>
int a[100];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    std::sort(a,a+n);
    printf("%d",a[n-1]-a[0]);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

        int N = sc.nextInt();
        int[] X = new int[N];
        int hsum = 0;
        int min = 0;

        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
        }
        for(int i=1; i<=100; i++){
            for(int j=0; j<N; j++){
                hsum += Math.pow((X[j] - i), 2);
            }
            if(i==1){
                min = hsum;
            }
            min = Math.min(min, hsum);
            hsum = 0;
        }
        System.out.println(min);
    }
}

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

typedef long long ll;

int main(){
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);
    for(ll i=0; i<N; i++) cin >> t[i];
    
    ll sum=0;
    for(ll i=0; i<N; i++){
        if(i!=N-1){
            if(T<=t[i+1]-t[i]){
                sum += T;
            }
            else {
                sum += t[i+1]-t[i];
            }
        }
        else {
            sum += T;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

ll dp[1000005][3];

int main(){
    int n;
    cin >> n;
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        dp[i][0] = (dp[i-1][0] * 8) % MOD;
        dp[i][1] = (dp[i-1][0] * 2 + dp[i-1][1] * 9) % MOD;
        dp[i][2] = (dp[i-1][1] + dp[i-1][2] * 10) % MOD;
    }
    cout << dp[n][2] << endl;
    return 0;
}

Measured memory_bytes: 27064
using System;
    using System.Collections.Generic;
     
    namespace ABC171Test
    {
        class Program
        {
            static void Main()
            {
                long N = long.Parse(Console.ReadLine());
                List<char> alplist = new List<char>();
     
                for (int code = 0x61; code < 0x7b; code++) alplist.Add(Convert.ToChar(code));
     
                long S = 0;
                int k=1;
                long buf=N;
                var result = string.Empty;
                
                buf = 0;
                while (S < N) {
                    buf = S;
                    S += (long)Math.Pow(26, k);
                    k++;
                }
     
     
                long row = N - buf-1;
     
                int l=k-1;
                
                while (l > 0) {
                    long b = (long)Math.Pow(26, l-1);
                    int al = (int)(row / b);
                    row = row % b;
                    result += alplist[al];
                    l--;
                }
                Console.WriteLine(result);
                
     
     
            }
     
     
        }
     
    }

Measured memory_bytes: 28188
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int a, b, c;
    int k;
    cin >> a >> b >> c;
    cin >>k;
    while(b <= a){
        b *= 2;
        k--;
    }
    while(c <= b){
        c *= 2;
        k--;
    }
    if(k < 0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

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

    solve();
}


Measured memory_bytes: 3648