akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);

int A, B;

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	cin >> A >> B;
	cout << gcd(A, B) << endl;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define vi vector<int>
int conc(string a, string b)
{
    string str = a+b;
    int ret = 0;
    for(int i=0; i<str.size(); i++){
        int t = str[i]-'0';
        ret = ret*10 + t;
    }
    return ret;
}
int main()
{
    faster;
    string a,b;
    int x,y;
    cin>>a>>b;
    x = conc(a,b);
    y = conc(b,a);
    int ans = 0;
    int sq=sqrt(x);
    if((sq*sq)==x)ans = 1;
    sq=sqrt(y);
    if((sq*sq)==y)ans = 1;
    if(ans==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}



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

class fast_Fourier_transform{
    private:
    const double PI=3.14159265358979; 
    
    std::vector<std::complex<double>> DFT(std::vector<std::complex<double>> A){
        int N=A.size();
        if(N==1)return A;
        std::vector<std::complex<double>> A0(N/2),A1(N/2),iA0,iA1,iA(N);
        for(int i=0;i<N;i++){
            if(i%2==0){
                A0[i/2]=A[i];
            }else{
                A1[i/2]=A[i];
            }
        }
        iA0=DFT(A0);
        iA1=DFT(A1);
        
        for(int i=0;i<N;i++){
            std::complex<double> ith_zeta = std::complex<double>(cos(2*PI*i/N),sin(2*PI*i/N));
            iA[i]=(iA0[i%(N/2)]+ ith_zeta*iA1[i%(N/2)]);
        }
        return iA;
    }
    
    std::vector<std::complex<double>> iDFT(std::vector<std::complex<double>> iA){
        int N=iA.size();
        std::vector<std::complex<double>> A,dA,rA;
        dA=DFT(iA);
        for(int i=0;i<N;i++){
            rA.push_back(dA[(N-i)%N]);
            A.push_back(rA[i]/std::complex<double>(N,0));
        }
        return A;
    }
    
    public:
    std::vector<int> convolution(std::vector<int> A,std::vector<int> B){
        int deg = A.size() + B.size() -1;
        int N=1;
        while(N<deg){N<<=1;}
        A.resize(N);B.resize(N);
        std::vector<std::complex<double>> dC(N),iC(N),dA,iA,dB,iB;
        std::vector<int> C(N);
        for(int i=0;i<A.size();i++){
            dA.push_back(A[i]);
        }
        for(int i=0;i<B.size();i++){
            dB.push_back(B[i]);
        }
        iA=DFT(dA);iB=DFT(dB);
        for(int i=0;i<N;i++){
            iC[i]=iA[i]*iB[i];
        }
        dC=iDFT(iC);
        for(int i=0;i<dC.size();i++){
            C[i]=(int)(0.1+dC[i].real());
        }
        return C;
    }
    
};


signed main(void){
    long long N,M,a,Amax=0;
    std::vector<int> A;
    std::cin >> N >> M;
    REP(i,N){
        std::cin >> a;
        Amax=std::max(Amax,a);
        A.push_back(a);
    }
    
    std::vector<int> B,C;
    B.resize(Amax+1,0);
    REP(i,N){
        B[A[i]]++;
    }
    fast_Fourier_transform FFT;
    C=FFT.convolution(B,B);
    
    /*REP(i,C.size()){
        if(C[i]==0)continue;
        cout <<i MM C[i] << endl;
    }*/
    
    long long Ans=0;
    long long now=0;
    RREP(i,C.size()){
        int d=C[i];
        if(M-now>=d){
            Ans+=d*i;
            now+=d;
        }else{
            Ans+=(M-now)*i;
            break;
        }
    }
    std::cout << Ans << std::endl;
    return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,T;
  cin >> N >> T;
  int res = 0;
  int pt = 0;
  for(int i=0;i<N;i++){
    int t; cin >> t;
    if( pt < t )
      res += T;
    else 
      res += (t + T) - pt;
    pt = t + T;
  }
  cout << res << endl;    
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   vector<int> a(n);

   rep(i,n) cin >> a[i];

   int ansmax = *max_element(a.begin(), a.end());
   int ansmin = *min_element(a.begin(), a.end());

   cout << ansmax - ansmin << endl;


   return 0;
}

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

int main()
{
  int n, k, r, s, p ;
  string t ;
  cin >> n >> k >> r >> s >> p >> t ;
  int64_t answer = 0 ;
  string ans ;
  for(int i = 0 ; i < n ; i++)
  {
    if(t.at(i) == 'r')
    {
      answer += p ;
      ans += 'p' ;
    }
    else if(t.at(i) == 's')
    {
      answer += r ;
      ans += 'r' ;
    }
    else
    {
      answer += s ;
      ans += 's' ;
    }
  }
  //cout << ans << endl ;
  for(int i = 0 ; i < n - k ; i++)
  {
    //cout << i << " " << i + k << endl ;
    if(i == n - k - 1 && ans.at(i) == ans.at(i + k))
    {
      int x ;
      if(ans.at(i) == 'r') x = r ;
      else if(ans.at(i) == 's') x = s ;
      else x = p ;
      answer -= x ;
      ans.at(i + k) = 'o' ;
    }
    else if(ans.at(i) == ans.at(i + k))
    {
      int x ;
      if(ans.at(i) == 'r') x = r ;
      else if(ans.at(i) == 's') x = s ;
      else x = p ;
      answer -= x ;
      ans.at(i + k) = 'o' ;
    }
    
  }
  //./a.out
  //cout << ans << endl ;
  cout << answer << endl ;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int i=0;i<n;i++){
            int num = Integer.parseInt(sc.next());
            map.put(num, map.containsKey(num)?map.get(num)+1: 1);
        }
        int ans = 0;
        for(int i: map.keySet()){
            if(map.get(i)%2==1) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 47816
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int INF = 1e9 + 7;

int N;
int dp[100010]; // dp[i] := i円引き出すための最小の操作回数

signed main()
{
	cin >> N;

	for (int i = 0; i <= N; ++i) dp[i] = INF;
	dp[0] = 0;

	for (int i = 0; i <= N; ++i) {
		chmin(dp[i + 1], dp[i] + 1);
		int six = 6, nine = 9;
		for (int j = 1; j <= 6; ++j) {
			if (i + six <= N)  chmin(dp[i + six], dp[i] + 1);
			if (i + nine <= N) chmin(dp[i + nine], dp[i] + 1);
			six *= 6;
			nine *= 9;
		}
	}

	cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int v[2010][2010];
int ver[2010][2010];
int hori[2010][2010];

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    for (int i = 0; i < N + 10; i++) {
        fill(v[i], v[i] + M + 10, 0);
        fill(ver[i], ver[i] + M + 10, 0);
        fill(hori[i], hori[i] + M + 10, 0);
    }
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < M; j++) {
            if (s[j] == '1') {
                v[i + 1][j + 1] = 1;
                if (j >= 1 && v[i + 1][j] == 1) {
                    hori[i + 1][j] = 1;
                }
                if (i >= 1 && v[i][j + 1] == 1) {
                    ver[i][j + 1] = 1;
                }
            }
        }
    }
    for (int i = 1; i < N + 1; i++) {
        for (int j = 1; j < M + 1; j++) {
            v[i][j] += v[i][j - 1];
            ver[i][j] += ver[i][j - 1];
            hori[i][j] += hori[i][j - 1];
        }
    }
    for (int i = 1; i < M + 1; i++) {
        for (int j = 1; j < N + 1; j++) {
            v[j][i] += v[j - 1][i];
            ver[j][i] += ver[j - 1][i];
            hori[j][i] += hori[j - 1][i];
        }
    }
    for (int i = 0; i < Q; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int vv = v[x2][y2] - v[x1 - 1][y2] - v[x2][y1 - 1] + v[x1 - 1][y1 - 1];
        int ver2 = ver[x2 - 1][y2] - ver[x1 - 1][y2] - ver[x2 - 1][y1 - 1] + ver[x1 - 1][y1 - 1];
        int hori2 = hori[x2][y2 - 1] - hori[x1 - 1][y2 - 1] - hori[x2][y1 - 1] + hori[x1 - 1][y1 - 1];
        cout << vv - ver2 - hori2 << endl;
    }
}


