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


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

struct edge {int to; ll cost; };

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

ll GCD(ll n, ll k){
  if(k==0) return n;
  else return GCD(k, n%k);
}
 
int main(){
  ll a, b;
  cin >> a >> b;
  vector<bool> isPrime(1000007, true);
  isPrime[0] = false;
  isPrime[1] = false;
  ll c = GCD(max(a,b), min(a,b));
  int ans = 0;
  for(ll i=2; i*i<=c; i++){
    if(c%i==0){
      while(c%i==0){
        c/=i;
      }
      ans++;
    }
  }
  if(c==1) ans += 1;
  else ans += 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>

int
main(int argc, char *argv[])
{
        int num[5];
        int i, j, tmp;

        scanf("%d %d %d %d %d", num, num + 1, num + 2, num + 3, num + 4);
        for (i = 0; i < 5; i++)
                for (j = i + 1; j < 5; j++)
                        if (num[i] < num[j]) {
                                tmp = num[i];
                                num[i] = num[j];
                                num[j] = tmp;
                        }
        printf("%d %d %d %d %d\n", num[0], num[1], num[2], num[3], num[4]);
        
        return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int f(int i,int *a,int* cost,int n){
	if(cost[i]>=0)
		return cost[i];
	if(i>=(n-3))
		return abs(a[i]-a[n-1]);
	cost[i] = min(f(i+1,a,cost,n)+abs(a[i]-a[i+1]),f(i+2,a,cost,n)+abs(a[i]-a[i+2]));
	return cost[i];
}
int main(){
	int n;cin>>n;
	int a[n]={0};
	for(int i=0;i<n;i++)
		cin>>a[i];
	int cost[n];
	memset(cost,-1,sizeof(cost));
	cost[n-1]=0;
	cout<<f(0,a,cost,n);
}

Measured memory_bytes: 6272
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;i++)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;





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

	vector<int> v(n);
	rep(i, 0, n)
		cin >> v[i];

	//max_list[i]:v[i+1]～v[n-1]の中の最大値
	vector<int> max_list;
	int temp;
	for (int i = n - 1; i >= 1; i--) {
		if (i == n - 1) {
			temp = v[i];
			max_list.push_back(temp);
		}
		else {
			temp = max(v[i], temp);
			max_list.push_back(temp);
		}
	}

	int temp_ans;
	int ans;

	rep(i, 0, n - 1) {
		if (i == 0) {
			temp_ans = max_list[n-2-i] - v[i];
			ans = 1;
		}
		else if (max_list[n-2-i] - v[i] > temp_ans) {
			temp_ans = max_list[n-2-i] - v[i];
			ans = 1;
		}
		else if (max_list[n-2-i] - v[i] == temp_ans) {
			ans += 1;
		}
	}

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



Measured memory_bytes: 1276
let () =
  let s1 = read_line () and
      s2 = read_line () in
  let len1 = String.length s1 and
      len2 = String.length s2 in
  for i = 0 to len1 - len2 do
    if s1.[i] = s2.[0] then
      if String.sub s1 i len2 = s2 then
        Printf.printf "%d\n" i
  done
;;

Measured memory_bytes: 2360
//https://atcoder.jp/contests/abc124/tasks/abc124_d
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string str;
int n,k,sta,ed,len,num;
int go0(int pos)
{
	int x=pos;
	while (x<str.length() && str[x]=='0') x++;
	return x-1;
}
int go1(int pos)
{
	int x=pos;
	while (x<str.length() && str[x]=='1') x++;
	x=go0(x);
	return x+1;
}
int main()
{
	scanf("%d %d",&n,&k);
	cin>>str;
	sta=0;
	ed=-1;
	len=1;
	num=0;
	while (ed+1<str.length())
	{
		ed++;
		if (str[ed]=='0')
		{
			num++;
			ed=go0(ed);
			//cout<<ed<<endl;
			if (num>k)
			{
				sta=go1(sta);
				//cout<<sta<<endl;
				num--;
			}
		}
		if (ed-sta+1>len) len=ed-sta+1;
	}
	printf("%d\n",len);
	return 0;
}

Measured memory_bytes: 512
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
L=[]
for _ in range(N-1):
    L.append(lint())
for i in range(N):
    tmp = 0
    for j in range(i,N-1):
        c,s,f=L[j]
        tmp = max(((tmp-1)//f+1)*f,s)+c
    print(tmp)

Measured memory_bytes: 74988
H,W=map(int, input().split())
s = []
dx = [  0, 0, 1, -1]
dy = [ -1, 1, 0, 0]
ans = "Yes"
for i in range(H):
  s.append( input())
for y in range(H):
  for x in range(W):
    if s[y][x] == '#':
      ng = 1
      for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if (ny < 0) or (ny >= H) or (nx<0) or (nx>=W):
          continue
        if s[ny][nx] == '#':
          ng = 0
      if ng == 1:
        ans = "No"
print(ans)


Measured memory_bytes: 3064
#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 ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< ll > vi;
typedef vector< vi > vvi;
typedef pair< ll,ll > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);	
	ll n,a,b;cin>>n>>a>>b;
	ll q=n/(a+b);
	ll r=n%(a+b);
	ll ans=q*(a)+min(r,a);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
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<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int d(int x){
	int a = 0;
	while(x){
		a += x%10;
		x/=10;
	}
	return a;
}
int main(){
	int N;
	int ans = 1e9;
	cin>>N;
	rep1(a,N-1){
		int b = N-a;
		chmin(ans,d(a)+d(b));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;

int main()
{
	ll  n;
	cin>>n;
	vector<pair<ll,ll> > v;
	for(ll i=0;i<n;i++)
	{
		ll x,l;
		cin>>x>>l;
		v.pb(mp((x+l),(x-l)));
	}
	sort(v.begin(),v.end());
	ll ma=INT_MIN,cnt=0;
	for(ll i=0;i<n;i++)
	{
			if(v[i].second>=ma)
		{
			cnt++;
			ma=v[i].first;
		}
	}
	cout<<cnt;
	return 0;	
	}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int H,W;
int N;
vi a;

int t[102][102];

int main(){
    cin >> H >> W;
    cin >> N;
    a.resize(N);
    rep(i,N){
        cin >> a[i];
    }

    vector<int> ans(H*W);
    int cnt = 0;
    int idx = 0;
    for(int i=0;i<H*W;i++){
        ans[i] = idx;
        cnt++;

        if(cnt == a[idx]){
            idx++;
            cnt = 0;
        }
    }
    //cout << ans << endl;


    int x,y;
    int d = 1;
    x = 0;
    y = 0;
    idx = 0;

    rep(i,H*W){
        //cout << x << " " << y <<  " " << ans[i] + 1 << endl;
        t[x][y] = ans[i]+1;
        int nx = x;
        int ny = y+d;
        if(ny == W){
            nx = x+1;
            ny = y;
            d *= -1;
        }else if(ny == -1){
            nx = x+1;
            ny = y;
            d *= -1;
        }

        x = nx;
        y = ny;
    }

    rep(i,H){
        rep(j,W) cout << t[i][j] << " ";
        cout << endl;
    }
}


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

int main(){
    char date[11];
    cin>>date;
    string str;
    if(date[5]!='0'||date[6]=='5'||date[6]=='6'||date[6]=='7'||date[6]=='8'||date[6]=='9'){
         str="TBD";
    }else{
        str="Heisei";
    }

cout<<str<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T> inline void chkmax(T &x, const T &y) { if(x < y) x = y; }
template<class T> inline void chkmin(T &x, const T &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);
const int inf = (int)1e9;

int n;
string s;

void read()
{
	cin >> s;
	n = s.size();
}

map<int, int> dp[2]; 

int get_dp(int mask, int pos)
{
	int ret = inf;
	if(dp[pos].count(mask))
		ret = min(ret, dp[pos][mask]);

	for(int mid = 0; mid < 26; mid++)
	{
		int nw_mask = mask ^ (1 << mid);
		if(dp[pos ^ 1].count(nw_mask))
			ret = min(ret, dp[pos ^ 1][nw_mask]);
	}

	return ret;
}

void solve()
{
	s = " " + s;
	int mask = 0, last = -1;
	
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++)
	{
		mask ^= 1 << (s[i] - 'a');
		
		int cdp = get_dp(mask, i & 1) + 1;
		if(!dp[i & 1].count(mask)) dp[i & 1][mask] = cdp; 
		else dp[i & 1][mask] = min(dp[i & 1][mask], cdp);
	
		last = cdp;
	}

	cout << last << endl;
}

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

	read();
	solve();
	return 0;
}



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

public class Main {
	static int n;
	static int[][] f;
	static int[][] p;
	static int[] a;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		f = new int[n][10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = sc.nextInt();
			}
		}
		p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = sc.nextInt();
			}
		}
		sc.close();

		a = new int[10];
		ans = Integer.MIN_VALUE;
		dfs(0);
		System.out.println(ans);
	}

	static void dfs(int index) {
		if (index == 10) {
//			System.out.println(Arrays.toString(a));
			if (Arrays.toString(a).equals("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]")) return;
			memo();
			return;
		} else {
			a[index] = 0;
			dfs(index + 1);
			a[index] = 1;
			dfs(index + 1);
		}
	}

	static void memo() {
		int partAns = 0;
		for (int i = 0; i < n; i++) {
			int count = 0;
			for (int j = 0; j < 10; j++) {
				if (a[j] == 1 && f[i][j] == 1) {
					count++;
				}
			}
			partAns += p[i][count];
		}
		ans = Math.max(partAns, ans);
	}
}

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

