akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#endif
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <array>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)
#define ar array

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No");
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

int main() {
  ll H,W;
  cin>>H>>W;
  ll ans = INF;
  for(ll i = 0; i <= H; i++){
    ll A = i*W;
    if((H-i)*W%2LL!=0LL){
      ll t = min((H-i),W);
      ll B = ((H-i)*W+t)/2LL;
      ll C = (H-i)*W-B;
      ll M = max(A,max(B,C));
      ll m = min(A,min(B,C));
      chmin(ans,M-m);
    }
    else {
      ll B = (H-i)*W/2LL;
      chmin(ans,abs(A-B));
    }
  }
  swap(H,W);
  for(ll i = 0; i <= H; i++){
    ll A = i*W;
    if((H-i)*W%2LL!=0LL){
      ll t = min((H-i),W);
      ll B = ((H-i)*W+t)/2LL;
      ll C = (H-i)*W-B;
      ll M = max(A,max(B,C));
      ll m = min(A,min(B,C));
      chmin(ans,M-m);
    }
    else {
      ll B = (H-i)*W/2LL;
      chmin(ans,abs(A-B));
    }
  }
  cout<<ans<<endl;
}

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

void solve() 
{
    int n;cin>>n;cout<<n+n*n+n*n*n<<endl;
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
string res = "No";

if(abs(a - c) <= d) res = "Yes";
else if((abs(a - b) <= d) && (abs(b - c) <= d)) res = "Yes";

cout << res << endl;
} 

Measured memory_bytes: 764
#include <iostream>
#include <map>
#include <cstring>
#include <cassert>
#include <vector>
#include <queue>
using namespace std;

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

int N, M;
vector<int> S;
vector<int> T;
void input() {
    cin >> N >> M;
    S.clear(); S.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    T.clear(); T.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> T[i];
    }
}

vector<int> A, B;
void init() {
    A.clear(); B.clear();
    int x = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < T[i]; j++) {
            A.push_back(x);
        }
        x = !x;
    }
    x = 1;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < T[i]; j++) {
            B.push_back(x);
        }
        x = !x;
    }
}

const int MAX_N = 15;

struct State {
    vector<int> bit;
    int t;
    State(vector<int> bit, int t) : bit(bit), t(t) {}
};

void solve() {
    init();
    map< vector<int>, bool > used;
    queue<State> Q;
    used[S] = true;
    Q.push(State(S, 0));
    while (!Q.empty()) {
        State cur = Q.front(); Q.pop();
        if (cur.bit == A || cur.bit == B) {
            cout << cur.t << endl;
            break;
        }
        for (int i = 0; i < N - 1; i++) {
            vector<int> nbit = cur.bit;
            if (nbit[i] == nbit[i + 1]) continue;
            swap(nbit[i], nbit[i + 1]);
            if (used[nbit]) continue;
            used[nbit] = true;
            Q.push(State(nbit, cur.t + 1));
        }
    }
}

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

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int s = a+b+c;
	int m = max(max(a, b), c);
	int t = s - m;
	while(k > 0)
	{
		k -= 1;
		m = 2*m;
	}
	cout << t + m;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//sin(x* pi / 180)
//be careful from the multiplication while using this define 
//alot of memset may couse TLE
#define TC int t;cin>>t;while(t--)
int dx[] = { 0,0,-1,1,1,1,-1,-1 };
int dy[] = { 1,-1,0,0,1,-1,1,-1 };
//</DEFINE>
int n;
ll OO = 1e18;
vector<int>v;
ll res[3000][3000][2];
//<FUNCTIONS>
ll solve(int l = 0, int r = n - 1, bool state = 1) {
	ll& ans = res[l][r][state];
	if (~ans)return ans;
	if (state) {
		ans = -OO;
		if (l == r)ans = v[l];
		else {
			ans = max(solve(l + 1, r, 0) + v[l], solve(l, r - 1, 0) + v[r]);
		}
	}
	else {
		ans = OO;
		if (l == r)ans = -v[l];
		else {
			ans = min(solve(l + 1, r, 1) - v[l], solve(l, r - 1, 1) - v[r]);
		}
	}
	return ans;
}
//</FUNCTIONS>	
int main() {
	Fast(), File();
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	memset(res, -1, sizeof(res));
	cout << solve() << endl;
}