Measured memory_bytes: 49152
#include<bits/stdc++.h>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
#define charToInt(c) (c-'0')
int main()
{
    ll a,b,c=0,d,i,j;
    string s;
      in>>s;
    for(i=0;s[i];i++)
    {
        s[i]=s[i]-48;
        c+=s[i];
    }
    if(c%9==0)
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }

}


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

int main() {
  int N,M;
  cin >> N>>M;
  int l=1,r=N;
  for(int i=0;i<M;i++){
    int L,R;
    cin>>L>>R;
    l=max(l,L);
    r=min(r,R);
  }
  cout<<max(0,r-l+1)<<endl;

  }


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b, a % b);
}
ll lcm(ll a, ll b)
{
	return a / GCD(a, b) * b;
}
int main()
{
	long long a, b, c, d;
	int flag = 0;

	cin >> a >> b >> c >> d;
	long long k1 = a / c;
	if (a % c == 0) {
		k1--; flag = 1;
	}
	long long k2 = b / c;
	long long sum = 0;
	long long k3 = a / d;
	if (!flag && a % d == 0) k3--;
	long long k4 = b / d;
	ll m = lcm(c, d);
	long long k5 = a / m;
	long long k6 = b / m;
	cout << b - a + 1 - (k2 - k1) - (k4 - k3) + (k6 - k5) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> a(N+1, 0);
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int n = x*x+y*y+z*z+x*y+y*z+z*x;
                if (n <= N) a[n]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) cout << a[i] << endl;
}

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

