akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
use itertools::Itertools;
use num::clamp;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, c: usize,
        stc: [(usize, usize, Usize1); n]
    }

    let mut cum = vec![0i64; 200010];
    for i in 0..c {
        let mut ccum = vec![0i64; 200010];
        for &(s, t, c) in &stc {
            if c != i {
                continue;
            }
            ccum[2 * s - 1] += 1;
            ccum[2 * t] -= 1;
        }
        for j in 1..ccum.len() {
            ccum[j] += ccum[j-1];
        }
        for j in 0..ccum.len() {
            if ccum[j] > 0 {
                cum[j] += 1;
            }
        }
    }

    let ans = cum.into_iter().max().unwrap();
    println!("{}", ans);
}


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

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  set<i64> s;
  for (i64 i = 0; i < n; i++)
    s.insert(a[i]);
  cout << s.size() << endl;
  return 0;
}



Measured memory_bytes: 8296
#include <stdio.h>

int main(void)
{
	int n;
	int i, j;
	char c[2];
	int num;
	int card[4][13] = {0};
	int acsec_key;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		scanf("%s %d", c, &num);
		//printf("%s\n", c);
		switch (c[0]) {
			case 'S':
				acsec_key = 0;
				//printf("s\n");
				break;
			case 'H':
				acsec_key = 1;
				//printf("h\n");
				break;
			case 'C':
				acsec_key = 2;
				//printf("c\n");
				break;
			case 'D':
				acsec_key = 3;
				//printf("d\n");
				break;
		}
		card[acsec_key][num - 1] = 1;
	}
	
	//printf("\n");
	
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 13; j++) {
			if (card[i][j] == 0) {
				switch (i) {
					case 0:
						c[0] = 'S';
						break;
					case 1:
						c[0] = 'H';
						break;
					case 2:
						c[0] = 'C';
						break;
					case 3:
						c[0] = 'D';
						break;
				}
				printf("%s %d\n", c, j + 1);
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
vector<long long> fact_inv, inv, Com;

void init_nCk(int n, int SIZE) {
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
    Com.resize(SIZE + 5);
    Com[0] = 1;
    for (int i = 1; i < SIZE + 5; i++) {
        Com[i] = Com[i - 1] * ((n - i + 1) * inv[i] % MOD) % MOD;
    }
}
 
long long nCk(int k) {
    assert(!(k < 0));
    return Com[k];
}
int main()
{
  ll S;
  cin >> S;
  if(S==1||S==2){
    cout << 0 << endl;
  }else{
    mint ans=0;
    REP2(i,1,S/3){
      ll s=S-i*3;
      init_nCk(s+i-1,s+i-1);
      ans+=nCk(s);
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 3660
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int gcd(int a, int b)
{
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> y(n + 1);
    for (int i = 0; i < n; i++) { cin >> y[i]; }
    y[n] = x;
    sort(y.begin(), y.end());
    vector<int> z(n);
    for (int i = 0; i < n; i++) { z[i] = y[i + 1] - y[i]; }
    int g = z[0];
    for (int i = 0; i < n; i++) { g = gcd(g, z[i]); }
    cout << g << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;
  
  vector<long long> a(n+1), b(n);
  for(int i=0; i<n+1; i++){
    cin >> a[i];
  }
  for(int j=0; j<n; j++){
	cin >> b[j];
  }
 
  long long num=0;
  for(int k=0; k<n; k++){
    if(a[k] >= b[k]){
	  num = num + b[k];
      a[k] = a[k]-b[k];
    }
    else if(a[k] < b[k] && b[k]-a[k] <= a[k+1]){
      num = num + b[k];
      a[k+1] = a[k+1] - (b[k]-a[k]);
      a[k] = 0;
    }
    else if(a[k] < b[k] && b[k]-a[k] > a[k+1]){
  	  num = num + a[k] + a[k+1];
      a[k] = 0;
      a[k+1] = 0;
    }
  }
  
  cout << num << endl;
  
}


Measured memory_bytes: 1792
n = int(input())
flg = True
x,y = 0,0
for i in range(n):
  a,b,c = map(int,input().split())
  if (a < abs(b) + abs(c) - (x+y)) or (a % 2 != (abs(b) + abs(c)) % 2):
    flg = False
    break
  else:
    x = b
    y = c
#print(flg)
print("Yes" if flg else "No")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){


int a,b,d,r;

double f ;

scanf("%d",&a) ;

scanf("%d",&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
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; ++i) {
            a[i] = scanner.nextInt();
        }
        int[] box = new int[n + 1];
        Map<Integer, List<Integer>> number = new HashMap<>();
        for (int i = 1; i <= n; ++i) {
            number.put(i, new ArrayList<>());
        }
        for (int i = 1; i <= n; ++i) {
            for (int k = 1; k * i <= n; ++k) {
                number.get(k * i).add(i);
            }
        }
        for (int i = n; i >= 1; --i) {
            box[i] = a[i] % 2;
            for (int k : number.get(i)) {
                a[k] = Math.abs(a[k] % 2 - box[i] % 2);
            }
        }

        int count = 0;
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                ++count;
            }
        }
        System.out.println(count);
        for (int i = 1; i <= n; ++i) {
            if (box[i] == 1) {
                System.out.print(i + " ");
            }
        }
        System.out.println();

    }
}

Measured memory_bytes: 162816
def f():
  a1 = list(map(int, input().split()))
  a2 = list(map(int, input().split()))
  a3 = list(map(int, input().split()))
  A = a1+a2+a3

  N = int(input())

  c = [False]*9

  for i in range(N):
    b = int(input())
    if b in A:
      c[A.index(b)] = True

  for i in range(3):
    if c[i] and c[3+i] and c[6+i]:
      return 'Yes'
    elif c[3*i] and c[3*i+1] and c[3*i+2]:
      return 'Yes'

  if c[0] and c[4] and c[8]:
    return 'Yes'
  elif c[2] and c[4] and c[6]:
    return 'Yes'

  return 'No'
print(f())

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    vii a(3, vi(3)), check(3, vi(3, 0));
    rep(i,3)
    rep(j,3) {
        cin >> a[i][j];
    }

    int n; cin >> n;
    int b; rep(i,n) {
        cin >> b;
        rep(j,3)rep(k,3) if(b == a[j][k]) check[j][k] = 1;
    }

    bool can = 0;
    rep(i,3) if(check[0][i] & check[1][i] & check[2][i]) can = 1;
    rep(i,3) if(check[i][0] & check[i][1] & check[i][2]) can = 1;
    if(check[0][0] & check[1][1] & check[2][2]) can = 1;
    if(check[0][2] & check[1][1] & check[2][0]) can = 1;

    if(can ) cout << "Yes"<< '\n';
    else cout << "No" << '\n';



//     printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll mkval(string s){
  if(s=="Vacant"){
    return 0;
  }else if(s=="Male"){
    return 1;
  }else{
    return 2;
  }
}
signed main(){
  ll n,now,left,right,m,fi;
  string s;
  cin >> n;
  cout << 0<<endl;
  cin >> s;
  now= mkval(s);
  if(now==0){
    return 0;
  }
  fi=now;
  left = 1;
  right = n;
  while(true){
    m = (left+right)/2;
    cout << m << endl;
    cin >> s;
    now = mkval(s);
    if(now==0){
      return 0;
    }
    if((m%2==1&&fi!=now)||(m%2==0&&fi==now)){
      left = m+1;
    }else{
      right = m;
    }
  }
}


Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