Measured memory_bytes: 144488
#include <iostream>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "RRR") {
    cout << 3 << endl;
  } else if (s == "RRS" || s == "SRR") {
    cout << 2 << endl;
  } else if (s == "SSS") {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;

double calcAverage(vector<double> S)
{
    double Sum = 0;
    for(int i = 0; i < S.size(); ++i){
        Sum += S[i];
    }
    return Sum / S.size();
}
double calcStandardDeviation(vector<double> S)
{
    double m = calcAverage(S);
    
    double aa = 0;
    for(int i = 0; i < S.size(); ++i){
        aa += pow(S[i] - m, 2);
    }
    return sqrt(aa/S.size());
}

int main()
{
    
    while(true){
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        vector<double> S(n);
        for(int i = 0; i < n; ++i){
            cin >> S[i];
        }
        cout << fixed << setprecision(4);
        cout << calcStandardDeviation(S) << endl;
    }
    return 0;
}

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

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

    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = a[0];
    for(int i = 1; i < n-1; ++i) ans += a[(i+1)/2];
    cout << ans << endl;
}

Measured memory_bytes: 4740
#include <iostream>
int main() {
	int N;
	std::cin >> N;
	int maxL = 0;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int L;
		std::cin >> L;
		maxL = std::max(maxL, L);
		sum += L;
	}
	std::cout << ((sum - maxL > maxL) ? "Yes" : "No") << std::endl;
}

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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            char[] alpha = {'A','B','C','D','E','F','G','H','I','J','K','L',
                              'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            for(int i = 0; i <s.Length ; i++)
            {
                for(int j = 0; j< 26; j++)
                {
                    if (s[i] == alpha[j]) Console.Write(alpha[(j + n) % 26]);
                }
            }
        }
    }
}


Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int count(vector<int> &a){
  int res = 0;
  int n = a.size();
  for(int i=0;i<n-1;i++) res += a[i] != a[i+1];
  return res;
}

vector<int> chmin(vector<int> &a,vector<int> b){
  int ac = count(a), bc = count(b);
  if(ac != bc) return a = ac < bc? a:b;
  
  int n = min(a.size(),b.size());
  for(int i=0;i<n;i++) 
    if(a[i] != b[i]) return a = a[i] < b[i]? a:b;
  
  return a;
}

signed main(){
  int n,D;
  cin>>n>>D;

  vector<vector<int> > A(n,vector<int>(D));
  cin>>A;

  vector<int> C(D,INF);
  for(int d=0;d<D;d++)
    for(int i=0;i<n;i++) Min(C[d], A[i][d]);
  
  const int N = 51;
  vector<int> dp[N]; // day
  for(int i=1;i<N;i++) 
    for(int j=0;j<N;j++) dp[i].push_back(j);
  
    
  for(int d=0;d<D;d++){
      for(int i=0;i<n;i++){
        auto his = dp[d];
        for(int d2=d;d2 < D;d2++){
          if(A[i][d2] != C[d2]) break;
          his.push_back(i);
          chmin(dp[d2+1],his);
        }
      }
  }
  
  vector<int> ans = dp[D];

  int cost = 0;
  for(int i=0;i<D;i++) cost += C[i];
  cout<<cost<<" "<<count(ans)<<endl;
  for(int i=0;i<D;i++) cout<< ans[i]+1 << endl;
      
  return 0;
}



Measured memory_bytes: 3208
from functools import reduce
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def gcdlist(numbers):
    return reduce(gcd, numbers)

N, X = map(int, input().split())
x = list(map(int, input().split())) + [X]
x.sort()

dis = [0]*N
for i in range(N):
    dis[i] = x[i+1] - x[i]

print(gcdlist(dis))

Measured memory_bytes: 14596
N = int(input())
L = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
S = list(input())