const int costLim = 1200001;

int main()
{
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> costVec;
    vector<vector<int>> skillUpVec;

    for (int i = 0; i < n; ++i)
    {
        vector<int> singleBookSkillUpVec;

        int cost;
        cin >> cost;
        costVec.push_back(cost);

        for (int j = 0; j < m; ++j)
        {
            int input;
            cin >> input;
            singleBookSkillUpVec.push_back(input);
        }

        skillUpVec.push_back(singleBookSkillUpVec);
    }

    bool isFinished = false;
    vector<bool> nowUseFrag(n, false);

    int minCost = costLim;

    while (!isFinished)
    {
        vector<int> singleFinalSkillVec(m, 0);
        int singleCost = 0;

        // フラグ参考に使う本についてskillを足していく
        for (int bookIndex = 0; bookIndex < n; ++bookIndex)
        {
            if (nowUseFrag.at(bookIndex))
            {
                singleCost += costVec.at(bookIndex);

                for (int algIndex = 0; algIndex < m; ++algIndex)
                {
                    singleFinalSkillVec.at(algIndex) += skillUpVec.at(bookIndex).at(algIndex);
                }
            }
        }

        // skillがxを超えたか検証
        // 超えていたらminCost更新
        for (int algIndex = 0; algIndex < m; ++algIndex)
        {
            if (singleFinalSkillVec.at(algIndex) < x)
            {
                break;
            }

            if (algIndex == m - 1)
            {
                minCost = min(minCost, singleCost);
            }
        }

        // フラグ更新
        for (int i = n - 1; i >= 0; --i)
        {
            bool isRenewalFinished = false;

            if (!nowUseFrag.at(i))
            {
                nowUseFrag.at(i) = true;

                for (int j = i + 1; j < n; ++j)
                {
                    nowUseFrag.at(j) = false;
                }

                break;
            }

            if (i == 0)
            {
                isFinished = true;
            }
        }
    }

    cout << (minCost == costLim ? -1 : minCost) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	ll n,t;
	cin >> n >> t;
	ll a[100010];
	FOR(i,n)cin >> a[i];
	ll maxi[100010];
	maxi[n]=0;
	for(int i=n-1;i>=0;i--){
		maxi[i]=max(maxi[i+1],a[i]);
	}
	ll sum=0,c=0;
	FOR(i,n){
		if(c<maxi[i+1]-a[i]){
			c=maxi[i+1]-a[i];
			sum=1;
		}else if(c==maxi[i+1]-a[i]){
			sum++;
		}
	}
	cout << sum << endl;
}

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

using namespace std;

typedef pair<int, int> P;

P f(P a, P b)
{
	return P(b.first - a.first, b.second - a.second);
}

int main()
{
	int m, n;

	while (true) {
		cin >> m;
		if (m == 0) break;

		vector<P> seiza(m);

		for (int i = 0; i < m; ++i) cin >> seiza[i].first >> seiza[i].second;

		cin >> n;

		vector<P> image(n);

		for (int i = 0; i < n; ++i) cin >> image[i].first >> image[i].second;

		P s0 = seiza[0];

		for (int i = 0; i < n; ++i) {
			int cnt = 1;

			P amount_of_change = f(s0, image[i]);
			for (int j = 1; j < m; ++j) {
				P sj = seiza[j];
				for (int k = 0; k < n; ++k) {
					if (sj.first + amount_of_change.first == image[k].first && sj.second + amount_of_change.second == image[k].second) {
						cnt++;
					}
				}
				if (cnt == m) {
					printf("%d %d\n", amount_of_change.first, amount_of_change.second);
					goto end;
				}
			}
		}
end:;
	}
}

Measured memory_bytes: 1180
from sys import stdin
n = int(stdin.readline().rstrip())
st = [stdin.readline().rstrip() for _ in range(n)]
dic = {}
for s in st:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

dic = sorted(dic.items(), key=lambda x: -x[1])
vmax = 0
res = []
for k, v in dic:
    vmax = max(vmax, v)
    if vmax == v:
        res.append(k)
    else:
        break
for s in sorted(res):
    print(s)


Measured memory_bytes: 44744
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
using namespace std;

int w,h;
string m[100];
string dp[100][100];

string max_string(const vector<string>& vs){
	int max_len=0;
	string s;
	for(int i=0 ; i < vs.size() ; i++ ){
		max_len = max( max_len , (int)vs[i].size() );
	}
	for(int i=0 ; i < vs.size() ; i++ ){
		if( vs[i].size() == max_len && ( s.empty() || s < vs[i] ) ){
			s = vs[i];
		}
	}
	return s;
}

