akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N 101
#define M 1000000000

int matrixChainOrder(int, int *);

int main(){
  int i, j, n, p[N];
  scanf("%d", &n);
  for(i=0; i<n; i++)scanf("%d%d", &p[i], &p[i+1]);
  printf("%d\n", matrixChainOrder(n, p));
  
  return 0;
}

int matrixChainOrder(int n, int *p){
  int i, j, k, l, m[n+1][n+1], q;
  
  for(i=1; i<=n; i++)m[i][i]=0;
  
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = M;
      for(k=i; k<j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(m[i][j] > q)m[i][j] = q;
      }
    }
  }
  return m[1][n];
}



Measured memory_bytes: 2052
#include<stdio.h>
#include<math.h>
int main()
{
	int r, dc, c=90;
	double x=0, y=0;
	while(scanf("%d,%d", &r, &dc), (r || dc)) {
		x += r*cos(c*M_PI/180);
		y += r*sin(c*M_PI/180);
		c -= dc;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ld pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
struct P {
    ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//???£??\????????????¨???
    ll to, cost;
};
struct S {//????????????±?????\????????????°
    int from, to, cost;
};
struct H {
    int x, y;
};
ll gcm(ll i, ll j) {//??????§???¬??´????°
    if (i > j) swap(i, j);
    if (i == 0) return j;
    return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
    return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad??????§??¨???????2???????????????¢
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m;
int a[100000], b[20][100000], c[20];
int dp[1048576];
int solve(int s,int sum) {
    if (s == (1 << m) - 1)
        return 0;
    if (dp[s] != -1) return dp[s];
    int res = inf;
    for (int i = 0; i < m; i++) {
        if (!(s&(1 << i))) {
            int ret = c[i] - b[i][sum + c[i]-1] + (sum != 0 ? b[i][sum-1] : 0);
            res = min(res, solve(s | (1 << i), sum + c[i]) + ret);
        }
    }
    return dp[s]=res;
}
signed main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[--a[i]]++;
        b[a[i]][i]++;
        for (int j = 0; j < m; j++)
            b[j][i + 1] = b[j][i];
    }
    for (int i = 0; i < 1048576; i++) 
        dp[i] = -1;
    cout << solve(0, 0) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 27628
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A

#include <iostream>
using namespace std;

static const int N = 100;

int bubbleSort(int a[], int n) {
  int sw = 0, flag = 1, i = 0;

  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = n - 1; j > i; j--) {
      if (a[j] < a[j-1]) {
        swap(a[j], a[j-1]);
        flag = 1;
        sw++;
      }
    }
  }

  return sw;
}

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

  int sw = bubbleSort(a, n);

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << ' ';
    cout << a[i];
  }
  cout << endl << sw << endl;

  return 0;
}



Measured memory_bytes: 3068
#include <cstdio>
#include <bitset>
#include <algorithm>

int n,k,s,a[5005];
std::bitset<5005> f;

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;++i)scanf("%d",&a[i]),a[i]=std::min(a[i],k),s+=a[i];
    std::sort(a,a+n+1),f[0]=1;
    for(int i=n;i>=0;--i)
    {
        bool v=true;
        for(int j=k-1;j>=k-s&&j>=0;--j)if(f[j])v=false,j=0;
        if(v)return printf("%d\n",i),0;
        f|=f<<a[i],s-=a[i];
    }
}


Measured memory_bytes: 128
'use strict'

const Main = (input) => {
  const S = input.split('\n')[0]
  if (S.length % 2 == 1) {
  	console.log('No')
  } else {
  	const n = S.length / 2
    for (let i = 0; i < n; i++) {
      if ((S[2 * i] == 'h') && (S[2 * i + 1] == 'i')) {
      	if (i == n - 1) {
          console.log('Yes')
        }
      } else {
        console.log('No')
        break
      }
    }
  }
}

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


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}
int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(C > B) swap(C,B);
    if(B > A) swap(A,B);
    int N = A-B + A-C;
    //cout << N << endl;
    if(N%2) cout << (N+3)/2;
    else cout << N/2;
    return 0;
}


Measured memory_bytes: 764
"use strict";