for i in range(0,len(S)):
  for j in range(0,len(L)):
    if S[i] == L[j]:
      print(L[j-len(L)+N],end='')
      break
  

Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int i, j, k, l, n,m;
int H, W, N, Q;
int a, b, c;

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

	int *y;
	y = new int[n];

	for (i = 0; i < n; i++)
	{
		cin >> y[i];
	}
	int *x;
	x = new int[n];
	m = n / 2;
	k = 0;
	x[m] = y[k];
	if(n&1)//odd
	{
		for(i=0;i<m;i++)
		{
			x[m + 1 + i]=y[k+1];
			x[m - 1 - i]=y[k+2];
			k += 2;
		}
	}
	else//even
	{
		k++;
		x[m - 1]=y[k];
		for (i = 1; i<m; i++)
		{
			x[m + i]=y[k+1];
			x[m - 1 - i]=y[k+2];
			k += 2;
		}
	}
	for (i = 0; i < n; i++)
	{
		cout << x[i] << ' ';
	}
	cout << endl;
	delete[] x;
	delete[] y;

	return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        long champion = sc.nextLong();
        for (int i = 0; i < n - 1; i++) {
            long challenger = sc.nextLong();
            Pair pair = new Pair(champion, challenger);
            long ans = pair.max % pair.min;
            if (ans == 0) {
                champion = pair.min;
            } else {
                long ans2 = pair.min;
                while (ans != ans2) {
                    Pair p = new Pair(ans, ans2);
                    ans = p.max - p.min;
                    ans2 = p.min;
                }
                champion = ans;
            }
        }
        System.out.println(champion);
    }

    static class Pair {
        long max;
        long min;

        public Pair(long a, long b) {
            this.max = a > b ? a : b;
            this.min = a > b ? b : a;
        }
    }
}


Measured memory_bytes: 50360
import sys
from heapq import*
input = sys.stdin.readline
def main():
    N,M,S = map(int,input().split())
    edges = [[]for _ in range(N)]
    d = {}
    A = 0
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        u -= 1
        v -= 1
        A = max(A,a)
        edges[u].append((v,a,b))
        edges[v].append((u,a,b))
    ex = [tuple(map(int,input().split()))for _ in range(N)]

    M = 2500
    dist = [[2**60]*M for _ in range(N)]
    prev = [-1]*N
    if S >= M:S = M-1
    dist[0][S] = 0
    q = [(0,S,0)]
    while q:
        cost,sil,u = heappop(q)
        if dist[u][sil] < cost:continue
        if sil+ex[u][0] < M and cost+ex[u][1] < dist[u][sil+ex[u][0]]:
            dist[u][sil+ex[u][0]] = cost + ex[u][1]
            heappush(q,(dist[u][sil+ex[u][0]],sil+ex[u][0],u))
        for v,a,b in edges[u]:
            if sil >= a and cost+b < dist[v][sil-a]:
                dist[v][sil-a] = cost+b
                heappush(q,(dist[v][sil-a],sil-a,v))
    for t in range(1,N):
        print(min(dist[t]))





if __name__ == "__main__":
    main()

Measured memory_bytes: 24092
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  int a;
  cin >> a;
  if (a >= 1000)
  {
    cout << "ABD" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
  return 0;
}

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

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

    if((s[2] == s[3]) && (s[4] == s[5])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;
int main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    string rw1;
    rw1.append(a,'1');
    rw1.append(w-a,'0');
    string rw2;
    rw2.append(a,'0');
    rw2.append(w-a,'1');
    for(int i=0;i<b;i++) cout<<rw1<<endl;
    for(int i=0;i<h-b;i++) cout<<rw2<<endl;
    return 0;
}


Measured memory_bytes: 1280
#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 <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
    string S;

    cin >> S;

    if(S == "ABC")
        cout << "ARC" << endl;
    else
        cout << "ABC" << endl;
}

void B() {
    ll N, K;

    cin >> N >> K;

    vi snukes(N, 0);

    R1(K) {
        ll di;
        cin >> di;
        R2(j, di) {
            ll ai;
            cin >> ai;
            snukes[ai-1]++;
        }
    }

    ll tot = 0;
    for(auto e : snukes) {
        if(e == 0) {
            ++tot;
        }
    }

    cout << tot << endl;
}

