akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
bool is_prime(ll n){
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return true;
}
vector<ll>divisor(ll n){
	vector<ll>res;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}
map<ll,int>prime_factor(ll n){
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++){
		while(n%i==0){
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
vector<ll>prime_enum(int n){
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++){
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i){
			is_prime[j]=false;
		}
	}
	return res;
}

int a[20000];
//~ ll Pow[20000];

int main(){
	int n;cin>>n;
	map<int,int>L;
	rep(i,n){
		scanf("%d",&a[i]);
		auto mp=prime_factor(a[i]);
		for(auto&p:mp)L[p.first]=max(L[p.first],p.second);
	}
	ll A=1;
	for(auto&p:L){
		(A*=ppow(p.first,p.second))%=MOD;
	}
	ll ans=0;
	rep(i,n){
		(ans+=A*ppow(a[i],MOD-2))%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;



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

    int n,h,maxa=0,a;
    cin>>n>>h;
    vi b(n);
    rep(i,n){
        cin>>a>>b[i];
        maxa=max(a,maxa);
    }
    ll ans=0;
    Rort(b);
    for(int i=0;i<n;i++){
        h-=max(b[i],maxa);
        ans++;
        if(h<=0){
            break;
        }
    }
    if(h<=0){
        fin(ans);
        return 0;
    }
    ans+=ceil(h/(double)maxa);
    fin(ans);


//////////////////////////////////////////////////////
return 0;}



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

int main(){
	int N, K;
	cin >> N >> K;
	double p[N];
	double sum[N+1];
	for(int i=0;i<N;i++){
		cin >> p[i];
	}
	sum[0] = 0;
	for(int i=1;i<N+1;i++){
		sum[i] = sum[i-1] + p[i-1];
	}
	double ans = 0.0;
	for(int i=0;i<=N-K;i++){
		ans = max(ans, (sum[i+K] - sum[i] + K) / 2);
	}
	printf("%.12f\n", ans);
}

Measured memory_bytes: 6880
import collections

N=int(input())
list=[]

for i in range(0,N) :
  a = input()
  list.append(a)

c = collections.Counter(list)

print("AC"+" x "+str(c['AC']))
print("WA"+" x "+str(c['WA']))
print("TLE"+" x "+str(c['TLE']))
print("RE"+" x "+str(c['RE']))

Measured memory_bytes: 16484
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<10, mod = 119<<23|1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, k, dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
ll dist[maxn][maxn];
char mat[maxn][maxn];
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m >> k;
	queue<pi> q;
	memset(dist, 0x3f, sizeof dist);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++) {
			cin >> mat[i][j];
			if(mat[i][j] == 'S') q.push({i, j}), dist[i][j] = 0;
		}
	ll ans = 1ll<<60;
	while(!q.empty()) {
		int x, y;
		tie(x,y) = q.front();
		q.pop();
		for(int i = 0; i < 4; i++) {
			int tx = x + dx[i], ty = y + dy[i];
			if(tx > 0 && tx < n && ty > 0 && ty < m && dist[tx][ty] > n+n+m+m && mat[tx][ty] != '#') {
				dist[tx][ty] = 1+dist[x][y];
				q.push({tx, ty});
			}
		}
		if(dist[x][y] <= k) ans = min(ans, 1ll + (min({x, n-x-1, y, m-y-1})+k-1)/k);
	}
	cout << ans;
}


