akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?????????: n??\???????´???°
vector<int> getPrimes(int n) {
	vector<char> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j += i;
			}
		}
	vector<int> primes;
	rep(i, 0, n + 1)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}

signed main() {
	vector<int> primes = getPrimes(1299709);
	for (int n; cin >> n&&n;) {
		int l = lower_bound(all(primes), n) - primes.begin();
		int u = upper_bound(all(primes), n) - primes.begin();
		if (primes[l] != primes[u])cout << 0 << endl;
		else cout << primes[l] - primes[l - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 4592
#include <stdio.h>
#define N 100
int main(){
  int i,j,k=0,n,F,min;
  int A[N];

    scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }

  for(i=0 ; i<n ; i++){
    min=i;
    for(j=i ; j<n ; j++){
      if(A[j] < A[min]){
	min=j;
      }
    }
    if(A[i]!=A[min]){
    F=A[i];
    A[i]=A[min];
    A[min]=F;
    k++;
    }
  }

  for(i=0 ; i<n-1 ; i++){
    printf("%d ",A[i]);
  }
 printf("%d",A[n-1]);
  printf("\n%d\n",k);

  return 0;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}


int main()
{
    int K, X;
    cin >> K >> X;
    if(500*K>=X)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);
    	
    	String N=sc.next();
    	
    	String result="ABC"+N;
    	
    	System.out.println(result);


    
    }
}



Measured memory_bytes: 21972
import java.util.PriorityQueue;
import java.util.Scanner;

class Vertex implements Comparable<Vertex> {
	int no;
	int state;
	int distance;
	static final int INF = 1000000000;
	Vertex(int no) {
		this.no = no;
		state = 0;
		distance = INF;
	}
	@Override
	public int compareTo(Vertex o) {
		return Integer.compare(this.distance, o.distance); 
	}
}
public class Main {
	static int N;
	static int W[][];
	static  Vertex vertex[];

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

		W = new int[N][N];
		vertex = new Vertex[N];

		for (int i = 0; i < N; i++) {
			vertex[i] = new Vertex(i);
			for (int j = 0; j < N; j++) {
				W[i][j] = Vertex.INF;
			}
		}

		for (int i = 0; i < N; i++) {
			sc.nextInt(); // u を読み飛ばし
			int k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				int v = sc.nextInt();
				int c = sc.nextInt();
				W[i][v] = c;
			}
		}
		dijkstra(0);
		for (int i = 0; i < N; i++) {
			System.out.println(i + " " + vertex[i].distance);
		}
	}

	private static void dijkstra(int start) {
		vertex[start].distance = 0;

		PriorityQueue<Vertex> que = new PriorityQueue<Vertex>();
		que.add(vertex[start]);
		for (int step = 0; step < N; step++) {
			Vertex p = que.poll(); // 確定頂点を保存する変数
			p.state = 1;
			for (int x = 0; x < N; x++) {
				if (vertex[x].distance > p.distance + W[p.no][x]) {
					vertex[x].distance = p.distance + W[p.no][x];
					que.remove(vertex[x]);
					que.add(vertex[x]);
				}
			}
		}

	}
}



Measured memory_bytes: 40084
#include <bits/stdc++.h>
#define int long long
using namespace std;