void C() {
    ll N, M;

    cin >> N >> M;
    vi hi(N);
    vii ri(M);
    vi go(N, 1);

    R1(N)
        cin >> hi[i];

    R1(M) {
        ll s, e;
        cin >> s >> e;
        s-=1;
        e-=1;
        if(hi[s] > hi[e])
            go[e] = 0;
        else if(hi[s] < hi[e])
            go[s] = 0;
        else {
            go[e] = 0;
            go[s] = 0;
        }
    }

    ll tot = 0;
    for(auto e : go) {
        tot += e;
    }

    cout << tot << endl;
}

int main()
{
    C();
}

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


int main(){
  int N;
  cin >> N;
  vector<pair<string,int>> p(N);
  for(int i = 0;i<N;i++){
      cin >> p[i].first;
      cin >> p[i].second;
  }
  string X;
  cin >> X;

  int num = 0;//Xがpの何番目にあるか
  for(int i = 0;i<N;i++){
      if(p[i].first == X){
          num = i;
          break;
      }
  }
  int ans  =0;
  for(int i = num+1;i<N;i++){
      ans += p[i].second;
  }
  cout << ans << endl;

}

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

using namespace std;

const int mod = 1e9 + 7;
const int N = 2e3 + 5;

int dp[N];

int main() {
    ios::sync_with_stdio(false);
    dp[0] = 1;
    for (int j = 1; j < N; j++) {
        for (int i = 3; i < N; i++) {
            if (i > j) continue;
            dp[j] = (dp[j] + dp[j - i]) % mod;
        }
    }
    int n;
    cin >> n;
    cout << dp[n] << endl;
}

Measured memory_bytes: 3608
N=int(input())
status=0
res=0
arr=[eval(i) for i in input().split()]
for i in arr:
    if i==0:
        status=1
        break
#print(N,": ",arr)
if status==0:
    res=1
    for i in arr:
        res=res*i
        if res>10**18:
            res=-1
            break

print(res)




Measured memory_bytes: 21776
#include <stdio.h>

int main(){
   int i,n,h,mx,nh;
    
   scanf("%d",&n);
   scanf("%d",&h);
   mx=h;nh=1;
   for (i=1;i<n;i++) {
      scanf("%d",&h);
      if (h>=mx) {
         nh++;
         mx=h;
      }
   }
   printf("%d\n",nh);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n; cin >> n;
    vector<int> h(n,0);
    rep(i,n) cin >> h.at(i);
    vector<int> dp(n,0);
    dp.at(1) = abs(h.at(1) - h.at(0));
    for(int i=2;i<n;i++){
        dp.at(i) = min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)) , dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }
    cout << dp.at(n-1) << endl;
    //rep(i,n) cout << i << " " << dp.at(i) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
#define MOD 1'000'000'007LL

ll fct[N] = {1};
ll fctinv[N];
ll pw(ll a, ll b){
	ll ret = 1;
	while(b){
		if(b&1) ret = ret * a % MOD;
		a = a*a % MOD;
		b /= 2;
	}
	return ret;
}
ll inv(ll a){
	return pw(a, MOD - 2);
}
ll cmb(ll a, ll b){
	return fct[a] * fctinv[b] % MOD * fctinv[a-b] % MOD;
}

int n;
vector<int> g[N];
int p[N] = {}, c[N];
ll b[N];

void dfs(int a){
	c[a] = 1;
	b[a] = 1;
	for(auto i : g[a]) if(i != p[a]) {
		p[i] = a;
		dfs(i);
		b[a] = b[a] * b[i] % MOD * cmb(c[a] + c[i] - 1, c[i]) % MOD;
		c[a] += c[i];
	}
	DEBUG("b[%d]=%lld\n", a, b[a]);
}

void dfa(int a){
	if(a > 1){
		int q = p[a];
		ll x = b[q], y = b[a] * cmb(n-1, c[a]) % MOD;
		DEBUG("a=%d, q=%d, b[a]=%lld, x=%lld, y=%lld\n", a, q, b[a], x, y);
		x = x * inv(y) % MOD;
		b[a] = b[a] * x % MOD * cmb(n-1, c[a]-1) % MOD;
		DEBUG("  => b[a] = %lld\n", b[a]);
	}
	for(auto i : g[a]) if(i != p[a]) dfa(i);
}