void solve(){
	for(int y=0 ; y < 100 ; y++ ){
		for(int x=0 ; x < 100 ; x++ ){
			dp[y][x].clear();
		}
	}

	int max_len=0;
	string ans;
	for(int y=h-1 ; y >= 0 ; y-- ){
		for(int x=w-1 ; x >= 0 ; x-- ){
			if( isdigit( m[y][x] ) ){
				dp[y][x].push_back( m[y][x] );
				vector<string> vs;
				if( x != w-1 && isdigit( m[y][x+1] ) ){
					vs.push_back( dp[y][x+1] );
				}
				if( y != h-1 && isdigit( m[y+1][x] ) ){
					vs.push_back( dp[y+1][x] );
				}
				dp[y][x] += max_string( vs );
			}
			if( !dp[y][x].empty() && dp[y][x][0] != '0' ){
				max_len = max( max_len , (int)dp[y][x].size() );
			}
		}
	}
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			if( dp[y][x].size() == max_len && ( ans.empty() || ans < dp[y][x] ) ){
				ans = dp[y][x];
			}
		}
	}
	cout << ans << endl;
}

int main(){
	while( cin >> w >> h , w || h ){
		for(int i=0 ; i < h ; i++ ){
			cin >> m[i];
		}
		solve();
	}
}

Measured memory_bytes: 1052
def main():
    n = int(input())
    a_s = [0] + list(map(int,input().split())) + [0]
    default = sum([abs(a_s[i-1] - a_s[i]) for i in range(1,len(a_s))])
    answer = 0
    for i in range(1,len(a_s)-1):
        if (a_s[i] >=  a_s[i-1]) == (a_s[i+1] >= a_s[i]):
            #長さは変わらず
            answer = default
        else:
            answer = default - abs(a_s[i]-a_s[i-1]) - abs(a_s[i+1]-a_s[i]) + abs(a_s[i+1] - a_s[i-1])
        print(answer)





if __name__ == '__main__':
    main()


Measured memory_bytes: 14172
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
-- import Data.Array
import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read . words <$> getLine :: IO [Int]
  solve' n as

solve' :: Int -> [Int] -> IO ()
solve' n as = go (IntMap.empty) . reverse $ zip as [1..n]
  where
    arr = listArray (1, n) as :: Array Int Int
    go :: IntMap.IntMap Int -> [(Int, Int)] -> IO ()
    go mp [] = do
      let m = sum . IntMap.elems $ mp
      print m
      if m == 0 
        then return ()
        else putStrLn . unwords . map show $ IntMap.keys mp
    go mp ((a, i):as) = go newmp as
      where
        bi = ((sumbs `mod` 2) + arr!i) `mod` 2
        newmp = if bi /= 0
          then IntMap.insert i bi mp
          else mp
        sumbs = sum $ catMaybes [ IntMap.lookup (i * j) mp | j <- [2..(n `div` i)]]


Measured memory_bytes: 96636
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        if(Pattern.matches("[A-Z]", a)) {
        	System.out.println("A");
        }else if(Pattern.matches("[a-z]", a)) {
        	System.out.println("a");
        }
        scanner.close();
    }
}

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 2e3 + 100;
const int maxN = 1e16;
const int oo = 1e18;
const int mod  = 1e9 + 7;

int n;
int a[N], dp[N][N];
ii tmp[N];

void upd(int &x, int y) { x = max(x, y); }

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("spm.out", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    FOR(i, 1, n) cin >> a[i], tmp[i] = {a[i], i};
    sort(tmp + 1, tmp + n + 1);
    FOR(i, 0, n + 1) FOR(j, 0, n + 1) dp[i][j] = -oo;
    dp[n + 1][0] = 0;
    FORW(i, n, 1) FOR(lef, 0, (n - i + 1)) {
        if(lef > 0 && lef <= tmp[i].se) upd(dp[i][lef], dp[i + 1][lef - 1] + tmp[i].fi * (tmp[i].se - lef));
        int rig = n - i + 1 - lef;
        if(rig > 0) upd(dp[i][lef], dp[i + 1][lef] + tmp[i].fi * (n - rig + 1 - tmp[i].se));
    }
    int ans = -oo;
    FOR(i, 0, n) upd(ans, dp[1][i]);
    cout << ans;
}


Measured memory_bytes: 36556
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;



int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    if (n % 2) cout << 0;

    else {
        ll ans = 0;
        ll f = 5;
        while (1) {
            ans += n / f / 2;
            if (f > n / 5) break;
            f *= 5;
        }
        cout << ans;
    }

}


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

