akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   vector<int> tmp;
   int a, b;
   for(int i = 0; i < 3; i++){
      cin >> a >> b;
      tmp.push_back(a);
      tmp.push_back(b);
   }
   int cnt1=0;
   int cnt2=0;
   int cnt3=0;
   int cnt4=0;
   for(int i = 0; i < 6; i++)
   {
      if(tmp[i] == 1){cnt1++;}
      else if(tmp[i] == 2){cnt2++;}
      else if(tmp[i] == 3){cnt3++;}
      else if(tmp[i] == 4){cnt4++;}
   }
   if((cnt1 == 3)||(cnt2 == 3)||(cnt3 == 3)||(cnt4 == 3)){
      cout << "NO" << endl;
   }
   else{cout << "YES" << endl;}
   return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    N, M, Q = map(int, readline().rstrip().split())
    train_cnt = [[0] * N for _ in range(N)]
    for _ in range(M):
        l, r = map(int, readline().rstrip().split())
        train_cnt[l-1][r-1] += 1
    
    for i in range(N):
        for j in range(1, N):
            train_cnt[i][j] += train_cnt[i][j-1]
    
    for j in range(N):
        for i in range(N-2, -1, -1):
            train_cnt[i][j] += train_cnt[i+1][j]
    
    for _ in range(Q):
        p, q = map(int, readline().rstrip().split())
        print(train_cnt[p-1][q-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 9708
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	vector<ll> A(N);
	FDS(i,N){
		cin>>A[i];
	}
	VSORT(A);
	VREV(A);
	ll j=0;
	vector<ll> B(2);
	B[0]=0;
	B[1]=0;
	FDS(i,N-1){
		if(A[i]==A[i+1]){
			B[j]=A[i];
			A[i+1]=0;
			j++;
		}
		if(j==2) break;
	}
	cout<<B[0]*B[1]<<endl;
}

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

using namespace std;
using ll=long long;

#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)

int main(){
    string s;
    cin>>s;
    int n=s.length();
    rep(i,0,n) cout<<"x";
}

Measured memory_bytes: 256
package main

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

// 二分探索で目的の値より大きいインデックスを返す
func upperBound(list []int64, n int64) int64 {
	var l int64 = 0
	var r int64 = int64(len(list) - 1)
	for l <= r {
		var mid int64 = l + (r-l)/2
		if list[mid] <= n {
			l = mid + 1
		} else {
			r = mid - 1
		}
	}
	return l
}

func main() {
	list := getStdinIntArr64()
	N := list[0]
	M := list[1]
	K := list[2]
	A := getStdinIntArr64()
	B := getStdinIntArr64()
	Asum := make([]int64, N+1)
	Bsum := make([]int64, M+1)

	var i int64 = 0
	var ans int64 = 0

	for i = 0; i < N; i++ {
		Asum[i+1] = Asum[i] + A[i]
	}
	for i = 0; i < M; i++ {
		Bsum[i+1] = Bsum[i] + B[i]
	}

	var apos int64 = 0
	for ; apos <= N; apos++ {
		if Asum[apos] > K {
			break
		}
		if M > 0 {
			var bpos int64 = upperBound(Bsum, K-Asum[apos])
			if bpos != 0 {
				bpos--
			}
			if apos+bpos > ans {
				ans = apos + bpos
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 21260
array = Array.new

while val = gets do
    array.push(val.chomp.split)
end

n = array[0][0].to_i
s,t = array[1]

strings = ''

for i in 1..n do
    strings += s.slice(i-1)
    strings += t.slice(i-1)
end

puts(strings)

Measured memory_bytes: 14360
#include <bits/stdc++.h>
#define mod 1000000007
#define djfs first
#define akdk second
#define N 100000000
#define fo(i,m,n) for(int i=m;i<n;i++)
#define M 7
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
using ul=unsigned long long;
using pii=pair<int,int>;
using vvi=vector<vector<int>>;
using vi=vector<int>;
using pll=pair<ll,ll>;
using vsi=vector<set<int>>;
using vll=vector<ll>;

ll power(ll a,ll n){
    ll j=0;
    ll x=1;
    while(1ll<<j<=n){
        if(1ll<<j&n)
            x=(x*a)%mod;

        a=a*a%mod;
        j++;
    }

    return x;
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int lb(vi &a,int x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;
    while(l<=r){
        int mid=(l+r)/2;
        if(x>=a[mid]){
            l=mid+1;
            ind=mid;
        }
        else
            r=mid-1;

    }

    return ind+1;

}

int up(vll &a,ll x){
    int n=a.size();
    int l=0;
    int r=n-1;
    int ind=-1;

    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>x){
            r=mid-1;
            ind=mid;
        }
        else
            l=mid+1;

    }

    return ind;
}

ll max(ll a,ll b){
    if(a>b)
        return a;
    else
        return b;

}

ll min(ll a, ll b){
    if(a>b)
        return b;
    else
        return a;

}

void yn(bool a){
    if(a)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

}


bool isodd(int a,int b,int agx,int agy){

    return (abs(a-agx)+abs(b-agy))%2;

}
int fap(vi &par,int x){
    if(par[x]!=x)
        par[x]=fap(par,par[x]);

    return par[x];
}

void unin(vi &par,vi &rank,int x,int y){
    int px=fap(par,x);
    int py=fap(par,y);

    if(px!=py){
        if(rank[px]<rank[py])
            swap(px,py);

        par[py]=px;
        rank[px]+=rank[py];
    }
}

struct fenwick_tree
{
    vll bit;
    int n;
    fenwick_tree(int n){
        this->n=n;
        bit=vll(n+1);
    }

    void update(int idx,ll val){
        while(idx<=n){
            bit[idx]+=val;
            idx+=idx&-idx;
        }
    }

    void rupdate(int l,int r,int x){
        update(l,x);
        update(r+1,-x);
    }

    ll query(int idx){
        ll tot=0;
        while(idx){
            tot+=bit[idx];
            idx-=idx&-idx;
        }

        return tot;
    }

};


int main(){

    ll n;
    cin>>n;
    cout<<(mod+(power(10,n)-power(9,n)-power(9,n)+power(8,n))%mod)%mod<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string res = "square1001";
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 2980
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;

template<class T>
void chmax(T &a, const T b) {
    if (b > a) a = b;
}

template<class T>
void chmin(T &a, const T b) {
    if (b < a) a = b;
}

namespace Math {
    ll modpow(ll b, ll p, ll m) {
        ll r = 1;
        for (; p; p >>= 1, b = b * b % m)
            if (p & 1)
                r = r * b % m;
        return r;
    }

    ll modinv(ll b, ll m) { return modpow(b, m - 2, m); }

    // Least significant bit.
    ll lsb(ll x) { return x & (-x); }

    template<class T>
    const T inf() { return 0; }

    template<>
    const ll inf<ll>() { return 0x3f3f3f3f3f3f3f3fll; }

    template<>
    const int inf<int>() { return 0x3f3f3f3f; }

    template<class T>
    T gcd(T a, T b) { return abs(__gcd(a, b)); }

    template<class T>
    T clamp(T n, T l, T r) { return n < l ? l : n > r ? r : n; }

    template<class T>
    T lcm(T a, T b) { return abs(a / gcd(a, b) * b); }

    template<class T>
    T sgn(T n) { return n == 0 ? 0 : n > 0 ? 1 : -1; }

    // Generic modular integer.
    template<int MOD, typename IntType = int>
    struct GModint {
        IntType val;

        GModint() : val(0) {}

        GModint(int v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        GModint(ll v, bool safe = false) { val = safe ? v : ((v % MOD) + MOD) % MOD; }

        explicit operator bool() const { return val != 0; }

        const bool operator==(const GModint &g) const { return val == g.val; }

        const bool operator!=(const GModint &g) const { return val != g.val; }

        const GModint operator+=(const GModint &g) { return *this = *this + g; }

        const GModint operator-=(const GModint &g) { return *this = *this - g; }

        const GModint operator*=(const GModint &g) { return *this = *this * g; }

        const GModint operator/=(const GModint &g) { return *this = *this / g; }

        const GModint operator^=(const GModint &g) { return *this = *this ^ g; }

        const GModint operator-() const { return GModint(val == 0 ? 0 : MOD - val, true); }

        const GModint operator+(const GModint &g) const {
            ll newval = val + g.val;
            if (newval >= MOD)
                newval -= MOD;
            return GModint(newval, true);
        }

        const GModint operator-(const GModint &g) const { return *this + (-g); }

        const GModint operator*(const GModint &g) const { return GModint(1ll * val * g.val); }

        const GModint operator/(const GModint &g) const { return *this * g.inv(); }

        template<class T>
        const GModint operator^(const T t) const { return GModint(modpow(val, t, MOD)); }

        const GModint inv() const { return GModint(modinv(val, MOD)); }
    };

    using Modint = GModint<1000000007>;
}

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

    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int x; cin >> x;
    cout << a[x-1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

#define MAX_H 5000000

int H;
int Q[MAX_H];

void maxHeapify(int idx) {
  int l = 2*idx+1;
  int r = 2*idx+2;
  int largest = idx;
  if(l < H && Q[largest] < Q[l]) largest = l;
  if(r < H && Q[largest] < Q[r]) largest = r;
  
  if(largest != idx) {
    swap(Q+idx, Q+largest);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  int i;
  for(i = H/2; i >= 0; i--) maxHeapify(i);
}

int heapMaximum() {
  return Q[0];
}

int ExtractMax() {
  if(H < 1) return -1;
  int max = heapMaximum();
  Q[0] = Q[H-1];
  H--;
  maxHeapify(0);
  return max;
}

void heapIncreaseKey(int idx, int key) {
  if(key < Q[idx]) return;
  Q[idx] = key;
  while(idx > 0 && Q[(idx-1)/2] < Q[idx]) {
    swap(Q+idx, Q+(idx-1)/2);
    idx = (idx-1)/2;
  }
}

void maxHeapInsert(int key) {
  H++;
  Q[H-1] = -1;
  heapIncreaseKey(H-1, key);
}

int main() {
  int i;
  char buf[256];
  H = 0;
  while(scanf("%s", buf), strcmp(buf, "end") != 0) {
    if(strcmp(buf, "insert") == 0) {
      int k;
      scanf("%d", &k);
      maxHeapInsert(k);
    } else if(strcmp(buf, "extract") == 0) {
      printf("%d\n", ExtractMax());      
    }
  }
  
  return 0;
}

Measured memory_bytes: 4692
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n == 0)  break;
            int[] scores = new int[n];
            for(int i=0; i<scores.length; i++){
                scores[i] = sc.nextInt();
            }
            double average = 0, variance = 0;
             
            for(int i=0; i<n; i++){
                average += scores[i];
            }
            average /= n;
            for(int i=0; i<n; i++){
                variance += (scores[i] - average)*(scores[i] - average);
            }
            variance /= n;
            System.out.println(Math.sqrt(variance));
             
        }
 
    }
 
}



Measured memory_bytes: 31396
#include <iostream>
using namespace std;
void bubbleSort(struct Card A[], int N);
void selectSort(struct Card B[], int N);
void print(struct Card C[], int N);
bool checkSort(struct Card A[], struct Card B[], int N);

struct Card{
    char type;
    int number;
};
    

void bubbleSort(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        for(int j = N-1; j >= i + 1; j--) {
            if(A[j].number < A[j-1].number) swap(A[j], A[j-1]);
        }
    }
}
    
    
void selectSort(struct Card B[], int N){
    for(int i = 0; i < N; i++){
        int position = i;
        for(int j = i+1; j < N; j++){
            if(B[position].number > B[j].number) position = j;
        }
        if(i != position) swap(B[i], B[position]);
    }
}

void print(struct Card C[], int N){
    for(int i = 0; i < N; i++){
        cout << C[i].type << C[i].number << ((i != N-1) ? " " : "\n");
    }
}


bool checkSort(struct Card A[], struct Card B[], int N){
    for(int i = 0; i < N; i++){
        if(A[i].type != B[i].type) return false;
    }
    return true;
}

    
int main(){
    Card bubbleCard[100], selectCard[100];
    int N;
        
    cin >> N;
        
    for(int i = 0; i < N; i++){
        cin >> bubbleCard[i].type >> bubbleCard[i].number;
        selectCard[i] = bubbleCard[i];
    }
    
    bubbleSort(bubbleCard, N);
    selectSort(selectCard, N);
    
    print(bubbleCard, N);
    cout << "Stable" << endl;
    
    
    print(selectCard, N);
    cout << ((checkSort(bubbleCard, selectCard, N) == true) ? "Stable" : "Not stable") << endl;
}



Measured memory_bytes: 3100
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, C, K) = nextIntList()
    val T = IntArray(N) { nextInt() }.sorted()
    var ans = 0
    var c = 0
    var k = 0
    for (t in T) {
        if (c == C || k < t) {
            ans++
            c = 1
            k = t + K
            continue
        }
        c++
    }
    println(ans)
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

int k;

vs ans;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>k;
    if(k<=9)
    {
    	cout<<k<<endl;
    	return 0;
	}
	ans.PB("1");
	ans.PB("2");
	ans.PB("3");
	ans.PB("4");
	ans.PB("5");
	ans.PB("6");
	ans.PB("7");
	ans.PB("8");
	ans.PB("9");
	int lf=0,rt=8;
	int cnt=9;
	while(cnt<k)
	{
		for(int i=lf;i<=rt;i++)
		{
			str s=ans[i];
			char n1=s[sz(s)-1]-1,n2=s[sz(s)-1]+1;
			if(n1>='0')
			{
				str t1=s;
				t1+=n1;
				ans.PB(t1);
				cnt++;
			}
			str t2=s;
			t2+=s[sz(s)-1];
			ans.PB(t2);
			cnt++;
			if(n2<='9')
			{
				str t3=s;
				t3+=n2;
				ans.PB(t3);
				cnt++;
			}
			if(cnt>=k)
			{
				cout<<ans[k-1]<<endl;
				return 0;
			}
		}
		lf=rt+1;
		rt=cnt-1;
	}
	cout<<ans[k-1]<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 6900
package main

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

var sc *bufio.Scanner

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const INF = 1000000000

type row struct {
	num    int
	blacks int
}

type rows []row

func (r rows) Len() int {
	return len(r)
}

func (r rows) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r rows) Less(i, j int) bool {
	return r[i].blacks < r[j].blacks
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	board := make([][]bool, n)
	for i := range board {
		board[i] = make([]bool, n)
		s := nextStr()
		for j, r := range s {
			if r == '#' {
				board[i][j] = true
			}
		}
	}

	var rows rows = make([]row, n)
	for i, line := range board {
		rows[i].num = i
		for _, b := range line {
			if b {
				rows[i].blacks++
			}
		}
	}
	sort.Sort(sort.Reverse(rows))

	if rows[0].blacks == 0 {
		fmt.Println(-1)
		return
	}

	ans := INF
	for _, r := range rows {
		if n-r.blacks > ans {
			break
		}
		count := 1
		for i := range board {
			if board[i][r.num] {
				count -= 1
				break
			}
		}
                count += (n - r.blacks)
		if ans > count {
			ans = count
		}
	}

	for j := 0; j < n; j++ {
		for i := range board {
			if !board[i][j] {
				ans++
				break
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char **argv)
{
  int N, M, C;

  cin >> N >> M >> C;

  vector<int> B(M);

  for (int i = 0; i < M; i++)
  {
    cin >> B.at(i);
  }

  int num_correct = 0;

  for (int i = 0; i < N; i++)
  {
    int correct_degree = C;
    for (int j = 0; j < M; j++)
    {
      int a;
      cin >> a;
      correct_degree += a*B.at(j);
    }
    if (correct_degree > 0)
      num_correct++;
  }

  cout << num_correct << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i;
	cin >> num;
	vector<ll> d(num), l(num + 1), r(num + 1);
	for (i = 0; i < num; i++)
		cin >> d[i];
	l[num] = 2;
	r[num] = 2;
	for (i = num - 1; i >= 0; i--) {
		if (l[i + 1] % d[i] == 0)
			l[i] = l[i + 1];
		else
			l[i] = d[i] * ((l[i + 1] / d[i]) + 1);
		r[i] = d[i] * ((r[i + 1] / d[i]) + 1) - 1;
		if (l[i] > r[i]) {
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n", l[0], r[0]);
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n,a[100010];
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int main(){
//	while(1){
	n=read();
	if(n>15000){
		int x=15000,y=n-15000,ans=0,sum=225015000;
		for(int i=x;i>=1;i--){
			if(y%2==1){y++;sum-=i*2;continue;}
			if(sum%3==0){ans=i;break;}
			y++;sum-=i*2;
		}
		//if(ans&&(y-1)*6+3<=30000)printf("yes");
		for(int i=1;i<=ans;i++)printf("%d ",i*2);
		int now=3;
		for(int i=1;i<=n-ans;i++)printf("%d ",now),now+=6;
		return 0;
	}
	int sum=0;
    for(int i=1;i<=n-2;i++)a[i]=2*i,sum+=a[i],printf("%d ",a[i]);
    bool ok=0;
    for(int i=3;i<=7000;i+=2){
    	for(int j=i+2;j<=7000;j+=2){
    		if(gcd(i,sum+j)!=1&&gcd(j,sum+i)!=1){printf("%d %d\n",i,j);ok=1;break;}
    	}
    	if(ok)break;
    }
//}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int q,q1;
	cin>>q>>q1;
	if(q*2<=q1 && q*4>=q1){
		if((q1-(2*q))%2==0)
			cout<<"Yes";
		else
			cout<<"No";
	}
	else {
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const long long INF = 1e18;

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<vector<long long>> memo(N, vector<long long>(N, INF));
    function<long long(int, int)> dp = [&](int l, int r) {
        if(memo[l][r] != INF) return memo[l][r];
        if(l == r) return memo[l][r] = A[l];
        return memo[l][r] = max(A[l] - dp(l + 1, r), A[r] - dp(l, r - 1));
    };
    cout << dp(0, N - 1) << '\n';
    return 0;
}


Measured memory_bytes: 71040
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import deque

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
    u,v,w = map(int,input().split())
    edge[u-1].append([v-1,w])
    edge[v-1].append([u-1,w])

# 親を探索(頂点0を根)
parent = [0] * N
for v,_ in edge[0]:
    parent[v] = 0
open_list = deque([0])
while open_list:
    now = open_list.popleft()
    for v,w in edge[now]:
        if v == parent[now]:
            continue
        open_list.append(v)
        parent[v] = now


# 根からの距離を探索
path = [0] * N
open_list = deque([0])
while open_list:
    now = open_list.popleft()
    for v,w in edge[now]:
        if v == parent[now]:
            continue
        open_list.append(v)
        path[v] = path[now] + w

for i in path:
    if i % 2 == 0:
        print(0)
    else:
        print(1)

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

typedef pair<int,int> ii;

const int N = 2e3+5;
const int oo = 1e9;

int n;
int res[N]={0}, dist[N];
vector<int> AdjList[N];

void bfs(int s){ 
	
	for(int i = 0; i < n; ++ i) dist[i] = oo;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	dist[s] = 0;
	pq.push({0, s});
	while(!pq.empty()){
		ii nodo = pq.top(); pq.pop();
		int d = nodo.first, u = nodo.second;
		//if(d > dist[u]) continue;
		res[d]++;
		for(int v: AdjList[u]){
			
			if( dist[v] > dist[u] + 1 ){
				dist[v] = dist[u] + 1;
				//cout<<u<<"-"<<v<<" "<<dist[v]<<endl;
				pq.push({dist[v], v});
				
			}
		}
	}
}

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

	for (int i = 0; i < n-1; ++i){
		AdjList[i].push_back(i+1);
		AdjList[i+1].push_back(i);
	}
	AdjList[x-1].push_back(y-1);
	AdjList[y-1].push_back(x-1);

	for (int i = 0; i < n; ++i)
	{
		bfs(i);
	}
		


	for (int i = 1; i < n; ++i)
	{
		cout<<(res[i]>>1)<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int f[10000005];

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
ll ans=0;
rep(i,1,n)
{
	for(int j=i;j<=n;j+=i)
	f[j]++;
	ans+=1ll*i*f[i];
}
ol(ans);

return 0;
}



Measured memory_bytes: 42696
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int N,M,X,Y;
int main(){
    cin >> N >> M >> X >> Y;
    vector<int> x(N),y(M);
    rep(i,N) cin >> x[i];
    rep(i,M) cin >> y[i];
    repi(Z,X+1,Y){
        bool flag = true;
        rep(i,N) if(x[i] >= Z) flag = false;
        rep(i,M) if(y[i] < Z) flag = false;
        if(flag){
            cout << "No War" << '\n';
            return 0;
        }
    }
    cout << "War" << '\n';
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] xn = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var x = xn[0];
        var n = xn[1];

        var ans = int.MaxValue;
        if (n != 0)
        {
            int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ok = true;
            var i = 0;
            while (ok)
            {
                if (Array.IndexOf(p, x + i) == -1)
                {
                    ans = Math.Min(ans, x + i);
                    ok = false;
                }

                if (Array.IndexOf(p, x + (i * -1)) == -1)
                {
                    ans = Math.Min(ans, x + (i * -1));
                    ok = false;
                }

                i++;
            }
        }
        else
        {
            ans = x;
        }

        // 出力
        
        Console.WriteLine(ans);
    }
}

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

using namespace std;
typedef long long ll;
const long double pi=3.14159265358979323846;
#define x  first
#define y  second

bool isP(ll x)
{
    for(int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)return 0;
    }
    return 1;
}
ll cnt[100002]={};
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("op.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,q,sum=0,x,xx;
        cin>>n;
        for(int i=0;i<n;i++)cin>>x,sum+=x,cnt[x]++;
        cin>>q;
        while(q--)
        {
            ll xx,y;
            cin>>xx>>y;
            sum-=cnt[xx]*xx;
            sum+=cnt[xx]*y;
            cnt[y]+=cnt[xx];
            cnt[xx]=0;
            cout<<sum<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 4352
package main

import (
	"fmt"
	"time"
)

func main() {
	var s string
	fmt.Scan(&s)

	layout := "2006/01/02"
	date, _ := time.Parse(layout, s)
	if date.After(time.Date(2019, 4, 30, 0, 0, 0, 0, time.UTC)) {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).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; }

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;

    auto pf = prime_factor(n);
    ll ans = 0;

    for(auto p:pf){
        ll num, cnt;
        tie(num, cnt) = p;
        ll tmp = 1;
        while(true){
            cnt -= tmp;
            if(cnt<0) break;
            tmp ++;
            ans++;
        }
    }
    cout<<ans<<endl;



    return 0;

}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int x, y;
    cin >> x >> y;

    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, -1, 0, 1};

    vector<string> board(x);
    rep(i, x) cin >> board[i];

    rep(i, x)
    {
        rep(j, y)
        {
            rep(k, 4)
            {
                int xx = i + dx[k];
                int yy = j + dy[k];
                if (0 <= xx && xx < x && 0 <= yy && yy < y && board[i][j] == '#' && (board[xx][yy] == '#' || board[xx][yy] == 'O'))
                {
                    board[i][j] = 'O';
                    board[xx][yy] = 'O';
                }
            }
        }
    }

    rep(i, x)
    {
        rep(j, y)
        {
            if (board[i][j] == '#')
            {
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';
    return 0;
}


Measured memory_bytes: 3596
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> D(13);
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		D[d]++;
	}

	int ans = 0;
	for (int bit = 0b0; bit < (1 << 13); bit++) {

		vector<int> time{ 0 };
		time.reserve(N);
		for (int i = 0; i < 13; i++) {
			for (int j = 0; j < D[i]; j++) {
				if (!(bit & (1 << i) ^ (j & 1))) time.emplace_back(i);
				else time.emplace_back(24 - i);
			}
		}

		DMP(time);

		int s = INF;
		for (int i = 0; i <= N; i++) {
			for (int j = i + 1; j <= N; j++) {
				chmin(s, min(abs(time[i] - time[j]), 24 - abs(time[j] - time[i])));
			}
		}
		chmax(ans, s);

	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,x,y) for (int i=x; i<=(y); ++i)

const int N=3e3+10,P=1e9+7;
int n,m,f[N][N][2],ans;

int main()
{
    scanf("%d%d",&n,&m);
    rep(i,0,n)
        f[0][i][!i]=1;
    rep(i,1,m)
        rep(j,0,n)
            rep(k,0,1)
            {
                int t=f[i-1][j][k];
                if (!t)
                    continue;
                if (j)
                    (f[i][j-1][k|(j==1)]+=t)%=P,(f[i][j][k|(j==1)]+=t)%=P;
                if (j<n)
                    (f[i][j+1][k]+=t)%=P,(f[i][j][k]+=t)%=P;
            }
    rep(i,0,n)
        ans=(ans+f[m][i][1])%P;
    printf("%d",ans);
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(2e3 + 5);
const int MAX_W = (int)(2e3 + 5);

int h, w;
char field[MAX_H][MAX_W];

int row_acc[MAX_H][MAX_W];
int col_acc[MAX_W][MAX_H];

int ans = -1;

int bi_left(int ok, int ng, int row, int score) {
  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (row_acc[row][next] >= score) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  if (field[row - 1][ok - 1] == '#') ok += 1;

  return ok;
}

int bi_right(int ok, int ng, int row, int score) {
  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (row_acc[row][next] < score) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  return ok;
}

int bi_top(int ok, int ng, int col, int score) {
  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (col_acc[next][col] >= score) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  if (field[ok - 1][col - 1] == '#') ok += 1;

  return ok;
}

int bi_down(int ok, int ng, int col, int score) {
  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;

    if (col_acc[next][col] < score) {
      ok = next;
    }
    else {
      ng = next;
    }
  }

  return ok;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

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

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      row_acc[i][j] = (field[i - 1][j - 1] == '#' ? 1 : 0);
      row_acc[i][j] += row_acc[i][j - 1];
    }
  }

  for (int j = 1; j <= w; ++j) {
    for (int i = 1; i <= h; ++i) {
      col_acc[i][j] = (field[i - 1][j - 1] == '#' ? 1 : 0);
      col_acc[i][j] += col_acc[i - 1][j];
    }
  }

  // for (int i = 1; i <= h; ++i) {
  //   for (int j = 1; j <= w; ++j) {
  //     row_acc[i][j] += row_acc[i][j - 1];
  //   }
  // }
  //
  // for (int j = 1; j <= w; ++j) {
  //   for (int i = 1; i <= h; ++i) {
  //     col_acc[i][j] += col_acc[i - 1][j];
  //   }
  // }

  // for (int j = 0; j <= w; ++j) {
  //   for (int i = 0; i <= h; ++i) {
  //     printf("%d ", col_acc[i][j]);
  //   }
  //   printf("\n");
  // }

  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      if (field[i - 1][j - 1] == '#') continue;

      int left = bi_left(j, 0, i, row_acc[i][j]);
      int right = bi_right(j, w + 1, i, row_acc[i][j] + 1);

      int top = bi_top(i, 0, j, col_acc[i][j]);
      int down = bi_down(i, h + 1, j, col_acc[i][j] + 1);

      int cur_light = (j - left) + (right - j) + (i - top) + (down - i) + 1;

      // printf("(%d, %d): %d\n", i, j, cur_light);


      // printf("(%d, %d): (%d, %d)~(%d, %d) - %d\n", i, j, left, right, top, down, cur_light);

      ans = max(ans, cur_light);
    }
  }

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

  return 0;
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y){x=x%MOD;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=MOD;y=y>>1;x=x*x;x%=MOD;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    ll sum=0;
    for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];}
    ll dp[n][n]; // dp(i,j) denotes the maximum sum player starting at array i...j can get
    memset(dp,0,sizeof(dp));
    // initialized everything with 0
    // if there are 2 elements only player who starts should obviously pick the greater elemennt

    for(int i=n-1;i>=0;i--)
    for(int j=i;j<n;j++)
    {
      if(i==j)
      dp[i][j]=a[i];
      else if(j==(i+1))
      dp[i][j]=max(a[i],a[j]);
  //    if((j-i)<2)continue;
      //0...1...2
      // we have already filled this above

      // now comes the main part
      // he has two options: either pick i or j
      // option 1: picks i : now array remaining is i+1.....j
      // and its b's turn now player b will make choice to maximize his own score
      // therefore he will pick  the max of dp[i+2,,,,j] by taking i+1 or dp[i+1.....j-1] by taking j
      // so we will be left with min(dp[i+2][j], dp[i+1][j-1]);

      // option 2 player a picks j: now the remaining aray is i...j-1;
      // and its player b's turn , player be will max for himself , so we will be left with min
        //i..i+1 i+2..j-2...j-1..j.
      else
      dp[i][j]=max(a[i]+min(dp[i+2][j],dp[i+1][j-1]),a[j]+min(dp[i+1][j-1],dp[i][j-2]));

    }
    cout<<2*dp[0][n-1]-sum<<"\n"; // will give the result for player A
    // hence player B will be left with S-dp[0][n-1]
    // result is dp[0][n-1]-(s-dp[0][n-1])
    // 2*dp[0][n-1]-s
    // got it?
    //cout<<dp[n-1][n-1]<<"\n";

  /*  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++)
    cout<<dp[i][j]<<' ';
    cout<<"\n";}*/
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
  
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);;
            Map<Integer,Integer> table = new HashMap<Integer,Integer>();
            int n = sc.nextInt();
            int count = 1;
            while(!table.containsKey(n)) {
                table.put(n,count);
                count++;
                if( (n & 1) == 1) {
                    n = 3*n + 1;
                } else {
                    n = n >> 1;
                }
            }
            System.out.println(count);
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<math.h>
using namespace std;
int tejun(int inp,int r);