int main() {
    int N;
    scanf("%d", &N);
    vector<int> A(N);
    int max = 0;
    int second = 0;
    int index = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if (max < A[i]){
            max = A[i];
            index = i;
        }
    }
    for(int i=0; i<N; i++){
        if (i != index && second < A[i]){
            second = A[i];
        }
    }
    for(int i=0; i<N; i++){
        if (i == index){
            printf("%d\n",second);
        }else{
            printf("%d\n",max);
        }
    }

}


Measured memory_bytes: 2432
#include<stdio.h>
#include<math.h>
#define pi M_PI
 
typedef struct xy{
double x;
double y;
}P;
 
P koch(P pre,P nex,int n);
 
int main(int argc,char argv[]){
  P pre={0,0},nex={100,0},PREV,MID,NEXT,DIS;
int n;
scanf("%d",&n);
 
if(n == 0)printf("%f %f\n",pre.x,pre.y);
else{
DIS.x = nex.x - pre.x;
DIS.y = nex.y - pre.y;
PREV.x = pre.x + DIS.x/3.0;
NEXT.x = pre.x + DIS.x*2.0/3.0;
PREV.y = pre.y + DIS.y/3.0;
NEXT.y = pre.y + DIS.y*2.0/3.0;
MID.x = PREV.x + (DIS.x/3.0)*cos(pi/3.0) - (DIS.y/3.0)*sin(pi/3.0);
MID.y = PREV.y + (DIS.x/3.0)*sin(pi/3.0) + (DIS.y/3.0)*cos(pi/3.0);
 
koch(pre,PREV,n - 1);
koch(PREV,MID,n - 1);
koch(MID,NEXT,n - 1);
koch(NEXT,nex,n - 1);
}
printf("%f %f\n",nex.x,nex.y);
return 0;
}