int main(){
    ll N,K;cin>>N>>K;
    vector<ll> V(N);
    REP(i, N) cin >> V[i];
    ll ans=0;
    REP(i,N+1) REP(j,N+1){
        if(i-1>=N-j||i+j>K) continue;
        ll tmp=0;
        priority_queue<ll,vector<ll>,greater<ll>> que;
        REP(k,i){
            tmp+=V[k];
            if(V[k]<0) que.push(V[k]);
        }
        REP(k,j){
            tmp+=V[N-k-1];
            if(V[N-k-1]<0) que.push(V[N-k-1]);
        }
        REP(k,K-i-j){
            if(que.empty()) break;
            tmp-=que.top();que.pop();
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int sum = N*A;

		if(sum<=B) {
			System.out.println(sum);
		}else {
			System.out.println(B);
		}


	}

}

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

int main()
{
  int a, b, c; //ピザの値段
  int x, y;    //必要な枚数
  cin >> a >> b >> c >> x >> y;

  if (x <= y)
  {
    int tmp = std::min(2 * c * x + b * (y - x), 2 * c * y);
    cout << std::min(tmp, a * x + b * y) << endl;
  }
  else
  {
    int tmp = std::min(2 * c * y + a * (x - y), 2 * c * x);
    cout << std::min(tmp, a * x + b * y) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  char s[10];
  char moji[10];
  int len;
  
  scanf("%s",s);
  
  for(int i=0;i<10;i++){
    len=strlen(moji);
    if( len == 0 ) break;
    else moji[len-1] = '\0';
  }
  for(int i=0;i<strlen(s);i++){
    len=strlen(moji);
    if(s[i]=='0') moji[len]='0';
    else if(s[i]=='1') moji[len]='1';
    else {
      if( len == 0 ) continue;
      else moji[len-1] = '\0';
    }
  }
  for(int i=0;i<strlen(moji);i++)
  printf("%c",moji[i]);
    
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		char[] str = sc.next().toCharArray();
		
		n = str.length;
		digits = new int[n];
		
		for(int i = 0; i < n; i++) {
			digits[i] = str[i] - '0';
		}
		
		plus = new boolean[n - 1];
		
		dfs(0);
		
		System.out.println(total);
	}
	
	static int n;
	static int[] digits;
	static boolean[] plus;
	static long total = 0;
	
	static void dfs(int depth) {
		if(depth == n - 1) {
			total += calc();
			return;
		}
		
		plus[depth] = false;
		dfs(depth + 1);
		plus[depth] = true;
		dfs(depth + 1);
	}
	
	static long calc() {
		long result = 0;
		
		long geta = 1;
		
		for(int i = n - 1; i >= 0; i--) {
			result += geta*digits[i];
			
			if(i != 0) {
				if(plus[i - 1]) {
					geta = 1;
				}
				else {
					geta *= 10;
				}
			}
		}
		
		return result;
	}
	
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mod = 1000000007;
const int mxn = 5002;
int n, x, y;
int dp2[mxn];
int dp[mxn][2];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x >> y;
	if(x > y) swap(x, y);
	
	int ret = 1;
	dp[0][0] = dp[0][1] = dp2[0] = dp2[1] = 1;
	for(int i = 1; i <= n; i++){
		dp2[i + 1] = (dp2[i] + (i >= x)) % mod;
		for(int j = x; j < i; j++) (dp2[i + 1] += dp2[i - j]) %= mod;
		
		for(int j = 1; j <= min(i, x - 1); j++){
			(dp[i][0] += dp[i - j][1]) %= mod;
		}
		for(int j = 1; j <= min(i, y - 1); j++){
			(dp[i][1] += (ll)dp2[1 + j - (i != n) - (j != i)] * dp[i - j][0] % mod) %= mod;
		}
		
		(ret *= 2) %= mod;
	}
	(ret += (mod - (dp[n][0] + dp[n][1]) % mod)) %= mod;
	
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3672
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			int a = scan.nextInt();
			int b = scan.nextInt();
			System.out.println(a*b +" "+2*(a+b));
		}finally{
			if(scan !=null)scan.close();
		}

	}
}