Measured memory_bytes: 9344
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
const int N=2e5 + 5;
void modify(int p, ll value,int n,ll t[]) {  // set value at position p
  for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = max(t[p] , t[p^1]);
}
ll query(int l, int r,int n,ll t[]) {  // sum on interval [l, r)
  ll res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) {res = max(res,t[l]);l++;}
    if (r&1) {r--;res = max(res,t[r]);}
  }
  return res;
}
int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll ar[n],br[n];
    forn(i,n)cin>>ar[i];
    forn(i,n)cin>>br[i];
    ll dp[2*(n+1)]={0};
    ll ans=0;
    forn(i,n){
        /*for(int j=0;j<ar[i];j++){
            dp[ar[i]]=max(dp[ar[i]],dp[j]+br[i]);
        }*/
        ll val=query(0,ar[i],n+1,dp);
        dp[n+1+ar[i]]=val+br[i];
        modify(ar[i],dp[n+1+ar[i]],n+1,dp);
        ans=max(ans,dp[n+1+ar[i]]);
        //cout<<ar[i]<<" "<<dp[ar[i]]<<" "<<val<<endl;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 6528
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  NextInt(&N)
  var A []int
  NextIntVec(&A)
  M := make(map[int]int)
  cnt := 0
  var ok bool
  for i, a := range A {
    if _, ok = M[i - a]; ok { cnt += M[i - a] }
    if _, ok = M[i + a]; !ok { M[i + a] = 0 }
    M[i + a]++
  }
  Write(cnt)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 21092
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	
	static Scanner sc;
	static int num;
	static int[] b_array,c_array,t_array;
	static int tmp,count_1,count_2;

	public static void main(String[] args) {
		
		sc = new Scanner(System.in);
		new Main();
	}
	Main(){
		while(true){
			num = sc.nextInt();
			if(num==0)
				return;
			b_array = new int[num];//before
			c_array = new int[num];//current
			t_array = new int[num];//tmp
			count_1=0;
			for(int i=0; i<num; i++){
				b_array[i] = sc.nextInt();
			}
			while(!Arrays.equals(c_array, b_array)){
				if(Arrays.equals(t_array, b_array)){
					for(int i=0; i<num; i++)
						b_array[i]=c_array[i];
				}
				for(int i=0; i<num; i++){
					tmp = b_array[i];
					count_2=0;
					for(int j=0; j<num; j++){
						if(tmp==b_array[j])
							count_2++;
					}
					c_array[i]=count_2;
				}
				if(!Arrays.equals(c_array, b_array)){
					for(int i=0; i<num; i++)
						t_array[i]=b_array[i];
					count_1++;
				}
			}
			System.out.println(count_1);
			for(int i=0; i<num-1; i++){
				System.out.print(c_array[i]+" ");
			}
			System.out.println(c_array[num-1]);
		}
	}
}

Measured memory_bytes: 26376
import itertools
N, K = map(int, input().split())
i=0
dlist=[]
mlist=[]
while(i<K) :
  d = int(input())
  val = input().split()
  dlist.append(d)
  mlist.append(val)
  i+=1
res=0
list=list(itertools.chain.from_iterable(mlist))
if(N==1):
  if(list.count("1")==0):
    res+=1
else:
  j=1
  while(j<=N):
    if(list.count(str(j))==0):
      res+=1
    j+=1
print(res)

Measured memory_bytes: 9580
program main
  implicit none
  integer(8) :: m = 10 ** 9 + 7
  integer(8) :: n, k, i, g, res
  integer(8), allocatable :: s(:), t(:)
  read *, n, k
  allocate (s(k), t(k))
  do i = 1, k
    t(i) = get_t(i)
  end do
  s(:) = t(:)
  do g = k, 1, -1
    do i = 2, k / g
      s(g) = s(g) - s(i * g)
      s(g) = modulo(s(g), m)
    end do
  end do
  res = 0
  do g = 1, k
    res = res + g * s(g)
    res = modulo(res, m)
  end do
  print "(i0)", res

  contains

  integer(8) function get_t(f)
    integer(8), intent(in) :: f
    integer(8) :: ng
    ng = k / f
    get_t = pow(ng, n)
  end function get_t

  function pow(n, p) result(res)
    integer(8), intent(in) :: n, p
    integer(8) :: res, i, imax
    integer(8), allocatable :: buf(:)
    imax = bit_size(p) - leadz(p) - 1
    allocate (buf(0:imax))
    buf(0) = modulo(n, m)
    do i = 1, imax
      buf(i) = modulo(buf(i - 1) ** 2, m)
    end do
    res = 1
    do i = 0, imax
      if (btest(p, i)) then
        res = res * buf(i)
        res = modulo(res, m)
      end if
    end do
    deallocate (buf)
  end function pow
end program main


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