const Main = args => {
  const input = args.trim();
  const N = input - 0;
  let result = 0;
  for (let index = 0; index < N; index++) {
    result = index + 1 + result;
  }

  console.log(result);
}

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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(int i=0;i<n;++i) cin>>v[i];
    ll ans=1e9+7;
    for(int i=0;i<=n-k;++i){
        ll cnt=0;
        if(v[i]<=0 && v[i+k-1]>=0){
        cnt=abs(v[i]-v[i+k-1])+min(abs(0-v[i]),abs(0-v[i+k-1]));
        } else {
            cnt=max(abs(v[i]),abs(v[i+k-1]));
        }
        ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  long long sm = 0;
  for(int bit = 0; (1<<(s.size()-1)) > bit;bit++){
    long long t = 0;
    for(int i = 0; s.size() > i; i++){
      t = t*10+s[i]-'0';
      if((1<<i)&bit){
        sm += t;
        t = 0;
      }
    }
    sm += t;
  }
  cout << sm << endl;
}


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

#ifdef DEBUG
#define watch(x) cout << "DEBUG: " << (#x) << " = " << (x) << endl
#else
#define watch(x) ;
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define endl "\n"
const int INF = 0x3f3f3f3f;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - (((begin) > (end)) << 1))

#define fi first
#define se second
#define pb push_back
#define all(X) begin(X),end(X)

#define rd1(x) scanf("%d", &x)
#define rd2(x, y) scanf("%d%d", &x, &y)
#define rd3(x, y, z) scanf("%d%d%d", &x, &y, &z)

#define rdl1(x) scanf("%lld", &x)
#define rdl2(x, y) scanf("%lld%lld", &x, &y)
#define rdl3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)

#pragma GCC optimize ("Ofast")
#pragma GCC target("avx,avx2")

typedef pair<string,pair<int,int>> sii;

bool comp(sii i, sii j){
	if(i.fi != j.fi)
		return i.fi < j.fi;
	return i.se.fi > j.se.fi;
}

sii a[200];

int main() {

#ifdef DEBUG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;

	rep(i,0,n){
		cin >> a[i].fi >> a[i].se.fi;
		a[i].se.se = i+1;
	}

	sort(a, a+n, comp);

	rep(i,0,n)
		cout << a[i].se.se << endl;

	return 0;
}


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

int main(){
    priority_queue<int> p;
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n;i++)
    {
        int k;
        cin >> k;
        p.push(k);
    }
    while(m--){
        int a = p.top();
        p.pop();
        a >>= 1;
        p.push(a);
    }
    long long ans = 0;
    for (int i = 0; i < n;i++){
        ans += p.top();
        p.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 892
N, K = map( int, input().split())
T = [(0,0)]*N
for i in range(N):
    t, d = map( int, input().split())
    T[i] = (d,t)
T.sort( key= None, reverse = True)
C = T[:K]
AC = T[K:]
kiso = 0
s = 0
S = [0]*(N+1)
for i in range(K):
    d, t = T[i]
    kiso += d
    if S[t] == 0:
        S[t] = 1
        s += 1
    else:
        S[t] += 1
ans = kiso + s**2
C.sort()
r = 0

for i in range(K):
    d, t = C[i]
    if S[t] >= 2:
        while r < N-K:
            if S[ AC[r][1]] == 0:
                S[t] -= 1
                S[ AC[r][1]] += 1
                s += 1
                kiso -= d
                kiso += AC[r][0]
                r += 1
                break
            r += 1
    ans = max( ans, kiso + s**2)
print( ans)

Measured memory_bytes: 53336
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const double EPS = 1e-9;
const int N = 100;

template <class T> T gcd(T a, T b) {
	if (b == 0) { return a; }
	return gcd(b, a % b);
}

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}

bool r[N], c[N];

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

	int n, m;

	cin >> n >> m;
	vector<string> g(n);

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

	for (int i = 0; i < n; ++i) {
		int rflag = true;
		for (int j = 0; j < m; ++j) {
			rflag = rflag && (g[i][j] == '.');
		}
		r[i] = rflag;
	}

	for (int i = 0; i < m; ++i) {
		int cflag = true;
		for (int j = 0; j < n; ++j) {
			cflag = cflag && (g[j][i] == '.');
		}
		c[i] = cflag;
	}


	for (int i = 0; i < n; ++i) {
		if (!r[i]) {
			for (int j = 0; j < m; ++j) {
				if (!c[j]) cout << g[i][j];
			}
			cout << '\n';
		}

	}

}

Measured memory_bytes: 3596
#include<stdio.h>
int max(int a, int b) {
  if (a > b) return a;
  else return b;
}

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