Measured memory_bytes: 17164
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
char s[100004];
int main(void){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    scanf("%s",s);
    int i;
    int j=0,nj=0;
    for(i=0;i<n;i++){
		if(s[i]=='c') printf("No\n");
		else if(s[i]=='b'){
			if(nj<b && nj+j<a+b){
				printf("Yes\n");
				nj++;
			}else{
				printf("No\n");
			}
		}else{
			if(nj+j<a+b){
				printf("Yes\n");
				j++;
			}else{
				printf("No\n");
			}
		}
	}
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
void solve(){
    ll n;
    cin>>n;
    map<string,ll>m;
    for(ll i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC "<<"x "<<m["AC"]<<endl;
    cout<<"WA "<<"x "<<m["WA"]<<endl;
    cout<<"TLE "<<"x "<<m["TLE"]<<endl;
    cout<<"RE "<<"x "<<m["RE"]<<endl;
    return;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 3660
import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = map(int, readline().split())

ans = 1
ng = False
for x in a:
    ans *= x
    if x == 0:
        print(0)
        exit()
    if ans > 10**18:
        ng = True
        ans = 1

if ng:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 18224
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


# import random
# import time

d, n = map(int, input().strip().split())
if n == 100:
    ans = (100**d) * 101
else:
    ans = (100**d) * n
print(ans)


Measured memory_bytes: 63980
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int ans, a;
    for (int j = 0; j < n; j++) {
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans += 1;
        }
    }
    
    cout << ans << endl;   

    return 0;
}



Measured memory_bytes: 256
'use strict'

function main(input){
  const lines = input.split('\n');
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const M = lines[0].split(' ').map(x => parseInt(x))[1];



  let result = ((N-M)*100 + M*1900)*Math.pow(2,M);

  console.log(result);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;cin >> t;
    while(t--){
        ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
        map<int,ll> cos;
        cos[2]=a,cos[3]=b,cos[5]=c;
        map<ll,ll> mp;
        mp[n]=0;
        int x[3]={2,3,5};
        priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
        pq.push({0,n});
        while(!pq.empty()){
            ll u=pq.top().first,v=pq.top().second;
            pq.pop();
            if(u>mp[v]||u>INF){
                continue;
            }
            REP(i,3){
                ll t1=INF,t2=INF;
                if(v-v/x[i]<=INF/d){
                    t1=(v-v/x[i])*d;
                }
                if(v-v/x[i]-1<=INF/d){
                    t2=(v-v/x[i]-1)*d;
                }
                if(!mp.count(v/x[i])){
                    mp[v/x[i]]=min(u+(v%x[i])*d+cos[x[i]],u+t1);
                    pq.push({mp[v/x[i]],v/x[i]});
                }
                else{
                    if(chmin(mp[v/x[i]],min(u+(v%x[i])*d+cos[x[i]],u+t1))){
                        pq.push({mp[v/x[i]],v/x[i]});
                    }
                }
                if(!mp.count(v/x[i]+1)){
                    mp[v/x[i]+1]=min(u+(x[i]-v%x[i])*d+cos[x[i]],u+t2);
                    pq.push({mp[v/x[i]+1],v/x[i]+1});
                }
                else{
                    if(chmin(mp[v/x[i]+1],min(u+(x[i]-v%x[i])*d+cos[x[i]],u+t2))){
                        pq.push({mp[v/x[i]+1],v/x[i]+1});
                    }
                }
            }
        }
        cout << mp[0] << endl;
    }
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n) cin >> v.at(i);
  int m = 0;
  
  rep(get,min(n,k)+1){
    rep(a,get+1){
      priority_queue<int,vector<int>,greater<int>> pq;
      int ans = 0;
      rep(i,a){
        ans += v.at(i);
        pq.push(v.at(i));
      }
      rep(i,get-a){
        ans += v.at(n-1-i);
        pq.push(v.at(n-1-i));
      }
      int cnt = k - get;
      while(!pq.empty() && cnt > 0){
        if(pq.top() < 0){
          ans -= pq.top();
          pq.pop();
          cnt --;
        }else{
          break;
        }
      }
      m = max(m,ans);
      //cout << m << endl;
    }
  }
  
  cout << m << endl;
  return 0;
}






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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = s.Contains("9") ? "Yes" : "No";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:23:02 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

s = ns()

ans = 0
for i in range(len(s)):
    if s[i] == '1':
        ans += 1

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

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

	res := 0
	for x := 1; x <= n; x++ {
		v := x
		sum := 0
		for v > 0 {
			sum += v % 10
			v /= 10
		}
		if a <= sum && sum <= b {
			res += x
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	char a;
	scanf("%c", &a);
	
	if(a >= 'a' && a <= 'z')	puts("a");
	else if(a >= 'A' && a <= 'Z')	puts("A");
	
	return 0;
}

Measured memory_bytes: 3684
// Author : Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();

// function to calculate any numbered power of some number without modulo
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
// function to check whether a bracketed sequence is balanced or not
bool isBalanced(const string &exp) {
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
// function to sort by second in a set of pairs
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}



// main funtion
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int n , m ;
	cin >> n >> m  ;
	ll ans = 0 ;
	ll rem = m ;
	// vector<int> b(n) ;
	// vector<ll> a(n) ;
	vector<pair<ll, ll>> p(n) ;
	for (int  i = 0  ; i < n ; i++) {
		cin >> p[i].first >> p[i].second ;
	}
	sort(p.begin() , p.end()) ;
	// for (int i = 0 ; i < n ; i++) {
	// 	cout << p[i].first << " " << p[i].second << "\n";
	// }
	for (int i = 0 ; i < n ; i++) {
		if (rem < p[i].second) {
			ans += p[i].first * rem ;
			break ;
		} else {
			rem -= p[i].second ;
			ans += p[i].first * p[i].second  ;
		}
	}
	cout << ans << "\n";

	// ll a , b ;
	// cin >> a >> b ;
	// // we have to find the Xor of a , a+1 , a+2 , .... , b .
	// ll cnt(60) ;
	// for(int i = 0 ; i < 60 ; i++){

	// }











	// }







	return 0 ;
}