using namespace std;
using int64 = long long int;

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

    for (int i = 1; i <= (int) sqrt(n); i++)
    {
        if (n % i == 0 && i <= 9 && n / i <= 9)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define int long long
#define debug(var) cout << "[" << #var << "] " << var << endl
//using ll = long long;

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=998244353;

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

    if (s.length() <= k) {
        cout << s;
    } else {
        cout << s.substr(0, k)  + "...";
    }

}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int ca = 0; ca < 4; ++ca) {
		vector<int> sw;
		sw.push_back(ca%2);
		sw.push_back(ca/2);
		for (int p = 1; p < s.length(); ++p) {
			if (sw[p] == 0) {
				if (s[p] == 'o') {
					sw.push_back(sw[p-1]);
				}
				else {
					sw.push_back(1-sw[p - 1]);
				}
			}else {
				if (s[p] == 'o') {
					sw.push_back(1-sw[p - 1]);
				}
				else {
					sw.push_back(sw[p - 1]);
				}
			}
		}
		if (sw[0] == sw[sw.size()-1]) {
			bool flag = true;
			if (s[0] == 'o' && sw[0]==0 
				|| s[0]=='x' && sw[0]==1) {
				flag = (sw[sw.size()-2] == sw[1]);
			}
			else {
				flag = (sw[sw.size()-2] != sw[1]);
			}
			if (flag) {
				for (int i = 0; i < s.length(); ++i) {
					if (sw[i] == 0) cout << "S";
					else cout << "W";
				}
				cout << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1392
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = []
 phU.append(P[0])
 phU.append(P[1])
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True) :
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = []
 phL.append(P[-1])
 phL.append(P[-2])
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 ph = phU + phL[1:-1]
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
P = P[idx:] + P[:idx]
for p in P : print(p[0],p[1])

Measured memory_bytes: 33184
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll cul(vector<ll>A,vector<ll>B) {
	if (A != B) {
		ll ans = 0;
		rep(B.size())
			ans += B[i];
		int flag = 1;
		rep(B.size()) {
			if (B[i] != A[i]) {
				B[i]++;
				flag = 0;
				break;
			}
			B[i] = 1;
		}
		if (flag == 1)
			B = A;
		ans += cul(A, B);
		return ans;
	}
	else {
		ll ans = 0;
		rep(A.size())
			ans += A[i];
		return ans;
	}
}


int main() {
	cout.precision(16);
	ll N, K;
	cin >> N >> K;
	vector<ll>p(N);
	vector<long double>e(N);
	rep(N) {
		cin >> p[i];
	}
	rep(N)
		e[i] = (p[i] + 1) / 2.0;
	long double ans = 0;
	long double ans2;
	rep(K) {
		ans += e[i];
	}
	ans2 = ans;
	ll memo = 0;
	rep(N  - K) {
		ans += e[i + K];
		ans = ans - e[i];
		if (ans2 < ans)
			memo = i;
		ans2 = max(ans2, ans);
	}
	cout << ans2;
	
	return 0;
}

Measured memory_bytes: 4992
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n,t,a;
	cin>>n>>t>>a;
	int h[n+1];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int ans=1<<30;
	int pos=0;
	for(int i=0;i<n;i++){
		int dif = abs(a*1000-(t*1000-h[i]*6));
		if(dif<ans){
			pos = i+1;
			ans = dif;
		}
	}
	cout<<pos<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vll a(3*N);
    for (int n = 0; n < 3*N; ++n) {
        cin >> a[n];
    }
    vll SumL(N+1);
    priority_queue<ll> PL;
    for (int n = 0; n < N; ++n) {
        SumL[0] += a[n]; PL.push(-a[n]);
    }
    for (int n = 1; n <= N; ++n) {
         PL.push(-a[N+n-1]); SumL[n] = SumL[n-1]+a[N+n-1]+PL.top(); PL.pop();
    }
    vll SumR(N+1);
    priority_queue<ll> PR;
    for (int n = 0; n < N; ++n) {
        SumR[0] += a[3*N-1-n]; PR.push(a[3*N-1-n]);
    }
    for (int n = 1; n <= N; ++n) {
        PR.push(a[2*N-n]); SumR[n] = SumR[n-1]+a[2*N-n]-PR.top(); PR.pop(); 
    }
    ll Score = -INFLL;
    for (int n = 0; n <= N; ++n) {
        Score = max(Score, SumL[n]-SumR[N-n]);
    }
    cout << Score << endl;

    return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
using namespace std;

bool compare(tuple<string, int, int> a, tuple<string, int, int> b){
  if(get<0>(a) != get<0>(b)){
    return get<0>(a) < get<0>(b);
  }else{
    return get<1>(a) > get<1>(b);
  }
}

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> restaurant(N);

  
  for(int i = 0; i < N; i++){
    string city;
    int score;
    cin >> city >> score;
    restaurant.at(i) = make_tuple(city, score, i + 1);
  }

  sort(restaurant.begin(), restaurant.end(), compare);

  /*
  for(auto c: restaurant){
    cout << get<0>(c) << " " << get<1>(c) << " " << get<2>(c) << endl;
  }
  */
 for(int i = 0; i < N; i++){
   string name;
   int score;
   int index;
   tie(name, score, index) = restaurant.at(i);
   cout << index << endl;
 }

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c;
	int temp;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);


	if(a>b){
		temp = a;
		a = b;
		b = temp;
	}

	if(b>c){
		temp = b;
		b = c;
		c = temp;
	}

	if(a>b){
		temp = a;
		a = b;
		b = temp;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}


Measured memory_bytes: 2108
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main :: IO()
main = do
    [n,a,b] <- getIntList
    -- ΣnCk[0,n] = 2^n より (2^n - 1 - nCa - nCb)が答
    putStrLn $ show $ let result = (power' 2 n) - 1 - (combination n a) - (combination n b)
                          divisor = 10^9 + 7
                      in snd $ divMod (result + 2 * divisor) divisor

fact' :: (Integral a) => a -> a -> a
fact' a 1 = a
fact' a n
    | a < n  = -1
    | a >= n = snd $ (a * fact' (a-1) (n-1)) `divMod` p
    where p = 10^9 + 7

power' :: (Integral a) => a -> a -> a
power' 1 _ = 1
power' a 1 = a
power' a b = let ret = snd $ divMod (x * x) p
             in if even b then ret else snd $ divMod (ret * a) p
             where p = 10^9 + 7
                   x = power' a $ fst (b `divMod` 2)

inv :: (Integral a) => a -> a -> a
inv n p = if n <= 0 || p <= 1
              then -1
              else power' n (p-2)

combination :: (Integral a) => a -> a -> a
combination 0 _ = 1
combination _ 0 = 1
combination m 1 = m
combination m n
    | m < n  = 0
    | m == n = 1
    | n > threshold  = combination m (m-n)
    | n <= threshold = snd $ ((fact' m n) * (inv (fact' n n) divisor)) `divMod` divisor
    where threshold = fst $ divMod m 2
          divisor = 10^9 + 7

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 49532
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 


ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}


int main(void){

  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22) cout<<"bust"<<endl;

  else cout<< "win"<<endl;
  return 0;
}

