akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
using namespace std;
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;
}

int N, A, B, C;
vi L(10);
int dfs(int i, int a, int b, int c) {
    if (i >= N) {
        if (min({a, b, c}) > 0) {
            return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        } else {
            return INF;
        }
    }
    int ret0 = dfs(i+1, a, b, c);
    int ret1 = dfs(i+1, a+L[i], b, c) + 10;
    int ret2 = dfs(i+1, a, b+L[i], c) + 10;
    int ret3 = dfs(i+1, a, b, c+L[i]) + 10;
    return min({ret0, ret1, ret2, ret3});
}
int main() {
  cin >> N >> A >> B >> C; 
  rep(i, 0, N) {
      cin >> L[i];
  }
  cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
n=input()
K=int(input())
m=len(n)

DP=[[[0]*(K+2) for _ in range(2)] for _ in range(m+1)]
DP[0][0][0]=1

for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(K+1):
            for k in range(num+1):
                if k==0:
                    DP[i][flag or k<num][j] +=DP[i-1][flag][j]
                else:
                    DP[i][flag or k<num][j+1] +=DP[i-1][flag][j]

print(DP[-1][0][K]+DP[-1][1][K])

Measured memory_bytes: 40944
import java.util.Scanner;

public class Main {

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

			if (a >= 30) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 35784
import numpy as np
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
value=np.zeros((n+1,w+1),dtype=int)
for i in range(n):
    wei=wv[i][0]
    value[i+1][:wei]=value[i][:wei]
    # np.maximum([1,-3,2],0) == [1,0,2]
    value[i+1][wei:]=np.maximum(value[i][wei:],value[i][:-wei]+wv[i][1])
# print(value)
print(value[n][w])

Measured memory_bytes: 92220
// Greatest Common Divisor
#include <stdio.h>

int gcd(int, int);

int main(){
    int x, y, z;
    scanf("%d%d", &x, &y);
    
    z = gcd(x, y); // 最大公約数を求める
    
    printf("%d\n", z);  // 最大公約数を表示
}

int gcd(int x, int y){
    int z, str;
    if(x < y) { // x > y として計算するため
        str = y; y = x; x = str; // xとyを交換
    }
    // ユークリッドの互除法を実行 //
    while(y > 0){
        z = x % y; // xをyで割った余りを求める
        
        // 次のループで新しく割り算を実行するため新しくxとyをセットする
        x = y;
        y = z;
    }
    return x;
}


Measured memory_bytes: 2072
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, a, sum int
	fmt.Scan(&n)
	s := make([]int, n)
	for i := range s {
		fmt.Scan(&a)
		sum += a
		s[i] = sum
	}

	ans := math.MaxInt32
	for i := 0; i < n-1; i++ {
		ans = min(ans, abs(2*s[i]-s[n-1]))
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 6440
N = int(input())
A = list(map(int, input().split()))

abs_list = [abs(a) for a in A]
count = 0
ans = 0

for a in A:
    if a < 0:
        count += 1
        

if count % 2 == 0:
    for i in range(N):
        ans += abs_list[i]
else:
    for i in range(N):
        ans += abs_list[i]
    ans -= 2*min(abs_list)

print(ans)

Measured memory_bytes: 14224
package main

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

type MyScanner struct {
	sc *bufio.Scanner
}

type MyWriter struct {
	stdout io.Writer
}

type MyPut interface{}

func getScanner(fp io.Reader) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 500001), 500000)
	return sc
}

func getHugeScanner(fp io.Reader, size int) *bufio.Scanner {
	sc := bufio.NewScanner(fp)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, size), size)
	return sc
}

func (mysc *MyScanner)String() string {
	mysc.sc.Scan()
	return mysc.sc.Text()
}

func (mysc *MyScanner)Int() int {
	i, _ := strconv.Atoi(mysc.String())
	return i
}

func (mysc *MyScanner)Int64() int64 {
	i, _ := strconv.ParseInt(mysc.String(), 10, 64)
	return i
}

func (mysc *MyScanner)Float64() float64 {
	i, _ := strconv.ParseFloat(mysc.String(), 64)
	return i
}

