akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
P=list(map(int,input().split()))

V=[(1+p)/2 for p in P]

from itertools import accumulate

S=[0]+list(accumulate(V))

ANS=0
for i in range(K,N+1):
    ANS=max(ANS,S[i]-S[i-K])

print(ANS)


Measured memory_bytes: 26248
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int N, K, R, S, P;
string T;

ll point(char c){
    if(c == 'r')return R;
    if(c == 's')return S;
    return P;
}
int main(){

    cin >> N >> K >> R >> S >> P >> T;
    for(int i = 0; i < T.size(); i++){
        if(T[i] == 'r')T[i] = 'p';
        else if(T[i] == 's')T[i] = 'r';
        else if(T[i] == 'p')T[i] = 's';
    }
    ll ans = 0;
    for(int i = 0; i < K; i++){
        for(int j = i; j < N; j += K){
            if(j < K){
                ans += point(T[j]);
                continue;
            }
            if(T[j] == T[j-K]){
                T[j] = 'a';
                continue;
            }
            ans += point(T[j]);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B, C = list(map(int, input().split()))
    print('Yes'if max([A, B, C]) == (
        sum([A, B, C]) - max([A, B, C])) else 'No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
n =int(input())
min_value =1000000000000000000000000000
w = list(map(int,input().split()))
for i in range(n):
  a = sum(w[0:i])
  b = sum(w[i:n])
  if abs(a - b) < min_value:
    min_value = abs(a-b)
print(min_value)

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;


bool f(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; i++) cout << s << ' ';
    for (int i = 0; i < n - k; i++) cout << (s == 1000000000 ? 999999999 : 1000000000) << ' ';

}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int ask(int n)
{
    fflush(stdout);
    cout << n << endl;
    string t;
    cin >> t;
    if (t[0] == 'V') exit(0);
    return t[0];
}

int main()
{
    int N;
    cin >> N;
    char i = ask(0), j= ask(N-1);
    int l = 0, r = N-1;
    while (true)
    {
        int mid = (l+r)/2;
        char m = ask(mid);
        if ((mid - l)%2 == 0)
        {
            if (i != m) r = mid;
            else l = mid;
        }
        else
        {
            if (i != m) {l = mid; i = m;}
            else r = mid;
        }
    }
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    long long count = 0;
    
    long long moved = 0;
    for (long long i=0; i < s.length(); i++){
        if (s[i] == 'W') {
            count += i - moved;
            moved++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
	using namespace std;
	typedef long long int lld;
	int main()
	{
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    lld n,m,q,i,x,y,j,p=0,l,k=0,s=0;
	    cin>>n;lld a[n];
	    for(i=0;i<n;i++)
	    	{
	    		cin>>a[i];
	    	}k=1;
	    	while(1)
	    	{k=k*2;	    		s++;

	    		for(i=0;i<n;i++)
	    		{
	    			if(a[i]%k!=0)
	    			{
	    				p++;break;
	    			}
	    		}
	    		if(p==1)
	    			break;
	    	}
	    	cout<<s-1;
	 }

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i;
ll a[nmax],l,r,mid,mx;
int ok(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x<=2)return 1;
	return 0;
}
int ok1(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x>=2)return 1;
	return 0;
}
int ok2(ll x)
{
	for(int i=1;i<=n;i++)x-=x%a[i];
	if(x==2)return 1;
	return 0;
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];
    l=0,r=1e15;
    while(l<=r)
	{
		mid=(l+r)/2;
		if(ok(mid))l=mid+1;
		else r=mid-1;
	}
	if(!l)rc(-1);
	mx=l-1;
	l=0,r=mx;
    while(l<=r)
	{
		mid=(l+r)/2;
		if(ok1(mid))r=mid-1;
		else l=mid+1;
	}
	if(ok2(r+1) && ok2(mx))cout<<r+1<<" "<<mx<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll a,b;
  cin >> a >> b;
  cout << (a^b) << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3604
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> v,v1;

int main()
{
    ll a,b,sum=0,flag,flag1;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        v.push_back(b);
        v1.push_back(b);
    }
    sort(v1.begin(),v1.end());
    for(int i=0; i<a; i++)
    {
        if(v[i]!=v1[i])
        {
            sum++;
        }
    }
    if(sum>2)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main(){
    char ch1[200], ch2[100], ch3[100];
    scanf("%s %s", ch1, ch2);
    
    strcpy(ch3, ch1);
    strcat(ch1, ch3);
    
    if ( strstr(ch1, ch2) == NULL ) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}


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

#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;

typedef long long ll;


//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}
//---------------//

ll A, B, C, X, Y;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> A >> B >> C >> X >> Y;
    if(2 * C >= A + B){
        cout << A * X + B * Y << endl;
    }else{
        int ans = 0;
        if(X >= Y){
            ans += Y * 2 * C;
            ans += min((X - Y) * A, (X - Y) * 2 * C);
            cout << ans  << endl;
        }else{
            ans += X * 2 * C;
            ans += min((Y - X) * B, (Y - X) * 2 * C);
            cout << ans  << endl;
        }
    }
}


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

ll solve() {
    ll N, C, s, t, c;
    cin >> N >> C;
    ll M = 1e5;
    vector<vector<ll>> d(C, vector<ll>(M+2));
    for ( int n = 0; n < N; n++ ) {
        cin >> s >> t >> c;
        c--;
        for ( int i = s; i <= t; i++ ) {
            d[c][i] = 1;
        }
    }
    ll m = 0, nm = 0;
    for ( int i = 0; i < M+2; i++ ) {
        ll a = 0;
        for ( int c = 0; c < C; c++ ) {
            a += d[c][i];
        }
        m = max(m, a);
    }
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 24704
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner = new Scanner(System.in);
            int b = scanner.nextInt();
            Boolean ans = false;
            while(b > 0){
                int c = b % 10;
                if(c == 7)
                {
                    System.out.println("Yes");
                    ans = true;
                    break;
                }
                b /= 10;

            }
            if(ans == false)
            System.out.println("No");

        }
    }



Measured memory_bytes: 35776
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const ll INF = 1000000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int a, b, q;
    vector<ll> s;
    vector<ll> t;
    vector<ll> xs;

    cin >> a >> b >> q;
    rep(i, a) {
        ll ca;
        scanf("%lld", &ca);
        s.pb(ca);
    }
    rep(i, b) {
        ll cb;
        scanf("%lld", &cb);
        t.pb(cb);
    }
    rep(i, q) {
        ll cq;
        scanf("%lld", &cq);
        xs.pb(cq);
    }
    s.pb(INF);
    t.pb(INF);
    sor(s);
    sor(t);

    rep(i, q) {
        ll x = xs[i];
        auto its = lb(s, x);
        auto itt = lb(t, x);
        ll dirs0, dirt0, dirs1, dirt1;

        dirs1 = *its - x;
        if (its - s.begin() == 0) {
            dirs0 = INF;
        } else {
            dirs0 = x - *(its - 1);
        }

        dirt1 = *itt - x;
        if (itt - t.begin() == 0) {
            dirt0 = INF;
        } else {
            dirt0 = x - *(itt - 1);
        }

        ll ret0, ret1, ret2, ret3;
        ret0 = max(dirs0, dirt0);
        ret1 = max(dirs1, dirt1);
        ret2 = (dirs0 > dirt1) ? dirt1 * 2 + dirs0 : dirs0 * 2 + dirt1;
        ret3 = (dirt0 > dirs1) ? dirs1 * 2 + dirt0 : dirt0 * 2 + dirs1;

        cout << min(min(ret0, ret1), min(ret2, ret3)) << endl;
    }

    /* ====================================== */
    return 0;
}

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

static const int N=1000;

int Lcs(string X, string Y){
  int c[N+1][N+1];
  int LMAX=0;
  int m=X.size(), n=Y.size();

  X=' ' + X;
  Y=' ' + Y;

  for(int i=0; i<=m; i++) c[i][0]=0;
  for(int j=0; j<=n; j++) c[0][j]=0;

  for(int i=1; i<=m; i++)
  {
    for(int j=1; j<=n; j++)
    {
      if(X[i] == Y[j])
      {
        c[i][j]=c[i-1][j-1]+1;
      }
      else
      {
        c[i][j]=max(c[i-1][j], c[i][j-1]);
      }
      LMAX=max(LMAX, c[i][j]);
    }
  }

  return LMAX;
}

int main(){
  string s1, s2;
  int n;
  cin >> n;

  for(int i=0; i<n; i++)
  {
    cin >> s1 >> s2;
    cout << Lcs(s1, s2) << endl;
  }
  return 0;
}



Measured memory_bytes: 7056
def examB():
    ABC = LI()
    K = I()
    ans = sum(ABC) + max(ABC)*(2**K-1)
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Measured memory_bytes: 3444
package main

import (
  "fmt"
  "os"
  "bufio"
  "strconv"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  x, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  if x < a {
    fmt.Println(0)
  } else {
    fmt.Println(10)
  }

}



Measured memory_bytes: 640
/**
    Sweet!
**/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

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

const int N = 2e5 + 10;
const int inf = 1e9+10;
const ll linf = 1e18+9;

int a, b, cnt = 1;
vector <int> v;
string Goat = "!";


int main() {
    cin >> a >> b;
    if(a <= b) {
        cout << "Impossible" << endl;
        fflush(stdout);
        return 0;
    }
    a = a + b;
    v.pb(0);
    for(int i = 1; i < a; i++) {
        if(!v.empty()) {
            cout << "? " << v.back() << " " << i << endl;
            fflush(stdout);
            char c;
            cin >> c;
            if(c == 'Y')
                v.pb(i);
            else
                v.pp;
        }
        else v.pb(i);
    }
    int nw = v.back();
    for(int i = 0; i < a; i ++) {
        cout << "? " << nw << " " << i << endl;
        fflush(stdout);
        char c;
        cin >> c;
        if(c == 'Y')
            Goat += '1';
        else
            Goat += '0';
    }
    cout << Goat << endl;
    fflush(stdout);
}


Measured memory_bytes: 724
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n):
    pi = 3.14159
    return 2*pi*n