Measured memory_bytes: 256
li=list(input())
lis=[]
for i in range(len(li)):
  lis.append(li[i])
  lis.append('')
lis.pop(-1)
sum=0
for i in range(2**(len(li)-1)):
    for j in range(len(li)-1):
      if (i >> j)&1:
          lis[2*j+1]='+'
    str=''.join(lis)
    calc=0
    a=[]
    #計算
    a=list(str.split('+'))
    for j in a:
      calc+=int(j)
    sum+=calc
    #戻す
    for j in range(len(li)-1):
      lis[2*j+1]=''
print(sum)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n,x;
    cin >> n >> x;
    vector<int> vec(n+1);
    rep(i,n) cin >> vec.at(i);
    vec.at(n) = 0;
    int boon = 0;
    int count = 0;
    for(int i=0;i<=n;i++){
        if(boon <= x) count++;
        boon += vec.at(i);
        //cout << boon << endl;
    }
    cout << count << endl;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9 + 1
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int kaisu, kaisu2;

    kaisu = (c + (b-1)) / b;
    kaisu2 = (a + (d-1)) / d;

    if(kaisu <= kaisu2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int count = 0;
      
      for(int i=0; i<str.length(); i++){
      	if(str.charAt(i) == '1'){
        	count++;
        }
      }
      
      System.out.println(count);
	}
}


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

const int MAXN = 1e5 + 10;
int n, ans;
pair <int, int> in[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> in[i].first;
		in[i].second = i;
	}
	sort(in, in + n);
	for (int i = 0; i < n; i += 2){
		if(in[i].second % 2 != i % 2)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int ans = 0;
    rep(i,s.size()) if (s[i] == '2') ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)
 
typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());
 