int main(){
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int num;
    cin >> num;
    int r=0;
    r = tejun(num,r);
    cout << r << endl;
  }
}

int tejun(int inp,int r){
  if(inp>9){
    int max=0;
    for(int j=1;pow(10,j)<inp;j++){
      int kake=(inp/(int)pow(10,j))*(inp%(int)pow(10,j));
      if(kake>max){
	max=kake;
      }
    }
    return tejun(max,r+1);
  }
  return r;
}

Measured memory_bytes: 1208
import java.util.*;
import java.io.*;

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String s = br.readLine();
            String[] str = s.split(" ");
            int a = Integer.parseInt(str[0]);
            String op = str[1];
            int b = Integer.parseInt(str[2]);
            //System.out.println(a+op+b);
            if("+".equals(op)){
                
                System.out.println(a + b);
                
            }
            else if("-".equals(op)){
                
                System.out.println(a - b);
                
            }
            else if("*".equals(op)){
                
                System.out.println(a * b);
                
            }
            else if("/".equals(op)){
                
                System.out.println(a / b);
                
            }
            else if("?".equals(op)){
                
               break;
                
            }
        }
    }
}

Measured memory_bytes: 17048
n, p = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]

ans = []
S = [0]

for x in X:
    S.append(S[-1] + x)