if __name__ == "__main__":
    n = i1num()
    print(solve(n))


Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct Node{
    int x;
    struct Node *prev;
    struct Node *next;
} node;
  
node noth;
node *nil=&noth;
  
node* find(int);
  
void insert(int key){
    node *n=(node *)malloc(sizeof(node));
    n->x=key;
    n->next=nil->next;
    nil->next->prev=n;
    nil->next=n;
    n->prev=nil;
}
  
void delete(int key){
    node *it=find(key);
      
    if(it!=nil){
        it->next->prev=it->prev;
        it->prev->next=it->next;
        free(it);
    }
}
  
void deletef(void){
    node *it=nil->next;
    if(it!=nil){
        it->next->prev=it->prev;
        it->prev->next=it->next;
        free(it);
    }
}
  
void deletel(void){
    node *it=nil->prev;
    if(it!=nil){
        it->next->prev=it->prev;
        it->prev->next=it->next;
        free(it);
    }
}
  
node* find(int key){
    node *it;
    for(it=nil->next;it!=nil;it=it->next){
        if(it->x==key) return it;
    }
    return nil;
}

int main(void){
    node *it;
    int n;
    int k;
    char a[20];
    nil->x=999;
    nil->prev=nil;
    nil->next=nil;
      
    scanf("%d",&n);
  
    while(n--){
        scanf("%s",a);
        if(a[0]=='i'){
            scanf("%d",&k);
            insert(k);
        }else if(a[0]=='d'){
            if(strlen(a)>8){
                if(a[6]=='F') deletef();
                else if(a[6]=='L') deletel();
            }else{
                scanf("%d",&k);
                delete(k);
            }
        }
    }
      
    for(it=nil->next;it!=nil;it=it->next){
        if(it->next!=nil)printf("%d ",it->x);
	else printf("%d",it->x);
    }
	printf("\n");
    return 0;
}