const int N = 1001;
int n;
int s[500][500];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int m = sqrt(n*2);
  if(m*(m+1)/2 != n){
    cout << "No" << endl;
    return 0;
  }
  int t = 0;
  cout << "Yes" << endl << m+1 << endl;
  FOR(i, 0, m+1){
    cout << m;
    FOR(j, 0, m) cout << " " << (s[i][j] = (j<i ? s[j][i-1] : ++t));
    cout << endl;
  }
}

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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc047 c
    static void solve(InputReader in, PrintWriter out){
        char[] s = in.ns().toCharArray();
        int m = 0;
        for (int i = 1; i < s.length; i++) {
            if(s[i]!=s[i-1]) m++;
        }
        out.println(m);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 23380
let id x = x

let init n f =
  let rec g i ns = if i = 0 then 0 :: ns else g (i - 1) (i :: ns) in
  List.map f (g n [])

let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let ss = split_string @@ Scanf.scanf "%s\n" id

let len = List.length ss

let () =
  ss
    |> List.mapi (fun idx s -> (len - idx - 1, s))
    |> (fun lst -> List.fold_right (fun (idx, s) (sum, b_cnt) -> if s = "B" then (sum + idx - b_cnt, b_cnt + 1) else (sum, b_cnt)) lst (0, 0))
    |> (fun (sum, _) -> sum)
    |> print_int;
  print_newline ()

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    for (int i = 0; i < n; i++) {
        ll x, c;
        cin >> x >> c;
        if (m.count(x)) {
            m[x] += c;
        } else {
            m[x] = c;
        }
    }
    for (auto [value, key] : m) {
        if (k <= key) {
            cout << value << "\n";
            break;
        }
        k -= key;
    }
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 7592
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int X, Y;
  cin >> X >> Y;
  cout << X+Y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int N;
	cin>>N;
	ll sum=0;
	int T[100001]={};
	for(int i=0;i<N;i++){
		cin>>T[i];
		sum+=T[i];
	}
	int M;
	cin>>M;
	for(int i=0;i<M;i++){
		int P,X;
		cin>>P>>X;
		cout<<sum-(T[P-1]-X)<<endl;;
	}
}

Measured memory_bytes: 640
from itertools import combinations
n, k = map(int, input().split())
nc2 = (n - 1) * (n - 2) // 2
if nc2 < k:
  print('-1')
  exit()
print(n - 1 + (nc2 - k))  # M
for i in range(2, n+1):
  print(f'1 {i}')