P koch(P pre,P nex,int n){
P PREV,MID,NEXT,DIS;
if(n == 0)printf("%f %f\n",pre.x,pre.y);
else{
DIS.x = nex.x - pre.x;
DIS.y = nex.y - pre.y;
PREV.x = pre.x + DIS.x/3.0;
NEXT.x = pre.x + DIS.x*2.0/3.0;
PREV.y = pre.y + DIS.y/3.0;
NEXT.y = pre.y + DIS.y*2.0/3.0;
MID.x = PREV.x + (DIS.x/3.0)*cos(pi/3.0) - (DIS.y/3.0)*sin(pi/3.0);
MID.y = PREV.y + (DIS.x/3.0)*sin(pi/3.0) + (DIS.y/3.0)*cos(pi/3.0);
 
koch(pre,PREV,n - 1);
koch(PREV,MID,n - 1);
koch(MID,NEXT,n - 1);
koch(NEXT,nex,n - 1);
}
}



Measured memory_bytes: 2092
using System;
class a
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = new int[n];
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            p[i] = int.Parse(str[i]);
        }
        int count = 0;
        for(int i = 1; i < n - 1; i++)
        {
            if ((p[i - 1] < p[i] &&p[i] < p[i+1])|| (p[i - 1] > p[i] &&p[i] > p[i + 1]))
            {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int N,K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
    }
    if(K == 1){
        cout << 0 << endl;
        return 0;
    }

    ll ans = INF;
    for(int tmp = 0; tmp <(1 << N) ;tmp++){
        bitset<15> bs(tmp);
        if(bs.count() != K || !bs.test(0)) continue;
        //cout << bs << endl;  
        ll tmp_a = a[0];
        ll cost = 0;
        rep2(i,1,N){
            if(bs.test(i)){
                if(tmp_a>=a[i]){
                    tmp_a = tmp_a + 1;
                    cost += tmp_a -  a[i];
                }
                else tmp_a = a[i];
            }
            else tmp_a = max(tmp_a, a[i]);
        }
        ans = min(ans,cost);
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 256
#include <stdio.h>
int n;
int a[100000];
int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", a+i);
    a[i]--;
  }
  int res = 0;
  for(i = 0; i < n; i++) {
    if(a[a[i]] == i) res++;
  }
  printf("%d\n", res / 2);
  return 0;
}