int main(){
	FOR(i, 1, N) fct[i] = fct[i-1] * i % MOD;
	REP(i, N) fctinv[i] = inv(fct[i]);
	scanf("%d", &n);
	REP(i, n-1){
		int a, b; scanf("%d%d", &a, &b);
		g[a].EB(b);
		g[b].EB(a);
	}
	dfs(1);
	dfa(1);

	FOR(i, 1, n+1) printf("%lld\n", b[i]);
}


Measured memory_bytes: 20852
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll x, y; cin >> x >> y;
	ll ans = 1145148931919810;
	ll po[] = {x, -x}, yo[] = {y, -y};
	for(ll i = 0; i < 2; i++)for(ll j = 0; j < 2; j++) ans = (po[i] > yo[j] ? ans : min(ans, i + j + (yo[j] - po[i])));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(2):
    a.append(list(map(int, input().split())))
a[1] = a[1][::-1]
import numpy
res_0 = numpy.cumsum(a[0])
res_1 = numpy.cumsum(a[1])
ans = 0
for i in range(n):
    check = res_0[i] + res_1[n-1-i]
    ans = max(ans,check)
print(ans)

Measured memory_bytes: 12448
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, M, p[100001], i, judge[100001], ac=0, wa[100001], wasum=0;
    string s[100010];

    cin >> N >> M;

    for(i=1; i<=100000; i++){
        judge[i] = 0;
        wa[i] = 0;
    }

    for(i=1; i<=M; i++){
        cin >> p[i] >> s[i];

        if(judge[p[i]] == 0 && s[i] == "AC"){
            judge[p[i]] = 1;

            wasum += wa[p[i]];

            ac++;
        }

        if(judge[p[i]] == 0 && s[i] == "WA"){
            wa[p[i]]++;
        }

        /*if(judge[p[i]] == 1){
            cout << p[i] << endl;
            wasum += wa[p[i]];
        }*/
    }

    cout << ac << " " << wasum << endl;

    return 0;
}

Measured memory_bytes: 8064
n = int(input())
h = list(map(int, input().split()))

cnt = 0
ansers = []

for i in range(len(h)-1):
  if h[i] >= h[i+1]:
    cnt += 1
  else:
    ansers.append(cnt)
    cnt = 0
else:
  ansers.append(cnt)

print(max(ansers))

Measured memory_bytes: 63984
class Dice:
    def __init__(self, dice):
        self.dice = dice
        self.rule={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
    def output(self):
        return self.dice
    def move(self, direction):
        self.dice = [self.dice[y] for y in self.rule[_]]
        return self.dice

dice = Dice([int(x) for x in input().split()])
for _ in input(): dice.move(_)
print(dice.output()[0])


Measured memory_bytes: 5604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<map>
#include<queue>
using namespace std;
int main() {
	int n, k, d[10];
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
	}
	for (int i = n;; i++) {
		string s = to_string(i);
		for (int j = 0; j < s.size(); j++) {
			for (int l = 0; l < k; l++) {
				if (s[j]-'0' == d[l])goto age;
			}
		}
		cout << i << endl;
		break;
	age:;
	}
	return 0;
}

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

const int MX = 100005;

int main(){
    long long n;
    cin >> n;
    vector<long long> cnt(MX);
    for(int i=0; i<n; i++){
        int a; cin >> a;
        cnt[a]++;
    }
    long long ans = 0;
    for(int i=0; i<MX; i++) ans += i*cnt[i];

    int q;
    cin >> q;
    for(int i=0; i<q; i++){
        int b, c;
        cin >> b >> c;
        // ans -= b*cnt[b];
        // ans -= c*cnt[c];
        // cnt[c] += cnt[b]; cnt[b] = 0;
        // ans += b*cnt[b];
        // ans += c*cnt[c];
        ans += (c-b)*cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
    return 0;
}

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

namespace workspace
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] an = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToArray();
            int ans = 0;

            for (int i = 0; i < an.Length - 2; i++)
            {
                if (an[i] == an[i + 1])
                {
                    if (an[i + 1] == an[i + 2])
                    {
                        an[i + 1] = an[i] + 1 > 10000 ? an[i] - 1 : an[i] + 1;
                    }
                    an[i] = an[i + 1] + 1 > 10000 ? an[i] - 1 : an[i] + 1;
                    ans++;
                }
            }
            if (an[an.Length - 2] == an[an.Length-1]) ans++;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i, c) for (int i = 0; i < (c);i++)