Measured memory_bytes: 31788
n = int(input())
A =list(map(int, input().split()))
mod = 10**9+7

d = {}
for i in range(n+1):
    if A[i] not in d:
        d[A[i]] = i
    else:
        l = d[A[i]]
        r = i
        break
#print(l, r)

def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for k in range(1, n+2):
    ans = cmb1(n+1, k, mod) - cmb1(l+n-r, k-1, mod)
    print(ans%mod)


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
long long INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

#define MAX_N 40
pair<int,int> ps[1<<(MAX_N/2)];
int c[MAX_N],A[MAX_N];

int inline bs(int begin, int end, int x){
    int left=begin,right=end-1,mid;
    if(x<ps[left].first || x>ps[right].first) return -1;
    while(left<=right){
        mid = (left+right)/2;
        if(x<ps[mid].first) right = mid-1;
        else left = mid+1;
    }
    if(x==ps[right].first) return right;
    else return -1;
}

int main(){
    int ans=MOD,n,ma,mb;

    scanf("%d %d %d",&n,&ma,&mb);
    REP(i,n){
        int a,b;
        scanf("%d %d %d",&a,&b,&c[i]);
        A[i] = ma*b - mb*a;
    }

    int n2 = n / 2;
    REP(i,1<<n2){
        int s=0,v=0;
        REP(j,n2){
            if(i>>j&1){
                s += A[j];
                v += c[j];
            }
        }
        ps[i] = make_pair(s,v);
    }

    ps[0] = ps[1];
    sort(ps,ps+(1<<n2));
    int m=1;
    FOR(i,1,1<<n2) if(ps[m-1].first != ps[i].first) ps[m++] = ps[i];

    REP(i,1<<(n-n2)){
        int s=0,v=0;
        REP(j,n-n2){
            if(i>>j&1){
                s += A[n2+j];
                v += c[n2+j];
            }
        }
        if(s!=0||v==0){
            if(bs(0,m,-s)!=-1) ans = min(ans,v+ps[bs(0,m,-s)].second);
        }else ans = min(ans,v);
    }

    if(ans!=MOD&&ans!=0) printf("%d\n",ans);
    else printf("-1\n");
    return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <climits>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    
    long long a, b, k;
    cin >> a >> b >> k;
    
    cout << max((long long)0, a-k) << " ";
    if(k-a >= 0){
        cout << max((long long)0, b - (k-a)) << endl;
    }
    else{
        cout << b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int d;
  cin>>d;

  int n=26;
  vector<int> c(n);
  rep(j,n){
    cin>>c[j];
  }
  vector<vector<int>> s(d,vector<int>(n));
  rep(i,d) rep(j,n) cin>>s[i][j];

  vector<int> t(d);
  rep(i,d){
    cin>>t[i];
    t[i]--;
  }

  lint score=0;
  vector<int> lastd(n,-1);
  rep(i,d){
    int j=t[i];
    lastd[j]=i;
    score+=s[i][j];
    rep(j,n) score-=c[j]*(i-lastd[j]);
    cout<<score<<endl;
  }

}

int main(){app();return 0;}


Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    //int[][] dp = new int[1001][1001];
    void solve(int[] arr) {
            int xor = 0;
            int n = arr.length;
            for(int i=0;i<n;i++){
                xor^=arr[i];
            }
            //System.out.println();
            for(int i=0;i<n;i++){
                System.out.print((xor^arr[i])+" ");
            }
            System.out.println();

    }



    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);
        s = br.readLine().split(" ");
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(s[i]);
        }

        test.solve(arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}