Measured memory_bytes: 4700
#include <iostream>
#include <vector>
#include <string>
class dice
{
private:
	std::vector<int> faces;
public:
	dice(int *surface){
		for(int i = 0 ; i < 6 ; i ++){
			faces.push_back(surface[i]);
		}
	};
	dice(){};
	int getSurface(){
		return faces[0];
	};
	int getRight(){
		return faces[2];
	};
	int *getFaces(){
		return faces.data();
	}
	void print(){
		for(int f : faces){
			std::cout << f << " " ;
		}
		std::cout << std::endl;
	}
	dice roll(char d)
	{
		int *s = new int[6];
		switch(d){
			case 'S':
			s[0] = faces[4]; s[1] = faces[0]; s[2] = faces[2];
			s[3] = faces[3]; s[4] = faces[5]; s[5] = faces[1];
			break;
			case 'N':
			s[0] = faces[1]; s[1] = faces[5]; s[2] = faces[2];
			s[3] = faces[3]; s[4] = faces[0]; s[5] = faces[4];
			break;
			case 'E':
			s[0] = faces[3]; s[1] = faces[1]; s[2] = faces[0];
			s[3] = faces[5]; s[4] = faces[4]; s[5] = faces[2];
 			break;
			case 'W':
			s[0] = faces[2]; s[1] = faces[1]; s[2] = faces[5];
			s[3] = faces[0]; s[4] = faces[4]; s[5] = faces[3];
			break;
		}
		dice newdice(s);
		delete[] s;
		return newdice;
	};
	bool isAnswer(int top,int front)
	{
		if(faces[0] == top && faces[1] == front){
			return true;
		}else{
			return false;
		}
	};
	int answerQuestion(int top,int front)
	{
		std::vector<std::string> patterns = {
			"","E","EE","W",
			"S","SE","SEE","SW",
			"SS","SSE","SSEE","SSW",
			"N","NE","NEE","NW",
			"ES","ESE","ESEE","ESW",
			"WS","WSE","WSEE","WSW"};
		std::vector<dice> canditates;
		for(std::string pattern : patterns){
			dice d = (*this);
			for(char op : pattern){
				d = d.roll(op);
			}
			canditates.push_back(d);
		}
		for(dice canditate : canditates){
			if(canditate.isAnswer(top,front)){
				return canditate.getRight();
			}
		}
		return -3;
	};
	bool isTheSame(dice &target)
	{
		int *f = target.getFaces();
		for(int i = 0 ; i < 6 ; i ++){
			if(f[i] != faces[i]) return false;
		}
		return true;
	}
	bool answertheSame(dice &target)
	{
		std::vector<std::string> patterns = {
			"","E","EE","W",
			"S","SE","SEE","SW",
			"SS","SSE","SSEE","SSW",
			"N","NE","NEE","NW",
			"ES","ESE","ESEE","ESW",
			"WS","WSE","WSEE","WSW"};
		std::vector<dice> canditates;
		for(std::string pattern : patterns){
			dice d = (*this);
			for(char op : pattern){
				d = d.roll(op);
			}
			canditates.push_back(d);
		}
		for(dice canditate : canditates){
			if(target.isTheSame(canditate)){
				return true;
			}
		}
		return false;
	};
};