using ll = long long;
using namespace std;
long long int choose(long long int num){
  return num * (num - 1) / 2;
}
int main(){
  int N;
  cin >> N;
  vector<int> data(N);
  REP(i, N) cin >> data.at(i);
  vector<int> cnt(N);
  REP(i, N) cnt.at(data.at(i) - 1)++;
  long long int sum = 0;
  REP(i, N) sum += choose(cnt.at(i));
  REP(i, N)
  {
    long long int ans=sum;
    ans -= choose(cnt.at(data.at(i) - 1));
    ans += choose(cnt.at(data.at(i) - 1)-1);
    cout << ans << endl;
  }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int MAXN=55,MOD=1e9+7,MAXL=63;
struct mat
{
    long long v[MAXN][MAXN];
    mat operator*(mat a)const
    {
        mat b;
        for(int i=0;i<MAXN;i++)
        {
            for(int j=0;j<MAXN;j++)
            {
                b.v[i][j]=0;
                for(int k=0;k<MAXN;k++)
                {
                    b.v[i][j]+=v[i][k]*a.v[k][j];
                    if(b.v[i][j]>=MOD)b.v[i][j]%=MOD;
                }
            }
        }
        return b;
    }
};
mat v,resp;
int main()
{
    int n;
    long long k;
    scanf("%d %lld",&n,&k);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)resp.v[i][j]=1;
            scanf("%lld",&v.v[i][j]);
        }
    }
    for(int i=MAXL;i>=0;i--)
    {
        if((1LL<<i)&k)
        {
            resp=resp*resp*v;
        }
        else resp=resp*resp;
    }
    long long rs=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            rs+=resp.v[i][j];
            if(rs>=MOD)rs%=MOD;
        }
    }
    printf("%lld\n",rs);
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<pair<ll,ll>> cnt(N);
    rep(i,N){
        ll now = A[i];
        ll sum = 0;
        ll kou = 0;
        rep(j,N){
            if(i == j) continue;
            if(now > A[j]){
                if(i < j){
                    sum++;
                    kou++;
                }
                else sum++;
            }
        }
        cnt[i] = {sum,kou};
    } 
    ll k_sum = (K-1)*K/2;
    k_sum %= MOD;
    ll ans = 0;
    rep(i,N){
        ans += (k_sum * cnt[i].first % MOD + cnt[i].second * K % MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections

def yn(b):
    print("Yes" if b==1 else "No")
    return

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def resolve():
    readline=sys.stdin.readline
    a,b=map(int, readline().rstrip().split())

    af = factorization(a)
    bf = factorization(b)

    c = collections.Counter()
    c[1]=2
    for x in af:
        c[x[0]]+=1
    for x in bf:
        c[x[0]]+=1
    ans=0
    for k in c.keys():
        if c[k]>=2:
            ans+=1
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16396
#include<iostream>
#include<string>
using namespace std;
int main(){
string s, sa, sb;
int f, i, ff=0;
string t = "keyence";
cin >> s;

for(int k=0; k<8;k++){
f=0;
sa=t.substr(0, k);
sb=t.substr(k, 7-k);

for(i=0; i<k; i++){
if(sa[i]!=s[i])
f=1;
}

for(i=0; i<7-k; i++){
if(sb[7-k-i-1]!=s[s.length()-i-1])
f=1;
}

if(f==0)
ff=1;
}

if(ff==1)
cout << "YES";
else
cout << "NO";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(auto& v: a) scanf("%lld", &v);

	for(auto v: a) {
		if(v != 0) continue;
		printf("0\n");
		return 0;
	}

	__int128 now = a[0];
	for(int i = 1; i < n; i++) {
		now *= a[i];
		if(now > (i64)1e18) {
			now = -1;
			break;
		}
	}
	printf("%lld\n", i64(now));
	return 0;
}


Measured memory_bytes: 4040
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

void func(void)
{
//DEBUG_OUT("----\n");
    uint32 N;
    cin >> N;

    int32 oddCnt = 0;
    int32 evenCnt = 0;
    int32 moreMulit4 = 0;
    for(uint32 i=0; i<N; i++){
        uint32 a;
        cin >> a;
        uint32 tmp;
        
        tmp = a & 1u;
        bool isOdd = (tmp == 1u);
        tmp = a & 3u;
        bool isMulti4 = (tmp == 0);
        if(isOdd){
            oddCnt++;
        }else if(isMulti4){
            moreMulit4++;
        }else{
            evenCnt++;
        }
    }

    bool isSuccess = false;
    if(oddCnt == moreMulit4){
        isSuccess = true;
    }
    else if((moreMulit4-1) == oddCnt){
        isSuccess = true;
    }
    else if(((oddCnt-1) == moreMulit4) && (evenCnt == 0)){
        isSuccess = true;
    }
    else if(oddCnt == 0){
        isSuccess = true;
    }

    if(isSuccess){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return;
}



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

using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  //inverse 逆元フェルマーの小定理から
  mint inv() const { return pow(mod-2);}
  //割り算は逆元をかける
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
  int n,k;
  std::cin >> n>>k;


  mint ans=0;

  //intでiを宣言するとバグる。why
  for (ll i = k; i <= n+1; i++) {

    // std::cout <<"i:"<<i << '\n';
    //
    // std::cout << n-i+1 << '\n';
    // std::cout << i*(n-i+1+n+1)/2 << '\n';
    // std::cout<<"i:"<<i<<" min:"<< i*(i-1)/2<<" max:" << (i*(n-i+n+1))/2 <<'\n';
    ll    temp=-i*(i-1)/2;
          temp+=(i*(n-i+n+1))/2;
          ans+=temp+1;
  }

  //

  std::cout << ans << '\n';





  // std::cout << ans << '\n';


  return 0;


}


Measured memory_bytes: 3588
<?php
$InputStrings = trim(fgets(STDIN));
$CountCharsArray=count_chars($InputStrings,1);
$IS_Beauty=true;
foreach ($CountCharsArray as $cnt) {
    if($cnt%2!==0){
        $IS_Beauty = false;
        break;
    }
}
if($IS_Beauty){
    echo "Yes",PHP_EOL;
}else{
    echo "No",PHP_EOL;
}

Measured memory_bytes: 3576
K=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K-1])

Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.*;