for i in range(nc2 - k):
  combs = list(combinations(range(2, n+1), 2))
  print(f'{combs[i][0]} {combs[i][1]}')


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

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for(int i = 0; i < N; i++) cin >> h[i];
	vector<int> dp(N, 0);
	
	//[K - 1]までは1回のジャンプで行くのが最適
	for(int i = 1; i < min(K, N); i++){
		dp[i] = abs(h[0] - h[i]);
	}
	
	if(N <= K){
		cout << dp[N - 1] << endl;
		return 0;
	}
	//REはおそらくここ
	for(int i = K; i < N; i++){
		dp[i] = dp[i - K] + abs(h[i] - h[i - K]);
		for(int j = K - 1; j > 0; j--){
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main(){

    int M, K; cin >> M >> K;

    if (K == 0) {
        REP(i,1<<M) {
            cout << i << ' ' << i;
            if (i != (1<<M)-1) cout << ' '; 
        }
        cout << endl;
    }else if (M == 1 && K == 1) {
        cout << -1 << endl;
    }else if (K >= 1<<M) {
        cout << -1 << endl;
    }else if (K == 1){
        vector<int> v1;
        vector<int> v2 = {3,2,1,2,3};
        vector<int> v3;
        REP(i,1<<M) {
            if (i!=1 && i!=2 && i!=3) {
                v1.push_back(i);
                v3.push_back(i);
            }
        }
        reverse(all(v1));
        for (auto x:v1) cout << x << ' ';
        for (auto x:v2) cout << x << ' ';
        for (auto x:v3) cout << x << ' ';
        cout << 1 << endl;
    }else {
        vector<int> v1;
        vector<int> v2 = {K^1,1,K,1,K^1};
        vector<int> v3;
        REP(i,1<<M) {
            if (i!=1 && i!=K && i!=(K^1)) {
                v1.push_back(i);
                v3.push_back(i);
            }
        }
        reverse(all(v1));
        for (auto x:v1) cout << x << ' ';
        for (auto x:v2) cout << x << ' ';
        for (auto x:v3) cout << x << ' ';
        cout << K << endl;
    }
}

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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"


bool cmp(const std::pair<ll,ll>&a, const std::pair<ll,ll>&b)
{
    if(a.X == b.X)
        return a.Y>b.Y;
    return a.X < b.X;
}
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,weight;
    cin>>n>>weight;

    vector<pair<ll,ll>>v;
    fr(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        v.pb({x,y});
    }
    sort(all(v),cmp);

    ll w[n+1],val[n+1],k=0;
    for(auto x:v)
    {
        w[++k]=x.X;
        val[k]=x.Y;
    }
    ll dp[n+1][weight+1];

    fr(i,0,n+1)
    {
        fr(j,0,weight+1)
        {
            if(i==0 || j==0)
                {dp[i][j]=0;continue;}
            if(w[i]<=j)
                dp[i][j]=max(dp[i-1][j], val[i]+dp[i-1][j- w[i]]);
            else
                dp[i][j]=dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }
        //cout<<nl;
    }
    cout<<dp[n][weight]<<nl;
return 0;
}



Measured memory_bytes: 82528
///****In the name of Allah, most Gracious, most Compassionate****//

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cout<< #a <<" --> "<<(a)<<endl
#define NL cout<<"\n"

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

const int N=3e5+5;
const int oo=1e9+7;

int32_t main()
{
    FastIO;
    ll x,y;
    cin>>x>>y;
    ll g= __gcd(x,y);
    ll xx = y/g;
    if(xx==1)
        cout<<"-1\n";
    else cout<<(xx-1)*x<<'\n';
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

#define INF 1001001001

int main() {
  int r, c, k;
  cin >> r >> c >> k;
  vector< vector<int> > item(r, vector<int>(c));
  rep(i,k) {
    int tr, tc, v;
    cin >> tr >> tc >> v;
    item[--tr][--tc] = v;
  }
  vector< vector< vector<ll> > > val(r, vector< vector<ll> >(c,vector<ll>(4)));

  if (item[0][0]) val[0][0][1] = item[0][0];
  rep(i,r) rep(j,c) rep(k,4) {
    if (i) {
      if (item[i][j]) {
        val[i][j][1] = max(val[i][j][1], val[i-1][j][k]+item[i][j]);
      }
      val[i][j][0] = max(val[i][j][0], val[i-1][j][k]);
    }
    if (j) {
      if (item[i][j] && k) {
        val[i][j][k] = max(val[i][j][k], val[i][j-1][k-1]+item[i][j]);
      }
      val[i][j][k] = max(val[i][j][k], val[i][j-1][k]);
    }
  }
  ll ans = 0;
  rep(i,4) ans = max(ans, val[r-1][c-1][i]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 671452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n, k;
  cin >> n >> k;
  if (k > (n - 1) * (n - 2) / 2)
    cout << -1 << endl, exit(0);
  else {
    int cnt = (n - 1) * (n - 2) / 2 - k;
    int m = n - 1 + cnt;
    cout << m << endl;
    repf(i, 2, n + 1) cout << 1 << " " << i << endl;
    repf(i, 2, n) repf(j, i + 1, n + 1) {
      if (cnt <= 0) exit(0);
      cout << i << " " << j << endl;
      cnt--;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n, a, b, c;
vector<int> l(8, 0);

int ans = inf;

void dfs( int x, int y, int z, int i, int xcnt, int ycnt, int zcnt ){
	if( i == n ){
		if( xcnt*ycnt*zcnt == 0 ) return;
		int synth = 10*(xcnt-1)+10*(ycnt-1)+10*(zcnt-1);
		ans = min( ans, abs(a-x)+abs(b-y)+abs(c-z)+synth );
		return;
	}
	dfs( x, y, z, i+1, xcnt, ycnt, zcnt );
	dfs( x+l[i], y, z, i+1, xcnt+1, ycnt, zcnt );
	dfs( x, y+l[i], z, i+1, xcnt, ycnt+1, zcnt );
	dfs( x, y, z+l[i], i+1, xcnt, ycnt, zcnt+1 );
}

int main(){
	cin >> n >> a >> b >> c;
	for( int i = 0; i < n; ++i ) cin >> l[i];
	dfs( 0, 0, 0, 0, 0, 0, 0 );
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
l = len(s)
s += "0"
ans = 0
a_cnt = 0
skip = False
for i in range(l):
    if skip:
        skip = False
        continue
    if s[i] == "A":
        a_cnt += 1
    elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
    else:
        a_cnt = 0

print(ans)


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<int> sum(n+1);
  rep(i, n) {
    int w;
    cin >> w;
    sum[i+1] = sum[i] + w;
  }
  int ans = INT_MAX;
  for(int i=1; i<n; i++) {
    chmin(ans, abs((sum[n]-sum[i])-sum[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * main
 */
int main () {
  long N, K;
  cin >> N >> K;

  int d = floor(log(N) / log(K)) + 1;

  cout << d << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x = x ^ a[i];
    }
    int s = x;
    for (int i = 0; i < n; i++) {
        cout << (s ^ a[i]) << " ";
    }
    return 0;
}

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

const int N_MAX=100, M_MAX=100;
char p[N_MAX+1][M_MAX+1];

int main(){
	int a,b;
	cin >> a >> b;
	if(a > b){
		rep(i,a) printf("%d", b);
	}else{
		rep(i,b) printf("%d", a);
	}
	return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned x){
  int s=0;
  char f[10];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(unsigned long long x){
  int s=0;
  char f[21];
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(double x){
  printf("%.15f",x);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
inline void wt_L(string &x){
  int i=0;
  for(i=0;x[i]!='\0';i++){
    putchar_unlocked(x[i]);
  }
}
int N;
int R;
int main(){
  rd(N);
  rd(R);
  wt_L(R + 100 *max_L(0, 10-N));
  wt_L('\n');
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// int N, R;
// {
//   rd(N,R);
//   wt(R + 100 * max(0,10-N));
// }


Measured memory_bytes: 384
N,A,B = $stdin.gets.chomp.split(" ").map(&:to_i)
L = (0...N).map{ $stdin.gets.to_i }

def v(n)
  bb = n*B
  n >= L.map{ |l| 
    d = l - bb 
    d > 0 ? (d-1)/(A-B)+1 : 0
  }.inject(:+)
end

def r(a,b)
  return a if v(a)
  n = b
  (Math.log2(b-a)+2).to_i.times do
    $stderr.puts "#{[a,n,b]}"
    if v(n)
      a,b = a,n
    else
      a,b = n+1,b
    end
    n = a + (b-a)/2
  end
  n
end

M = L.map{ |l| (l-1)/(A-B)+1 }.inject(:+)
puts r(1,M)

Measured memory_bytes: 41980
def f l,s
l[0]&&s>0?$h[l+[s]]||=(r=0;l[0].map{|i,j|r+=f l[1..-1],s-i};r):s==0?1:0
end
while 0<m=gets.to_i
$h={}
c=(1..m).map{i,j=gets.split.map &:to_i;(0..j).map{|k|k*i}}
gets.to_i.times{p f c,gets.to_i}
end

Measured memory_bytes: 6196
def brute(k,n):
	def gen(k,p):
		ret = []
		if p==0:
			return [()]
		for seq in gen(k,p-1):
			for i in xrange(1,k+1):
				ret.append(seq+(i,))
		return ret
	seqs = []
	for i in xrange(1,n+1):
		seqs += gen(k,i)
	X = len(seqs)
	Y = (X-1)/2
	seqs.sort()
	#if len(seqs)<100:print seqs
	return seqs[Y]

def down_onestep(seq,k,n):
	if seq[-1]==1:
		seq.pop()
		return
	seq[-1]-=1
	while len(seq)<n:
		seq.append(k)

def f(k,n):
	if k%2==0:
		return (k/2,)+(k,)*(n-1)
	if k==1:
		return (1,)*((n+1)/2)
	else:
		seq = [(k+1)/2]*n
		for i in xrange( (n)/2 ):
			down_onestep(seq, k, n)
		return tuple(seq)
	return None

def test():
	for k in xrange(1,6):
		for n in xrange(1,8):
			if f(k,n)==brute(k,n):continue
			print k,n
			print brute(k,n)
			print f(k,n)
			print

def main():
	k,n = map(int, raw_input().split())
	print " ".join(map(str, f(k,n) ))

main()
	


Measured memory_bytes: 21596