func (mw MyWriter)Puts(v MyPut) {
	_, _ = fmt.Fprintf(mw.stdout, "%v\n", v)
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := MyScanner{getScanner(stdin)}
	mw := MyWriter{stdout}

	s := sc.String()
	t := sc.String()

	ans := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			ans++
		}
	}
	mw.Puts(ans)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

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

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

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()

int main(){
  ll a,b,x;
  cin >> a >> b >> x;
  if(a>0){cout << b/x-(a-1)/x;}
  else cout << b/x+1;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    for(int i=1;;++i){
        if(in()==0){
            cout<<i<<endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3580
x,y;
main(){
char c;
for(;scanf("%d %c %d",&x,&c,&y),c!='?';){
switch(c){
case '+':x+=y;break;
case '-':x-=y;break;
case '*':x*=y;break;
case '/':x/=y;break;
}
printf("%d\n",x);
}
}

Measured memory_bytes: 1824
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    L, R = map(int, input().split())

    ans = 200000000

    for a in range(L, R+1):
        for b in range(a+1, R+1):
            if a * b % 2019 < ans:
                ans = a * b % 2019
                if ans == 0:
                    print(ans)
                    sys.exit()

    print(ans)


if __name__ == '__main__':
    main()



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

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

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

    int minH = (int)1e9 + 1;
    for(int i = 0; i < N; i++)
    {
        minH = min(minH, H[i]);
    }

    for(int i = 0; i < N; i++)
    {
        H[i] -= minH;
    }

    vector<int> right(N);
    right[N - 1] = H[N - 1];

    for(int i = N - 2; i >= 0; i--)
    {
        right[i] = min(right[i + 1], H[i]);
    }

    bool flag = false;
    for(int i = 0; i < N - 1; i++)
    {
        if(H[i] - right[i + 1] >= 2)
        {
            flag = true;
            break;
        }
    }

    cout << (flag ? "No" : "Yes") << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<LP> v(N);
    rep(i, N){
        ll x, y; cin >> x >> y;
        v[i] = make_pair(x, y);
    }
    sort(all(v));
    map<LP, ll> m;
    rep(i, N){
        Rep(j, i+1, N){
            m[make_pair(v[j].first-v[i].first, v[j].second-v[i].second)]++;
        }
    }

    ll ma=0;
    for(auto a: m){
        ma = max(ma, a.second);
    }

    cout << N - ma << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int n,s,ct;
int main()
{
    cin>>n>>s;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            if(s-i-j>=0 && s-i-j<=n) ct++;
    cout<<ct<<endl;
    return 0;
}

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

using namespace std;

int main(){
    int A, B, K;
    cin>>A>>B;
    if((A+B)%2==0){
        K=(A+B)/2;
        cout<<K<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


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

int N;
ll M;
vector<ll> A;

bool judge(ll x) {
    ll cnt = 0;
    for (int i=0; i<N; i++) {
        cnt += N-(int)(lower_bound(A.begin(), A.end(), x-A[i])-A.begin());
    }
    return cnt>=M;
}

ll binary_search() {
    ll l = 0, r = 10000000000;
    while (l<=r) {
        ll mid = (l+r)/2;
        if (judge(mid)) l = mid+1;
        else r = mid-1;
    }
    return r;
}

int main() {
    cin >> N >> M;
    for (int i=0; i<N; i++) {
        int Ai; cin >> Ai;
        A.push_back(Ai);
    }
    sort(A.begin(), A.end());
    
    vector<ll> acc = {0};
    for (int i=0; i<N; i++) acc.push_back(acc[acc.size()-1]+A[i]);
    
    ll border = binary_search();
    ll cnt = 0, ans = 0;
    
    for (int i=0; i<N; i++) {
        int idx = lower_bound(A.begin(), A.end(), border-A[i]+1)-A.begin();
        cnt += N-idx;
        ans += A[i]*(N-idx)+acc[N]-acc[idx];
    }
    
    ans += border*(M-cnt);
    
    cout << ans << endl;
}


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

int main() {
  int N, Y;
  cin >> N >> Y;
  int x,y,z;
  int answer=0;
  
  for(x = Y/10000; x>=0; x--){
   for(y = (Y-10000*x)/5000; y>=0; y--){
     z = N - x - y;
  		if(Y == 10000*x + 5000*y + 1000*z){
        	answer = 1;
          	break;
        }
   }
    if(answer == 1) break;
  }
  
  if(answer == 0){
  	cout << "-1 -1 -1" << endl;
    return 0;
  }
    
  cout << x <<" "<< y <<" "<<z << endl;
  return 0;
}


Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 14.08.2020 01:03:59
**/

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

int main() {

    int n;
    cin >> n;
    vector<tuple<int,int>> rob(n);
    int x,l;
    rep(i,n){
        cin >> x >> l;
        rob.at(i)=make_tuple(x+l,x-l);
    }
    sort(rob.begin(),rob.end());

    int count=1,right=get<0>(rob.at(0));
    for(int i=1; i<n; i++){
        if(get<1>(rob.at(i))>=right){
            count++;
            right=get<0>(rob.at(i));
        }
    }
    
    cout << count << endl;

    return 0;
}

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

int main(){

	int max=-1, aux, sum,j,k,i;
	int ar[5];

	scanf("%d%d%d%d",&ar[0],&ar[1],&ar[2],&k);

	for (int i = 0; i < 3; ++i)
		if(ar[i]>max){
			max=ar[i];
			j=i;
		}

	sum=max<<k;
	i=0;
	while(i<3){
		if(i!=j)
			sum+=ar[i];
		i++;
	}
		
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a : i32 = read();
    let b : i32 = read();

    let ans = if (a * b) % 2 == 0 {
        "Even"
    } else {
        "Odd"
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 + -dy
y3 = y2 + dx
x4 = x3 + -dx
y4 = y3 + -dy

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10 ** 9)
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = {i: False for i in range(N+1)}
for m in range(M):
    a = ir()
    A[a] = True
C = [0 for _ in range(N+1)]
C[0] = 1
for i in range(len(C)):
    if A[i]:
        continue
    if i >= 2:
        C[i] += C[i-2]
        C[i] += C[i-1]
        C[i] %= 1000000007
    elif i >= 1:
        C[i] += C[i-1]
        C[i] %= 1000000007

print(C[N] % 1000000007)


Measured memory_bytes: 16212
n = int(input())
s = list(map(int,input().split()))
num = list(i+1 for i in range(n))
tp = list(zip(s,num))
tp1 =[]
for i in tp :
  tp1.append(list(i))
tp1 = sorted(tp1)
tp1 =[tp1[i][1] for i in range(n)]
print(*tp1)

Measured memory_bytes: 31332
N = int(input())

cnt = [0] * N

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = x * x + y * y + z * z + x * y + y * z + z * x
            if tmp <= N:
                cnt[tmp-1] += 1

for i in range(N):
    print(cnt[i])

Measured memory_bytes: 74848
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;

#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--)
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, MOD = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const ll N = 100009;

vector<vector<ll> > mul(vector<vector<ll> > mat1, vector<vector<ll> > mat2, int row)
    {
        vector< vector<ll> > result(row, vector<ll>(5, 0));
        for(ll i = 0; i < row; i++)
            for(ll j = 0; j < 5; j++) {
                for(ll k = 0; k < 5; k++) {
                    result[i][j] = ((result[i][j]%MOD) + (mat1[i][k]%MOD) * (mat2[k][j]%MOD)) % MOD;
                }
            }
        return result;
    }
int main()
{
  fast();

  ll t=1;
  //cin >> t;
  while(t--)
  {
    ll n;
    cin >> n;
    ll arr[n];
    f(i,0,n)
      cin >> arr[i];
    sort(arr, arr + n);
    f(i,1,n)
    {
      if(arr[i] == arr[i-1])
      {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES";
  }
  return 0;
}


Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val k = scanner.nextInt()
    val s = scanner.nextInt()
    var answer = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (z in 0..k) {
                answer++
            }
        }
    }
    print(answer)

}

Measured memory_bytes: 31376
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n;
    cin>>n;
    svec s(n);
    rep(i,n)cin>>s[i];
    mat v(n,vec(26,0));
    vec ans(26,LINF);
    rep(i,n)rep(j,s[i].size())v[i][s[i][j]-'a']++;
    rep(i,n)rep(j,26){
        ans[j]=min(ans[j],v[i][j]);
    }
    rep(i,26){
        rep(j,ans[i])cout<<(char)('a'+i);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;
//ll int freq[100001];
ll int bigPower(ll int x, unsigned ll int y, ll int p)
{
    ll int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
    // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
void findAns()
{
    int x, n;
    cin >> x >> n;
    int a;
    unordered_set<int> data;

    for (int i = 0; i < n; i++)
    {
        cin >> a;
        data.insert(a);
    }
    int minAns = 2000;
    int ans;
    for (int i = 0; i < 110; i++)
    {
        if (data.find(i) == data.end())
        {
            if (abs(x - i) < minAns)
                ans = i, minAns = abs(x - i);
        }
    }

    cout << ans;


}
int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("o1.txt", "w", stdout);
// #endif

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

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

int main(void){
int n,s;
int sum=0,start=0,end=0,num=1;
int swl=0;
cin>>n>>s;
vector<int> a;
a.resize(n);
for(int i=0;i<n;i++){
 cin>>a[i];
}
sum=a[0];
while(start<n){
 //cout<<start<<" to "<<end<<" sum="<<sum<<" num="<<num<<endl;
 if(sum>=s){
  if(num<swl||swl==0)swl=num;
 sum-=a[start];
 start++;
 num--;
 }else if(end<n-1){
 end++;
 sum+=a[end];
 num++;
 }else break;
}


cout<<swl<<endl;
return 0;
}


Measured memory_bytes: 3136
import math
a,b,h,m = map(int, input().split())

ans = 0
a_h = (h+m/60)/12*2*math.pi
a_m = m/60*2*math.pi

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(a_h-a_m))))


Measured memory_bytes: 9472
#include <stdio.h>

#define NMAX 1000001

int parent(int i){
  return i/2;
}

int left(int i){
  return i * 2;
}

int right(int i){
  return i * 2 + 1;
}

int main(void){
  int H,i,A[NMAX];

  scanf("%d",&H);

  for(i = 1;i <= H;i++){
    scanf("%d",&A[i]);
  }
  for(i = 1;i <= H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1){
      printf("parent key = %d, ",A[parent(i)]);
    }
    if(left(i) <= H){
      printf("left key = %d, ",A[left(i)]);
    }
    if(right(i) <= H){
      printf("right key = %d, ",A[right(i)]);
    }printf("\n");
  }
  return 0;   
}



Measured memory_bytes: 2040
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
long A[100005];

int main() {
    scanf("%d", &N);
    for (int i = 0; i != N; ++i)
        scanf("%ld", &A[i]);
    sort(A, A + N);
    int l = N - 1;
    while (l && A[l] != A[l - 1]) --l;
    if (l <= 1) {
        puts("0"); return 0;
    }
    int r = l - 2;
    while (r && A[r] != A[r - 1]) --r;
    if (r == 0) {
        puts("0"); return 0;
    }
    long rect = A[l] * A[r];
    printf("%ld\n", rect);
    return 0;
}

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

using namespace std;

int main(){
	string n;
	cin>>n;
	if(n[n.size() - 1] - '0' == 2 || n[n.size() - 1] - '0' == 4 || n[n.size() - 1] - '0' == 5 || n[n.size() - 1] - '0' == 7 || n[n.size() - 1] - '0' == 9) cout<<"hon"<<endl;
	else if(n[n.size() - 1] - '0' == 0 || n[n.size() - 1] - '0' == 1 || n[n.size() - 1] - '0' == 6 || n[n.size() - 1] - '0' == 8) cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int a, b, m, x, y, z;
std::vector<int> va, vb, res;
int main() {
    cin >> a >> b >> m;
    va.assign(a, 0);
    vb.assign(b, 0);
    for (int i = 0; i < a; i++) {
        cin >> va[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> vb[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> x >> y >> z;
        res.push_back(va[--x]+vb[--y] - z);
    }
    res.push_back(*std::min_element(va.begin(), va.end()) + *std::min_element(vb.begin(), vb.end()));
    std::cout << *std::min_element(res.begin(), res.end()) << std::endl;
    
    
}

Measured memory_bytes: 1660
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
   int n; cin>>n;
   vector<int> a(n);
   vector<int> b(n);
   vector<int> c(n);
   int ans=0;
   for(int i=0;i<n;i++) cin>>a[i];
   for(int i=0;i<n;i++) cin>>b[i];
   for(int i=0;i<n-1;i++) cin>>c[i];
   for(int i=0;i<n;i++){
      if(i==0) ans+=b[a[i]-1];
      else{
         if(a[i]==a[i-1]+1){
            ans=ans+b[a[i]-1]+c[a[i-1]-1];
         }
         else ans+=b[a[i]-1];
      }
      //cout<<ans<<endl;
   }
   //cout<<b[a[1]]<<b[a[1]-1]<<endl;
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
// Program to print BFS and DFS traversal from a given 
// source vertex. BFS(int s) and DFS traverses vertices 
// reachable from s. 

#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<cstdio>
#define MAX 10000001
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>

#include<cstdlib>
#include<cassert>
#include<unordered_map>
#define ll long long
#define ld long double
#define lli long long int
#define pb push_back
#define INF 1000000000
#define mod 1000000007
#define MOD 1000000007
//#define mp make_pair
#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<lli,lli>
#define vi vector<lli>
#define vvi vector<lli>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define print(x) printf("%lli\n",x);
#define print2(x,y) printf("%lli %lli\n",x,y);
#define print3(x,y,z) printf("%lli %lli %lli\n",x,y,z);

#define scan(x) scanf("%lld",&x);
#define scan2(x,y) scanf("%lld %lld",&x,&y);
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.push_back(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   printf("%lli ",a[i]); printf("\n");
#define printvector(a,n) for(lli i=0;i<n;i++)   printf("%lli ",a[i]); printf("\n");

#define YES printf("YES\n");
#define Yes printf("Yes\n");
#define yes printf("yes\n");
#define NO  printf("NO\n");
#define No  printf("No\n");
#define no  printf("no\n");

#define endl '\n'

#define deb(x) cout<<#x<<" "<<x<<endl;

void addEdge(vector<lli>adj[],lli u, lli v) 
{ 
	adj[u].push_back(v); // Add v to u’s list. 
	//adj[v].push_back(u);
} 

void DFS(vector<lli>adj[],lli total_vertex,lli source,map<lli,bool>&mp,map<lli,bool>pre) 
{ 
    lli V = total_vertex;
    lli s = source;
    bool visited[V]={0};
    
    stack<lli> stack;
    visited[s]=true;
    stack.push(s);
    vector<lli>cr;
    
    while (!stack.empty()) 
	{ 
	// Pop a vertex from stack and print it 
	s = stack.top(); 
	if(pre[s]==true){
			for(auto xt : cr)
			    mp[xt]=true;
			}
        cr.pb(s);
        stack.pop(); 
		for (auto i : adj[s]) 
		{ 
			if (!visited[i]) 
			{ 
				visited[i] = true; 
				stack.push(i); 
			} 
		} 
	}
}

int main() 
{ 
    lli t=1;
    //cin>>t;
    while(t--){
        string s;
        cin>>s;
        map<string,int>mp;
        mp["SUN"]=7;
        mp["MON"]=6;
        mp["TUE"]=5;
        mp["WED"]=4;
        mp["THU"]=3;
        mp["FRI"]=2;
        mp["SAT"]=1;
        cout<<mp[s]<<endl;
    }
return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if(s.size()==3)
		reverse(s.begin(),s.end());
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
ll a[1000000];
ll f[1000000];
int main()
{
	int n;ll k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>f[i];
	ll ok=1e12;
	ll ng=-1;
	sort(a,a+n);
	sort(f,f+n);
	reverse(f,f+n);
	//a[i]をf[i]に対応付けたとき可能な最小値をにぶたん
	while(ok-ng>1)
	{
		ll mid=(ok+ng)/2;
		ll cnt=0;
		ll m;
		for(int i=0;i<n;i++)
		{
			m=mid/f[i];
			cnt+=max(0LL,a[i]-m);
		}
		if(cnt>k)
			ng=mid;
		else
			ok=mid;
	}
	cout<<ok<<endl;
	return 0;
}

Measured memory_bytes: 5888
/*****Enigma_27*****/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<ll,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,t=1,ans=0,flag=0,x,y;
int main()
{   ios
	char a[105][105];
	for(i=0;i<105;i++) for(j=0;j<105;j++) a[i][j]='#';
	cin>>x>>y;
	for(i=1;i<=x;i++) for(j=1;j<=y;j++) cin>>a[i][j];
	for(i=0;i<=x+1;i++) {for(j=0;j<=y+1;j++) cout<<a[i][j];cout<<endl;}


	return 0;
}


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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); ++i){
    if(i%2){
      if(s[i] == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(s[i] == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

int main()
{
  auto i = 0;
  auto v = std::vector<int>{};

  while (std::cin >> i)
  {
    v.push_back(i);
  }

  for (auto j = 0; j < v.size(); j++)
  {
    if (v[j] == 0)
      break;
    std::cout << "Case " << j + 1 << ": " << v[j] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    vi v(26);
    vc cs(n);
    rep(i, n) cin >> cs[i];
    rep(i, n) {
      char c = cs[i];
      v[c - 'A']++;
      auto maxIter = max_element(all(v));
      int maxVotes = *maxIter;
      int maxIndex = distance(v.begin(), maxIter);
      int remain   = n - i - 1;
      bool b       = true;
      rep(j, v.size()) if (j != maxIndex) b &= v[j] + remain < maxVotes;
      if (b) {
        cout << char(maxIndex + 'A') << ' ' << i + 1 << endl;
        goto next;
      }
    }
    cout << "TIE" << endl;
  next:;
  }
}

Measured memory_bytes: 3096
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string s;
int l,sum1,sum2,ans1,ans2;
int main()
{
    cin>>s;
    l=s.size();
    for (int i=0; i<l; i++)
    {
        if (s[i]=='g')
            if (sum1+1<=sum2)
            {
                ans1++;
                sum1++;
            }
            else
            {
                sum2++;
            }
        if (s[i]=='p')
        {
            if (sum1+1>sum2)
            {
                ans2++;
                sum2++;
            }
            else sum1++;
        }
    }
    cout<<ans1-ans2<<endl;
    return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    ll n, a, b; cin >> n >> a >> b;
    ll ans = 0;
    rep(i, 0, n) {
        ll c, d; cin >> c >> d;
        ans += 1ll * (c >= a) * (d >= b);
    }
    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n); 0<=i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define SetPre(x) setprecision(x)

double calc_dist(int x_0, int y_0, int x_1, int y_1){
    return sqrtl( (x_0-x_1)*(x_0-x_1) + (y_0-y_1)*(y_0-y_1) );
}
int main(void){
    int N; //町の数（2-8）
    //標準入力
    cin >> N;

    int x_i[N], y_i[N];
    double dist_sum = 0;
    ll pattern = 1;

    //標準入力
    REP(i,N) {
        cin >> x_i[i] >> y_i[i];
        }

    //0～N-1を並べた順列作成
    VI junretsu(N);
    iota(junretsu.begin(), junretsu.end(), 0);

    //パターン数計算
    REP(i,N)
    {
        pattern *= (i+1);
    }

    //debug
    //cout << "pattern" << pattern << endl;

    //next_permutation関数で全通り試す
    int i=0;
    do
    {
        REP(i,N-1){
            dist_sum += calc_dist(  x_i[junretsu.at(i)],
                                    y_i[junretsu.at(i)],
                                    x_i[junretsu.at(i+1)],
                                    y_i[junretsu.at(i+1)]);
        }
    } while (next_permutation(junretsu.begin(), junretsu.end()));

    cout << SetPre(10) << (dist_sum/pattern) << endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=A[:]
count=0
zero=0
for i in range(N):
  if(A[i]<0):
    count+=1
  elif(A[i]==0):
    zero+=1
for i in range(N):
  B[i]=abs(A[i])
if(zero==0 and count%2==1):
  print(sum(B)-2*min(B))
else:
  print(sum(B))

Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
bool lrp[2];
int lr[2];

void c(bool f,char s){
  if(s=='u'){
    if(lrp[f]==0){
      if(lr[!f]>=lr[f])lr[f]++;
      else lr[f]--;
    }
    lrp[f]=1;
  }else {
    if(lrp[f]==1){
      if(lr[!f]>=lr[f])lr[f]++;
      else lr[f]--;
    }
    lrp[f]=0;
  }
}


int main(){
  int n;
  while(cin>>n&&n){
    string s;
    lrp[0]=lrp[1]=0;
    lr[0]=lr[1]=0;
    while(n--){
      cin>>s;
      if(s[0]=='l') c(0,s[1]);
      else c(1,s[1]);
    }
    cout<<min(lr[0],lr[1])<<endl;
  }
  return 0;
}

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

using namespace std;
const int N = 1e5 + 5;
int n, a[N];
long long cum[N];
long long go(bool positive) {
	long long sum = 0, cost = 0;
	for (int i = 1; i <= n; ++i) {
		if (positive && cum[i] + sum <= 0) {
			cost += abs(cum[i] + sum) + 1;
			sum += abs(cum[i] + sum) + 1;
		} else if (!positive && cum[i] + sum >= 0) {
			cost += cum[i] + sum + 1;
			sum -= cum[i] + sum + 1;
		}
		positive = !positive;
	}
	return cost;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		cum[i] = cum[i - 1] + a[i];
	}
	printf("%lld\n", min(go(true), go(false)));
	
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



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

    ll g = g(A[0], A[1]);
    rep(i, 2, N) {
        g = g(g, A[i]);
    }
    cout << g << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >>K>>S;
  int X,Y,Z;
  int count=0;
  for(X=0;X<=K;X++){
    for(Y=0;Y<=K;Y++){
      if(S-X-Y>=0&&S-X-Y<=K){
        count++;
      }
    }
  }
  cout <<count;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int a[N], b[N];
int dp[1001][1 << 12];
int main() {
    int n, m;
    cin >> n >> m;
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    int mx = (1 << n) - 1;
    for(int i = 0, c; i < m; i++) {
        cin >> a[i] >> c;
        for(int j = 0, x; j < c; j++) {
            cin >> x;
            x--;
            b[i] |= (1 << x);
        }
        for(int j = (1 << n) - 1; j >= 0; j--) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | b[i]] = min(dp[i+1][j | b[i]], dp[i][j] + a[i]);
        }
    }
    if(dp[m][mx] > 1e9) dp[m][mx] = -1;
    cout << dp[m][mx] << '\n';
    return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d){
        cout << "Yes" << endl;
    }

    else if(abs(a-b) <= d && abs(b-c) <= d){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
using namespace std;


int main(void)
{
	int N, l, r,i,sa;
	int sum = 0;
	scanf("%d", &N);
	for (i = 1; i <=N; i++)
	{
		scanf("%d", &l);
		scanf("%d", &r);
		sa = r - l + 1;
		sum += sa;
	}
	printf("%d", sum);

	return 0;
}

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

ll order(ll n) {
  ll ret=0;
  while (n > 0) {
    n /= 10;
    ret++;
  }
  return ret;
}
int main() {
  ll N, i;
  cin >> N;
  ll sqN = sqrt(N);
  
  ll ans=100;
  for (ll i = 1; i <= sqN; i++) {
    ll orders = order(i) > order(N/i) ? order(i) : order(N/i);
    
    if (N%i == 0 && ans > orders) {
      ans = orders;
      
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int cmp_count = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
			cmp_count++;
		}else{
			A[k] = R[j++];
			cmp_count++;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	int S[n];
	for(int i = 0; i < n; i++) scanf("%d",&S[i]);

	mergeSort(S,0,n);

	for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
	printf("%d\n",S[n-1]);
	printf("%d\n",cmp_count);

}


Measured memory_bytes: 6468
#include<cstdio>
#define max(a,b) ((a)>(b)?(a):(b))
#define maxn 100050
using namespace std;
int dp[maxn][3];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	printf("%d\n",max(max(dp[n][0],dp[n][1]),dp[n][2]));
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  bool ans=false;
  FOR(i,1,10){
    if(n%i==0){
      if(n/i<10){
        ans=true;
      }
    }
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  A = [list(map(int,input().split())) for _ in range(3)]
  n = int(input())
  
  for _ in range(n):
    b = int(input())
    for i in range(3):
      for j in range(3):
        if A[i][j] == b:
          A[i][j] = 0
  #-
  
  if A[0][0] == A[0][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][0] == A[2][0] == 0:
    print('Yes')
    exit()
  if A[0][0] == A[1][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[1][0] == A[1][1] == A[1][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[2][1] == A[2][2] == 0:
    print('Yes')
    exit()
  if A[2][0] == A[1][1] == A[0][2] == 0:
    print('Yes')
    exit()
  if A[0][1] == A[1][1] == A[2][1] == 0:
    print('Yes')
    exit()
  if A[0][2] == A[1][2] == A[2][2] == 0:
    print('Yes')
    exit()
  print('No')
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
 cin>>N;
 int h[N];
 for(int i=0;i<N;i++){
   cin>>h[i];
 }
 int dp[N];
 dp[0]=0;
 dp[1]=abs(h[0]-h[1]);
 for(int i=2;i<N;i++){
   dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
 }
 cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 4384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
x = input()
cnt = x.count("1")
if cnt == 1:
    for i in range(n):
        if x[i] == "1":
            print(0)
        elif i == n - 1:
            print(2)
        else:
            print(1)
    exit()

def f(x):
  if x==0:
    return 0
  return 1+f(x%bin(x).count('1'))

xx = int(x, 2)
Y = xx % (cnt + 1)
Z = xx % (cnt - 1)
for i in range(n):
    if x[i] == '1':
        print(1 + f((Z - pow(2, n - i - 1, cnt - 1)) % (cnt - 1)))
    else:
        print(1 + f((Y + pow(2, n - i - 1, cnt + 1)) % (cnt + 1)))

Measured memory_bytes: 89080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e1+1;
const ll p=1e9+7;
int main()
{
    int x,y,i,j;
    cin>>x>>y;
    for(i=0;i<x+2;i++)
        if(i==0||i==x+1)
        {for(j=0;j<y+2;j++)printf("#");printf("\n");}
        else
        {
            string s;
            cin>>s;
            cout<<'#'<<s<<'#'<<endl;
        }
	return 0;
}


Measured memory_bytes: 256
//ΔAGC030D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 3333;
const int MO = 1e9+7;
int mul(int x,int y){
	return (LL)x*y%MO;
}
int n,q,a[N],f[N][N],g[N][N];
int main()
{
	int i,j,x,y,z=1,e=(MO+1)/2;
	scanf("%d%d",&n,&q);
	for(i=1;i<=n;i=i+1)
		scanf("%d",a+i);
	for(i=1;i<=n;i=i+1)
		for(j=1;j<=n;j=j+1)
			f[i][j]=a[i]>a[j];
	while(q--){
		scanf("%d%d",&x,&y);
		for(i=1;i<=n;i=i+1){
			g[i][x]=f[i][x]+f[i][y];
			g[i][y]=f[i][y]+f[i][x];
			g[x][i]=f[x][i]+f[y][i];
			g[y][i]=f[y][i]+f[x][i];
		}
		g[x][y]=f[y][x]+f[x][y],g[y][x]=f[x][y]+f[y][x];
		for(i=1;i<=n;i=i+1){
			f[i][x]=mul(g[i][x],e);
			f[i][y]=mul(g[i][y],e);
			f[x][i]=mul(g[x][i],e);
			f[y][i]=mul(g[y][i],e);
		}
		for(i=1;i<=n;i=i+1){
			g[i][x]=0;
			g[i][y]=0;
			g[x][i]=0;
			g[y][i]=0;
		}
		z=z*2%MO;
	}
	x=0;
	for(i=1;i<=n;i=i+1)
		for(j=i+1;j<=n;j=j+1)
			x=(x+f[i][j])%MO;
	cout<<mul(x,z);
	return 0;
}

Measured memory_bytes: 82304
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(void){
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; i++)
    {
        if(p[i] > p[i+1] && p[i] < p[i-1]) ans++;
        else if(p[i] < p[i+1] && p[i] > p[i-1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256