akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define foreach(a,A) for(auto &a:A)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    auto top = make_vector(n, (ll)0), bottom = make_vector(n, (ll)0);
    rep(i, n){
        cin >> top[i];
    }
    rep(i, n){
        cin >> bottom[i];
    }

    ll res = -INF;
    rep(i, n){
        ll score = 0;
        rep(j, i + 1){
            score += top[j];
        }
        rep(j, i, n){
            score += bottom[j];
        }
        chmax(res, score);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main(){
  int H, W;
  std::cin >> H >> W;
  std::vector<std::string> S(H+2);
  std::vector<std::vector<int>> left(H+2, std::vector<int>(W+2, 0));
  std::vector<std::vector<int>> right(H+2, std::vector<int>(W+2, 0));
  std::vector<std::vector<int>> up(H+2, std::vector<int>(W+2, 0));
  std::vector<std::vector<int>> down(H+2, std::vector<int>(W+2, 0));

  S[0] = "";
  S[H+1] = "";

  for(int i = 0; i<W+2; ++i){
    S[0] += "#";
    S[H+1] += "#";
  }

  for(int i=1; i<H+1; ++i){
    std::cin >> S[i];
    S[i] = "#" + S[i] + "#";
  }

  for(int i=1; i<H+1; ++i){
    for(int j=1; j<W+1; ++j){
      if(S[i][j] != '#'){
        left[i][j] = left[i][j-1] + 1;
        up[i][j] = up[i-1][j] + 1;
      }
    }
  }

  for(int i=H; i>0; --i){
    for(int j=W; j>0; --j){
      if(S[i][j] != '#'){
        right[i][j] = right[i][j+1] + 1;
        down[i][j] = down[i+1][j] + 1;
      }
    }
  }

/*
  for(int i=0; i<H+2; ++i){
    for(int j=0; j<W+2; ++j){
      std::cout << S[i][j];
    }
    std::cout << std::endl;
  }
*/

  int ans = 0;

  for(int i=1; i<H+1; ++i){
    for(int j=1; j<W+1; ++j){
      if(ans < left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3){
        ans = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3;
      }
    }
  }

  std::cout << ans << std::endl;

/*
  for(int i=0; i<H+2; ++i){
    for(int j=0; j<W+2; ++j){
      std::cout << left[i][j];
    }
    std::cout << std::endl;
  }

  for(int i=0; i<H+2; ++i){
    for(int j=0; j<W+2; ++j){
      std::cout << right[i][j];
    }
    std::cout << std::endl;
  }

  for(int i=0; i<H+2; ++i){
    for(int j=0; j<W+2; ++j){
      std::cout << up[i][j];
    }
    std::cout << std::endl;
  }

  for(int i=0; i<H+2; ++i){
    for(int j=0; j<W+2; ++j){
      std::cout << down[i][j];
    }
    std::cout << std::endl;
  }
*/

  return 0;
}


Measured memory_bytes: 71040
#include <iostream>
using namespace std;
int main()
{
	int antenna[5];
	int k;
	for (int i = 0; i < 5; i++)
	{
		scanf("%d", &antenna[i]);
	}
	scanf("%d", &k);
	bool isconnected = true;
	for (int i = 0; i < 5; i++)
	{
		for (int j = i+1; j < 5; j++)
		{
			if (antenna[j] - antenna[i] > k)
			{
				isconnected = false;
				break;
			}
		}
	}
	if (isconnected)
	{
		printf("Yay!");
	}
	else
	{
		printf(":(");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

const int INF = 1e8;

using namespace std;


int main(){
	_

	int n;

	cin>>n;

	int ans = 0;

	vi v(n + 1), dp(n + 1);

	rep(i, 0, n)
		cin>>v[i + 1];

	dp[1] = 0;
	dp[2] = abs(v[1] - v[2]);

	rep(i, 3, n + 1)
		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));

	cout<<dp[n]<<"\n";

	return 0;
}

Measured memory_bytes: 1024
using System;

   class Program
    {
        static void Main(string[] args)
        {

            int[] M = new int[10];
            for (int i =0; i<10;i++)
            {
                M[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(M);
            Array.Reverse(M);
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(M[i]);
            }
        }
    }


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

int main(){
    int N,K;cin>>N>>K;
    vector<int>v(N);
    for(register int i=0;i<N;i++)cin>>v[i];
    int dp[N+1];
    memset(dp,0,sizeof dp);
    dp[0] = 0;
    for(int i=1;i<N;i++){
            int ck = K;
        int  mi = INT_MAX;
        for(int j=i-1;ck>0 && j>=0;j--,ck--){
            mi = min(mi,abs(v[i]-v[j])+dp[j]);
        }
        dp[i] = mi;
        //cout<<i<<" "<<dp[i]<<endl;
    }
    cout<<dp[N-1]<<endl;
	return 0 ;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a[2] = {0};
	int n,i,x,y;
	scanf("%d", &n);
	while (n != 0){
		a[0] = 0;
		a[1] = 0;
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			if (x>y)a[0] = a[0] + x + y;
			else if (x < y)a[1] = a[1] + x + y;
			else{
				a[0] = a[0] + x;
				a[1] = a[1] + y;
			}
		}
		printf("%d %d\n", a[0], a[1]);
		scanf("%d", &n);
	}
	return 0;

}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int64 a, b, x;
    cin >> a >> b >> x;
    if (a == 0) {
        if (a == 0 && b == 0) {
            cout << 1;
        }
        else {
            cout << (b / x + 1);
        }
    }
    else {
        int64 ans = (b / x - (a - 1) / x);
        cout << ans;
    }
}