char s[500][500];
bool vis[500][500];
int ans,n,m;

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

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>s[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) if(!vis[i][j]){
			int cntb=0,cntw=0;
			vis[i][j]=true;
			if(s[i][j]=='#') cntb++;
			else cntw++;
			queue<pair<int,int> > q;
			q.push(make_pair(i,j));
			while(!q.empty()){
				pair<int,int> t=q.front();
				q.pop();
				for(int d=0;d<4;d++){
					int nx=t.first+dx[d],ny=t.second+dy[d];
					if(nx<=0||ny<=0||nx>n||ny>m) continue;
					if(vis[nx][ny]) continue;
					if(s[t.first][t.second]==s[nx][ny]) continue;
					vis[nx][ny]=true;
					q.push(make_pair(nx,ny));
					if(s[nx][ny]=='#') cntb++;
					else cntw++;
				}
			}
			ans+=cntb*cntw;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>
#include <unordered_map>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること

    ll n = inp1;
    vector<ll> x = inp(n);
    auto y = x;
    sort(ALL_OF(y));
    ll xmid = y[n/2], xmed = y[n/2-1];

    REP(i, n) {
        if (x[i] < xmid) {
            cout << xmid << endl;
        } else {
            cout << xmed << endl;
        }
    }
    
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
using namespace std;

int main(void) {
    int r[4] = {};
    int a, b;
    for (int i = 0; i < 3; ++i) {
        cin >> a >> b;
        ++r[a - 1];
        ++r[b - 1];
    }
    if (r[0] == 3 || r[1] == 3 || r[2] == 3 || r[3] == 3) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toString()
    val list = readLine()!!.toString().split(' ').map { it.toInt() }.sorted()
    var ans = 0
    for (i in 0 until list.lastIndex - 1) {
        for (j in i + 1 until list.lastIndex) {
            for (k in j + 1 until list.size) {
                if (list[i] == list[j] || list[j] == list[k]) continue
                if (list[i] + list[j] > list[k]) {
                    ans++
//                    println("$i, $j, $k")
//                    println("${list[i]}, ${list[j]}, ${list[k]}")
                }
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 40876
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

X,Y  =inpl()

ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000

if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000

if X == 1 and Y == 1:
    ans += 400000

print(ans)


Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
  char c;
  cin >> c;
  vector<char> v={'a','b','c','d','e','f','g','h','i','j','k','l','o','p','q','r','s','t','u','v','w','x','y','z'};
  rep(i,26){
    if(v[i]==c){
      cout << v[i+1] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100;
int M=10;
int INF=1234567890;
int main()
{
  int n,m,t,i,ii,j,k,ff,res=-INF;
  bool f[N_MAX][M];
  int c[N_MAX],p[N_MAX][M+1];
  cin >> n;
  for(i=0;i<n;i++)
    for(j=0;j<M;j++)
      cin >> f[i][j];
  for(i=0;i<n;i++)
    for(j=0;j<=M;j++)
      cin >> p[i][j];
  m=1<<M;
  for(i=1;i<m;i++){
    ii=i;
    t=0;
    fill(c,c+n,0);
    for(j=0;j<M;j++){
      ff=ii%2;
      if(ff>0)
        for(k=0;k<n;k++)
          c[k]+=f[k][j];
      ii/=2;
    }
    for(k=0;k<n;k++)
      t+=p[k][c[k]];
    res=max(t,res);
  }
  cout << res << endl;
  return 0;
}

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

int main() {
    string x;
    int sum = 0;

    while(1){
        cin >> x;
        if(x == "0"){
            break;
        }

        int i;
        for(i = 0; i < x.size(); i++){
            sum += x[i] - '0';
        }

        cout << sum << endl;
        sum = 0;
    }
}



Measured memory_bytes: 3156
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

l = input()
L = len(l)

dp1 = [0]*(L+1) #未満
dp2 = [0]*(L+1) #以下
dp1[0] = 1
dp2[0] = 0
for i in range(L):
    if l[i] == '1':
        dp1[i+1] += dp1[i]*2
        dp1[i+1] %= mod
        dp2[i+1] += dp1[i]
        dp2[i+1] %= mod
        dp2[i+1] += dp2[i]*3
        dp2[i+1] %= mod
    else:
        dp1[i+1] += dp1[i]
        dp1[i+1] %= mod
        dp2[i+1] += dp2[i]*3
        dp2[i+1] %= mod

ans = dp1[-1] + dp2[-1]
ans %= mod
print(ans)

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

int main(void){
	int A,B;
	char S[11],T[11],U[11];

	scanf("%s %s",S,T);
	scanf("%d %d",&A,&B);
	scanf("%s",U);

	if(strcmp(S,U)==0)
		A=A-1;
	else if(strcmp(T,U)==0)
		B=B-1;
	printf("%d %d",A,B); 

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;

string s;
int a, b;

int main(){
    cin >> a >> b;
    cin >> s;
    
    for(int i=0; i<a; i++){
        if(!(s[i]>='0' && s[i]<='9')){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a]!='-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i=a+1; i<=a+b; i++){
        if(!(s[i]>='0' && s[i]<='9')){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int cost(int* A, int n, int* dp, int k)
{
    int mini,i;
    if (n == 1)
    return dp[1];
    if (n == 2)
    return dp[2];
    if (dp[n]!=(-1))
    return dp[n];
    else
    {
     mini = cost(A,n-1,dp,k) + abs(A[n]-A[n-1]);
     for (i=1; i<=k; i++)
     {
         if ((n-i)>0)
         mini = min(mini,cost(A,n-i,dp,k) + abs(A[n]-A[n-i]));
     }
     dp[n] = mini;
     return dp[n];   
    }
}

int main()
{
    int A[100001],n,i,dp[100001],min,k;
    cin >> n >> k;
    for (i=0; i<n+1; i++)
    dp[i] = -1;
    for (i=1; i<=n; i++)
    {
        cin >> A[i];
    }
    dp[1] = 0;
    dp[2] = abs(A[2]-A[1]);
    min = cost(A,n,dp,k);
    cout << min;
    return 0;
}

Measured memory_bytes: 10368
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array



int func(vector<vector<int>>& dp,vector<int>& arr,int n, int l, int r){
	if(dp[l][r]) return dp[l][r];
	if(l > r) return 0;
	if(l == r) {
		dp[l][r] = arr[l];
		return dp[l][r];
	}
	dp[l][r] = arr[l] - func(dp,arr,n,l+1,r);
	dp[l][r] = max(dp[l][r], arr[r] - func(dp,arr,n,l,r-1));
	return dp[l][r];
}

void solve(){
	int n;
	cin >> n;
	vector<int> arr(n);
	for(auto& e : arr) cin >> e;
	// print x - y
	vector<vector<int>> dp(n,vector<int>(n,0));
	cout << func(dp,arr,n,0, n-1) << "\n";	
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 73920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

ll N;

ll solve(vector<ll> A, vector<bool> B) {
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            if (A.at(i-1) == A.at(i)) {
                B.at(A.at(i)) = false;
                continue;
            }
        }
        for (ll j=2; A.at(i)*j <= A.at(N-1); j++) B.at(A.at(i)*j) = false;
        /*if (A.at(i)*2 <= A.at(N-1) && B.at(A.at(i)*2)){
            for (ll j=2; A.at(i)*j <= A.at(N-1); j++) B.at(A.at(i)*j) = false;
        }*/
    }
    for (int i = 0; i < N; i++) {
        if (B.at(A.at(i))) ans++;
    }
    return ans;
}

int main(){
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    sort(A.begin(), A.end());
    vector<bool> B(A.at(N-1)+1, true);
    cout << solve(A,B) << endl;
    return 0;
}


Measured memory_bytes: 6480
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt(),b=scanner.nextInt(),c=scanner.nextInt();

        int diff=a-b;
        if(diff<=c)
            System.out.println(c-diff);
        else
            System.out.println(0);
        
    }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var input = Console.ReadLine();
            var matches = Regex.Matches(input, @"[ACGT]+").Cast<Match>();
            var ans = 0;
            if(matches.Count() != 0) {
                ans = matches.Max(s => s.Length);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15948
n,l = map(int,input().split())

list = [l+i for i in range(n)]
sum = sum(list)

abs_list = [abs(l+i) for i in range(n)]
abs_min_taste_index = abs_list.index(min(abs_list))

ans = sum - list[abs_min_taste_index]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MP make_pair
#define PB push_back
typedef long long ll;

int N;
ll a[300300], l[300300], r[300300], pqsum, ans = -1e18;
priority_queue<ll> pq;

int main () {
        scanf("%d", &N);
        fo(i, 0, 3*N) scanf("%lld", &a[i]);

        fo(i, 0, N) pqsum += a[i], pq.push(-a[i]);
        l[N-1] = pqsum;
        fo(i, N, 3*N) {
                pqsum += a[i], pq.push(-a[i]);
                pqsum += pq.top(), pq.pop();
                l[i] = pqsum;
        }
        while (pq.size()) pq.pop();
        pqsum = 0ll;

        for (int i = 3*N-1; i >= 2*N; i--) pqsum += a[i], pq.push(a[i]);
        r[2*N] = pqsum;
        for (int i = 2*N; i--; ) {
                pqsum += a[i], pq.push(a[i]);
                pqsum -= pq.top(), pq.pop();
                r[i] = pqsum;
        }

        fo(i, N-1, 2*N) ans = max(ans, l[i] - r[i+1]);

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

        return 0;
}


Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    int L, R, d;
    cin>>L>>R>>d;

    int r = R/d;
    int l = L/d;
    if(L%d!=0) l++;
    out(r-l+1);
}

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

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

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

  int mn = a[0], mx = a[0];
  long long sum = 0;
  for(int i=0; i<n; i++){
      mn = min(mn, a[i]);
      mx = max(mx, a[i]);
      sum += a[i];
    }

  cout<<mn<<" "<<mx<<" "<<sum<<endl;

  return 0;
}



Measured memory_bytes: 3128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;
        for (int i=0; i<=k; i++) {
            for (int j=0; j<=k; j++) {
                int z = s - i -j;
                if (z <= k && z >= 0) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

int main(){
    int a, b, c, divisor, counter;
    counter = 0;
    cin >> a >> b >> c;
    for(divisor = a; divisor <= b; divisor++){
        if((c % divisor) == 0){ counter++; }
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 3104
s = input()
letter_dict = {'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,
    'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,
    'R':18,'S':19,'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26
    }
a = [0] * 27
b = [0] * 5
for i in s:
	a[letter_dict[i]] += 1
count = 0
for i in a:
	if i != 0:
		b[i] += 1

if b[2] == 2:
	print('Yes')
else:
	print('No')


Measured memory_bytes: 38384
class Process:
    def __init__(self, process_name, process_time):
        self.name = process_name
        self.time = process_time
        self.remaing_time = process_time
        self.complete_flg = False

    def get_name(self):
        return self.name

    def get_time(self):
        return self.time

    def get_remaining_time(self):
        return self.remaing_time

    def exec_process(self, quantum):
        if self.remaing_time <= quantum:
            self.complete_flg = True
            use_time = self.remaing_time
            self.remaing_time = 0
            return use_time
        else:
            self.remaing_time -= quantum
            return quantum

    def get_complete_flg(self):
        return self.complete_flg

if __name__ == '__main__':
    n, q = [int(x) for x in input().split()]
    all_time = 0
    procesies = []
    for _ in range(n):
        name, time = input().split()
        temp_process = Process(name, int(time))
        procesies.append(temp_process)

    while len(procesies) != 0:
        target_process = procesies.pop(0)
        all_time += target_process.exec_process(q)
        if target_process.get_complete_flg():
            print(target_process.get_name() + " " + str(all_time))
        else:
            procesies.append(target_process)



Measured memory_bytes: 17248
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> fac;
long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}


long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
	int n, k;
    cin >> n >> k;
    fac.push_back(1);
    for (int i = 1; i <= k; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    vector<unordered_set<int>> v(n + 1, unordered_set<int>());
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        v[a].insert(b);
        v[b].insert(a);
    }
    vector<pair<int, int>> v1, v2;
    long long int res = k;
    v1.push_back(make_pair(1, 1));
    while (v1.size() > 0) {
        v2.clear();
        for (auto p : v1) {
            int index = p.first, root = p.second;
            if (v[index].size() == 0) continue;
            if (v[index].size() > k - 1 - (1 - root)) {
                cout << 0 << endl;
                return 0;
            }
            res *= myc(k - 1 - (1 - root), v[index].size());
            res %= mod;
            res *= fac[v[index].size()];
            res %= mod;
            for (auto next : v[index]) {
                v[next].erase(index);
                v2.push_back(make_pair(next, 0));
            }
        }
        v1 = v2;
    }
    cout << res << endl;
}


Measured memory_bytes: 21408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nn 3003
int dp[nn][nn][2];
int solve(int *arr, int n, int i, int j, int turn) {
    if (i > j)
        return 0;
    if (dp[i][j][turn] == -1) {
        int a1 = arr[i] + solve(arr, n, i + 1, j, !turn);
        int a2 = arr[j] + solve(arr, n, i, j - 1, !turn);
        if(turn == 0){
         dp[i][j][turn] =max(a1,a2);
        }
        else{
            dp[i][j][turn] = min(a1-arr[i],a2-arr[j]);
        }
    }
    return dp[i][j][turn];
}
main() {
    int n;
    cin >> n;
    int i;
    int arr[n];
    int sum = 0;
    memset(dp, -1, sizeof(dp));
    for (i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    int s1 = solve(arr, n, 0, n - 1, 0);
    // cout << s1 << " ";
    cout << (2 * s1 - sum);
}

Measured memory_bytes: 141440
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back //FASTER THAN PUSH BACK!
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a%mod;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res)%mod;
    else return (a*res*res)%mod;
}

// vi adj[100005];
// vector<bool> vis(100005,false);


// void dfs(int s)
// {
//     vis[s]=true;
    
//     for(int u:adj[s])
//     {
//         if(!vis[u])
//         {
//             vis[u]=true;
//             dfs(u);
//         }
//     }
// }

void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,sum=0,pos=-5,flag=0,count=0;
    string S,T,U;
    int a,b,c,d;
    cin>>n;
    cout<<2*PI*n;
}




signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3872
#include<iostream>

using namespace std;

int main(){
	int a, b, c, d, r, s, h;

	while (cin >> a >> b){
		//c
		h = a;
		s = b;
		for (;;){
			r = h % s;
			if (r == 0) {
				c = s;
				break;
			}
			h = s;
			s = r;
		}
		//d
		h = a;
		s = b;
		if (a < b){
			for (;;){
				if ((b % a) == 0){
					d = b;
					break;
				}
				b = b + s;
			}
		}
		else if (a >= b){
			for (;;){
				if ((a % b) == 0){
					d = a;
					break;
				}
				a = a + h;
			}
		}

		cout << c << ' ' << d << endl;
	}
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h == 0) {
                break;
            }
            write(h, w);
        }

    }

    static void write(int h, int w) {
        // 3 <= h, w
        for (int j = 1; j <= w; j++) {
            System.out.print("#");
            
        }
        System.out.println("");
        for (int i = 2; i <= h - 1; i++) {
            System.out.print("#");
            for (int j = 2; j <= w - 1; j++) {
                System.out.print(".");
            }
            System.out.println("#");
        }
        for (int j = 1; j <= w; j++) {
            System.out.print("#");
        }
        System.out.printf("%n%n");
        /*
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                if (i == 1 || j == 1 || i == h || j == w) {
                    System.out.print("#");;
                } else {
                    System.out.print(".");;
                }
                if (j == w) {
                    System.out.println("");;
                    if (i == h) {
                        System.out.println("");;
                    }
                }
            }
        }
        */

    }

}


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

int main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    cout << max(a*b,c*d) << endl;
}

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

int main(int argc, char const *argv[])
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n", (a * n < b) ? (a * n) : b);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int box(int boll,int box_capa){
  return boll/box_capa;
}

int main (void){
  int r,g,b,n,n_r,n_rg,i,j,counter = 0;
  scanf("%d %d %d %d",&r,&g,&b,&n);
  for(i = 0 ;i <= box(n,r);i++){
    n_r = n - (r * i);
    for(j = 0 ;j <= box(n_r,g);j++){
      n_rg = n_r - (g * j);
      if(n_rg % b == 0){
        counter ++;
      }
    }
  }  
  printf("%d\n",counter);
  return 0; 
}


Measured memory_bytes: 128
// ABC044A - 高橋君とホテルイージー

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

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	int answer;
	if (N <= K) {
		answer = N * X;
	} else {
		answer = K * X + (N - K) * Y;
	}

	cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         long K=gl();
         int[] a=new int[N+1];

         for (int i=0; i<N;i++) {
        	 a[i]=gi()-1;
         }

         int pos=0;
         int r=0;
         Map<Integer,Integer> map=new HashMap<Integer,Integer>();
         while(!map.containsKey(pos)) {
        	 map.put(pos, r);
        	 r++;
        	 pos=a[pos];

         }

         long s=(long)map.get(pos);
         if(K>s) {
             long b=r-s;
             long ri=(K-s)%b;
             for(int i=0; i<ri;i++) {
        	     pos=a[pos];
             }
         } else {
             pos=0;
             for(int i=0; i<K;i++) {
        	     pos=a[pos];
             }
         }
         

         System.out.println(pos+1);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 65700
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int a = n%10;
    if(a == 3)cout << "bon" << endl;
    else if(a == 0 or a == 1 or a == 6 or a == 8)cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		count int
	)

	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	flag := true
	for flag {
		for i := 0; i < n; i++ {
			if nums[i]%2 == 0 {
				nums[i] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			count++
		}
	}
	fmt.Println(count)
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> a(1000001, 0);
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    ++a[A];
  }
  
  for(int x = 1; x <= 1000000; x++){
    if(!a[x]) continue;
    
    if(a[x] > 1) a[x] = 0;
    
    for(int y = x + x; y <= 1000000; y += x){
      a[y] = 0;
    }
  }
  
  int cnt = 0;
  for(int x = 1; x <= 1000000; x++){
    cnt += a[x];
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

signed main() {
  string S, T; cin >> S >> T;
  int ans = S.size();
  for (int i = 0; i < S.size(); ++i) {
    if (i + T.size() > S.size()) break;
    int cnt = 0;
    for (int j = 0; j < T.size(); ++j) {
      if (S[i + j] != T[j]) ++cnt;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int P[100001];
int m[100001];
vector<int> sonota;
int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	sonota.pb(max(m[a], m[b]));
	m[a] = min(m[a], m[b]);
	return true;
}

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


	int N, M;
	cin >> N >> M;
	rep(i, N) cin >> m[i];

	rep(i, N) P[i] = -1;
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		Unite(x, y);
	}

	ll kotae = 0;
	int kazu = 0;
	rep(i, N) {
		if (Find(i) == i) {
			kazu++;
			kotae += m[i];
		}
	}
	if (kazu == 1) co(0);
	else {
		kazu -= 2;
		if (kazu > sonota.size()) co("Impossible");
		else {
			sort(sonota.begin(), sonota.end());
			rep(i, kazu) {
				kotae += sonota[i];
			}
			co(kotae);
		}
	}

	Would you please return 0;
}

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

struct query{
  ll type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(ll a=0,ll b=0):type(a),value(b) {}
};

ll INF=(1LL<<60);

struct segtree{
  ll SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(ll n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(ll k,ll l,ll r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(ll k,ll l,ll r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    ll m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(ll a,ll b,query x,ll k,ll l,ll r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      ll m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(ll type,ll a,ll b,ll k,ll l,ll r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      ll m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(ll a,ll b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(ll a,ll b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(ll a,ll b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(ll a,ll b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};


// Set,Add,Getmin,Getsum
int main(){
  ll n,q;
  cin >> n >> q;
  segtree T(n);
  for(ll i=0;i<q;i++){
    ll type,a,b;
    cin >> type;
    if(type==0){
      cin >> a >> b;
      T.Add(a-1,a,b);
    }
    else {
      cin >> a >> b;
      cout << T.Getsum(a-1,b) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 11032
#include<bits/stdc++.h> 
#define int long long
using namespace std;
inline int read(){
	register int x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200],str[200];int tt;
inline void print(int x,char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
const int maxn=2233;
int p,f[maxn*3][maxn*6],n,ans;
signed main(){
	n=read()*3;p=read();
	f[0][3000]=1;
	for(int i=0;i<n;i++){
		for(int j=-i;j<=i;j++){
			(f[i+1][j+1+3000]+=f[i][j+3000])%=p;
            (f[i+2][j-1+3000]+=f[i][j+3000]*(i+1))%=p;
            (f[i+3][j+3000]+=f[i][j+3000]*(i+1)*(i+2))%=p;
		}
	}
	for(int j=3000;j<=3000+n;j++)(ans+=f[n][j])%=p;
    print(ans);
	return 0;
}

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

double dist(vector<double> &x, vector<double> &y, pair<double, double> vertex)
{
    double ret = 0.;
    double xx = vertex.first;
    double yy = vertex.second;
    for (int i = 0; i < x.size(); i++)
    {
        ret = max(ret, (x[i] - xx) * (x[i] - xx) + (y[i] - yy) * (y[i] - yy));
    }
    return sqrt(ret);
}

double f(double A, double B, double C, double a, double b, double c)
{
    a *= a;
    b *= b;
    c *= c;
    double numerator = 0.;
    numerator += a * (b + c - a) * A;
    numerator += b * (c + a - b) * B;
    numerator += c * (a + b - c) * C;

    double denominator = 0.0;
    denominator += a * (b + c - a);
    denominator += b * (c + a - b);
    denominator += c * (a + b - c);
    if (denominator <= 0)
    {
        return 2000.;
    }
    return numerator / denominator;
}

pair<double, double> center(set<pair<double, double>> vertex)
{
    if (vertex.size() == 1)
    {
        return *vertex.begin();
    }
    if (vertex.size() == 2)
    {
        double x = 0.;
        double y = 0.;
        for (pair<double, double> v : vertex)
        {
            x += v.first / 2.;
            y += v.second / 2.;
        }
        return make_pair(x, y);
    }
    if (vertex.size() == 3)
    {
        // https://ja.wikipedia.org/wiki/%E5%A4%96%E6%8E%A5%E5%86%86#%E5%A4%96%E5%BF%83%E3%81%AE%E4%BD%8D%E7%BD%AE
        vector<double> xs;
        vector<double> ys;
        for (pair<double, double> v : vertex)
        {
            xs.push_back(v.first);
            ys.push_back(v.second);
        }
        double a = sqrt(pow(xs[1] - xs[2], 2) + pow(ys[1] - ys[2], 2));
        double b = sqrt(pow(xs[2] - xs[0], 2) + pow(ys[2] - ys[0], 2));
        double c = sqrt(pow(xs[0] - xs[1], 2) + pow(ys[0] - ys[1], 2));
        double Ax = xs[0];
        double Bx = xs[1];
        double Cx = xs[2];
        double Ay = ys[0];
        double By = ys[1];
        double Cy = ys[2];
        return make_pair(f(Ax, Bx, Cx, a, b, c), f(Ay, By, Cy, a, b, c));
    }
    else
    {
        return make_pair(0., 0.);
    }
}

int main()
{
    int N;
    cin >> N;
    vector<double> x(N);
    vector<double> y(N);

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }

    double ans = 1000. * 1000.;
    for (int i = 0; i < N; i++)
    {
        for (int j = i; j < N; j++)
        {
            for (int k = j; k < N; k++)
            {
                set<pair<double, double>> vertex;
                vertex.insert(make_pair(x[i], y[i]));
                vertex.insert(make_pair(x[j], y[j]));
                vertex.insert(make_pair(x[k], y[k]));
                pair<double, double> c = center(vertex);
                ans = min(ans, dist(x, y, c));
            }
        }
    }
    cout << fixed << setprecision(8) << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    int res = 0;
    int pre = 0;
    for (int i = 0; i < n; ++i) {
        if (pre >= A[i]) {

        } else {
            res += A[i] - pre;
        }
        pre = A[i];
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define DEBUG(a) cerr<<#a<<"="<<a<<endl
#define DEBUG_ARRAY(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define DEBUG(a) 
#define DEBUG_ARRAY(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

const long long MOD = 998244353;
ll dp[4001][4001];
void solve(string S){
    ll r,b;
    r=b=0;
    dp[0][0]=1;
    REP((int)S.size()*2){
        if(i<(int)S.size()){
            if(S[i]=='0'){
                r+=2;
            }else if(S[i]=='1'){
                r++;b++;
            }else{
                b+=2;
            }
        }
        For(j,i+1){
            if(j+1<=r&&i-j<=b){
                dp[j+1][i-j]+=dp[j][i-j];
                dp[j+1][i-j]%=MOD;
            }
            if(j<=r&&i-j+1<=b){
                dp[j][i-j+1]+=dp[j][i-j];
                dp[j][i-j+1]%=MOD;
            }
        }
    }
    cout<<dp[r][b]<<endl;
}

int main(){
    string S;
    cin>>S;
    solve(S);
    return 0;
}


Measured memory_bytes: 123392
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int a,b;
	std::cin >> a >> b;
	char aa = a+'0';
	char bb = b+'0';
	std::string s,t;
	rep(i,b) s+=aa;
	rep(i,a) t+=bb;
	if(s<t) print(s);
	else print(t);

	return 0;
}


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

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;

int main(){
	bool lebih = 0, nol = 0;
	int N;
	LL cnt = 1;
	scanf("%d", &N);
	LL arr[N + 1];
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		if (arr[i] == 0) nol = 1;
	}
	if (nol) printf("0\n");
	else {
		for (int i = 0; i < N; i++) {
			if (cnt > 1e18 / (long double)arr[i]) lebih = 1;
			cnt *= arr[i];	
		}
		if (lebih) printf("-1\n");		
		else printf("%lld\n", cnt);
	}
}

Measured memory_bytes: 4608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println(Math.max(Math.max(a + b, a - b), a * b));
        }

    }
}



Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

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

	double PI = acos(-1);

	double C = c * PI / 180.0;

	double S, l, h;

	S = 1.0 / 2.0 * a * b * sin(C);

	double x = sqrt(a * a + b * b - 2.0 * a * b * cos(C));
	l = a + b + x;


	h = 2.0 * S / a;

	printf("%lf\n%lf\n%lf\n", S, l, h);

	return 0;
}


Measured memory_bytes: 3432
from bisect import bisect_right
from itertools import accumulate
def resolve():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    cum_A = [0]+list(accumulate(A))
    cum_B = [0]+list(accumulate(B))

    ans = 0
    for i in range(N + 1):
        limit = K - cum_A[i]
        if limit < 0:
            break
        cnt = i
        cnt += bisect_right(cum_B, limit)-1
        ans = max(ans, cnt)
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 50572
# -*- coding: utf-8 -*-

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    n = int(input())
    ab = [None] * n
    count = 0

    for i in range(n):
        ab[i] = list(map(int, input().split()))

    for k in range(n - 1, -1, -1):
        q = (count + ab[k][0]) % ab[k][1]

        if q > 0:
            count += ab[k][1] - q

    print(count)


Measured memory_bytes: 27380
N, K = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
ans = abs(x[0]) + abs(x[0]-x[0+K-1])

for i in range(N-K+1):
    temp1 = abs(x[i]) + abs(x[i]-x[i+K-1])
    temp2 = abs(x[i+K-1]) + abs(x[i]-x[i+K-1])
    ans = min(ans, temp1, temp2)

print(ans)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl
ll dp[100100];
int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0; dp[1] = abs(h[1]-h[0]);
  for(int i = 2;i<n;i++){
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1408