Measured memory_bytes: 512
s=input()
n=len(s)
start=0
buf='R'
dp=[0]*n
for i in range(n+1):
    #print(dp,buf,i)
    if i==n:
        if (i-start)%2==1:
            dp[start]+=(i-start+1)//2
            dp[start-1]+=(i-start)//2
        else:
            dp[start]+=(i-start)//2
            dp[start-1]+=(i-start)//2
        break
    if s[i]!=buf:
        if s[i]=='L':
            if (i-start)%2==1:
                dp[i]=(i-start)//2
                dp[i-1]=(i-start+1)//2
            else:
                dp[i]=(i-start)//2
                dp[i-1]=(i-start)//2    
            buf='L'
            start=i
        else:
            if (i-start)%2==1:
                dp[start]+=(i-start+1)//2
                dp[start-1]+=(i-start)//2
            else:
                dp[start]+=(i-start)//2
                dp[start-1]+=(i-start)//2   
            start=i
            end=i
            buf='R'
for i in range(n):
    print(dp[i],end=' ')
print('\n')

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

int main(){

    int k, n;
    cin >> k >> n;

    vector<int> a(n);
    rep(i,n) {cin >> a[i];}

    if (a[n-1] <= k/2) {
        cout << a[n-1]-a[0] << endl;
        return 0;
    }

    int max_num = 0;
    int max_index = 0;
    rep(i,n-1) {
        int sa = a[i+1] - a[i];
        if (max_num < sa) {
            max_num = sa;
            max_index = i;
        }
    }

    if ((k-a[n-1]+a[0]) > max_num) {
        cout << a[n-1]-a[0] << endl;
        return 0;
    }
    int ans = a[max_index] + (k - a[max_index+1]);

    cout << ans << endl;

    return 0;
} 


Measured memory_bytes: 4024
import java.util.*;

public class Main { 
public static void main(String[] args) {
 Scanner in = new Scanner(System.in);
 int a = in.nextInt(), b =  in.nextInt(), c = in.nextInt();
  if(a + b >= c) {System.out.println("Yes");}
  else {System.out.println("No");
}
}
}

Measured memory_bytes: 21844
import Data.List
import Data.Ord

primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