Measured memory_bytes: 256
void main() {
    string[] tmp = readln.split;
    string x = tmp[0], y = tmp[1];
    if (x < y) {
        '<'.writeln;
    } else if (x > y) {
        '>'.writeln;
    } else {
        '='.writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
n = int(input())
 
T_s = 0
H_s = 0
 
for i in range(n):
    animals = input().split()
    T_a = animals[0]
    H_a = animals[1]
    if T_a < H_a:
        H_s += 3
    elif T_a > H_a:
        T_s += 3
    else:
        T_s += 1
        H_s += 1
 
print(T_s, H_s)

Measured memory_bytes: 7656
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main(int argc, char* argv[]){
  char x[10];
  scanf("%c",x);
  x[0]++;
  printf("%c\n",x[0]);
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    long long n,m;
    cin>>n>>m;
    long long x;
    long long sum = 0;
    for(long long i=0;i<m;i++)
    {
        cin>>x;
        sum = sum + x;
    }
    if(sum>n)
    {
        cout<<"-1";
    }
    else
    {
        cout<<(n-sum);
    }
}


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

using namespace std;

int main(){
    long long a,b,x=1;
    cin >>a >>b;
    for(int i=2;i<=min(a,b)/2;i++){
        if((a%i==0)*(b%i==0)){
            x=i;
        }
    }
    if(max(a,b)%min(a,b)==0){
        x=min(a,b);
    }
    long long int answer = a*b/x;
    cout <<answer<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include<math.h>
#include<bitset>
using namespace std;

int main() {
	int n; cin >> n;
	if (n % 1000 == 0)cout << 0;
	else cout << 1000-n%1000 << endl;
}

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

int main()
{
    ll n;
    cin >> n;
    int ans = 0;
    rep(i, 0, n){
        ans = 0;
        for(ll x = 1; x*x <= i+1; x++){
            for(ll y = 1; x*x + y*y + x*y <= i+1; y++){
                for(ll z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= i+1; z++){
                    if(x*x + y*y + z*z + x*y + y*z + z*x == i+1) ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main{

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

	private Scanner scan;
	private int N,cnt;
	private int[] A;

	public void mainrun() {
		scan = new Scanner(System.in);

		N = scan.nextInt();
		cnt = 0;

		A = new int[N];
		for(int i = 0;i < N;i++) {
			A[i] = scan.nextInt();
		}

		mergeSort(0,N);

		for(int i = 0;i < N;i++) {
			System.out.print(A[i] + (i == N-1 ? "\n" : " "));
		}

		System.out.println(cnt);

		scan.close();
	}

	public void merge(int left,int mid,int right) {
		int n1 = mid - left;
		int n2 = right - mid;

		int L[] = new int[n1 + 1];
		int R[] = new int[n2 + 1];

		for(int i = 0 ; i < n1;i++) {
			L[i] = A[left + i];
		}

		for(int i = 0 ; i < n2;i++) {
			R[i] = A[mid + i];
		}

		L[n1] = Integer.MAX_VALUE;
		R[n2] = Integer.MAX_VALUE;

		int i = 0,j = 0;

		for(int k = left;k < right;k++) {
			if(L[i] <= R[j]) {
				A[k] = L[i];
				i++;
			}else {
				A[k] = R[j];
				j++;
			}
			cnt++;
		}
	}

	public void mergeSort(int left,int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(left,mid);
			mergeSort(mid,right);
			merge(left,mid,right);
		}
	}
}


Measured memory_bytes: 169280
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int n, k, h[100010], mini = 1000000010, tmp;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &h[i]);
	sort(h, h + n);
	for (int i = 0; i <= (n - k); i++) {
		tmp = h[i + k - 1] - h[i];
		mini = min(mini, tmp);
	}
	printf("%d\n", mini);
	return 0;
}

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

MOD = int(10**9 + 7)

def f(S):
    st = 0
    cnt = 0
    x = 1
    for i, c in enumerate(S):
        if i%2 == 0 and c == 'B' or i%2 == 1 and c == 'W':
            st += 1
            cnt += 1
        else:
            if st == 0:
                return 0
            x = x*st%MOD;
            st -= 1

    if st > 0:
        return 0

    for i in range(1, cnt+1):
        x = x*i%MOD

    return x



def main():
    N = int(input())
    S = input()

    print(f(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3516
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second



using namespace __gnu_pbds;
using namespace std;
// const int mod=1e9+7;
 const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 


int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}
const int MAXN=6e3;
vector<int>  adj[MAXN];
bool cycle=false;
int visited[MAXN];
int color[MAXN];
// void dfs(int node)
// {
//     visited[node]=1;
//     for(auto i:adj[node])
//     {
//         if(visited[i.fi]==0)
//         {
//             visited[i.fi]=1;
//             color[i.se]=1;
//             dfs(i.fi);
//             visited[i.fi]=2;
//         }
//         else if(visited[i.fi]==1)
//         {
//             cycle=true;
//             color[i.se]=2;
//         }
//         else
//             color[i.se]=1;
//     }
//     visited[node]=2;
// }


signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt[n][26];
    reset(cnt);
    cnt[0][s[0]-'A']++;
    for(int i=1;i<n;i++)
    {
        cnt[i][s[i]-'A']++;
        for(int j=0;j<26;j++)
            cnt[i][j]+=cnt[i-1][j];
    }

    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int k=i+1;k<n;k++)
        {
            if(s[i]!=s[k])
            {
                sum+=k-i-1 - (cnt[k-1][s[i]-'A']-cnt[i][s[i]-'A'])-(cnt[k-1][s[k]-'A']-cnt[i][s[k]-'A']);
            
                if((i+k)%2==0 && s[(i+k)/2]!= s[i] && s[(i+k)/2]!=s[k])
                    sum--;
            }
        }
    }
    cout<<sum<<endl;

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 4808
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    int cnt[6] = {0};
    double a;
 
    cin >> n;
    while (n--) {
	cin >> a;
	if (a < 165) cnt[0]++;
	else if (a < 170) cnt[1]++;
	else if (a < 175) cnt[2]++;
	else if (a < 180) cnt[3]++;
	else if (a < 185) cnt[4]++;
	else cnt[5]++;
    }
    for (int i = 0; i < 6; i++) {
	cout << i+1 << ":";
	for (int j = 0; j < cnt[i]; j++) {
	    cout << "*";
	}
	cout << endl;
    }
    return 0;
}

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

int main(){
  int num[3][3], check[3][3] = {};
  for(int i =0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> num[i][j];
    }
  }
  int n, tmp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> tmp;
    for(int j = 0;j<3;j++){
      for(int k = 0;k <3;k++){
        if(num[j][k] == tmp){
          check[j][k] = 1;
        }
      }
    }
  }
  string ANS ="No";
  for(int i =0;i<3;i++){
    if(check[i][0] == 1 && check[i][1] == 1 && check[i][2] == 1)
      ANS = "Yes" ;
  }
  for(int i =0;i<3;i++){
    if(check[0][i] == 1 && check[1][i] == 1 && check[2][i] == 1)
      ANS = "Yes" ;
  }
  if(check[0][0] == 1 && check[1][1] == 1 && check[2][2] == 1)
    ANS = "Yes" ;
  if(check[0][2] == 1 && check[1][1] == 1 && check[2][0] == 1)
    ANS = "Yes" ;
  cout << ANS << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }


int main(){
    ll n; cin>>n;
    ll res=0;
    for(ll i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0) res+=i;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(reverse = True, key = lambda x:x[1])

i = 0
cnt = 0
while cnt < N and i < M:
  A.extend([BC[i][1] for _ in range(BC[i][0])])
  cnt += BC[i][0]
  i += 1
A.sort(reverse = True)
l = A[0:N]

print(sum(l))

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

int main() {
    
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> b;
    for (int i = 0; i < M; i++) {
        int x;
        cin >> x;
        b.push_back(x);
    }
    int total = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0; 
        for (int j = 0; j < M; j++) {
            int x;
            cin >> x;
            sum += b[j] * x;
        }
        if ((sum + C) > 0) {
            total++;
        }
    }
    cout << total << endl;
    return 0;
}

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

using namespace std;
vector <int> A[30];
vector <int> B[30];
vector <int> V1,V2;
bool F1[30],F2[30];
int main()
{

    string S,T;
    cin>>S>>T;
    for(int i=0;i<S.size();i++)A[S[i]-'a'].push_back(i);
    for(int i=0;i<T.size();i++)B[T[i]-'a'].push_back(i);

    for(int i=0;i<S.size();i++){
        if(F1[S[i]-'a'])continue;
        F1[S[i]-'a']=1;
        V1.push_back(A[S[i]-'a'].size());
    }
    for(int i=0;i<T.size();i++){
        if(F2[T[i]-'a'])continue;
        F2[T[i]-'a']=1;
        V2.push_back(B[T[i]-'a'].size());
    }

    if(V1==V2)cout<<"Yes"<<endl;else cout<<"No"<<endl;



    return 0;
}


Measured memory_bytes: 2824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Mod 1000000007
char path[1001][1001];
ll n,m,visit[1001][1001];

ll dp(ll i, ll j)
{
    ll p,r;
    if(path[i][j]=='#')return 0;
    if(i==n-1 && j==m-1)return 1;
    if(visit[i][j]!=-1)return visit[i][j];
    p=r=0;
    if(j+1<m)p=dp(i,j+1);
    if(i+1<n)r=dp(i+1,j);
    return visit[i][j]=(p+r)%Mod;
}

int main()
{
    ll i;
    scanf("%lld %lld",&n,&m);
    for(i=0; i<n; i++)scanf("%s",path[i]);
    memset(visit,-1,sizeof(visit));
    printf("%lld\n",dp(0,0));
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S;
    int Q;
    cin >> S >> Q;

    int T;
    bool is_reversed = false;
    string prefix, suffix;
    rep(_, Q) {
        cin >> T;
        if (T == 1) {
            is_reversed = !is_reversed;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if (is_reversed) {
                if (F == 1) suffix = suffix + C;
                else prefix = C + prefix;
            } else {
                if (F == 1) prefix = C + prefix;
                else suffix = suffix + C;
            }
        }
    }

    string ans = prefix + S + suffix;
    if (is_reversed) reverse(ans.begin(), ans.end());
    cout << ans << endl;
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if((a<=c and c<=b) or (a>=c and c>=b)){
		cout<<"Yes"<<"\n";
	}
	else {
		cout<<"No"<<"\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, n;
    long long int mi=1000001, ma=-1000001, su=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<=mi){
            mi=a;
        }
        if(a>=ma){
            ma=a;
        }
        su+=a;
    }
    cout<<mi<<" "<<ma<<" "<<su<<endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <sstream>
#include <cstring>
#include <bitset>
#include <stack>
using namespace std;
#define MP make_pair
#define PB push_back
const int INF=1e9;
const long long INFLL=1e18;

int n,m,a[1005],last;
priority_queue<pair<int,int> > pq;
vector <int> ans;

int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i],pq.push(MP(m+1-a[i],i));
	ans.PB(0);
	for (int i=1;i<=m;i++)
	{
		pair<int,int> p=pq.top();
		pq.pop();
		if (p.second==last)
		{
			pair<int,int> other=pq.top();pq.pop();
			swap(p,other);pq.push(other);
		}
		p.first--;pq.push(p);last=p.second;ans.PB(last);
	}
	if (pq.top().first>0)
	{
		puts("-1");
		return 0;
	}
	cout<<n*(m+1)-m<<endl;
	for (int i=1;i<=m;i++)
	{
		for (int j=1;j<=n;j++) if (j!=ans[i] && j!=ans[i-1]) cout<<j<<" ";
		cout<<ans[i]<<" ";
	}
	for (int j=1;j<=n;j++) if (j!=ans[m]) cout<<j<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N1, K := sc.Next(), sc.NextInt()
	ans := getCount(N1, K)
	fmt.Println(ans)
}