public class Main{

    static Scanner sc = new Scanner(System.in);
    static int h = Integer.parseInt(sc.next());
    static int w = Integer.parseInt(sc.next());
    static char[][] s = new char[h][w];

    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();

        for (int i=0; i<h; i++){
            s[i] = sc.next().toCharArray();
        }

        int ans = 0;

        Set<Integer> set = new TreeSet<>();

        for (int i=0; i<h; i++){
            for (int j=0; j<w; j++){
                if (s[i][j]=='#'){
                    continue;
                }
//                System.out.print(i);
//                System.out.println(j);
                P tmp = new P(i, j);
                int tt = bfs(tmp);
                set.add(tt);
            }
        }
        long end = System.currentTimeMillis();
//        out.println(end-start);
        StringBuilder sb = new StringBuilder();
        sb.append(((TreeSet<Integer>) set).last());
        out.println(sb);
        out.flush();

    }

    public static int bfs(P tmp){
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};

        int ret = 0;
        Queue<P> queue = new ArrayDeque<>();
        ((ArrayDeque<P>) queue).add(tmp);
        int[][] d = new int[h][w];

        d[tmp.s][tmp.t] = 0;

        while (!queue.isEmpty()){
            P p = ((ArrayDeque<P>) queue).pollFirst();
            for (int k=0; k<4; k++){
                int ny = p.s+dy[k];
                int nx = p.t+dx[k];
                if (ny<0 || h<=ny || nx<0 || w<=nx) continue;
                if (s[ny][nx]=='#') continue;
                if (d[ny][nx]!=0) continue;
                if (ny==tmp.s && nx==tmp.t) continue;
                P pp = new P(ny, nx);
                ((ArrayDeque<P>) queue).add(pp);
                d[ny][nx] = d[p.s][p.t]+1;
                ret = Math.max(ret, d[ny][nx]);
            }
        }
        return ret;
    }

    public static class P{
        int s;
        int t;
        public P(int s, int t){
            this.s = s;
            this.t = t;
        }
    }
}