int main(void) {
  int A, B, C, X, Y;
  scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
  if (A+B < 2*C) {
    printf("%d", X*A+Y*B);
  } else {
    int a, b, c;
    c = 2*min(X, Y);
    a = X-c/2;
    b = Y-c/2;
    int cost = a*A + b*B + c*C;
    if (a == 0) {
      if (B > 2*C) {
        printf("%d", 2*max(X, Y)*C);
        exit(0);
      } else {
        printf("%d", cost);
        exit(0);
      }
    }
    if (b == 0) {
      if (A > 2*C) {
        printf("%d", 2*max(X, Y)*C);
        exit(0);
      } else {
        printf("%d", cost);
        exit(0);
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>(v)
#define OUT(v) cout>>(v)>>endl


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

  VI D;
  REP(i, N) {
    int d;
    cin >> d;
    D.PB(d);
  }
  SORT(D);
  if (D[N / 2 - 1] == D[N / 2])
    cout << 0 << endl;
  else {
    cout << D[N / 2] - D[N / 2 - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,k; cin >> n >> k;
    vl v(100005);
    rep(i,n){
        ll a,b; cin >> a >> b;
        v[a] += b;
    }
    ll ans = 1;
    while(1){
        k -= v[ans];
        if(k <= 0) break;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
	int N; cin>>N;
	vector<int64_t> p, m;
	while(N--){
		int x, y; cin>>x>>y;
		p.push_back(x + y);
		m.push_back(x - y);
	}
	sort(p.begin(), p.end());
	sort(m.begin(), m.end());
	cout<< max(p.back() - p[0], m.back() - m[0]) <<endl;
}


Measured memory_bytes: 6648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 String vowels = "aeiou";
	        Scanner scan = new Scanner(System.in);
	        String letter = scan.next();
	        if(vowels.contains(letter)) {
	            System.out.println("vowel");
	        }else{
	            System.out.println("consonant");
	        }
		}

	}




Measured memory_bytes: 21844
package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	"strconv"
)

func reverseString(s string) string {
	n := len(s)
	bytes := []byte(s)
	for i := 0; i < n/2; i++ {
		bytes[i], bytes[n-1-i] = bytes[n-1-i], bytes[i]
	}
	return string(bytes)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)

	s := next()
	l := list.New()
	for _, c := range s {
		l.PushBack(string(c))
	}
	q := nextInt()

	rev := false

	for i := 0; i < q; i++ {
		t := nextInt()
		switch t {
		case 1:
			rev = !rev
		case 2:
			f, c := nextInt(), next()
			if (!rev && f == 1) || (rev && f == 2) {
				l.PushFront(c)
			} else {
				l.PushBack(c)
			}
		}
	}

	if !rev {
		for e := l.Front(); e != nil; e = e.Next() {
			putf("%s", e.Value.(string))
		}
	} else {
		for e := l.Back(); e != nil; e = e.Prev() {
			putf("%s", e.Value.(string))
		}
	}
	putf("\n")
    wt.Flush()
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)   
#define REP(i,n) for(int i=0;i<(n);i++)            
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)       
                
#define pb push_back   
#define PII pair<int,int>
                
#define VS vector<string>
#define VI vector<int> 
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl    
int main(void) {
    ll n;cin >> n;
    ll digit=0; 
    ll rest = 0;
    digit = n/11;
    rest = n%11;                                                                                                                           
    if(rest == 0) cout << digit*2 << endl;
    else if(rest <= 6) cout << digit*2 + 1 << endl;
    else cout << digit*2 +2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  ll m,i,d,c;
  ll sum=0,digit=0,ans=0;

  cin>>m;

  for(i=0;i<m;i++){
    cin>>d>>c;
    sum+=d*c;
    digit+=c;
  }

  ans=sum/9+digit-1;
  if(sum%9==0)ans--;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<ll> s, t, x;

pair<ll, ll> bin_ss(ll p) {
    int l = 0, r = s.size() - 1;
    while (l + 1 < r) {
        int c = (l + r) / 2;
        if (s[c] <= p) {
            l = c;
        } else {
            r = c;
        }
    }
    return make_pair(l, r);
}

pair<ll, ll> bin_st(ll p) {
    int l = 0, r = t.size() - 1;
    while (l + 1 < r) {
        int c = (l + r) / 2;
        if (t[c] <= p) {
            l = c;
        } else {
            r = c;
        }
    }
    return make_pair(l, r);
}

int main() {
    cout << fixed << setprecision(10);
    
    int A, B, Q; cin >> A >> B >> Q;

    // vector<ll> s(A), t(B), x(Q);
    s.resize(A);
    t.resize(B);
    x.resize(Q);

    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    rep(i, Q) cin >> x[i];

    s.emplace_back(1e12);
    s.emplace_back(-1e12);
    t.emplace_back(1e12);
    t.emplace_back(-1e12);

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    // Qごとに、左右の最短の神社寺に行ったときに最小の距離を算出する (2 * 2) / per q 
    rep(i, Q) {
        ll ans = 1e12;
        auto sp = bin_ss(x[i]);
        auto tp = bin_st(x[i]);
        // 神社探索
        // 左
        ll s_init;
        if (sp.first != 0) {
            s_init = s[sp.first];
            ll tans = 0;
            tans += abs(x[i] - s_init);
            auto tp_s = bin_st(s_init);
            tans += min(abs(s_init - t[tp_s.first]), abs(s_init - t[tp_s.second]));
            ans = min(ans, tans);
        }
        // 右
        if (sp.second != s.size() - 1) {
            s_init = s[sp.second];
            ll tans = 0;
            tans += abs(x[i] - s_init);
            auto tp_s = bin_st(s_init);
            tans += min(abs(s_init - t[tp_s.first]), abs(s_init - t[tp_s.second]));
            ans = min(ans, tans);
        }
        // 寺探索
        // 左
        ll t_init;
        if (tp.first != 0) {
            t_init = t[tp.first];
            ll tans = 0;
            tans += abs(x[i] - t_init);
            auto sp_t = bin_ss(t_init);
            tans += min(abs(t_init - s[sp_t.first]), abs(t_init - s[sp_t.second]));
            ans = min(ans, tans);
        }
        // 右
        if (tp.second != t.size() - 1) {
            t_init = t[tp.second];
            ll tans = 0;
            tans += abs(x[i] - t_init);
            auto sp_t = bin_ss(t_init);
            tans += min(abs(t_init - s[sp_t.first]), abs(t_init - s[sp_t.second]));
            ans = min(ans, tans);
        }

        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n,m;
ll match[10][10];

int solve(ll y,ll x){
	if(y == n-1 && x == n-1){
		// rep(i,n){
		// 	rep(j,n)cout << match[i][j] << " ";
		// 	cout << endl;
		// }
		// cout << endl;
		return 1;
	}
	ll ny = y;
	ll nx = x+1;
	if(nx == n){
		nx = 0;
		ny++;
	}
	if(y == x || match[y][x] != 0)return solve(ny,nx);
	ll res = 0;
	ll xwin = 0;
	ll xlose = 0;
	ll ywin = 0;
	ll ylose = 0;
	rep(i,n){
		if(match[y][i] == 1)ywin++;
		if(match[y][i] == -1)ylose++;
	}
	rep(i,n){
		if(match[x][i] == 1)xwin++;
		if(match[x][i] == -1)xlose++;
	}
	// if(ywin > n/2)return 0;
	// if(ylose > n/2)return 0;
	// if(xwin > n/2)return 0;
	// if(xlose > n/2)return 0;

	if(xwin < n/2 && ylose < n/2){
		match[x][y] = 1;
		match[y][x] = -1;
		res += solve(ny,nx);
		match[x][y] = 0;
		match[y][x] = 0;
	}
	if(ywin < n/2 && xlose < n/2){
		match[x][y] = -1;
		match[y][x] = 1;
		res += solve(ny,nx);
		match[x][y] = 0;
		match[y][x] = 0;
	}
	return res;
}

int main(){
	while(cin >> n >> m && n){
		rep(i,10)rep(j,10)match[i][j] = 0;
		rep(i,m){
			ll x,y;
			cin >> x >> y;
			x--;
			y--;
			match[x][y] = 1;
			match[y][x] = -1;
		}
		bool ok = true;
		rep(i,n){
			ll lose = 0;
			ll win = 0;
			rep(j,n){
				if(match[i][j] == 1)win++;
				if(match[i][j] == -1)lose++;
			}
			ok &= (win <= n/2 && lose <= n/2);
		}
		if(!ok)cout << 0 << endl;
		else cout << solve(0,0) << endl;
	}
}


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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  long long int A, B, C, K;
  cin >> A >> B >> C >> K;
  long long int O = 0;
  if(A>K){
    O=K;
    K=0;
  }else{
    O=O+A;
    K=K-A;
  }
  
  if(B>K){
    K=0;
  }else{
    K=K-B;
  }
  
  O = O-K;
  
  cout << O << endl;
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


Measured memory_bytes: 3656
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    N = II()
    C = IS()
    r = 0
    w = 0
    for c in C:
        if c=='R': r+=1
        else : w +=1
    ans = 0

    for c in C:
        if(r==0 or w==0):
            break
        else:
            if c == 'W':
                r-=1
                ans+=1
            if c == 'R':
                r-=1
    print(ans)




if __name__ == '__main__':
    main()

Measured memory_bytes: 9420
#include <iostream>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  for (int i=1;i<10000;i*=10)
  {
    if (i>b) {a=a*i+b;break;}
  }
  int i;
  for (i=1;i*i<a;i++);
  if (i*i==a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  //system("pause");
  return 0;
}

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

typedef long long ll;

int main()
{
    ll H, W;
    cin >> H >> W;

    ll a = (W + 1) / 2;
    ll b = (H + 1) / 2;
    ll c = W / 2;
    ll d = H / 2;

    if (W == 1 || H == 1)
    {
        cout << 1;
    }
    else
    {
        cout << a * b + c * d;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
minus = 0
for i in range(n):
    if a[i] < 0:
        minus += 1
        a[i] = -a[i]

if minus % 2 == 0:
    print(sum(a))
else:
    a.sort()
    print(sum(a[1:]) - a[0])


Measured memory_bytes: 14412
#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;

int CountA, CountB, CountC;
int threshold;

int main() {

	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'a') CountA++;
		if (S[i] == 'b') CountB++;
		if (S[i] == 'c') CountC++;
	}

	if (S.size() % 3 == 0) threshold = S.size() / 3;
	else threshold = S.size() / 3 + 1;

	if (CountA <= threshold && CountB <= threshold && CountC <= threshold)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
def solve():
    S = input()
    T = input()
    len_t = len(T)
    len_s = len(S)
    dp = [[0] * (len_t + 1) for _ in range(len_s + 1)]
    for i, s in enumerate(S):
        pre_dp_i = dp[i]
        dp_i = dp[i+1]
        for j, t in enumerate(T):
            tmp_dp = max((pre_dp_i[j] + 1) * (s == t),
                         pre_dp_i[j+1],
                         dp_i[j])
            dp_i[j+1] = tmp_dp
    res = ''
    while len_t > 0 and len_s > 0:
        current = dp[len_s][len_t]
        if current == dp[len_s - 1][len_t]:
            len_s -= 1
        elif current == dp[len_s][len_t - 1]:
            len_t -= 1
        else:
            res = S[len_s - 1] + res
            len_s -= 1
            len_t -= 1
    return res


if __name__ == "__main__":
    answer = solve()
    print(answer)


Measured memory_bytes: 112220
import sys

s= int(sys.stdin.readline())

t = 10**9
r= s%t
if r==0:
    x3 = 0
    y3 = s//t
else:
    x3 = t - s%t
    y3 = s//t + 1

print( 0,0,t,1,x3,y3 )

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

int main() {
    long long n, bunbo = 2, ans = 0;
    cin >> n;
    if(n%2 == 1) {
        cout << 0 << '\n';
        return 0;
    }

    while(bunbo <= n) {
        bunbo *= 5;
        ans += n/bunbo;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int a = 1, b = n - 1;
	int ans = 1000000;
	for (int i = 0;a <= b;i++) {
		int aa = 0, bb = 0;
		int A = a, B = b;
		for (int j = 0;j < 6;j++) {
			aa += A % 10;
			A /= 10;
		}
		for (int j = 0;j < 6;j++) {
			bb += B % 10;
			B /= 10;
		}
		ans = min(ans, aa + bb);
		a++;
		b--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

constexpr int MAX = 2020;
ll dp[MAX][MAX];

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<P> a(n);
    rep(i,n) {
        cin>>a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end(), greater<>());
    rep(i,MAX) rep(j,MAX) dp[i][j] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; i+j < n; ++j) {
            int idx = i+j;
            ll lcost = a[idx].first * (a[idx].second-i);
            chmax(dp[i+1][j], dp[i][j]+lcost);
            ll rcost = a[idx].first * ((n-j-1) - a[idx].second);
            chmax(dp[i][j+1], dp[i][j]+rcost);
        }
    }

    ll ans = 0;
    rep(i,n+1) {
        chmax(ans, dp[i][n-i]);
    }
    cout << ans << '\n';
    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;

struct UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind(int _size) : data(_size, -1) {}
	
	bool unite(int _x, int _y) {
		_x = root(_x); _y = root(_y);
		if (_x != _y) {
			if (data[_y] < data[_x]) swap(_x, _y);
			data[_x] += data[_y]; data[_y] = _x;
		}
		return _x != _y;
	}
	
	bool same(int _x, int _y) { return root(_x) == root(_y); }
	
	int root(int _x) { return data[_x] < 0 ? _x : data[_x] = root(data[_x]); }
	
	int size(int _x) { return -data[root(_x)]; }
};

int N, Q, p[100010];
char q[100010];
int mark[100010], v[100010];
lint anc[100010];

void solve() {
	UnionFind uf(N);
	
	for_(i,0,N) if (!mark[i]) uf.unite(i, p[i]);
	for_(i,0,N) if (mark[i]) anc[ uf.root(i) ] = i + 1;
	
	lint ans = 0;
	
	for_rev(i,Q-1,0) {
		if (q[i] == 'M') {
			--mark[ v[i] ];
			if (!mark[ v[i] ]) {
				int tmp = anc[ uf.root(p[ v[i] ]) ];
				uf.unite(v[i], p[ v[i] ]);
				anc[ uf.root(v[i]) ] = tmp;
			}
		} else {
			ans += anc[ uf.root(v[i]) ];
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (scanf("%d %d", &N, &Q), N) {
		for_(i,1,N) {
			scanf("%d", &p[i]); --p[i];
		}
		
		minit(mark, 0);
		mark[0] = 1;
		
		for_(i,0,Q) {
			scanf("%s %d", &q[i], &v[i]); --v[i];
			if (q[i] == 'M') ++mark[ v[i] ];
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	static int A[100002];
	ARSCD1(A,N);
	
	int ans = 0;
	int pn = 0;
	
	FORq(i,2,N){
		int now = A[i-1];
		int next = A[i];
		int bl;
		if (now == next) bl = 0;
		if (now > next) bl = -1;
		if (now < next) bl = 1;
		
		if (bl == 0){
			continue;
		}
		
		if (pn == 0){
			if (bl == 0){
				continue;
			}else if(bl == -1){
				pn = -1;
				continue;
			}else{
				pn = 1;
				continue;
			}
		}
		
		if (pn == bl){
			now = next;
		}else{
			pn = 0;
			ans += 1;
		}
	}
	
	
	PRINTD(ans + 1);
	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

/*vector<int> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(f);
    rak.assign(f+1,1);
}

int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rank[a]+=rank[b];
    }
}*/

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s,u;
//vvl v;
//vl vis,d;
pll c[1000005];
int main() {
    IOS;
    cin>>s;
    u=s.substr(5,5);//cout<<u<<el;
    if(u>"04/30")cout<<"TBD";
    else cout<<"Heisei";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define M 100005
using namespace std;

char s[M]; 
char p[M];
int cnt,tot,tot1=1,tot2=1,f,ans=0;
int k1[M],k2[M];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='x')p[++cnt]=s[i];
	}
	int l=1,r=cnt;
	while(l<=r)
	{
		if(l==r)break;
		if(p[l]==p[r])l++,r--;
		else {
			cout<<"-1"<<endl;
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='x')tot++;
		if(tot==(cnt+1)/2)
		{
			f=i;
			break;
		}
	}
	for(int i=1;i<=f;i++)
	{
		if(s[i]=='x')k1[tot1]++;
		else tot1++;
	}
	for(int i=n;i>=f+1;i--)
	{
		if(s[i]=='x')k2[tot2]++;
		else tot2++; 
	}
	for(int i=1;i<=tot;i++)
	{
		ans+=abs(k1[i]-k2[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define ll long long int

ll p[51],a[51];

ll f(ll n,ll x){
	if(n==0)return 1;
	if(x==1)return 0;
	if(x<=1+a[n-1])return f(n-1,x-1);
	if(x==2+a[n-1])return p[n-1]+1;
	if(x<2+2*a[n-1])return p[n-1]+1+f(n-1,x-2-a[n-1]);
	return 2*p[n-1]+1;
}

int main(void){
	ll x,n;
	scanf("%lld%lld",&n,&x);
	p[0] = 1;
	a[0] = 1;
	for(int i=1;i<=n;i++){
		p[i] = 2*p[i-1]+1;
		a[i] = 2*a[i-1]+3;
	}
	printf("%lld",f(n,x));
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define SIZE 100005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;

int x,a,b;

int main(){
	cin >> x >> a >> b;
	if(x-a>0) x-=a;
	int ans=0;
	while(x-b>=0){
		x-=b;
		ans++;
	}
	cout << x <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll co[L], a[L];
void fff()
{
	int n;
	cin >> n;
	ll sumis = 0;
	FOR(i,0,n)
	{
		cin >> a[i];
		sumis += a[i];
		co[a[i]]++;
	}
	ll q, b, c;
	cin >> q;
	while(q--)
	{
		cin >> b >> c;
		sumis -= (b*co[b]);
		sumis -= (c*co[c]);
		co[c] += co[b];
		co[b] = 0;
		sumis += (c*co[c]);
		cout<<sumis<<ln;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 5088
a,b = map(str,input().split())
b = int(b)
a = int(a)
bb = str(b)
aa = str(a)

ans = ""



if a < b:
    for i in range(b):
        ans = ans + aa
elif a == b:
    for i in range(a):
        ans = ans + bb
else:
    for i in range(a):
        ans = ans + bb
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int[] antennas=new int[5];
		int k;
		int ans=0;

		for(int i=0;i<5;i++) {
			antennas[i]=sc.nextInt();
		}
		k=sc.nextInt();

		for(int i=0;i<5;i++) {
			for(int j=0;j<5;j++) {
				if(i==j) continue;
				if(antennas[i]<antennas[j]) {
					if(antennas[j]-antennas[i]>k) ans++;
				}
			}
		}

		if(ans==0) System.out.println("Yay!");
		else System.out.println(":(");

		sc.close();
	}
}


Measured memory_bytes: 23380
nums = list(map(int, list(input())))
ans = 0
ansStrGrobal = ''
def culc(ope, count, summation, ansStr):
    global ansStrGrobal
    tmp = nums[count]
    if ope == 1:
        summation += tmp
        ansStr += '+'
    else:
        summation -= tmp
        ansStr += '-'

    count += 1
    if count == 4:
        if summation == 7:
            ansStrGrobal = ansStr
        return
    
    culc(1, count, summation, ansStr)
    culc(0, count, summation, ansStr)
    
    
culc(1, 0, 0, '')

print(str(nums[0]) + ansStrGrobal[1] + str(nums[1]) + ansStrGrobal[2] + str(nums[2]) + ansStrGrobal[3] + str(nums[3]) + '=7')

Measured memory_bytes: 3188
/**
*  author: rits1272
*  created: Aug 22, 2020
**/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

void solve(){
    int n, x, t;
    cin >> n >> x >> t;
    int ans = n/x*t + (n%x == 0 ? 0 : t);
    cout << ans << "\n";
    return;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
#define SIZE 100000
int prime[SIZE];

int sosu ( int n ) {
	int i , lim = (int)(sqrt(n));
	for ( i = 2; i <= lim; i++ ) {
		if ( n % i == 0 ) return 0;
	}
	return 1;
}

void tmp(void) {
	int i;
	prime[0] = prime[1] = 0;
	for ( i = 2; i < SIZE; i++ ) {
		prime[i] = sosu(i);
	}
	return;
}

int main (void) {
	int n , i , sosu1 , sosu2;
	tmp();
	
	while ( scanf("%d",&n) != EOF ) {
		for ( i = n - 1; ; i-- ) {
			if ( prime[i] ) {
				sosu1 = i;
				break;
			}
		}
		for ( i = n + 1; ; i++ ) {
			if ( prime[i] ) {
				sosu2 = i;
				break;
			}
		}
		printf("%d %d\n",sosu1,sosu2);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void) {
	int n = 0;

	scanf("%d", &n);
	n = n % 10;

	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		printf("hon");//2,4,5,7,9
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		printf("pon");//0,1,6,8
	}
	else {
		printf("bon");//3
	}

	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int n=50;
  ll K=0;
  scanf("%lld",&K);
  int amari=K%50;
  ll wari=K/50;
  /*
  for (size_t i = 0; i < n; ++i) {
    a[i]+=wari;
  }
  */

  printf("%d\n",n);
  for (ll i=wari,j=1 ; j<=n ; i++,j++) {
    if(j<=n-amari){
      printf("%lld ",i);
    }else{
      printf("%lld ",i+1);
    }

  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[3001][3001];

ll go(ll arr[],ll i,ll j)
{
    if(i>j)
        return 0;
        
    if(i==j)
        return arr[i];
    
    if(dp[i][j] != -1)
        return dp[i][j];
    
    ll ans1 = arr[i] + min(go(arr,i+2,j),go(arr,i+1,j-1));
    ll ans2 = arr[j] + min(go(arr,i,j-2),go(arr,i+1,j-1));
    
    dp[i][j] = max(ans1,ans2);
    return dp[i][j];
}

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

    ll arr[n+1];
    ll sum = 0;
    
    for(int i=1;i<=n;i++)
    {
        cin >> arr[i];
        sum += arr[i];
    }
    
    memset(dp,-1,sizeof(dp));
    ll x = go(arr,1,n);
    ll y = sum - x;
    
    cout << x - y << endl;
    return 0;
    
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>

int min(int a, int b){
  return a < b ? a : b;
}
int main(void)
{
  int N, K, ans = 1000000000;
  scanf("%d%d", &N, &K);
  int x[N];
  for(int i = 0; i < N; i++) scanf("%d", &x[i]);
  for(int i = 0; i < N-K+1; i++){
    int left = abs(x[i]),
        right = abs(x[i+K-1]),
        distance = x[i+K-1]-x[i] + min(left, right);
    if(distance < ans) ans = distance;
  }
  printf("%d\n", ans);
  return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M; cin >> N >> M ;
  vector<vector<P>> graph(N);
  vector<bool> used(M,false);
  rep(i,M){
    int a,b; cin >> a >> b ;
    a--; b--;
    graph[a].pb(P(b,i));
    graph[b].pb(P(a,i));
  }
  bool ans = true;
  rep(u,N){
    for(auto p:graph[u]){
      if(used[p.second]) continue;
      function<bool(int,int)> dfs = [&](int v,int s){
        if(v==s) return true;
        for(auto pp:graph[v]){
          if(used[pp.second]) continue;
          used[pp.second] = true;
          return dfs(pp.first,s);
        }
        return false;
      };
      used[p.second] = true;
      ans &= dfs(p.first,u);
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

// ベクトル
// 偏角[0, 2Pi)でソートできる
struct Vec{
    ld x, y;
    int mode;
    Vec(ld _x, ld _y): x(_x), y(_y){
        if(x >  0 && y == 0) mode = 0;
        if(x >  0 && y >  0) mode = 1;
        if(x == 0 && y >  0) mode = 2;
        if(x <  0 && y >  0) mode = 3;
        if(x <  0 && y == 0) mode = 4;
        if(x <  0 && y <  0) mode = 5;
        if(x == 0 && y <  0) mode = 6;
        if(x >  0 && y <  0) mode = 7;
    }
};
bool operator<(const Vec& l, const Vec& r){
    assert(l.x != 0 || l.y != 0);
    assert(r.x != 0 || r.y != 0);
    if(l.mode == r.mode){
        switch(l.mode){
        case 1:
            // 基本
            return l.y * r.x < l.x * r.y;
        case 3:
            // Pi/2回転
            return l.x * r.y > l.y * r.x;
        case 5:
            // 反転
            return l.y * r.x < l.x * r.y;
        case 7:
            // -Pi/2回転
            return l.x * r.y > l.y * r.x;
        default:
            return false;
        }
    }
    return l.mode < r.mode;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(32);
    ll n;
    cin >> n;
    vll x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
    }
    vector<Vec> v;
    rep(i, n){
        if(!(x[i] == 0 && y[i] == 0)) v.emplace_back(x[i], y[i]);
    }
    n = SZ(v);
    sort(ALL(v));
    ll ans = 0;
    rep(i, n){
        ll cumx = 0;
        ll cumy = 0;
        rep(j, n){
            ll idx = (i+j)%n;
            cumx += v[idx].x;
            cumy += v[idx].y;
            chmax(ans, cumx*cumx+cumy*cumy);
        }
    }
    cout << sqrt(ld(ans)) << endl;
    return 0;
}

Measured memory_bytes: 256