int main(int argc, char const *argv[])
{
	int n = 0;
    std::cin >> n;
    std::vector<dice> dices;
    for(int i = 0 ; i < n ; i ++){
        int *d = new int[6];
        for(int j = 0 ; j < 6 ; j ++){
            std::cin >> d[j];
        }
        dice temp(d);
        delete [] d;
        dices.push_back(temp);
    }
    int num = dices.size();
    for(int i = 0 ; i < num ; i ++){
        for(int j = i+1 ; j < num ; j ++){
            if(dices.at(i).answertheSame(dices.at(j))){
                std::cout << "No" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 3216
//             بسم الثالوث الاقدس

#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<fstream>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;


bool prime(int x)
{
	if (x == 1)
		return false;
	else if (x == 2)
		return true;
	for (int i = 2; i*i <= x; i++)
	{
		if (x%i == 0)
			return false;

	}
	return true;
}
bool AreDoubleSame(double dFirstVal, double dSecondVal)
{
	return fabs(dFirstVal - dSecondVal) < numeric_limits<double>::epsilon();
}


/*
jesus help me.......
jesus help me.......
jesus help me.......
*/




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


	//freopen("keys.in", "r", stdin);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)
		cout << "Left" << endl;
	else if (a + b < c + d)
		cout << "Right" << endl;
	else
		cout << "Balanced" << endl;




	//system("pause");
	return 0;
}
/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> difficulties(n);
	for (int i = 0; i < n; ++i) {
		cin >> difficulties[i];
	}

	sort(difficulties.begin(), difficulties.end());

	int median = difficulties[n / 2];
	cout << median - difficulties[n / 2 - 1] << "\n";

	return 0;

}

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

// #undef DEBUG
// #define DEBUG
/// {{{ DEBUG --- ///
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if(&o == &cerr) { o << '{'; for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? ", " : ""); o << "}"; } else { for(size_t i = 0; i < v.size(); i++) o << v[i] << (i + 1 != v.size() ? " " : ""); } return o; }
#ifdef DEBUG
#define dump(...) (cerr<<"["<<__LINE__<< "] "<<#__VA_ARGS__<<" = "<<make_tuple(__VA_ARGS__)<<"\n")
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
#else
#define dump(...) (0)
#endif
/// }}}--- ///

ll sign(ll x) {
  return x < 0 ? -1 : 1;
}

ll dfs(int i, int to, ll r, ll now, ll t1, ll t2) {
  if(i == to) return r == 0;
  ll k = abs(r) / now;
  k = min(k, i ? 9ll : 8ll);
  ll res = 0;
  res += ((i ? 10 : 9) - k) * dfs(i + 1, to, r - sign(r) * now * k, now - t1 - t2, t1 / 10, t2 * 10);
  if(k != (i ? 9 : 8)) {
    k++;
    res += ((i ? 10 : 9) - k) * dfs(i + 1, to, r - sign(r) * now * k, now - t1 - t2, t1 / 10, t2 * 10);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s; cin >> s;
  int d = stoi(s);
  int m = s.size();
  ll ans = 0;
  for(int l = 2; l <= m * 2; l++) {
    ll now = pow((long double) 10, l - 1) - 1;
    ll t1 = 9 * pow((long double) 10, l - 2);
    ll t2 = 9;
    ans += (l % 2 ? 10 : 1) * dfs(0, l / 2, d, now, t1, t2);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		sc.close();
		int max = N * 100;
		long[][] dp = new long[N + 1][max + 1];
		dp[0][0] = 1;
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < max; j++) {
				if(dp[i][j] != 0) {
					dp[i + 1][j] += dp[i][j];
					int k = j + A[i];
					dp[i + 1][k] += dp[i][j];
				}
			}
		}
		long cnt = 0;
		for(int i = 0; i <= max; i++) {
			if(i % 2 == P) {
				cnt += dp[N][i];
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26324
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll Q,H,S,D;
ll N;

int main(){
    cin>>Q>>H>>S>>D>>N;

    Q*=4;
    H*=2;

    S=min(S,min(Q,H));
    ll ans=min(S*N,N/2*D+N%2*S);

    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec(k) vector<k>
#define vecvec(k) vector<vector<k> >
#define pai(k) pair<k,k>
#define mod 1000000007
#define mpai make_pair
#define p1 first
#define p2 second
#define umap(x,y) unordered_map<x,y>


ll solve(ll *arr, int n)
{
	ll dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	ll cost[n+1][n+1];
	memset(cost,0,sizeof(cost));
	for(int i=0;i<n;i++)
	{
		dp[i][i]=arr[i];
	}
	// for(int i=0;i<n-1;i++)
	// {
	// 	dp[i][i+1]=arr[i]+arr[i+1];
	// }
	int ans=0;
	for(int L=2;L<=n;L++)
	{
		for(int i=0;i<=n-L+1;i++)
		{
			int j=i+L-1;
			cost[i][j]=1e18;
			dp[i][j]= dp[i][j-1]+dp[j][j] ;
			for(int k=i;k<=j;k++)
			{
				// cout<<"h";
				cost[i][j]=min(cost[i][j],cost[i][k] + cost[k+1][j] +dp[i][j]);
			}
			// ans+=dp[i][j];
		}
	}
	// for(int i=0;i<n;i++)
	// {
	// 	for(int j=0;j<n;j++)
	// 		{cout<<dp[i][j]<<" ";
	// }
	// 	cout<<" \n";
	// }
	return cost[0][n-1];
}

int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    ll n,x;
    cin>>n;
   ll arr[n];

    for(int i=0;i<n;i++){
	cin>>arr[i];
}
ll ans=solve(arr,n);
cout<<ans<<"\n";


return 0;
}


Measured memory_bytes: 2816