char c = 'z';
vector<string> a;

void solve(int n, string s) {
	if (n == 0) { a.pb(s); return; }
	string rs = s; reverse(all(rs));
	s += rs;
	int sz = s.size();
	vector<P> p; int cnt = 0;
	rep(i, sz) {
		if (s[i] == c) cnt++;
		else {
			if (cnt) {
				p.pb(P(i, cnt));
				cnt = 0;
			}
		}
	}
	if (cnt) p.pb(P(sz, cnt));
	if (cnt == sz) {
		rep(i, sz / 2) cout << c;
		cout << '\n';
		exit(0);
	}
	int ch = 0;
	for (P i : p) chmax(ch, i.second);
	for (P i : p) {
		if (i.second == ch && i.first >= sz / 2) {
			solve(n - 1, s.substr(i.first - sz / 2, sz / 2));
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	rep(i, n) chmin(c, s[i]);
	solve(k - 1, s);
	string ans = "";
	rep(i, n) ans += 'z';
	for (string t : a) {
		string rt = t; reverse(all(rt));
		t += rt;
		rep(i, n + 1) chmin(ans, t.substr(i, n));
	}
	cout << ans << '\n';
}

Measured memory_bytes: 12728
H,W = map(int,input().split())

S = H*W
ans = 10**10

hs = H//2
ws = W//2

for h in range(1,hs+1):
    a = h*W
    if (H-h)%2 == 0 or W%2 == 0:
        b = (S-a)//2
    else:
        b = min(H-h,W)*(max(H-h,W)//2)
    c = S-a-b
    d = max(a,b,c)-min(a,b,c)
    ans = min(ans,d)

for w in range(1,ws+1):
    a = H*w
    if (W-w)%2 == 0 or H%2 == 0:
        b = (S-a)//2
    else:
        b = min(W-w,H)*(max(W-w,H)//2)
    c = S-a-b
    d = max(a,b,c)-min(a,b,c)
    ans = min(ans,d)

print(ans)


Measured memory_bytes: 3064
import bisect

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

C = 0
for t in T:
    index = bisect.bisect_left(S, t)
    if index < len(S) and S[index] == t:
        C += 1

print(C)


Measured memory_bytes: 16740
N = int(input())
a = list(map(int, input().split()))
ans = [0] * N
a_max = max(a)
max_iter = len(bin(a_max)) - 2
i = 0
for i in range(max_iter+1):
    pow2 = 2 ** i
    count_1 = 0
    count_0 = 0
    for j in range(N):
        if a[j]>>i & 1:
            count_1 += 1
        else:
            count_0 += 1
            # ans[j] += 1 * pow2
    if count_1 % 2 == 0:
        #1 -> 1
        for j in range(N):
            if a[j]>>i & 1:
                ans[j] += 1 * pow2
    else:
        # 0-> 1
        for j in range(N):
            if not a[j]>>i & 1:
                ans[j] += 1 * pow2
print(*ans)
        

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

using card = pair<char, int>;

void print_arr(vector<card> &a){
    rep(i,a.size()-1){
        printf("%c%d ",a[i].first,a[i].second);
    }
    printf("%c%d\n",a[a.size()-1].first,a[a.size()-1].second);
}

vector<card> bubble_sort(vector<card> c){
    for(int i=0; i<c.size(); i++){
        for(int j=(int)c.size()-1; j>=i+1; j--){
            if(c[j].second < c[j-1].second){
                card temp = c[j];
                c[j] = c[j-1];
                c[j-1] = temp;
            }
        }
    }
    return c;
}

vector<card> selection_sort(vector<card> c){
    for(int i=0; i<c.size(); i++){
        int min_idx = i;
        for(int j=i; j<c.size(); j++){
            if(c[j].second < c[min_idx].second){
                min_idx = j;
            }
        }
        if(min_idx==i) continue;
        card temp = c[i];
        c[i] = c[min_idx];
        c[min_idx] = temp;
    }
    return c;
}

bool is_same_cards(vector<card> a, vector<card> b){
    if(a.size()!=b.size()) return false;
    rep(i, a.size()){
        if(a[i]!=b[i]) return false;
    }
    return true;
}


int main(){
    int n; cin >> n;
    vector<card> cards(n);
    rep(i,n){
        string s; cin >> s;
        cards[i].first = s[0];
        cards[i].second = s[1]-'0';
    }
    auto bubbled = bubble_sort(cards);
    print_arr(bubbled);
    cout << "Stable" << endl;
    auto selected = selection_sort(cards);
    print_arr(selected);
    cout << (is_same_cards(bubbled,selected) ? "Stable" : "Not stable") << endl;
    return 0;
}


Measured memory_bytes: 3244
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	ld n, m, d;
	cin >> n >> m >> d;
	ld ans = ((m - 1) / n) * ((n - d) / n);
	if (d > 0) {
		ans *= 2;
	}
	cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 300005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int segment_tree[MAX*4];
void update(int index,int l,int r,int ind,int val)
{
    if(ind<l||ind>r) return;
    if(l==r)
    {
        segment_tree[index]=val;
        return;
    }
    int m=(l+r)/2;
    update(index*2,l,m,ind,val);
    update(index*2+1,m+1,r,ind,val);
    segment_tree[index]=max(segment_tree[index*2],segment_tree[index*2+1]);
}
int query(int index,int l,int r,int L,int R)
{
    if(L>r||R<l) return 0;
    if(L<=l&&r<=R)
    {
        return segment_tree[index];
    }
    int m=(l+r)/2;
    int f=query(index*2,l,m,L,R);
    int s=query(index*2+1,m+1,r,L,R);
    return max(f,s);
}
int A[MAX];
int main()
{
    int n,i,k;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    for(i=n-1;i>=0;i--)
    {
        int current=query(1,0,300000,max(0,A[i]-k),min(300000,A[i]+k));
        update(1,0,300000,A[i],current+1);
    }
    printf("%d",segment_tree[1]);
    return 0;
}


Measured memory_bytes: 9092
#include <stdio.h>

int main(void){
	int a , b, c;
	char buf[256];
	
	fgets(buf,256,stdin);
	sscanf(buf,"%d %d %d",&a, &b, &c);
	
	int max = a;
	if(b>max) max = b;
	if(c>max) max = c;
	printf("%d\n",a+b+c-max);
}

Measured memory_bytes: 128
#include <iostream>
 int main() {
  int H, W;
  while (1) {
   std::cin >> H >> W;
   if (H == 0 && W == 0) break;
   for (int i = 0; i < H; i++) {
     for (int j = 0; j < W; j++) {
       std::cout << "#";
     }
     std::cout <<std::endl; 
   }
   std::cout <<std::endl;
  }


return 0;


}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
using namespace std;
int main()
{
        int n,rep = 0;
        cin >> n;
        vector<int> p(n);
        for (int i = 0; i < n; i++) {
                cin >> p[i];
                if (p[i] != i + 1)
                        rep++;
        }
        if (rep > 2)
                cout << "NO" << endl;
        else    
                cout << "YES" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //std::vector<int> v(5);
  int n,m,c; cin>>n>>m>>c;
  std::vector<int> b(m);
  //std::vector<int> a(m);
  int cnt = 0;
  rep(i,m) cin>>b[i];
  rep(i,n) {
    int ans = 0;
    rep(j,m) {
      int num; cin>>num;
      ans += (b[j]*num);
    }
    if ((ans + c) > 0) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 504
import sys
import math
import bisect

def main():
    n = int(input())
    A = [0] * (n + 1)
    m = 0
    while (m + 1) ** 2 <= n:
        m = m + 1
    for x in range(1, m + 1):
        for y in range(1, m + 1):
            for z in range(1, m + 1):
                val = x*x + y*y + z*z + x*y + y*z + z*x
                if val >= 1 and val <= n:
                    A[val] += 1
    for i in range(1, n + 1):
        print(A[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 9212
import numpy as np
N=int(input())
la=list(map(int,input().split()))
lan=np.array(la)
count=0
while(1):
    if(np.any(lan%2==1)):
        lan=lan[~(lan%2==1)]
    if(np.any(lan%2==0)):
        lan=lan/2
        count=count+len(lan)
    else:
        break;
print(count)

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

int main() {
    int n, k, x, sum = 0;
    cin >>  n >> k;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x > abs(k - x)) {
            sum += abs(k - x) * 2;
        } else {
            sum += x * 2;
        }
    }
    cout << sum << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
int main(){
    int n;cin>>n;
    vector<P> v;
    for(int i=0;i<n;i++){
        ll a;cin>>a;
        v.push_back(P(a,i));
    }
    sort(v.begin(),v.end(),greater<P>());
    ll mi=INF;
    ll ans[100010]={};
    v.push_back(P(0LL,0LL));
    for(int i=0;i<n;i++){
        mi=min(v[i].second,mi);
        ans[mi]+=(i+1)*(v[i].first-v[i+1].first);
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);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 SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}



const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
int main() {
    IN(ll, n);
    COUT(n*(n-1)/2);
}


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

bool is_valid(ll num)
{
    unordered_set<int> num_set ={3,5,7};
    while (num>0)
    {
        int now = num%10;
        num/= 10;
        if(num_set.count(now)>0) num_set.erase(now);
    }
    return num_set.size() == 0;
}

int cnt=0;
int N;
int main()
{
    int N;
    cin >> N;
    vector<ll> cands={0};
    int cnt = 0;
    for(;;)
    {
        vector<ll> new_cands;
        for (auto cand: cands)
        {
            for (auto n: {3,5,7})
            {
                long long now = cand*10+n;
                if (now <= N)
                    new_cands.push_back(now);
            }
        }
        swap(cands, new_cands);
        for (auto cand: cands)
            if (is_valid(cand))
                ++cnt;
        if (cands.size() == 0) break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>
int main()
{
	char c,s[105],t[105];
	int i,j,n,k;
	k=0;
	scanf("%s",&s);
	scanf("%s",&t);
	n=strlen(s);
	for(i=0;i<n;i++)
	{
		if(strcmp(s,t)==0)
		{
			k=1;break;	
		}
		c=s[n-1];
		for(j=n-2;j>=0;j--)
		s[j+1]=s[j];
		s[0]=c;
	}
	if(k==0)
	printf("No\n");
	else
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
n = int(input())

p = list(map(int,input().split(' ')))

c = 0

for i in range(1, len(p)-1):
  f = p[i-1]
  s = p[i]
  t = p[i+1]
  ma = max(f,t)
  mi = min(f,t)
  if s > mi and s < ma:
    c += 1

print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
using namespace std;
int main(){
	int ban, val, pos = 0, tmp, i, sd = 0;
	int borad[1000], masu[1000] = {0};

	while (cin >> ban >> val)
	{
		pos = 0;
		if (ban == 0 && val == 0)break;
		memset(masu, 0, sizeof(masu));
		memset(borad, 0, sizeof(borad));
		for (i = 0; i < ban; i++)
			cin >> borad[i];
		for (i = 0; i < val; i++)
			cin >> masu[i];
		for (i = 0; i < val; i++)
		{
			if (pos >= ban)break;
			pos += masu[i];	
			pos += borad[pos];
		}

		cout << i << endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  int ans = 0;
  for(int i=0;i<N;++i){
    if(i%2==1) continue;
    if(a[i]%2==1) ans++;
  }
  cout<<ans<<endl;
}



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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

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

    int maxk = (n+1)/2;

    if(k <= maxk) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;
    cin >> a;
    
    int b;
    cin >> b;
    
    if(a == b) cout << "a == b" << endl;
    
    else if(a > b) cout << "a > b" << endl;
    
    else  cout << "a < b" << endl;
    
    return 0;
    
}


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

int checkprime(int x){
    for(int i=2;i<=x/2;i++){
        if(x%i==0)
        return 0;
    }
    return 1;
}

int main(){
    int x;
    cin>>x;
    while(1){
        int temp=checkprime(x);
        if(temp)
        break;
        x++;
    }
    cout<<x;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, m, x; cin >> n >> m >> x;
        set<int> s;
        while (m--) {
                int w; cin >> w;
                s.emplace(w);
        }

        int ans = 1e9, cnt = 0;
        for (int i = x + 1; i <= n; i++) {
                if (s.count(i)) cnt++;
        }

        ans = cnt;
        cnt = 0;
        for (int i = x - 1; i >= 0; i--) {
                if (s.count(i)) cnt++;
        }

        cout << min(ans, cnt);
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> a(n);
	RBF(ai, a) {
		cin >> ai;
	}

	int ans = 0, i = 1;
	RBF(ai, a) {
		if (ai == i) {
			i++;
		}
		else {
			ans++;
		}
	}

	if (i == 1) {
		col(-1);
	}
	else {
		col(ans);
	}

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i=0;i<n;i++){cin >> a[i];}
    for(int j=0;j<n-1;j++){
        int tmp = a[j];
        for(int k=j;k<n;k++){
            if(abs(a[k]-tmp) > ans){
                ans = abs(a[k]-tmp);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    N, M = inpl()
    AB = [inpl() for _ in range(M)]

    edges = {}
    for a, b in AB:
        if a not in edges:
            edges[a] = []
        if b not in edges:
            edges[b] = []

        edges[a].append(b)
        edges[b].append(a)

    Q = deque()
    Q.append(1)
    assigned = set()
    assigned.add(1)
    cost = {}
    cost[1] = 0
    previous_v = {}

    while Q:
        v = Q.popleft()
        for nv in edges[v]:
            if nv not in assigned:
                assigned.add(nv)
                Q.append(nv)

            tmp = cost[v] + 1
            if nv not in cost:
                cost[nv] = tmp
                previous_v[nv] = v
            elif tmp < cost[nv]:
                cost[nv] = tmp
                previous_v[nv] = v

    for i in range(2, N + 1):
        if i not in previous_v:
            print("No")
            break
    else:
        print("Yes")
        for i in range(2, N + 1):
            print(previous_v[i])

    return


if __name__ == '__main__':
    main()


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

int main()
{
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool flag = true;
    rep(i, 0, s.size()){
        if(i != a && s[i] < '0' || '9' < s[i]) flag = false;
        if(i == a && s[i] != '-') flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define EPS 1e-10
using namespace std;
typedef long long ll;
struct Point{
	double x,y;
	Point(double x = 0.0,double y = 0.0): x(x),y(y) {}
	Point operator + (Point p){
		return Point(x + p.x,y + p.y);
	}
	Point operator - (Point p){
		return Point(x - p.x,y - p.y);
	}
	Point operator * (double lambda){
		return Point(x * lambda,y * lambda);
	}
	Point operator / (double lambda){
		return Point(x / lambda,y / lambda);
	}
	double norm(){
		return x * x + y * y;
	}
	double abs_(){
		return sqrt(norm());
	}
	bool operator == (const Point &p)const
	{
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
	bool operator < (const Point &p)const
	{
		if(abs(x - p.x) < EPS) return y - p.y < -EPS;
		else return x - p.x < EPS;
	}
};
typedef Point Vector;
struct Segment{
	Point p1,p2;
	Segment(Point p1 = Point(),Point p2 = Point()): p1(p1),p2(p2) {}
};
typedef Segment Line;
struct Circle{
	Point c;
	double r;
	Circle(Point c = Point(),double r = 0.0): c(c),r(r) {}
};
typedef vector<Point> Polygon;
int coTanNum(Circle a,Circle b){
	if(a.r < b.r) swap(a,b);
	double d = (a.c - b.c).abs_(),rdif = a.r - b.r,rsum = a.r + b.r;
	if(d < rdif - EPS) return 0;
	if(abs(d - rdif) < EPS) return 1;
	if(d < rsum - EPS) return 2;
	if(abs(d - rsum) < EPS) return 3;
	return 4;
}
Circle a,b;
int main(){
	scanf("%lf%lf%lf%lf%lf%lf",&a.c.x,&a.c.y,&a.r,&b.c.x,&b.c.y,&b.r);
	printf("%d\n",coTanNum(a,b));
	return 0;
}



Measured memory_bytes: 3252
a, b, k = gets.split.map(&:to_i)

k.times do |i|
  if i.even?
    a -= 1 if a.odd?

    l = a / 2
    a -= l
    b += l
  else
    b -= 1 if b.odd?

    l = b / 2
    b -= l
    a += l
  end
end

puts "#{a} #{b}"

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

int H,W;
char fie[11][11];
int num[11][11];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
char dc[]="URDL";
int N;
typedef pair<int,int> P;

set<P> used;
vector<char> ans;

int check(int st,int &x,int &y,int d){
  while( 0 <= x && x < W && 0 <= y && y < H ){
    if( 0 <= num[x][y] && num[x][y] < N &&
        ( st & (1<<num[x][y]) ) == 0 ){
      return num[x][y];
    }
    x += dx[d]; y += dy[d];
  }
  return -1;
}

bool solve(int st,int x,int y,int d){

  //cout << bitset<30>(st)<< " " << x << " "<< y << " " << d << endl;
  if( st == (1<<N)-1 ) {
    for(int i=0;i<(int)ans.size();i++) cout << ans[i];
    cout << endl;
    return true;
  }

  for(int i=3;i<6;i++){
    int nd = (i+d)%4;
    int id;
    int nx = x, ny = y;
    if( (id = check( st, nx, ny, nd )) != -1 ){
      int nst = st | (1<<id);
      ans.push_back( dc[nd] );      
      if( solve( nst, nx, ny, nd ) ) return true;
      ans.pop_back();
    }
  }
  return false;

}

int main(){
  cin >> H >> W;
  N =0;
  memset(num,-1,sizeof(num));
  int sx,sy,sd;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> fie[j][i];
      if( fie[j][i] == 'o' ) num[j][i] = N++;
      if( fie[j][i] == 'U' ){ sx = j; sy = i; sd = 0; }
      if( fie[j][i] == 'R' ){ sx = j; sy = i; sd = 1; }
      if( fie[j][i] == 'D' ){ sx = j; sy = i; sd = 2; }
      if( fie[j][i] == 'L' ){ sx = j; sy = i; sd = 3; }
    }
  }
  assert( solve( 0, sx, sy, sd ) );

  

}

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

using namespace std;


int main() {

    int a,b,soma, sub, prod, res;
    cin >> a;
    cin >> b;

    soma = a + b;
    sub = a - b;
    prod = a * b;
    
    if(soma > sub && soma > prod) {
        res = soma;
    }
    else if(sub > soma && sub > prod) {
        res = sub;
    }
    else if(prod > sub && prod > soma) {
        res = prod;
    }
    else if(soma == sub && soma == prod) {
        res = soma;
    }
        
    cout << res << '\n';

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

/*実行開始からの経過時間を表すよ。これで1900msまで動作を繰り返すよ。
while (clock() < 1900000) { ; }
*/

/*まだ使えないテクニックのメモだよ。
for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ
*/


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

	int x = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o') { x++; }
	}

	if (s.size() < 15) {
		x += 15 - s.size();
	}

	TOF(x >= 8);

	return 0;
}

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

int main()
{
  int A,B,C,K;
  cin >> A >> B >> C >> K;

  int sum;
  sum = ( K <= A )
    ? K
    : ( K <= A+B )
    ? A
    : A-(K-(A+B));
  
  cout << sum;
  return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin);
    int a,c;
    cin>>a>>c;
    cout<<2*c-a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;


void solve(long long N, std::vector<long long> A){
    sort(A.begin(), A.end());
    ll ans = 0;
    loop (N / 2, i) {
        ll v = A[i * 2] + A[i * 2 + 1];
        ans += max(v, -v);
    }
    if (N % 2) ans += A[N - 1];
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        int val;
        cin >> val;
        v.push_back(val);
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int x = 0; x < n; ++x){
        for(int y = x+1; y < n; ++y){
            for (int z = y+1; z < n; ++z) {
                if (v[z] >= v[y] + v[x]) break;
                res += 1;
          }
      }
    }
    cout << res;
    return 0;
}




Measured memory_bytes: 384
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, p, r[50], d[50][50]; bool a[50][30];
int main() {
	while (true) {
		scanf("%d", &n);
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			scanf("%d", &r[i]);
			for (int j = 0; j < 30; j++) {
				a[i][j] = false;
			}
			for (int j = 0; j < r[i]; j++) {
				scanf("%d", &p); a[i][p - 1] = true;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = 9999999;
			}
		}
		for (int i = 0; i < n; i++) {
			queue<pair<int, int> > que; que.push(make_pair(0, i)); d[i][i] = 0;
			while (!que.empty()) {
				pair<int, int> state = que.front(); que.pop();
				int dist = -state.first;
				int node = state.second;
				for (int j = 0; j < n; j++) {
					for (int k = dist; k < 30; k++) {
						if (a[node][k] && a[j][k]) {
							if (d[i][j] > k) {
								d[i][j] = k; que.push(make_pair(-k, j));
							}
						}
					}
				}
			}
		}
		int ret = 9999999;
		for (int i = 0; i < n; i++) {
			int res = 0;
			for (int j = 0; j < n; j++) {
				res = max(res, d[j][i]);
			}
			ret = min(ret, res);
		}
		printf("%d\n", ret == 9999999 ? -1 : ret + 1);
	}
	return 0;
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  mint ans = 0;
  for(int i = 0; i < 60; ++i){
    mint cnt[2] = {};
    for(auto a : A)
      cnt[(a>>i)&1] += 1;
    ans += cnt[0]*cnt[1]*mint(1LL<<i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2*1e5;
const int mod = 1e9+7;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    vll c(n);
    c[0] = a[0];
    REP(i,n) c[i] = c[i-1] + a[i];
    vll c_pos = c;
    ll accum = 0;
    ll ans_pos = 0;
    // はじめが正
    rep(i,n) {
        if (i&1) {
            c_pos[i] += accum;
            if (c_pos[i] >= 0) {
                ans_pos += c_pos[i]+1;
                accum -= c_pos[i]+1;
            }
        }
        if (!(i&1)) {
            c_pos[i] += accum;
            if (c_pos[i] <= 0) {
                ans_pos += -c_pos[i]+1;
                accum += -c_pos[i]+1;
            }
        }
    }
    // はじめが負
    vll c_neg = c;
    accum = 0;
    ll ans_neg = 0;
    rep(i,n) {
        if (i&1) {
            c_neg[i] += accum;
            if (c_neg[i] <= 0) {
                ans_neg += -c_neg[i]+1;
                accum += -c_neg[i]+1;
            }
        }
        if (!(i&1)) {
            c_neg[i] += accum;
            if (c_neg[i] >= 0) {
                ans_neg += c_neg[i]+1;
                accum -= c_neg[i]+1;
            }
        }
    }
    cout << min(ans_pos,ans_neg) << endl;
}

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

using namespace std;
// using P = pair<long, long>;
using P = pair<double, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

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

  long n, b, c;
  cin >> n >> b >> c;

  if (n+b+c >= 22) {
    cout << "bust" << endl;
  } else {
        cout << "win" << endl;
  }

}


Measured memory_bytes: 256