func getCount(N1 string, K int) int {
	N := len(N1)
	dp := make([][][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([][]int, 2)
		for j := 0; j < len(dp[i]); j++ {
			dp[i][j] = make([]int, 5)
		}
	}
	dp[0][0][0] = 1

	for i := 0; i < N; i++ {
		for j := 0; j < 4; j++ {
			for smaller := 0; smaller < 2; smaller++ {
				mx := int(N1[i] - '0')
				if smaller == 1 {
					mx = 9
				}
				//fmt.Printf("%+v\n", mx)
				for x := 0; x <= mx; x++ {
					d := 0
					if smaller == 1 || x < int(N1[i]-'0') {
						d = 1
					}
					if x == 0 {
						dp[i+1][d][j] += dp[i][smaller][j]
					} else {
						dp[i+1][d][j+1] += dp[i][smaller][j]
					}
				}
			}
		}
		//fmt.Printf("%+v\n", dp)
	}
	ans := dp[N][0][K] + dp[N][1][K]
	return ans
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string A, B;

  cin >> A >> B;

  string ans = "";
  if (A < B)
    ans = "<";
  else if (A > B)
    ans = ">";
  else
    ans = "=";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long h;
	cin>>h;
	long long step = 1;
	long long sum = 0;
	while(step <= h)
	{
		sum += step;
		step *=2;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
num = abs(b - a + 1)

if a <= 0 <= b:
    print('Zero')
elif a < 0 and b < 0:
    if num % 2 == 0:
        print('Positive')
    else:
        print('Negative')
else:
    print('Positive')

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string s;
  int K;
  cin >> K;
  cin >> s;
  int len = s.size();
  if(len <= K){
    cout << s << endl;
    return 0;
  }
  string sub = s.substr(0,K);
  sub = sub + "...";
  cout << sub << endl; 
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int i;
  int length;
  int c;
  scanf("%d",&length);

  int A[length];
  for(i = 0 ; i < length ; i++){
    scanf("%d" , &A[i]);
  }

  for(c = 0 ; c < length ; c++){
    printf("%d",A[c]);
     if(length - 1 != c)printf(" ");
  }
  printf("\n");



  /*insertion sort start*/
  int v;
  int j;
  for(i = 1 ; i < length ; i++){
    int v = A[i];
    int j = i - 1;
    while (j >= 0){
      if(A[j] < v)break;
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;

    for(c = 0 ; c < length ; c++){
      printf("%d",A[c]);
       if(length - 1 != c)printf(" ");
    }
    printf("\n");
  }



  return 0;
}



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

main() {
  int N; cin >> N;
  ll tsum = 1, asum = 1;
  for (int i = 0; i < N; i++) {
    ll T, A; cin >> T >> A;
    ll g = max((tsum + T - 1) / T, (asum + A - 1) / A);
    tsum = g * T, asum = g * A;
  }
  cout << tsum + asum << endl;
}


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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

int main() {
  string s;
  const string ans = "CODEFESTIVAL2016";
  cin >> s;
  int res = 0;
  REP(i,16) {
    res += (ans[i] != s[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int t,a,b;
	while(1){
	scanf("%d",&a);
		if(a==0){
			return 0;
		}
	for(t=0;t<9;t++){
		scanf("%d",&b);
		a-=b;
	}
	printf("%d\n",a);
	}
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main() {
	int count[4][3][10];
	int n, b, f, r, v;
	cin >> n;
	for (int i = 0;i < 4;i++) {
		for (int j = 0;j < 3;j++) {
			for (int k = 0;k < 10;k++) {
				count[i][j][k] = 0;
			}
		}
	}

	for (int i = 0;i < n;i++) {
		cin >> b >> f >> r >> v;
		count[b-1][f-1][r-1] = count[b-1][f-1][r-1] + v;
	}

	for (int i = 0;i < 4;i++) {
		for (int j = 0;j < 3;j++) {
			for (int k = 0;k < 10;k++) {
			    if(k==9)cout << " " << count[i][j][k] << endl;
				else cout << " " << count[i][j][k];
			}
		}
		if(i!=3)cout << "####################" << endl;
	}
}


Measured memory_bytes: 3096
from math import pi,sin,cos

def print_p(p):
    print("{0:.8f} {1:.8f}".format(*p))

def koch(n,p1,p2):
    if n==0: return
    s = tuple(map(lambda z: (2*z[0]+  z[1])/3, zip(p1,p2)))
    t = tuple(map(lambda z: (  z[0]+2*z[1])/3, zip(p1,p2)))
    u = ( (t[0]-s[0])*cos(60*(pi/180)) - (t[1]-s[1])*sin(60*(pi/180)) + s[0] \
         ,(t[0]-s[0])*sin(60*(pi/180)) + (t[1]-s[1])*cos(60*(pi/180)) + s[1] )
    koch(n-1,p1,s)
    print_p(s)
    koch(n-1,s,u)
    print_p(u)
    koch(n-1,u,t)
    print_p(t)
    koch(n-1,t,p2)

if __name__=='__main__':
    n=int(input()) 
    p1 = [0.0  , 0.0]
    p2 = [100.0, 0.0]
    print_p(p1)
    koch(n,p1,p2)
    print_p(p2)

Measured memory_bytes: 8112
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    IN(ll, b);
    IN(ll, c);
    YES(2 * max({a, b, c}) == a + b + c);
}

Measured memory_bytes: 256
a_500 = gets.to_i
b_100 = gets.to_i
c_50 = gets.to_i
x = gets.to_i
cnt = 0
money = 0

(0..a_500).each do |a|
  (0..b_100).each do |b|
    (0..c_50).each do |c|
      cnt += 1 if a * 500 + b * 100 + c * 50 == x 
    end
  end
end

puts cnt

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using I = long long;
const I M = 1e9+7;
vector<I> factorial = {1};
I power(I m, I n) {
  if(!n) return 1;
  return (n & 1) ? (power(m, n - 1) * m % M) : power(m * m % M, n >> 1);
}
I inverse(I n) {
  return power(n, M - 2);
}
I memo[1001][1001];
I combination(I n, I r) {
  if(memo[n][r]) return memo[n][r];
  return memo[n][r] = (r % n == 0ll ? 1ll : (combination(n - 1, r - 1) + combination(n - 1, r)) % M);
}
int main() {
  I N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  while(factorial.size() <= N) factorial.emplace_back(factorial.back() * factorial.size() % M);
  vector<I> dp(N+1);
  dp[0] = 1;
  for(auto i=A; i<=B; ++i) if(i*C <= N) {
    auto dup = dp;
    auto c = 1ll;
    for(auto k=1ll; k<=(C-1); ++k) {
      c = c * combination(i*k, i) % M;
      c = c * inverse(k) % M;
    }
    for(auto j=0ll; j<N; ++j) if(dup[j]) {
      auto d = c;
      for(auto k=C; k<=D && j+i*k<=N; ++k) {
        d = d * combination(i*k, i) % M;
        d = d * inverse(k) % M;
        auto e = d * combination(N-j, i*k) % M;
        dp[j+i*k] += dup[j] * e % M;
        dp[j+i*k] %= M;
      }
    }
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 7424
#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++)

int intToBit(int num){
  int bit=0;
  while(1){
    int tmp;
    tmp = num%10;
    bit |= (1<<tmp);
    num /= 10;
    if(num == 0) break;
  }
  return bit;
}

int main() {
  int N,K;
  cin >> N >> K;
  int hate=0;
  rep(i,K){
    int D;
    cin >> D;
    hate |= (1<<D);
  }
  int res = N;
  while(1){
    if(!(intToBit(res) & hate)) break;
    res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#pragma region atcoder
#include <atcoder/all>
using namespace atcoder;
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;
using mint = modint998244353;

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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
struct S{
	mint x, w;
	S(mint x = 0, mint w = 1):x(x), w(w){};
};

S op(S a, S b){
	return S(a.x * b.w + b.x, a.w * b.w);
}

S e(){
	return S();
}

S mapping(int f, S a){
	if(f == 0) return a;
	else return S((a.w - 1) / 9 * f, a.w);
}

int composition(int f, int g){
	if(f == 0) return g;
	else return f;
}
int id(){
	return 0;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	lazy_segtree<S, op, e, int, mapping, composition, id> tree(n);
	rep(i,n) tree.set(i, S(1, 10));
	rep(i,q){
		int l, r, d; cin >> l >> r >> d;
		l--;
		tree.apply(l, r, d);
		S ans = tree.prod(0,n);
		printf("%d\n", ans.x.val());
	}
}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin,c.end()
#define tr(c,i) for(typeof(c).begin() i=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((c-1)/b <= (a-1)/d) cout<<"Yes";
    else cout<<"No";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}

Measured memory_bytes: 3676
N = int(input())

res = 0
for i in range(1,N+1):
  if i%2==0: continue
  cnt = 0
  num = i
  for j in range(1, int(i**0.5)+1):
    if num%j==0:
      cnt += 1
      if j != num//j:
        cnt += 1

  if cnt == 8: 
    res += 1

print(res)

Measured memory_bytes: 61896
# coding: utf-8

# input
N = int(input())
(D, X) = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))


# solve
t = 0
for i in range(N):
    j = 0
    while (True):
        if (1+j*A[i] <= D):
            t += 1
            j += 1
        else:
            break

print(t+X)


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

string s;

int main()
{
    cin >> s;
    for (int i = 0; i + 1 < s.length(); i++)
        if (s[i] == s[i + 1]) { printf("Bad\n"); return 0; }
    printf("Good\n");
    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    cout<<max(max(a+a-1,b+b-1),a+b);
}


Measured memory_bytes: 256
program abc55
 implicit none
 integer(8)::ia,ib,a,b,c,d,swap
 integer(8)::f(4)
 read(*,*)a,b,c,d
 f(1)=b*d
 f(2)=a*c
 f(3)=a*d
 f(4)=b*c
 print'(i0)',maxval(f)
end program abc55

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

int main() {
  int num,
      five = 0,
  	  seven = 0;
  
  for (int i = 0; i < 3; i++) {
    cin >> num;
    if (num == 5) {
      five++;
    } else if (num == 7) {
      seven++;
    }
  }
  
  if ((five == 2) && (seven == 1)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int A[N],top=0;
   
int main(){
  int a,b,c;
  char s[N];
     
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a = A[top-2];
      b = A[top-1];
      c = a + b;
      A[top-2] = c;
      top = top -1;
    }
    else if(s[0]=='-'){
      a = A[top-2];
      b = A[top-1];
      c = a - b;
      A[top-2] = c;
      top = top -1;
    }
    else if(s[0]=='*'){
      a = A[top-2];
      b = A[top-1];
      c = a * b;
      A[top-2] = c;
      top = top -1;
    }
    else{
      A[top] = atoi(s); 
      top = top + 1;
    }
  }
   
  printf("%d\n",A[0]);
    
  return 0;
}

Measured memory_bytes: 548
#include<iostream>

using namespace std;

int main()
{
    int n = 0;
    while (cin >> n && n) {
        if (n == 1) {
            cout << 1 << endl;
            continue;
        }
        for (int i = 0; i < n; i++) {
            int res = (1 << i);
            if (n < res ) {
                cout << res/2 << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int k = s.size();
  int N, S, W, E;
  N = 0; S = 0; W = 0; E = 0;
  
  for (int i = 0; i < k; i++) {
    if (s[i] == 'N') N++;
    if (s[i] == 'S') S++;
    if (s[i] == 'W') W++;
    if (s[i] == 'E') E++;
  }
  
  if ( (min(S, N) == 0 && max(S, N) > 0) || (min(W, E) == 0 && max(W, E) > 0) ) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  int A,B;cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1LL << 30)
#define pii pair<int, int>
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x)                         \
    cout << "\n"                          \
         << #x << ": ";                   \
    rep(i, x.size()) cout << x[i] << " "; \
    cout << endl
#define debug2d(x)                  \
    cout << "\n"                    \
         << #x << " is: \n";        \
    rep(i, x.size())                \
    {                               \
        rep(j, x[0].size())         \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }

#define MOD 1000000007
using namespace std;
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;
}
int N, M, K;
int Q;
int ans = 0;


vector<vector<int>>  bfs(vector<vector<int>> &g, int s){
    vector<vector<int>> dist(g.size(), vector<int> (3, INF));

    queue<pii> q;

    dist[s][0] = 0;
    q.push(make_pair(s,0));

    while(!q.empty()){
        int v = q.front().first;
        int l = q.front().second;
        q.pop();
        for (auto u: g[v]){
            int nl = (l+1)%3;
            if (dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(make_pair(u,nl));

        }
    }
    return dist;    
}





/*
    NOTE:
    - 変数名
 */
signed main()
{
    cin>>N>>M;

    vector<vector<int>> to(N);
    rep(i,M){
        int a,b;
        cin>>a>>b;
        --a;--b;
        to[a].push_back(b);
    }

    int sv,tv;
    cin>>sv>>tv;
    --sv;--tv;

    vector<vector<int>> dst = bfs(to,sv);

    int ans = dst[tv][0];
    cout<<((ans==INF) ? (-1) : (ans/3) )<<endl;





    return 0;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto n = load<int>();
	auto s = load<string>();
	if (n >= 3200)
		cout << s << '\n';
	else
		cout << "red\n";
}


Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
typedef int64_t ll;
typedef uint64_t ull;
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100001)
#define MOD (998244353)

ll d[MAXN];
ll dc[MAXN];

// べき乗余
int64_t modpow(int64_t b, int64_t e)
{
    int64_t result = 1;
    while(e>0)
    {
        if(e&1) result = (result * b) % MOD;
        e >>= 1;
        b = (b * b) % MOD;
    }
    return result;
}


int main(void)
{
    ll n;
    scanf("%ld",&n);

    for(int i=0;i<n;i++) scanf("%ld",&d[i]);
    for(int i=0;i<n;i++) dc[d[i]]++;

    if(dc[0]!=1 || d[0]!=0)
    {
        printf("0\n");
        return 0;
    }

    ll ans = 1;
    for(int i=1;i<MAXN;i++)
    {
        ans *= modpow(dc[i-1], dc[i]);
        ans %= MOD;
    }

    printf("%ld\n", ans);
    return 0;
}


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

const int N=5e2+50;
int mp[N][N]; char tar[N][N];
int main() {
    int h,w; cin>>h>>w;
    for(int i=1;i<=h;i++) cin>>(tar[i]+1);
    for(int i=1;i<=w;i++) mp[1][i]=1;
    for(int i=2;i<=h;i+=2) mp[i][1]=1;
    for(int i=3;i<=h;i+=2) 
        for(int j=1;j<w;j++) 
            mp[i][j]=1;
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++)
            if(mp[i][j] || tar[i][j]=='#') putchar('#');
            else putchar('.'); putchar('\n');
    } putchar('\n');
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++)
            if(!mp[i][j] || tar[i][j]=='#') putchar('#');
            else putchar('.'); putchar('\n');
    }
}

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

#define MAX 1000

int main(void) {
  int s[MAX];
  int n;

  while(1) {
    double a = 0;
    double m = 0;

    scanf("%d", &n);

    if(!n) {
      break;
    }

    for(int i=0; i<n; ++i) {
      scanf("%d", &s[i]);
      m += s[i];
    }

    m /= n;

    for(int i=0; i<n; ++i) {
      a += pow(s[i] - m, 2);
    }

    a /= n;

    printf("%f\n", sqrt(a));

  }
}



Measured memory_bytes: 2096
#include <stdio.h>

int main(void)
{
  long long x, ans;

  scanf("%lld", &x);

  ans = x / 11LL * 2LL;
  if (x % 11LL > 0LL)ans++;
  if (x % 11LL > 6LL)ans++;

  printf("%lld\n", ans);

  return(0);
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  cout << s.substr(0, k - 1);
  char c = s[k - 1];
  c += ('a' - 'A');
  cout << c;
  cout << s.substr(k, n - k) << endl;
}


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

#define ll long long



void solve(){
    string s;cin>>s;
    int n=s.size()/2;
    int ans=0;
    for(int i=0; i<n; i++){
        if(s[i]!=s[s.size()-1-i])ans++;
    } 
    cout<<ans<<endl; 
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
n = int(input())

if n == 1 or n == 2 or n == 3:
    ans = 0
else:
    prime = [2,3]
    fac = [0] * (n+1)
    fac[2] = 1
    fac[3] = 1
    for i in range(4,n+1):
        ii = i
        for j in range(2,i+1):
            det = 0
            if j in prime:
                if ii % j == 0:
                    det = 1
                while ii % j == 0:
                    fac[j] += 1
                    ii = ii // j
            if det == 0:
                prime.append(ii)
    
    #print(fac)
    c = [0] * 5
    for k in range(2,n+1):
        if fac[k] >= 74:
            c[4] += 1
        if fac[k] >= 24:
            c[3] += 1
        if fac[k] >= 14:
            c[2] += 1
        if fac[k] >= 4:
            c[1] += 1
        if fac[k] >= 2:
            c[0] += 1
    #print(c)
    pos = [0] * 4
    pos[0] = (c[1]*(c[1]-1)*(c[0]-2))//2
    pos[1] = c[4]
    pos[2] = c[2]*(c[1]-1)
    pos[3] = c[3]*(c[0]-1)
    ans = sum(pos)

print(ans)
    
        



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define FOR(i, a, b) for(ll i = a; i < b; i++)
#define FORR(i, a, b)   for(ll i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define MOD1 1000000007
#define MOD2 998244353
#define F first
#define S second
#define IOS std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define print(a) for(auto x : a)    cout<<x<<" "; cout<<"\n";
using namespace std;

#define maxn 10000001

void OFFLINE(){
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
    #endif
}

vector<int> arr(maxn, 1);

int main(){

    IOS;
    // OFFLINE();
    //check for corner test cases

    ll n;
    cin >> n;

    for(int i = 2; i <= n; i++){

        for(int j = i; j <= n; j += i)
            arr[j]++;
    }
    
    ll ans = 0ll;
    for(int i = 1; i <= n; i++)
        ans += (1ll * i * arr[i]);
    
    cout<<ans<<"\n";
    
    
    //check for corner test cases
    return 0;
}


Measured memory_bytes: 42116