main = interact $ unlines . map (show' . ceia . map read . words) . init . lines
 where show' (p,q) = show p ++ " " ++ show q

ceia [m,a,b] = maximumBy (comparing (uncurry (*))) pqs
 where
  pqs = [(p,q) | p<-ds, q<-(takeWhile (\d->d*p<=m) ds), cond p q]
  ds = takeWhile (<= div m 2) primes
  cond p q = let [a',b',p',q'] = map fromIntegral [a,b,p,q] in a'/b' <= p'/q' && p'/q' <= 1.0

Measured memory_bytes: 11852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t, dp[100005][2], mod = 1000000007;
bool onw[100005], onb[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < n - 1 ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}

int black(int node);

int white(int node){
	if( dp[node][0] )
		return dp[node][0];
	onw[node] = true;
	dp[node][0] = 1;
	for( int i = 0 ; i < adj[node].size() ; i++ )
		if( !onw[adj[node][i]] and !onb[adj[node][i]] )
			dp[node][0] = (dp[node][0] * (white(adj[node][i]) + black(adj[node][i])) % mod) % mod;
	onw[node] = false; 
	return dp[node][0];
}

int black(int node){
	if( dp[node][1] )
		return dp[node][1];
	onb[node] = true;
	dp[node][1] = 1;
	for( int i = 0 ; i < adj[node].size() ; i++ )
		if( !onw[adj[node][i]] and !onb[adj[node][i]] )
			dp[node][1] = (dp[node][1] * white(adj[node][i])) % mod;
	onb[node] = false;
	return dp[node][1];
}

int main(){
	cin >> n;
	ginp;
	int last = 0;
	if( n == 1 ){
		cout << "2" << endl;
		return(0);
	}
	cout << (black(1) + white(1)) % mod << endl;
	return(0);
}

Measured memory_bytes: 14464
#
# my_value_list = []
#
# while True:
#     try:
#         my_value_list.append(input().split())
#     except EOFError:
#         break
#
# for i in range(0, len(my_value_list)):
#     if my_value_list[i][1] == "+":
#         print(int(my_value_list[i][0]) + int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "-":
#         print(int(my_value_list[i][0]) - int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "/":
#         print(int(my_value_list[i][0]) // int(my_value_list[i][2]))
#     elif my_value_list[i][1] == "*":
#         print(int(my_value_list[i][0]) * int(my_value_list[i][2]))
#     else:
#         break

my_value = int(input())
my_value_list_str = input().split()

my_value_list = [int(i) for i in my_value_list_str]
my_value_list.sort()

print("{} {} {}".format(my_value_list[0], my_value_list[my_value-1], sum(my_value_list)))

Measured memory_bytes: 8776
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;

const int MAX_V=1e5;
int n;
int cnt[MAX_V][2],mx[2][2];
int main(){
	cin>>n;
	REP(i,n){
		int v;
		cin>>v;
		v--;
		cnt[v][(i&1)]++;
	}
	memset(mx,-1,sizeof(mx));
	FOR(i,0,MAX_V){
		REP(p,2){
			if (mx[p][0]==-1 || cnt[i][p]>=cnt[mx[p][0]][p]){
				mx[p][1]=mx[p][0];
				mx[p][0]=i;
			}else if (mx[p][1]==-1 || cnt[i][p]>=cnt[mx[p][1]][p]){
				mx[p][1]=i;
			}
		}
	}
	int ans;
	if (mx[0][0]!=mx[1][0]){
		ans=0;
		REP(i,2){
			ans+=cnt[mx[i][0]][i];
		}
	}else{
		ans=max(cnt[mx[0][0]][0]+cnt[mx[1][1]][1],cnt[mx[0][1]][0]+cnt[mx[1][0]][1]);
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){

    ll n,k;
    cin>>n>>k;

    vector<ll> data(n);

    rep(i,n){
        ll tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    sort(ALL(data));

   double mymax=data.at(n-1);

   double mymin=0;

    while (ceil(mymax)!=ceil(mymin)){
        double tmplength=(mymax+mymin)/2;

        ll cnt=0;

        rep(i,n){
            ll kirisage=data.at(i)/tmplength;
            if (double(data.at(i)-kirisage*tmplength)<=0.000001){
                cnt+=kirisage-1;
            }
            else {
                cnt+=kirisage;
            }

        }
      

        if (cnt<=k){
            mymax=tmplength;
        }
        else {
            mymin=tmplength;
        }

    }
  
  ll answer=ceil(mymax);


    cout<<answer<<endl;


    



}








            






Measured memory_bytes: 4900
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define*********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void) {

	long long N; cin >> N;
	long long M; cin >> M;
	vector<vector<ll>> c(N,vector<ll>(0));
	vector<pii> a(M);
	for (ll i = 0; i < M; i++) {
		ll p, y; cin >> p >> y;
		c[--p].push_back(y);
		a[i] = make_pair(p, y);
	}
	for (ll i = 0; i < N; i++) {
		sort(all(c[i]));
	}
	for (ll i = 0; i < M; i++) {
		vector<ll>::iterator itr = lower_bound(all(c[a[i].first]), a[i].second);
		ll ans = itr - c[a[i].first].begin();
		printf("%06d", ++a[i].first);
		printf("%06d\n", ++ans);
	}
	return 0;
}

Measured memory_bytes: 8576
/*input
2 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}



int main()
{
	//IOS;
	ll x,y;
	cin>>x>>y;
	if(abs(x-y)<=1) cout<<"Brown\n";
	else cout<<"Alice\n";

	return 0;
}


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

int main()
{
    int x1,y1,x2,y2,x3,y3,x4,y4,a,b;
    cin>>x1>>y1>>x2>>y2;
    a=abs(x2-x1);b=abs(y2-y1);
    if(y2>=y1)x3=x2-b;
    else x3=x2+b;

    if(x2>=x1)y3=y2+a;
    else y3=y2-a;

    x4=x3+x1-x2;
    y4=y3+y1-y2;

    printf("%d %d %d %d\n",x3,y3,x4,y4);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string.h>

int main()
{
    long long N, A[5], time, am, temp;
    int index;
    scanf("%lld", &N);
    for (int i = 0; i < 5; ++i)
    {
        scanf("%lld", &A[i]);
        if (i == 0){
            am = A[i];
            index = i;
        }
        else
        {
            if (A[i] < am)
            {
                am = A[i];
                index = i;
            }

        }
        
    }
    if (N <= am){
        printf("%d\n", 5);
        return 0;
    }
    long long q = N / am;
    if (N % am != 0) ++q;
    long long ans = q + 4LL;
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
    int i, n, a;
    map<int, int> memo;
    cin >> n;
    for(i=0; i<n; i++) {
        cin >> a;
        memo[a] += 1;
    }
    int flg = 0;
    for(auto iter = begin(memo); iter != end(memo); ++iter){
        if(iter->second > 1){
            flg = 1;
            break;
        }
    }

    if(flg == 0) cout << "YES" << endl;
    else cout << "NO" << endl;


}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int arr1Size = sc.nextInt();
        int[] arr1 = new int[arr1Size];
        for(int i = 0; i < arr1Size; ++i)
            arr1[i] = sc.nextInt();

        int arr2Size = sc.nextInt();
        int[] arr2 = new int[arr2Size];
        for(int i = 0; i < arr2Size; ++i)
            arr2[i] = sc.nextInt();

        int count = 0;

        for(int n : arr2)
            for(int m : arr1){
                count += n == m ? 1 : 0;
                if(n==m) break;
            }

        System.out.println(count);
    }
}



Measured memory_bytes: 40452
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<int> que;
    for (ll i = 0; i < n; i++){
        ll num;
        cin >> num;
        que.push(num);
    }

    while(m > 0){
        ll num = que.top();
        num /= 2;
        que.pop();
        que.push(num);
        m--;
    }

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<usize>();
    p(v.iter().max().unwrap() - v.iter().min().unwrap());
}

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

#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back

template<typename A, typename B> inline char smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline char smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}

typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;

template<typename I>
inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 3000 + 7;

int n, P;
int S[N][N], C[N][N];

inline int smod(int x) { return x >= P ? x - P : x; }
inline void sadd(int &x, const int &y) { x += y; x >= P ? x -= P : x; }
inline int fpow(int x, int y, const int &P = ::P) {
	int ans = 1;
	for (; y; y >>= 1, x = (ll)x * x % P) if (y & 1) ans = (ll)ans * x % P;
	return ans;
}

inline void ycl() {
	S[0][0] = C[0][0] = 1;
	for (int i = 1; i <= n + 1; ++i) {
		C[i][0] = 1;
		for (int j = 1; j <= i; ++j) S[i][j] = (S[i - 1][j - 1] + (ll)S[i - 1][j] * j) % P, C[i][j] = smod(C[i - 1][j - 1] + C[i - 1][j]);
	}
}

inline void work() {
	ycl();
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int cnt = 0, ni22 = fpow(2, fpow(2, n - i, P - 1)), fn1 = fpow(2, n - i), fn = 1;
		for (int j = 0; j <= i; ++j) sadd(cnt, (ll)S[i + 1][j + 1] * ni22 % P * fn % P), fn = (ll)fn * fn1 % P;
//		dbg("i = %d, ni22 = %d, fn1 = %d, cnt = %d\n", i, ni22, fn1, cnt);
		if (i & 1) sadd(ans, P - (ll)cnt * C[n][i] % P);
		else sadd(ans, (ll)cnt * C[n][i] % P);
	}
	printf("%d\n", ans);
}

inline void init() {
	read(n), read(P);
}

int main() {
#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 69504
#include<bits/stdc++.h>
using namespace std;
#define test int t ; cin>>t ; while(t--)
#define ll long long
#define inp(n) cin>>n;
#define loopp(i,a,b) for(ll i=a;i<b;i++)
#define loopn(i,a,b) for(ll i=a;i>=b;i--)

int main()
{
    string a="AC";
    string b="WA";
    string c="TLE";
    string d="RE";
    string e;
    int a1=0,b1=0,c1=0,d1=0;
    test
    {
        inp(e);
        if(e==a)
            a1+=1;
        if(e==b)
            b1+=1;
        if(e==c)
            c1+=1;
        if(e==d)
            d1+=1;
    }
    cout<<a<<" x "<<a1<<endl
    <<b<<" x "<<b1<<endl<<c<<
    " x "<<c1<<endl<<d<<" x "<<d1<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("street.in","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;
int a[100005];
int main()
{
     int n,x;
     cin >> n >> x;
     for(int i=0;i<n;i++)
     {
         cin >> a[i];
     }
     ll sum = 0,last = a[0];
     for(int i=1;i<n;i++)
     {
         ll r = last + a[i];
         ll tmp = max(r-x,0LL);
         sum += tmp;
         last = max(a[i]-tmp,0LL);
         //cout << last << endl;
       //  last = min(a[i]-tmp,1LL * a[i]);
     }
     cout << sum << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i, N) { cin >> S[i]; }
  sort(S.begin(), S.end());
  rep(i, N) { cout << S[i]; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
l=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
  l[int(str(i)[0])][int(str(i)[-1])]+=1
c=0
for i in range(10):
  for j in range(10):
    c+=l[i][j]*l[j][i]
print(c)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
		
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] vs = new int[N];
			int[] cs = new int[N];
			
			for(int i = 0; i < N; i++) {
				vs[i] = sc.nextInt();
			}
			for(int i = 0; i < N; i++) {
				cs[i] = sc.nextInt();
			}
			
			int answer = 0;
			for(int i = 0; i < N; i++) {
				answer += Math.max(0, vs[i] - cs[i]);
			}
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

# 入力を各変数に格納(N,M,X)
cell_size, toll_size, start_cell = map(int, input().split())
# 数字が文字列リストなので数値リストに変換
toll_list = [int(i) for i in input().split()]

# 0からX
zero_to_start = 0
for i in range(0, start_cell):
	
	if i in toll_list:
		zero_to_start += 1

# XからN
start_to_end = 0
for i in range(start_cell, cell_size):

	if i in toll_list:
		start_to_end += 1

# 小さい方を出力
if zero_to_start <= start_to_end:
	print(zero_to_start)
else:
	print(start_to_end)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define IN2(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000001;
constexpr int MOD = 1000000007;

signed main() {
	INIT;
	VAR(int, n);
	VEC(int, a, n);
	std::sort(ALL(a));
	int min = INFINT;
	FOR(i, -100, 101) {
		int sum = 0;
		REP(j, n) {
			sum += (a[j] - i)*(a[j] - i);
		}
		min = std::min(min, sum);
	}
	OUT(min)BR;
	return 0;
}

Measured memory_bytes: 256
A,B,C,X,Y = map(int, input().split())
ans = 0
if A+B <= 2*C:
    ans = A*X + B*Y
else:
    ans += 2*C*min(X, Y)
    if X >= Y:
        ans += min(A, 2*C)*(X-Y)
    else:
        ans += min(B, 2*C)*(Y-X)
print (ans)

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

int main()
{
    int N, M, C, X;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < M; i++)
    {
        cin >> B.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> A[i][j];
        }
    }
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j < M; j++)
        {
            X = A[i][j] * B.at(j);
            sum += X;
        }
        if ((sum + C) > 0)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
let () =
  let n = read_int () in
  let tbl = Hashtbl.create ~random:true n in
  let rec read i =
    if i <= 0 then ()
    else begin
      match Scanf.scanf "%s %s\n" (fun x y -> (x, y)) with
      | ("insert", x) -> (Hashtbl.add tbl x true; read (i - 1))
      | ("find", x) -> (print_endline (if Hashtbl.mem tbl x then "yes" else "no"); read (i - 1))
      | _ -> exit 1
    end
  in
  read n

Measured memory_bytes: 44040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	ll n,a[5],b=0;
	vector<pair<ll,ll>>v(5);
	cin>>n;
	for(int i=0;i<5;i++)
	{
		cin>>v[i].first;
		v[i].second=i;
	}
	sort(v.begin(),v.end());
	if(n%v[0].first)b=1;
	if(n<=v[0].first)cout<<5<<endl;
	else cout<<(v[0].second)+(n/v[0].first)+b+(4-v[0].second)<<endl;
	return 0;
}
	

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static int rec(int x) {
		int min = Integer.MAX_VALUE / 2;
		if (x == 0) return 0;
		
		if (200 <= x) {
			min = Math.min(min, rec(x - 200) + 380);
		}
		if (300 <= x) {
			min = Math.min(min, rec(x - 300) + 550);
		}
		if (500 <= x) {
			min = Math.min(min, rec(x - 500) + 850);
		}
		
		if (200*5 <= x) {
			min = Math.min(min, rec(x - 200*5) + (int)(380*5*0.8));
		}
		if (300*4 <= x) {
			min = Math.min(min, rec(x - 300*4) + (int)(550*4*0.85));
		}
		if (500*3 <= x) {
			min = Math.min(min, rec(x - 500*3) + (int)(850*3*0.88));
		}
		
		return min;
	}

	static boolean solve() {
		int n = in.nextInt();
		
		if (n == 0) return false;
		
		out.println(rec(n));
		
		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 26784
def secc(a,b,c):
    k =[]
    k.append(a)
    k.append(b)
    k.append(c)
    k.sort()
    if(k[1]==b):
        return True
    else:
        return False
n = int(input())
a = list(map(int,input().split()))
c =0 
for i in range(1,n-1):
    if(secc(a[i-1],a[i],a[i+1])):
        c+=1 
print(c)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0]+a[1] == a[2]) co("Yes");
  else co("No");
  
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    h, w, K = map(int, input().split())
    field = []
    base = 0
    for i in range(h): 
        s = input()
        s = [1 if _ == '#' else 0 for _ in s]
        field.append(s)
        base += sum(s)
    ans = 0  
    for i in range(2**h):
        for j in range(2**w):
            num = base
            for k in range(h):
                if (i >> k) & 1:
                    num -= sum(field[k])
                else:
                    for l in range(w):
                        if (j >> l) & 1 and field[k][l] ==1:
                            num -= 1
        
            if num == K:
                ans += 1
    print(ans)

            

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 9160