akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	changeNum := 10
	for x := 0; x < 1; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		for y := 0; y < 80000; y++ {
			changes := make([]int, changeNum)
			pres := make([]int, changeNum)
			for i := 0; i < changeNum; i++ {
				changes[i] = rand.Intn(d)
				pres[i] = schedule[changes[i]]
				schedule[changes[i]] = rand.Intn(26)
			}
			nextScore := calcScore(schedule, c, s, d)
			t = float64(score) * 0.5
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				for i := 0; i < changeNum; i++ {
					schedule[changes[i]] = pres[i]
				}
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


Measured memory_bytes: 6256
n = int(input())
a = list(map(int, input().split()))

approved = True
for i in range(n):
    if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
        approved = False
        break
print("APPROVED" if approved else "DENIED")


Measured memory_bytes: 9108
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
//ll INF = 1LL<<40;
int INF = 1LL<<15;

int R, C;
int sy, sx, gy, gx;

int xv[4] = {-1, 1, 0, 0};
int yv[4] = {0, 0, -1, 1};

queue<TP> q;

int check(vector<vector<char>> &c, int step, int x, int y){
    if(x == C-1 && y == R-1){
//        cout << step << endl;
        return step;
    }else if(c[y][x] != '.'){
        return -1;
    }
    c[y][x] = (char)(step%10 + '0');
//    if(step%10==0){
//        REP(i, R){
//            REP(j, C){
//                cout << c[i][j];
//            }
//            cout << endl;
//        }
//    }
    int ret = INF;
    REP(i, 4){
        int nx = x + xv[i];
        int ny = y + yv[i];
        if(0 <= nx && nx < C && 0 <= ny && ny < R && c[ny][nx] == '.'){
            q.push(make_tuple(nx, ny, step+1));
        }
    }
    while(!q.empty()){
        tie(x, y, step) = q.front(); q.pop();
        int tmp = check(c, step, x, y);
        if(tmp != -1){
            ret = min(ret, tmp);
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> R >> C;
    vector<vector<char>> c(R, vector<char>(C,' '));
    int white = 0;
    REP(i, R){
        REP(j, C){
            cin >> c[i][j];
            if(c[i][j] == '.'){
                white++;
            }
        }
    }

//    REP(i, R){
//        REP(j, C){
//            cout << c[i][j];
//        }
//        cout << endl;
//    }
    int steps = check(c, 0, 0, 0);
    if(steps != INF){
        cout << white - steps - 1 << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll ans = 0;
	for (int iter = 0; iter < 1000000; iter++) {
		for (int i = 0; i < n; i++) {
			if (a[i] >= n) {
				ll cnt = a[i] / n;
				ans += cnt;
				a[i] -= cnt*n + cnt;
				for (int j = 0; j < n; j++) {
					a[j] += cnt;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;

int main(){
  string s; cin >> s;
  int n = s.size();
  int front, back;
  for(int i = 0; i < n; i++){
    if(s[i] == 'A'){
      front = i;
      break;
    }
  }
  for(int i = n - 1; i >= 0; i--){
    if(s[i] == 'Z'){
      back = i;
      break;
    }
  }
  cout << back - front + 1 << endl;
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long X = sc.nextLong();
		int count = 0;
		long A = 100;
		for( int i=0; i<4000; i++ ){
			A = A+A/100;
			count++;
			if( A>=X ){
				break;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35768
#include <bits/stdc++.h>
using namespace std;
int main(){
 string s;
 cin >> s;
  char c = s[0];
  int cnt = 0;
  for (int i = 0; i < s.size(); i++){
    if(c != s[i]){
        c = s[i];
        cnt++;
    }
}
   cout << cnt << endl; 

}
    

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int E[200010];
int vis[200010];
vector<int> path;
void dfs(int u) {
	++vis[u];
	path.push_back(u);
	if (vis[E[u]] < 2) {
		dfs(E[u]);
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	long long k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int v;
		cin >> v;
		E[i] = v;
	}
	dfs(1);
	vector<int> path2, path1;
	for (int u : path) {
		if (vis[u] == 2) {
			path2.push_back(u);
		} else {
			path1.push_back(u);
		}
	}
	if (k < path1.size()) {
		cout << path1[k];
	} else {
		k -= path1.size();
		cout << path2[k % (path2.size() / 2)];
	}
}

Measured memory_bytes: 20772
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#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 int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define N 400005


void Weapons19(){
    int r;cin>>r;
    ld pi=3.141592653589793238;
    ld p=2*pi*r;
    cout<<p;










}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

    

    Weapons19();
    
}


Measured memory_bytes: 3800
n, m = map(int, input().split())
a = list(map(int, input().split()))
d = []
e = 0; f = 0; g = 0
for _ in range(m):
    b, c = map(int, input().split())
    d.append([c, b])
a.sort()
d.sort(reverse=True)
for i in range(len(d)):
    for _ in range(d[i][1]):
        if a[e] < d[i][0]:
            a[e] = d[i][0]
        else:
            f = 1
            break
        e += 1
        if e == n:
            f = 1
            break
    if f == 1: break
for i in range(n): g += a[i]
print(g)

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> ref(a);
    vector<int> mic(b);
    for(int i = 0; i < a; i++) cin >> ref[i];
    for(int i = 0; i < b; i++) cin >> mic[i];

    int ans = INF;
    for(int i = 0; i < m; i++){
        int x, y, c; cin >> x >> y >> c;
        x--; y--;
        int sum = ref[x] + mic[y] - c;
        ans = min(ans,sum);
    }

    sort(ref.begin(), ref.end());
    sort(mic.begin(), mic.end());

    ans = min(ans, ref[0]+mic[0]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<int> v(3);
	for (auto &x : v) cin >> x;
	sort(v.begin(), v.end());

	int ans = 10 * v[2] + v[1] + v[0];
	cout << ans << endl;
}


Measured memory_bytes: 256
from heapq import heappop,heappush
n=int(input())
a=list(map(int,input().split()))
p=sum(a[2*n:])
right_min=[p]
hq=[]
for i in range(2*n,2*n+n):
	heappush(hq,-a[i])
for i in range(n):
	p+=a[-n-i-1]
	heappush(hq,-a[-n-i-1])
	p+=heappop(hq)
	right_min.append(p)
l=sum(a[:n])
hq=[]
for i in range(n):
	heappush(hq,a[i])
right_min.reverse()
ans=l-right_min[0]
for i in range(n):
	l+=a[n+i]
	heappush(hq,a[n+i])
	l-=heappop(hq)
	ans=max(ans,l-right_min[i+1])
print(ans)

Measured memory_bytes: 42884
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int N = 5 + 1e5;
int main()
{
	int n; cin >> n;
	// Eratosthenes
	vector<int> arr(N,1);
	for (int i = 2;i < N;i++) {
		if (arr[i]) {
			for (int j = 2;i * j < N;j++) {
				arr[i * j] = 0;
			}
		}
	}
	for (int i = n;i < Max;i++) {
		if (arr[i]) {
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 3680
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

struct page
{
    ll index;
    string name;
    ll score;
};

bool cmp(const page &a, const page &b)
{
    return (a.name < b.name) || (a.name==b.name && a.score > b.score);
}


void solve() {
    ll a, b, c, d, n, k, x,l;
    // string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Good";

    cin  >> n;

    vector<page> book;

    rep1(i,n){
        string name;
        ll score;
        cin >> name >> score;
        page tmp = {i,name,score};

        book.push_back(tmp);
    }

    sort(all(book), cmp);

    for(auto& page:book ){
        cout << page.index << endl;
    }

    // std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!.split(" ").map { it.toInt() }

    val even = if (input[0] > 1) {
        input[0].let { it * (it - 1) / 2 }
    } else {
        0
    }
    val odd = if (input[1] > 1) {
        input[1].let { it * (it - 1) / 2 }
    } else {
        0
    }

    println(even + odd)
}

Measured memory_bytes: 37908
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	int n, x, t, ans;
	cin >> n >> x >> t;
	if(n%x == 0){
		ans = n/x*t;
	}else{
		ans = (n/x+1)*t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    let mut result: usize = a - 1;
        if a <= b {
        result += 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}


vector<vector<int>> adj(MAXN);

LL max(LL a, LL b){
	return a>b?a:b;
}

int n;
vector<LL> v;
int an[MAXN];
vector <int> lc;

void dfs(int u,int p){
	auto x = upper_bound(all(lc), v[u]) - lc.begin();
	int ch = -1;
	int val;
	if(x >=1 && lc[x-1]!=v[u] || x == 0){
		ch = x;
		val = lc[x];
		lc[x] = v[u];
	}
	an[u] = lower_bound(all(lc), INT_MAX) - lc.begin();
	for(auto i:adj[u]){
		if(i!=p){
			dfs(i,u);
		}
	}
	if(ch!=-1) lc[x] = val;
}

int main(){
  fio();
  cin>>n;
  set<LL> s;
  forn(i,n) {
  	int x; cin>>x;
  	v.pb(x);
  }
  lc.resize(n+1);
  forn(i,n+1) lc[i] = INT_MAX;
  forn(i,n-1){
  	int u, x; cin>>u>>x;
  	u--, x--;
  	adj[x].pb(u);
  	adj[u].pb(x);
  } 
  dfs(0,-1);
  forn(i,n) cout<<an[i]<<endl;

  return 0;
}


Measured memory_bytes: 31472
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 2e5 + 100;

ll gett(ll n){
    return (n + 1)* n / 2;
}

void solve() {
    ll n;
    cin >> n;

    cout << gett(n) - 3 * gett(n / 3) - 5 * gett(n / 5)  + 15 * gett(n / 15);
}

#else

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++)  << ":} ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;

int N;
int cntA = 0;
int cntB = 0;
int cntBA = 0;
string str[10000+5];

int solve()
{
	//printf("cntBA:%d, cntA:%d, cntB:%d\n", cntBA, cntA, cntB);

	int m = min(cntA, cntB); //-AとB-を連結,+min個

	int rest = abs(cntA-cntB);

	//BA同士を一つに連結、これで＋(cntBA-1)個、また連結後のものを-AまたはーBと連結、これで＋１。
	/*
	if(cntBA)
	{
		m += cntBA-1;
		if(rest) m++;
	} 
	*/
	if(cntBA && cntA + cntB)
	{
		m += cntBA;
	}
	else if(cntBA && !(cntA+cntB))
	{
		m += cntBA-1;
	}
	
	int cnt = 0;
	for(int i = 0; i < N; i++)
		for(int j = 0; j <= str[i].length()-2; j++)
		{
			if(str[i][j] ==  'A' && str[i][j+1] == 'B') cnt++;
		}
	
	return m+cnt;
}

void Print()
{
	cout << "show:" << endl;
	for(int i = 0; i < N; i++)
		cout << str[i] << endl;
}

int main()
{
	scanf("%d", &N); getchar();
	for(int i = 0; i < N; i++) 
	{
		getline(cin, str[i]);
		int l = str[i].length()-1;
		if(str[i][0] == 'B' && str[i][l] == 'A') cntBA++;
		else if(str[i][0] != 'B' && str[i][l] == 'A') cntA++;
		else if(str[i][0] == 'B' && str[i][l] != 'A') cntB++;
	}
	//Print();
	printf("%d\n", solve());
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816],dp[225816][2][2];

int main(void){
	int n,i,m,j,k;
	ll ans = -INFLL;
	std::fill(dp[0][0],dp[225816][0],-INFLL);
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
	}
	a[n] = -INFLL;
	dp[0][0][i%2] = 0ll;
	for(i=0; i<n; ++i){
		for(k=0; k<2; ++k){
			for(j=0; j<2; ++j){
				dp[i+2][j][k] = std::max(dp[i+2][j][k],dp[i][j][k]+a[i+j]);
			}
			dp[i+2][1][k] = std::max(dp[i+2][1][k],dp[i][0][k]+a[i+1]);
			dp[i+1][k][0] = std::max(dp[i+1][k][0],dp[i][k][1]);
		}	
	}
	for(k=0; k<2; ++k){
		for(j=0; j<2; ++j){
			ans = std::max(ans,dp[n][j][k]);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 12240
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int A, B, C, X, r = 0;
	cin >> A >> B >> C >> X;
	X = X / 50;
	for(int i = 0; i <= min(int(X/10), A); i++){
		for(int j = 0; j <= min(int((X-10*i)/2), B); j++){
			if(X-10*i-2*j<=C)r++;
		}
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <utility>
#include <cmath>

void prime_factorization(std::map<long, long> &prime_factor, long M);
long modinv(long a, long m);
long nCr(long n, long r);

int main()
{
  long N, M;
  std::cin >> N >> M;
  std::map<long, long> prime_factor;
  prime_factorization(prime_factor, M);
  long ans = 1;
  for (auto x : prime_factor)
  {
    ans *= nCr((N-1+x.second), x.second);
    ans %= 1000000007;
  }
  std::cout << ans << std::endl;
}

/* ++++++++++ function ++++++++++ */
void prime_factorization(std::map<long, long> &prime_factor, long M)
{
  long num;
  double limit = std::sqrt(M);
  for (int i = 2; i < limit; i++)
  {
    num = 0;
    if (M % i == 0)
    {
      while (M % i == 0)
      {
        num++;
        M /= i;
      }
      prime_factor[i] = num;
    }
    if (i != 2) i++;
  }
  if (M != 1) prime_factor[M] = 1;
}

long modinv(long a, long m) {
    long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; std::swap(a, b);
        u -= t * v; std::swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long nCr(long n, long r){
  long ans = 1;
  for(long i = n; i > n - r; i--){
    ans = ans*i;
    ans %= 1000000007;
  }
  for(long i = 1; i < r + 1; i++){
    ans *= modinv(i, 1000000007);
    ans %= 1000000007;
  }
  return ans;
}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])

queue = deque()
queue.append((start, 0))
visited = [[float('inf')]*W for _ in range(H)]
visited[start[0]][start[1]] = 0

ds = [(1,0),(-1,0),(0,1),(0,-1)]
while queue:
	n, d = queue.popleft()
	if n == end:
		print(d)
		exit()
	i, j = n
	if visited[i][j] != d:
		continue
	nd = d
	for di, dj in ds:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		if nd < visited[ni][nj]:
			queue.appendleft(((ni,nj), nd))
			visited[ni][nj] = nd
	nd = d+1
	for di in range(-2, 3):
		for dj in range(-2, 3):
			if (di, dj) == (0,0): continue
			ni, nj = i+di, j+dj
			if not (0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if nd < visited[ni][nj]:
				queue.append(((ni,nj), nd))
				visited[ni][nj] = nd
print(-1)


Measured memory_bytes: 98756
import sys

# import numba as nb
import numpy as np

input = sys.stdin.readline


# @nb.njit("i8(i8,i8,i8[:],i8[:])")
def solve(N, W, w, v):
    dp = np.full(shape=(N + 1, np.sum(v) + 1), fill_value=(N * W), dtype=np.int64)
    dp[:, 0] = 0
    for i in range(N):
        np.minimum(w[i], dp[i][:v[i]], dp[i + 1][:v[i]])
        np.minimum(w[i] + dp[i][: - v[i]], dp[i][v[i]:], dp[i + 1][v[i]:])
    return np.where(dp[-1] <= W)[0][-1]


def main():
    N, W = map(int, input().split())

    w = np.empty(shape=N, dtype=np.int64)
    v = np.empty(shape=N, dtype=np.int64)
    for i in range(N):
        w[i], v[i] = map(int, input().split())

    ans = solve(N, W, w, v)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 106636
#include <cstdio>
#include <complex>
using namespace std;

typedef complex<double> Point;

#define X real()
#define Y imag()

int n;
Point ans[2001];

int main() {
  ans[0] = Point(1, 0);
  for (int i=0; i<2000; i++) {
    Point d = -ans[i]/Point(0, 1);
    ans[i+1] = ans[i] + d/sqrt(norm(d));
  }

  while (1) {
    scanf("%d", &n);
    if (n == -1) return 0;
    printf("%f\n%f\n", ans[n-1].X, ans[n-1].Y);
  }
}

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int a,b; cin >> a >> b;
	if(a>b) swap(a,b);
	ll res = 1;
	const ll m = TEN(9)+7;
	rep1(i,a) res=res*i%m;
	rep1(i,b) res=res*i%m;
	if(a==b){
		cout << res*2%m << endl;
	}else if(a+1==b){
		cout << res << endl;
	}else{
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

typedef pair<int, int> II;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	map<int, int> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		m[a] += 1;
	}
	vector<II> v;
	for (auto kv : m) {
		v.push_back(II(kv.second, kv.first));
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < ((int)v.size() - k); ++i) {
		ans += v[i].first;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);

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

    int M,S;
    M = 0; S = 0;

    for (int i = 0; i < N - 1; i++) {
        if (A.at(i) >= A.at(i + 1)) {
            S++;
        }

        else {
            if (M < S) {
                M = S;
            }

            S = 0;
        }

    }

    if (M < S) {
        M = S;
    }

    cout << M << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

int main() {
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;++i)cin >>v[i];
  sort(all(v));
  int cnt = 0;
  for(int j=0;j<n-2;++j){
    for(int k=j+1;k<n-1;++k){
      int a = v[n-1-j];
      int b = v[n-1-k];
      auto iter = upper_bound(all(v), a-b);
      auto dist = distance(v.begin(), iter);
      cnt += max(0, (int)(n-1-k - dist));
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
s= str(input())
t= str(input())

S = ['a']*len(s)
T = ['a']*len(t)

for i in range (0, len(s)):
	S[i]=ord(s[i])

for i in range (0, len(t)):
	T[i]=ord(t[i])

S = sorted(S)
T = sorted(T, reverse=True)

check = 0

for i in range (0, min(len(s), len(t))):
	if S[i] < T[i]:
		print('Yes')
		exit()
	elif S[i] == T[i]:
		check+=1

if check == min(len(S),len(t)) and len(T)>len(S):
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;


int n;
string parse(string s,vector<string> &vec) {
    int idx=0;
    string res="";
    string tmp="";
    while(s[idx]!=':') {
        tmp+=s[idx];
        idx++;
    }
    res=tmp;
    tmp="";
    idx++;
    while(idx<s.size()) {
        if(s[idx]==',') {
            vec.pb(tmp);
            tmp="";
            idx++;
        }
        if(s[idx]=='.') break;
        tmp+=s[idx];
        idx++;
    }
    vec.pb(tmp);
    return  res;
}
map<string,int> ids;
int to_id(string &s) {
    if(!ids.count(s)) ids[s]=ids.size();

    return ids[s];
}

vector<int> G[1003];
bool flag[1003];
int dfs(int v,int u) {
    if(flag[v]) return 0;
    flag[v]=true;
    if(G[v].size()==0) {
        return 1;
    }
    int ret=0;

    rep(i,G[v].size()) {
        if(G[v][i]==u) continue;
        ret+=dfs(G[v][i],v);
    }

    return ret;
}

void solve() {
    string first_root="";
    ids.clear();
    rep(i,1003) G[i].clear();
    rep(i,1003) flag[i]=false;
    
    rep(i,n) {
        vector<string> vec;
        string s;
        cin>>s;

        string root=parse(s,vec),t;
        if(first_root=="") first_root=root;

        rep(j,vec.size()) {
            t=vec[j];
            G[to_id(root)].pb(to_id(t));
        }
    }

    cout<<dfs(to_id(first_root),-1)<<endl;

}
int main() {
    while(cin>>n) {
        if(n==0) break;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n,cnt=0;
  cin>>n;

  int a[101];

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


  for(int i=0;i<n;i++){
    for(int j=0;j<n-i-1;j++){
      if(a[j]>a[j+1]){
	cnt++;
	int temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }

  for(int i=0;i<n;i++){
    if(i==n-1){
      cout<<a[i]<<endl;
    }else{
      cout<<a[i]<<" ";
    }
  }

  cout<<cnt<<endl;
  return 0;

}



Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N;
	cin >> N;
	ll i;
	ll A[N];
	for(i=0;i<N;i++){
		cin >> A[i];
	}
	sort(A,A+N);
	for(i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int n,a[maxn],b[maxn],ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> n;
	rep(n+1) cin >> a[i];
	rep(n) cin >> b[i];
	rep(n){
		if(b[i]<a[i]){
			a[i]-=b[i];
			ans+=b[i];
		}
		else if(b[i]<a[i]+a[i+1]){
			a[i+1]-=b[i]-a[i];
			a[i]=0;
			ans+=b[i];
		}
		else{
			ans+=a[i]+a[i+1];
			a[i]=0;
			a[i+1]=0;
		}
	}
	print1(ans);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int min(x,y){
    if(x<y){
        return x;
    }else{
        return y;
    }
}

int max(x,y){
    if(x<y){
        return y;
    }else{
        return x;
    }
}

int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    printf("%d",max(min(b,d)-max(a,c),0));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;



/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int n , p;
	cin>>n>>p;
	string s;
	cin>>s;

	if(p==2 || p==5){
		int ans = 0;
		for(int i = 0 ; i < n ; ++i){

			int val = s[i]-'0';
			if(val%p==0)
				ans += i+1;
		}
		cout<<ans<<endl;
		return ;
	}
	map<int,int> mp;
	mp[0]++;
	int res = 0;
	int ans = 0;
	int x = 1;
	for(int i = n-1 ; i >= 0 ; --i){

		res = (s[i]-'0')*x + res;
		res%=p;
		ans += mp[res];
		//debug(res);
		x*=10;
		x%=p;
		mp[res]++;


	}

	cout<<ans<<endl;
}

signed main(){

    //fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t ; ++i){

    	solve();
    }
}






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

int main(){
  int N;
  cin >> N;
  vector<int> d(100);
  int ans = 0;
  for(int k = 0;k<N;++k){ 
    cin >> d[k];
  }
  for (int i = 0;i<N-1;++i){
    for (int j = i+1;j<N;j++){
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String args[]) {
    int rep = 1;
    if( args.length > 0 ) { rep = Integer.parseInt(args[0]); }
    (new Main()).__solve(rep);
  }

  void __solve(int rep) {

    try (
      Scanner cin = new Scanner(System.in);
    ) {

      for( int i = 0; i < rep; ++i ) {
        __solve(cin);
      }

    }

  }

  void __solve(Scanner cin) {
	  int N = cin.nextInt();
	  int K = cin.nextInt();
	  double ans = 0.0;
	  double d = 1.0 / N;
	  for( int i = 1; i <= N; ++i ) {
		  double tmp = 1.0 / N;
		  int I = i;
		  while( I < K ) {
			  tmp /= 2.0;
			  I *= 2;
		  }
		  ans += tmp;
	  }
	  System.out.println(ans);
  }

}


Measured memory_bytes: 21076
n=int(input())
w=list(map(int,input().split()))
a=[w[0]]
for i in range(n-1):
    a.append(a[i]+w[i+1])
index=0
MIN=10000000
# print(a)
for i in range(n):
    if abs(a[n-1]/2-a[i])<=MIN:
        MIN=abs(a[n-1]/2-a[i])
        index=i
print(abs(a[n-1]-2*a[index]))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define int long long 
main(){
    int a,b;
    cin>>a>>b;
    bitset<32>x(a),y(b);
    cout<<(x&y)<<endl;
    cout<<(x|y)<<endl;
    cout<<(x^y)<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>

using namespace std;

const int S = 4;
const int M = 3;

int cheker(int *t, int b){
  int ans = t[0];
  for(int j=0;j<M;j++){
    ans = (b>>j & 1)? (ans+t[j+1]) : (ans-t[j+1]);
  }
  return ans;
}

void solve(int *t){
  for(int i=0;i<(1<<M);i++){ //0 -> + , 1 -> -
    if(cheker(t,i) == 7){
      cout << t[0];
      for(int j=0; j<M; j++){
	cout << (((i>>j)&1) ? "+" : "-") << t[j+1]; 
      }
      cout << "=7" << endl;
      return;
    }
  }
}

int main(){
  char c[S];
  int t[S];
  cin >> c;
  for(int i=0;i<S;i++) t[i] = c[i] - '0';
  solve(t);

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<ll> v(n);
		rep(i, n)
			cin >> v[i];
		sort(ALL(v));
        
        ll res = 0, wait = 0;
        
        REP(i, 1, n)
            res += wait += v[i - 1];
        
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int L = 0, R = n+1;
	for (int i = 1; i <= m; i++) {

		int a, b;
		cin >> a>>b;
		L = max(L, a);
		R = min(R, b);
	}
	cout << max(0, R - L + 1) << endl;

}

Measured memory_bytes: 256
#! /usr/bin/python3
# One Card Poker

""" 弱 2 < 3 < ... < 13 < 1 強  """

A, B = map(int, input().split())
# Alice, Bob のカード


def main():
    """ 勝者の出力 """
    if A == B:
        print('Draw')
    elif A == 1:
        print('Alice')
    elif B == 1:
        print('Bob')
    elif A > B:
        print('Alice')
    elif A < B:
        print('Bob')
    else:
        print('Error')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

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

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef pair<ll, ll>        pll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vii;
typedef vector<pll>         vll;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    if(k<=a){
        cout << k;
    }else if(k<=a+b){
        cout << a;
    }else{
        cout << a-(k-(a+b));
    }
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string A,B;
  ll x,y;
  string C;
  cin>>A>>B>>x>>y>>C;
  if(A==C){cout<<x-1<<" "<<y<<endl;}
  if(B==C){cout<<x<<" "<<y-1<<endl;}
}

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


public class Main{
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            long MOD = 1000000007;
            int n = sc.nextInt(), m = sc.nextInt();
            char c[][]=  new char[n][m];
            for(int i = 0; i < n; i++) {
                String tmp = sc.nextLine();
                c[i] = tmp.toCharArray();
            }
            long dp[][] = new long[n + 1][m + 1];
            dp[0][1] = 1;
            for(int i = 1; i <= n; i++)
            {
                for(int j = 1; j <= m; j++)
                {
                    if(c[i - 1][j - 1] == '.')
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                }
            }
            out.println(dp[n][m]);
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }

        out.close();

        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String

        int result = 3*n;
        out.println(result);                    // print via PrintWriter
        */
        // Stop writing your solution here. -------------------------------------
        out.close();
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 37896
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;
long long int mpown(long long int m, int n);

int bitCount(int bits);
int main()
{
    int n,q;
    cin >> n >> q;
    pair<long long int,long long int> evs[2*n];
    long long int d[q];
    long long int inps,inpt,inpx;
    for(int i=0;i<n;i++){
        cin >> inps >> inpt >> inpx;
        evs[i*2+0]=make_pair(inps-inpx,inpx);
        evs[i*2+1]=make_pair(inpt-inpx,-inpx);
    }
    for(int i=0;i<q;i++)cin >> d[i];
    sort(evs,evs+2*n);
    set<long long int> xset;
    int indt=0;
    for(int i=0;i<q;i++){
        while(indt < 2*n){
            if(evs[indt].second<0){
                xset.erase(-evs[indt].second);
            }else{
                xset.insert(evs[indt].second);   
            }
            indt++;
            if(indt >=2*n)break;
            if(evs[indt].first > d[i])
            {indt--;break;
            }
        }
        if(xset.empty()){
            cout << -1 << endl;
        }else{
            cout << *xset.begin() << endl;
        }
    }
    // cout << ans << endl;
}

int bitCount(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); //  2bitごとに計算
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); //  4bitごとに計算
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); //  8bitごとに計算
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); //  16ビットごとに計算
    return (bits & 0x0000ffff) + (bits >> 16);             //  32ビット分を計算
}
long long int mpown(long long int m, int n)
{
    if (n == 0)
        return 1;
    else if (n == 1)
        return m;
    else
    {
        long long int temp = mpown(m, n / 2);
        return temp * temp * (n & 1 ? m : 1);
    }
}

Measured memory_bytes: 20212
#include<iostream>
using namespace std;
int prime(long int n);

int main(){
        long int n;
        long int num;
        long int count=0;
        long int i;
        cin>>n;
        for(i=0;i<n;i++){

                cin>>num;
                if(prime(num)==1){
                        count++;
                }
        }
        cout<<count<<endl;
        return 0;
     
}

int prime(long int n){
        long int i;
        long int sqrt;
        if(n==2)return 1;
        for(i=1;i<n;i++){
                if(n<i*i){
                        sqrt=i;
                        break;
                }
        }
        for(i=2;i<=sqrt;i++){
                if(n%i==0){
                        return 0;
                }
        }
        return 1;
}

Measured memory_bytes: 3064