for t in range(1, n+1):
    tmp = 5 * S[n] + (t + n) * p
    cur = n - t * 2
    while cur > 0:
        tmp += 2 * S[cur]
        cur -= t

    ans.append(tmp)

print(min(ans))

Measured memory_bytes: 31180
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void AtCoderBeginnerContest999() {
	int n;
	cin >> n;
	int r = 0;
	int k = 0;
	while (n > 0)
	{
		if (n % 10 == 1) {
			r += pow(10, k) * 9;
		}
		else if (n % 10 == 9) {
			r += pow(10, k);
		}
		else {
			r += pow(10, k) * (n % 10);
		}
		k++;
		n /= 10;

	}
	cout << r;

}

 int main() {
	 AtCoderBeginnerContest999();
	 return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main () {
    int N, K;
    cin>>N>>K;
    std::string input;
    cin>>input;
    char character = input[K-1];

    character -= ('A' -'a');
    input[K-1] = character;
    cout<<input<<endl;
}

Measured memory_bytes: 256
import sys
N=int(input())
if N==2:
    print(-1)
    sys.exit()
ans=[["."]*N for i in range(N)]
if N%4==0:
    k=N//4
    for i in range(k):
        num=4*i
        for j in range(2):
            ans[j+num][0+num]="a"
            ans[j+num][1+num]="b"
        for j in range(2,4):
            ans[j+num][2+num]="a"
            ans[j+num][3+num]="b"
        for j in range(2):
            ans[2+num][j+num]="c"
            ans[3+num][j+num]="d"
        for j in range(2,4):
            ans[0+num][j+num]="c"
            ans[1+num][j+num]="d"
    for u in ans:
        print("".join(u))
    sys.exit()
n=N
while n%2==0:
    n//=2
k=N//n
for i in range(k):
    num=n*i
    for j in range(2):
        ans[j+num][num]="a"
        ans[j+num][(n-2)//2+num]="b"
        ans[j+num][n-3+num]="c"
    for j in range(n-2,n):
        ans[2+num][j+num]="a"
        ans[(n+1)//2+num][j+num]="b"
        ans[n-1+num][j+num]="c"
    lsls=["d","e"]
    for j in range(2,(n+1)//2):
        ans[j+num][j-2+num]=lsls[j%2]
        ans[j+num][j-1+num]=lsls[j%2]
    for j in range((n+3)//2,n):
        ans[j+num][j-2+num]=lsls[j%2]
        ans[j+num][j-3+num]=lsls[j%2]
    lsls=["f","g"]
    for j in range(2,(n+1)//2):
        ans[j+num][n-1-j+num]=lsls[j%2]
        ans[j+1+num][n-1-j+num]=lsls[j%2]
    for j in range((n+3)//2,n):
        ans[j+num][n-1-j+num]=lsls[j%2]
        ans[j-1+num][n-1-j+num]=lsls[j%2]
for u in ans:
    print("".join(u))

Measured memory_bytes: 47600
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#define N 8000
using namespace std;

int x, y, cnt, z;
bitset<N * 2> bs;
int d[4005][16005];
int e[4005][N * 2];
string s;
vector<int> v[2];

bool f(int p) {
    int i;
    bs = 0;
    bs[N + v[0][0]] = true;
    for(i = 1; i < v[0].size(); i++)
    {
        bs = (bs << v[0][i]) | (bs >> v[0][i]);
//        int t = v[0][i];
//        for(int j = 0; j <= 2 * N; j++)
//        {
//            if(j >= t && d[i-1][j-t]) d[i][j] = 1;
//            if(j + t <= 2 * N && d[i-1][j+t]) d[i][j] = 1;
//        }
    }
    return bs[N + p];
}

bool g(int p) {
    bs = 0;
    int i;
    bs[v[1][0] + N] = true;
//    e[0][v[1][0] + N] = 1;
    for(int i = 1; i < v[1].size(); i++)
    {
        bs = (bs << v[1][i]) | (bs >> v[1][i]);
//        int k = v[1][i];
//        for(int j = 0; j <= 2 * N; j++)
//        {
//            if(j >= k && e[i - 1][j - k]) e[i][j] = 1;
//            if(j + k <= 2 * N && e[i - 1][j + k]) e[i][j] = 1;
//        }
    }
    return bs[p + N];
//    return e[v[1].size() - 1][p + N];
}

int main()
{
    int i;
    cin>>s>>x>>y;
    s += 'T';
    v[1].push_back(0);
    for(int i = 0; s[i]; i++) {
        if(s[i]=='F') cnt++;
        else {
            v[z].push_back(cnt);
            z = !z;
            cnt = 0;
        }
    }
    if(f(x) & g(y)) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

int main(){
  int L,R,d;cin>>L>>R>>d;
  int ans = (R-L)/d;
  if(L%d==0 || R%d==0) cout<<ans+1<<endl;
  else if(L%d==0 && R%d==0) cout<<ans+2<<endl;
  else cout<<ans<<endl;
}
  

Measured memory_bytes: 3592