Measured memory_bytes: 69520
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        HashSet<int> vs = new HashSet<int>();
        int n = int.Parse(Console.ReadLine());

        vs.Clear();
        for(var i = 1; i < 10; ++i)
        {
            for(var j=1; j<10; ++j)
            {
                vs.Add(i * j);
            }
        }
        var cnt = vs.Count;
        vs.Add(n);
        if (cnt == vs.Count)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
        return;
    }
}

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

int main() {
 int n;
 int a[5000];
 int S[5000];
 while ((cin >> n) && n != 0) {
  for (int i=0; i<n; ++i) {
   cin >> a[i];
  }
  S[0] = 0;
  for (int i=0; i<n; ++i) {
   S[i+1] = S[i] + a[i];
  }
  int max = -100001;
  for (int i=0; i<n; ++i) {
   for (int j=i+1; j<=n; ++j) {
    max = (S[j]-S[i] > max) ? S[j]-S[i] : max;
   }
  }
  cout << max << endl;
 }
}


Measured memory_bytes: 1192
a = input()
for i in range(int(input())):
    b = list(input().split(' '))
    if 'print' in b:
        f = int(b[1])
        s = int(b[2])
        print(a[f:s+1])
    elif 'reverse' in b:
        f = int(b[1])
        s = int(b[2])
        a = a[:f] + a[f:s+1:][::-1] + a[s+1:]
    else:
        f = int(b[1])
        s = int(b[2])
        a = a[:f] + b[3] + a[s+1:]


Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 3560
using System;
using System.Linq;
using System.Text;

namespace CircumscribedCircleOfATriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                decimal[] input = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
                decimal[] b = {input[2] - input[0], input[3] - input[1],
            (input[2] * input[2] - input[0] * input[0] - input[1] * input[1] + input[3] * input[3])/ 2,
            input[4] - input[0], input[5] - input[1],
            (input[4] * input[4] - input[0] * input[0] - input[1] * input[1] + input[5] * input[5])/ 2 };
                decimal d, e;
                if (b[0] == 0)
                {
                    d = b[2] / b[1];
                    e = (b[5] - d * b[4]) / b[3];
                }
                else
                {
                    d = (b[5] - b[2] * b[3] / b[0]) / (b[4] - b[3] * b[1] / b[0]);
                    e = (b[2] - d * b[1]) / b[0];
                }

                double distance = Math.Pow((double)((e - input[0]) * (e - input[0]) + (d - input[1]) * (d - input[1])), 0.5);
                distance = Math.Round(distance * 1000) / 1000;

                sb.AppendLine(String.Format("{0:0.000} {1:0.000} {2:0.000}", e, d, distance));
            }
            Console.Write(sb);
        }
    }
}



Measured memory_bytes: 10136
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

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

  vector<string> v;

  for (int i = 0; i < s.length(); i++){
    for (int j = 1; j <= k; j++){
      v.push_back(s.substr(i, j));
    }
  }
  // for(auto itr = v.begin(); itr != v.end(); ++itr) {
  //         std::cout << *itr << "\n";
  //     }
  // cout << endl;
  sort(v.begin(), v.end());
  // for(auto itr = v.begin(); itr != v.end(); ++itr) {
  //       std::cout << *itr << "\n";
  //   }
  //   cout << endl;
  unique(v.begin(), v.end());
  // for(auto itr = v.begin(); itr != v.end(); ++itr) {
  //       std::cout << *itr << "\n";
  //   }
  //   cout << endl;

  cout << v[k-1] << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    map<int, int> mp;
    multiset<int> ms;

    REP(i, 0, W) {
        mp[i] = i;
        ms.insert(0);
    }

    REP(i, 0, H) {
        int a, b; cin >> a >> b;
        a--;

        int right = -1;
        auto itr = mp.lower_bound(a);
        while (itr != mp.end() && itr->first <= b) {
            right = itr->second;
            ms.erase(ms.find(itr->first - itr->second));
            mp.erase(itr++);
        }

        if (right != -1 && b < W) {
            ms.insert(b - right);
            mp[b] = right;
        }

        if (ms.size()) cout << *ms.begin() + i + 1 << endl;
        else cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 22324
#include <bits/stdc++.h>
using namespace std;
int main() {
    int e;
    while(scanf("%d",&e),e) {
        int ans=1<<30;
        for(int z=0;z*z*z<=e;z++) {
            for(int y=0;z*z*z+y*y<=e;y++) {
                int x=e-z*z*z-y*y;
                ans=min(ans,x+y+z);
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3084
H, W = map(int, input().split())
m = []
m.append('#'*(W+2))
white = 0
for i in range(H):
  s = input()
  m.append(list('#' + s + '#'))
  white += s.count('.')
m.append('#'*(W+2))

op = set([(1, 1)])
dist = 0
while len(op) > 0:
  dist += 1
  next_op = set()
  for y, x in op:
    m[y][x] = dist
    if (y, x) == (H, W):
      print(white - dist)
      exit()

    for dx,dy in [0,1],[0,-1],[1,0],[-1,0]:
      if m[y-dy][x-dx] == '.':
        next_op.add((y-dy,x-dx))
  op = next_op

print('-1')

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;

int main(){
    int a,b,d,r;
    double f;

    scanf("%d %d",&a,&b);
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    printf("%d %d %.8lf\n",d,r,f);
    return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0;i<(int)(n);++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> vec(3 * n);
  for (ll i = 0; i < 3 * n; ++i) {
    cin >> vec[i];
  }
//  sort(vec, vec+3*n);
  sort(vec.begin(), vec.end(), greater<int>());
  ll ans = 0;
  for (ll i = 1; i < 2 * n; i+=2) {
    ans += vec[i];
  }
//  debug(ans);
  cout << ans << '\n';
}



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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll N;
    cin >> N;
    REPS(n, 1, 3500) {
        REPS(h, 1, 3500) {
            ll tmp = (ll)4*n*h - (ll)N*n - (ll)N*h;
            if (tmp == 0) continue;
            if ((ll)(N*h*n) % tmp != 0) continue;
            ll w = (ll)(N*h*n) / tmp;
            if (1 <= w && w <= 3500) {
                cout << n << ' ' << h << ' ' <<  w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import heapq
N,M = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
AB.sort(key=lambda x:x[0])
index = 0
Works = []
ans = 0

for d in range(1,M+1):#d日後までの支払いのうち一番高いやつ
    while 1:
        if index>=N:break
        if AB[index][0]<=d:
            heapq.heappush(Works,-AB[index][1])
            index += 1
        else:
            break
    if Works:
        ans -= heapq.heappop(Works)
print(ans)

Measured memory_bytes: 25732
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

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

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 3e2 + 15;
const int S = 0;
const int T = N - 1;
int n, a[N];

int d[N];

struct edge {
	int v, c;
};

vector <edge> e;
vector <int> g[N];

inline void add_edge(int u, int v, int c) {
	g[u].pb(e.size());
	e.pb({v, c});

	g[v].pb(e.size());
	e.pb({u, 0});
}

int q[N], ql, qr;
bool used[N];

int ptr[N];

inline bool bfs() {
	memset(used, 0, sizeof(used));
	d[S] = 0;
	q[ql = qr = 0] = S;
	used[S] = true;
	while(ql <= qr) {
		int v = q[ql++];
		for(int ind : g[v]) {
			int to = e[ind].v, cap = e[ind].c;
			if(cap <= 0)
				continue;
			if(!used[to]) {
				used[to] = true;
				d[to] = d[v] + 1;
				q[++qr] = to;
			}
		}
	}
	return used[T];
}

int dfs(int v, int cmin) {
	if(v == T || cmin == 0)
		return cmin;
	for(; ptr[v] < g[v].size(); ++ptr[v]) {
		int ind = g[v][ptr[v]];
		int to = e[ind].v, cap = e[ind].c;
		if(cap <= 0)
			continue;
		if(d[to] == d[v] + 1) {
			int flow = dfs(to, min(cmin, cap));
			if(flow) {
				e[ind].c -= flow;
				e[ind ^ 1].c += flow;
				return flow;
			}
		}
	}
	return 0;
}

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	int ans = 0;
	for(int i = 1; i <= n; ++i) {
		if(a[i] >= 0) {
			ans += a[i];
			add_edge(i, T, a[i]);
		}
		else {
			add_edge(S, i, -a[i]);
			for(int j = i + i; j <= n; j += i)
				if(a[j] >= 0)
					add_edge(i, j, inf);
		}
	}
	while(bfs()) {
		memset(ptr, 0, sizeof(ptr));
		while(int flow = dfs(S, inf))
			ans -= flow;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import copy
sys.setrecursionlimit(10 ** 7)

def bubbleSort(L):
    flg = True
    while flg:
        flg = False
        i = 0
        for j in range(len(L)-1,i,-1):
            if L[j][1] < L[j-1][1]:
                L[j] , L[j-1] = L[j-1], L[j]
                flg = True
        i += 1
    return L

def selectionSort(L):
    for i in range(len(L)):
        minj = i
        for j in range(i,len(L)):
            if L[j][1] < L[minj][1]:
                minj = j
        if minj != i:
            L[i],L[minj] = L[minj],L[i]
    return L

N = int(input())
C1 = list(input().split())
C2 = copy.deepcopy(C1)
bC = bubbleSort(C1)
sC = selectionSort(C2)

print(*bC)
s = "Stable" #BubbleSort is stable sort!
print(s)

print(*sC)
s = "Stable"
for i in range(len(sC)-1):
    if sC[i][1] == bC[i][1] and sC[i][0] != bC[i][0]:
        s = "Not stable"
        break
print(s)


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

// cl /EHsc xxxx.c
int main(int arc, char *argv[])
{
	int a, b;
	int d, r;
	double f;

	scanf("%d %d", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	
	
	printf("%d %d %lf\n", d, r, f);
	
	return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;
    if(a > b) cout << "Alice" << endl;
    else if(a < b) cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc082/tasks/abc082_b

int main() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << ((s < t) ? "Yes": "No") << "\n";

    return 0;
}


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

#define N 100000

int main(void){
    ios::sync_with_stdio(false);
    vector<bool> prime(N+1,true);
    prime[0]=prime[1]=false;
    for (size_t i = 0; i*i <= N; i++)
    {
        if (prime[i])
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    vector<int> likeCnt(N);
    for (size_t i = 1; i <= N; i++)
    {
        likeCnt[i]=likeCnt[i-1];
        if (i%2==1&&prime[i]&&prime[(i+1)/2])
        {
            likeCnt[i]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l,r;
    for (size_t i = 0; i < q; i++)
    {
        cin >> l >> r;
        cout << likeCnt[r] - likeCnt[l-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 1024
# Sort II - Partition
def partition(A,p,r):
    x = A[r]
    i = p - 1
    for j in range(p,r,1):
        if A[j] <= x:
            i += 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    return i + 1
n = int(input())
A = list(map(int,input().split()))
q = partition(A,0,len(A)-1)
print(*['['+str(a)+']' if i==q else a for i,a in enumerate(A)])


Measured memory_bytes: 18484
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}


int main(){

	ll d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d) cout<<"Yes";
	else cout<<"No";
	
	

	
	
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
	int i,j;
	int N, K;
	int a[100] = {};
	int total = 0;
	scanf("%d%d",&N,&K);
	for(i = 0;i < K;i++){
        int d;
		scanf("%d", &d);
		for(j = 0;j < d;j++){
            int index;
			scanf("%d", &index);
			a[index - 1]++;
		}
	}
	for(i = 0;i < N;i++){
		if(a[i] == 0) total++;
	}
	printf("%d\n", total);
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;

void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }

}

int main(){
    ll K, N;
    cin >> K >> N;
    ll A[N];
    rep(i, N){
        cin >> A[i];
    }

    ll ans = K + 1;
    ll D[N];
    rep(i, N-1){
        D[i] = A[i+1] - A[i];
    }
    D[N-1] = K - A[N-1] + A[0];

    rep(i, N){
        chmin(ans, K-D[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3840
// TLE, Timit Limit Exceeded.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(int argc, char** argv)
{
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	for(auto& e : s) cin >> e;
	int res = 1e9;
	for(int bt=0; bt<1<<h-1; bt++)
	{
		vector<int> p{0};
		for(int i=1; i<h; i++)
			if((bt >> (i - 1)) & 1)
				p.push_back(i);
		p.push_back(h);
		int n = p.size() - 1;
		int cur = n - 1;
		int l = 0, r = 0;
		while(l < w)
		{
			vector<int> c(n);
			while(r < w)
			{
				for(int t=0; t<n; t++)
					for(int i=p[t]; i<p[t+1]; i++)
						if(s[i][r] == '1')
							c[t] ++;
				if(*max_element(c.begin(), c.end()) > k) break;
				r ++;
			}
			if(l == r)
			{
				cur = 1e9;
				break;
			}
			l = r;
			if(l < w) cur ++;
		}
		res = min(res, cur);
	}
	cout << res << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n;cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    vector<vector<ll>>dp(n-1,(vector<ll>(21,0)));
    dp[0][v[0]]++;
    for(int i=1;i<n-1;i++){
        int x=v[i];
        for(int j=0;j<21;j++){
            if(j+x<=20)dp[i][j+x]+=dp[i-1][j];
            if(j-x>=0)dp[i][j-x]+=dp[i-1][j];
        }
    }
    int y=v[n-1];
    cout<<dp[n-2][y]<<endl;
}


Measured memory_bytes: 3168
x, n = map(int, input().split())
ps = list(map(int, input().split()))
anss = [101] * 102
for i in range(102):
  if (i not in ps):
    anss[i] = abs(x - i)
m = min(anss)
for i, ans in enumerate(anss):
  if ans == m:
    print(i)
    exit()


Measured memory_bytes: 61836
package main

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

func main() {
	H := nextInt()
	W := nextInt()
	h := nextInt()
	w := nextInt()

	fmt.Println((H - h) * (W - w))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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


fn main(){
    let line: Vec<u32> = read_as_vec();
    let (p, q, r) = (line[0], line[1], line[2]);
    
    println!("{}", p+q+r -cmp::max(cmp::max(p, q), r));
}


Measured memory_bytes: 4352
import scala.collection.mutable.HashMap
import scala.collection.immutable.List

object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    
    import Function.tupled
    println(List.fill(n)(sc.nextInt)
            .groupBy(identity)
            .mapValues(_.length)
            .map(tupled {(number, count) =>
                       if (count >= number) count - number
                       else count
                       }
               )
            .sum
          )
  }
}


Measured memory_bytes: 90420
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    int min = 210000;
    for (int i = 0; i < n; i++) {
	    int p = sc.nextInt();
	    if (p <= min) {
	    	ans++;
	    	min = p;
	    }
    }
	System.out.println(ans);    	
  }
}



Measured memory_bytes: 62464
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod2 1000000007
#define mod 998244353
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ji=30*h+0.5*m;
    double hun=6*m;
    double kaku=abs(ji-hun);
    double ans2=a*a+b*b-2.0*a*b*cos(pi*kaku/180.0);
    double ans=sqrt(ans2);
    printf("%.12lf\n",ans);
    return 0;
}



Measured memory_bytes: 4228