Measured memory_bytes: 23744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n,k,r,s,p;
	cin>>n>>k>>r>>s>>p;
	string t;
	cin>>t;
	ll ans=0;
	for(int i=0;i<n-k;i++)
	  if(t[i]==t[i+k])t[i+k]='0';
	for(int i=0;i<n;i++)
	{
		if(t[i]=='r')ans+=p;
		if(t[i]=='s')ans+=r;
		if(t[i]=='p')ans+=s;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int fib(int);
int F[45];
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) F[i] = 0;
  printf("%d\n",fib(n));
  return 0;
}
int fib(int n){
  if(n==0 || n==1){
    return 1;
  }
  if(F[n]!=0) return F[n];
  F[n] = fib(n-2) + fib(n-1);
  return F[n];
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    init();

    int a, n, m;
    cin >> a >> n >> m;

    int ans = 0;
    eFOR(i, 1, 10000) {
        ll x = 1;
        FOR(j, 0, n)x *= i;
        if (m < x)break;

        int d = 0;
        while (x) {
            d += x % 10;
            x /= 10;
        }

        if (d + a == i)ans++;
    }

    cout << ans << "\n";
}



Measured memory_bytes: 3156
a,b,c=input().split()
ls=[a,b,c]
ls.sort()
if ls[0]==ls[1]==ls[2]:
  print("1")
else:
  if ls[0]==ls[1]:
    print("2")
  else:
    if ls[1]==ls[2]:
      print("2")
    else:
      print("3")

Measured memory_bytes: 9052
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;

int main()
{
    int n; cin >> n;
    vector<int> a(n+1), b(n+1);
    for(int i = 0; i < n+1; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= b[i]){
            ans += min(a[i], b[i]) + min(a[i+1], b[i] - a[i]);
            a[i+1] -= min(a[i+1], b[i] - a[i]);
        }
        else{
            ans += b[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<set>
#include<typeinfo>
#include<numeric>
#include<complex>
#include<memory>
using namespace std;

const double pi=4*atan(1.0);

constexpr long long mod=static_cast<long long>(1e9+7);

using cWeightEdges=vector<vector<pair<int,int>>>;
using cEdges=vector<vector<int>>;

int main(){
	string str;
	cin>>str;

	bool is_c=false;
	bool is_f=false;
	bool ans=false;
	for(const auto& val:str){
		if(val=='C')is_c=true;
		else if(val=='F'){
			if(is_c)is_f=true;
		}
	}

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

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int H, W;
	while(true){
 
	cin >> H >> W;
 
	if(H==0 && W==0){break;}
 
	for(int i=0; i<H; i++){
		if(i==0 || i==H-1){
		for(int j=0; j<W; j++){
			cout << "#";
		}
		cout<<endl;
		}
		else{
			cout << "#";
			for(int j=0; j<W-2; j++){
				cout << ".";
			}
			cout<< "#"<<endl;
		}
	}
 
	cout<<endl;
 
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int a,b,x;
  cin >> a >> b >> x;
  if (a <= x && a + b >= x) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int a, b;
	cin >> a >> b;
	cout << (a - 1) * (b - 1) << endl;
	
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<cstdio>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,m;
 cin>>n;
 vector<ll> vec;
 ll a,tmp=0;
 rep(i,0,n){
  cin>>a;
  vec.emplace_back(a);
 }
 sort(all(vec));
 ll base=vec[n-1];
 ll cmp=cei(base,2);
 rep(i,0,n){
  if(abs(cmp-tmp)>abs(cmp-vec[i])){
   tmp=vec[i];
  }
 }
 cout<<base<<" "<<tmp<<endl;
return 0;}


Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    ll N, K;
    cin >> N >> K;
    cout << floor(log(N) / log(K)) + 1;
    return 0;
}

Measured memory_bytes: 640
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    H = list(map(int,input().split()))

    dp = [0] * N
    dp[1] = abs(H[1] - H[0])
    for i in range(2,N):
        dp[i] = min(dp[j] + abs(H[i] - H[j]) for j in range(max(0,i-K),i))
    print(dp[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 85172