akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <cstdint>
#include <algorithm>
#include <functional>

template<typename F>
constexpr decltype(auto) fix(F&& f) {
	return[f = std::forward<F>(f)](auto&&... args) {
		return f(f, std::forward<decltype(args)>(args)...);
	};
}

using i64 = std::int64_t;

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

	std::vector<std::pair<i64, int>> vec(n);
	for (int i = 0; i < n; ++i) {
		i64 a;
		std::cin >> a;

		vec[i] = { a, i };
	}

	std::sort(vec.begin(), vec.end(), std::greater<>{});

	std::vector memo(n, std::vector<i64>(n, -1));
	auto solve = fix([&](auto f, int idx, int l) -> i64 {
		if (idx == n)
			return 0;

		if (memo[idx][l] != -1)
			return memo[idx][l];

		int r = l + n - 1 - idx;
		int ld = std::abs(vec[idx].second - l);
		int rd = std::abs(vec[idx].second - r);

		i64 ret = 0;
		
		ret = std::max(ret, vec[idx].first * ld + f(f, idx + 1, l + 1));
		ret = std::max(ret, vec[idx].first * rd + f(f, idx + 1, l));

		return memo[idx][l] = ret;
	});

	std::cout << solve(0, 0) << std::endl;
}

Measured memory_bytes: 34936
#include <iostream>
#include <vector>

using namespace std;

vector<int> v;

int main(){
    string S;
    cin >> S;
    int ans = S.size();
    int cnt = 0;
    for(int i = 0; i+1 < S.size(); i++){
        if(S[i] == S[i+1]){
            cnt++;
        }else{
            v.push_back(cnt);
            if(cnt == 0) v.push_back(0);
            cnt = 0;
        }
        if(i+2 == S.size()){
            v.push_back(cnt);
        }
    }
   
    for(int i = 0; i+1 < v.size(); i++){
        if(v[i] != 0){
            if(v[i+1] == 0){
                ans -= (v[i]+2)/3;
            }else{
                ans -= (v[i]+2)/3;
                if(v[i]%3 == 1) v[i+1]--;
            }
        }
    }
    if(v.size() != 0){
        ans -= (v[v.size()-1]+2)/3;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2804
import collections
from decimal import Decimal

n = int(input())
a = [Decimal(input()) for _ in range(n)]
a = [int(i*10**9) for i in a]
MAX = 19
p_dict = collections.defaultdict(int)

for i in a:
    b_cnt = 0
    while i % 2 == 0 and b_cnt < 18:
        i //= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0 and f_cnt < 18:
        i //= 5
        f_cnt += 1
    p_dict[(b_cnt, f_cnt)] += 1

ans = 0
for b1, f1 in p_dict:
    for b2, f2 in p_dict:
        if b1+b2 >= 18 and f1+f2 >= 18:
            if b1 == b2 and f1 == f2:
                ans += p_dict[(b1, f1)] * (p_dict[(b2, f2)] - 1)
            else:
                ans += p_dict[(b1, f1)] * p_dict[(b2, f2)]
print(ans//2)

Measured memory_bytes: 41664
# D
# Multiple of 2019
import itertools

s = input()[::-1]

d = len(s)

# _list = [None]*d
_map = [0]*2019
_map[0] = 1

ans = 0
j,_ = 1,0

for i in s:
    _ += int(i) * j
    _tmp = _ % 2019
    j = (j*10)%2019
    _map[_tmp] += 1
    
for _l in _map:
    ans += _l * (_l - 1) / 2
    
print(int(ans))

Measured memory_bytes: 9356
//Name: Pankaj Mandrawal (pankaj_m05)
//Problem: OCD
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define mod 10000000009
#define sz(c) int((c).size())
#define sortall(x) sort(all(x))         
#define PI 3.1415926535897932384626     
#define all(c) (c).begin(), (c).end()
#define clr(x) memset(x, 0, sizeof(x))  
#define MAX32 numeric_limits< int >::max() 
#define MIN32 numeric_limits< int >::min()
#define rall(c) (c).rbegin(), (c).rend()
#define deb(x) cerr << #x << " = " << x << endl
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = (int)(l); i < (int)(r); ++i)
#define tr(c, it) for(typeof(c).begin() it = c.begin(); it != c.end(); it++)
#define deb2(x, y) cerr << #x << " = " << x << "," << #y << " = " << y << endl

using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vill;
typedef pair < int, int > pi;
typedef unsigned long long int ull;

ll mypow(ll x, ll y) { 
    if (y == 0) 
        return 1; 
    ll p = mypow(x, y / 2) % mod; 
    p = (p * p) % mod; 
    if (!(y & 1)) 
        return p;
    return (p * x) % mod; 
} 

void plssolve() {
	int n, k; cin >> n >> k;
	ll sum = 0, temp;
	vector< ll > v(n);
	for(int it = 0; it < n; ++it) {
		int p; cin >> p;
		v[it] = p + 1;
		if(it < k)
			sum += v[it];
	}
	temp = sum;
	for(int it = 0; it < n - k; ++it) {
		temp -= v[it];
		temp += v[it + k];
		sum = max(sum, temp);
	}
	cout << sum / 2 << ((sum & 1) ? ".5" : ".0") << '\n'; 
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    cout << fixed;
    int t = 1;
    //cin >> t;
    while(t--) {
        plssolve();
    }
    return 0;
}

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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  
  int ans = 0;
  for (int i = 0; i <= a; ++i) {
    for (int j = 0; j <= b; ++j) {
      for (int k = 0; k <= c; ++k) {
        int sum_price = 500 * i + 100 * j + 50 * k;
        if (sum_price == x) ++ans;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int X, N;
  cin >> X >> N;
  int flag, ans, sa = 100000;
  vector<int> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  for(int i = -2; i <= 102; i++){
    flag = 1;
    for(int j = 0; j < N; j++){
      if(data.at(j) == i)flag = 0;
    }
    if(flag == 0)continue;
    if(abs(i - X) < sa){
      sa = abs(i - X);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
 
using namespace std;
typedef long long int ll;
 
#define C cout<<
#define E <<endl
#define CE cout<<endl
 
ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<int> st;
 
template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }

int main(){
    cin>>n;
    a=0;
    b=0;
    c=0;
    for(int i=0;i<n;i++){
        cin>>aa[i];
        if(aa[i]>a){
            a=aa[i];
        }
        else if(aa[i]>b){
            b=aa[i];
        }
    }
    for(int i=0;i<n;i++){
        C (aa[i]==a ? b:a) E;
    }

}

Measured memory_bytes: 3840
package main

import "fmt"

func main() {
	var T string
	fmt.Scan(&T)
	for i := 0; i < len(T); i++ {
		if T[i] == '?' {
			fmt.Print("D")
		} else {
			fmt.Print(string(T[i]))
		}
	}
	fmt.Println()
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No";
    }else {
        cout << "Yes";
    }
}

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

typedef long long ll; 
#define sz(a) ((int)(a.size()))

const int mod=1e9+7; 
int mul(int a, int b){
  return (ll)a*b%mod; 
}
void add_self(int &a, int b){
  a+=b; 
  if(a>= mod) a-=mod; 
}
void mul_self(int &a, int b){
  a=(ll)a*b%mod; 
}
void sub_self(int &a, int b){
  a-=b; 
  if(a<0) a+=mod;
}
int exp(int a, int b){
  int ret=1; 
  while(b){
    if(b%2){
      mul_self(ret,a); 
    }
    mul_self(a,a); 
    b/=2; 
  }
  return ret; 
}
//--------------------------------------------------


void solve(){ 
  int a; cin>>a; 
  string s; cin>>s; 
  if(a<3200){
    cout<<"red"<<endl; 
  }
  else {
    cout<<s<<endl; 
  }
}

int main(){
  clock_t beg=clock(); 
  solve(); 
  clock_t end=clock(); 
  fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
}

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

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, d;
  cin >> n >> d;
  d = d*d;
  ll ct = 0;
  for(ll i = 0; i < n; i++)  {
    ll x, y;
    cin >> x >> y;
    ll tt = (x*x) + (y*y);
    if(tt <= d) ct++;
  }
  cout << ct << endl;
  return 0;
} //good night.

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int A[3];
int B[3];
ll dp[4][5010];
ll ep[4][5010 * 5010];

void solve() {
	cin >> N;
	rep(i, 0, 3) cin >> A[i];
	rep(i, 0, 3) cin >> B[i];
	rep(i, 0, 3 + 1) {
		rep(j, 0, N + 1) {
			dp[i][j] = -inf;
			ep[i][j] = -inf;
		}
	}
	dp[0][0] = N;
	rep(i, 0, 3) {
		rep(j, 0, N + 1) {
			if(j - A[i] >= 0) {
				MAX(dp[i + 1][j], max(dp[i + 1][j - A[i]] + B[i] - A[i], dp[i][j]));
			}
			else MAX(dp[i + 1][j], dp[i][j]);
		}
	}
	ll nn = -inf;
	rep(i, 0, N + 1) MAX(nn, dp[3][i]);
	debug(nn);

	N = nn;
	ep[0][0] = N;
	rep(i, 0, 3) {
		rep(j, 0, N + 1) {
			if(j - B[i] >= 0) {
				MAX(ep[i + 1][j], max(ep[i + 1][j - B[i]] + A[i] - B[i], ep[i][j]));
			}
			else MAX(ep[i + 1][j], ep[i][j]);	
		}
	}
	ll res = -inf;
	rep(i, 0, N + 1) MAX(res, ep[3][i]);
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main(){
  int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
  int cou=0;
  for(int i=a;i<=b;i++){
    if(c%i==0)cou++;
  }
  printf("%d\n",cou);
  return 0;
}

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

using namespace std;

int PrimeNumbers(int *arr, int Num)
{
    int primeNum = 0;
    double k = 0;
    int flag = 0;
    for (int i = 0; i < Num; i++)
    {
        flag = 1;
        k = floor(sqrt(arr[i]));
        for (int j = 2; j <= k; j++)
        {
            if (arr[i] % j == 0)
            {
                flag = 0;
                break;
            }
        }
        if (flag == 1)
        {
            primeNum++;
        }
    }
    return primeNum;
}

int main(int argc, char *argv[])
{
    int Num;
    cin >> Num;
    int *arr = new int[Num];
    for (int i = 0; i < Num; i++)
    {
        cin >> arr[i];
    }

    cout << PrimeNumbers(arr, Num) << endl;


    return 0;
}



Measured memory_bytes: 3092
#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(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll k,modk=0;
	cin >> k;
	set<int>s;
	modk = 7 % k;
	s.insert(modk);
	rep(i, k) {
		if (modk == 0) {
			cout << s.size() << endl;
			return 0;
		}
		modk = (modk * 10LL + 7LL) % k;
		s.insert(modk);
	}
	cout << -1 << endl;

	return 0;
}



Measured memory_bytes: 50432
import java.util.*;
public class Main {
	
	static int judge(double g){
		if(g <= 48.00) return 0;
		for(int i=0; i<=3; i++)
			if(g>48.00+3*i && g<=51.00+3*i) return i+1;
		if(g>60.00 && g<=64.00) return 5;
		if(g>64.00 && g<=69.00) return 6;
		if(g>69.00 && g<=75.00) return 7;
		if(g>75.00 && g<=81.00) return 8;
		if(g>81.00 && g<=91.00) return 9;
		return 10;
	}
	
	static String name(int i){
		switch(i){
		case 0:	return "light fly";
		case 1: return "fly";
		case 2: return "bantam";
		case 3: return "feather";
		case 4: return "light";
		case 5: return "light welter";
		case 6: return "welter";
		case 7: return "light middle";
		case 8:	return "middle";
		case 9: return "light heavy";
		default: return "heavy";
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			System.out.println(name(judge(sc.nextDouble())));			
			
		}
	}

}

Measured memory_bytes: 12000
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		long sum = 0;
		int cntneg = 0;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			long x = input.nextLong();
			if (x < 0) {
				x*=-1;
				cntneg++;
			} 
			sum+=x;
			min=Math.min(x, min);
		}
		if (cntneg%2==1) sum-=min*2; //Times 2 because after excluding, 
		//we also subtract the minimum value
		System.out.println(sum);
	}
}

Measured memory_bytes: 48416
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    R, S, P = map(int, input().split())
    t = list(input())
    res = 0
    for i in range(n):
        if i < k:
            res += R if t[i] == "s" else S if t[i] == "p" else P
        else:
            if t[i - k] != t[i]:
                res += R if t[i] == "s" else S if t[i] == "p" else P
            else:
                t[i] = "0"
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 4084
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){

int n,r;
string st;
while(1){
cin>>st;
if(st=="#")break;
int side=0,side2=0;int c=0;
for(int i=0;i<st.size();i++)
{
	if(st[i]=='a')side2=0;if(st[i]=='s')side2=0;if(st[i]=='d')side2=0;if(st[i]=='f')side2=0;
if(st[i]=='z')side2=0;if(st[i]=='x')side2=0;if(st[i]=='c')side2=0;if(st[i]=='v')side2=0;
if(st[i]=='q')side2=0;if(st[i]=='w')side2=0;if(st[i]=='e')side2=0;if(st[i]=='r')side2=0;
if(st[i]=='t')side2=0;if(st[i]=='g')side2=0;if(st[i]=='b')side2=0;

if(st[i]=='y')side2=1;if(st[i]=='h')side2=1;if(st[i]=='m')side2=1;
if(st[i]=='u')side2=1;if(st[i]=='j')side2=1;if(st[i]=='n')side2=1;
if(st[i]=='i')side2=1;if(st[i]=='k')side2=1;if(st[i]=='p')side2=1;
if(st[i]=='o')side2=1;if(st[i]=='l')side2=1;

if(i>0&&side2!=side)c++;
side=side2;

}
cout<<c<<endl;

}
return 0;
}

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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for (int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

  vector<int> hs(n);

  rep(i, n) { cin >> hs[i]; };

  int count = 0;
  rep(i, n) {
    if (hs[i] >= k) {
      count++;
    }
  };

  p(count);

  return 0;
}


Measured memory_bytes: 640
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define     loopp(i,n) 	for(int i = 1 ; i <=n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::reverse_iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define     sorted      is_sorted(v.begin(),v.end())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>
#define 	set_it 	    set<int>::reverse_iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  //  freopen ("(input).txt" , "r",  stdin) ;
  //  string st,stt ;
  //  int low=0,high=0;
  //  int l=0,r;
    int n,k,t,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n>>k  ; vect v ,a ,b  ; sett s ; set_it ; mapp m,mm ;  map_it ; pairr p[k] ;
    loop(i,k)
    {
        cin>>p[i].ff>>p[i].ss;
        if(p[i].ff==1)
            m[p[i].ss]++;
    }
    loop(i,k)
    {
        if(m[p[i].ff]>0&&p[i].ss==n)
        {
            temp=1;break;
        }

    }
    if(temp==1)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}

Measured memory_bytes: 19244
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	cout << (b - a) * (b - a + 1) / 2 - b << endl;
	
	return 0;
}


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<long double> v(N);
	for (auto& e: v) scanf("%Lf", &e);
	std::sort(v.begin(), v.end());
	long double sum{v.front()};
	for (int i{1}; i < N; i++)
		sum = (sum + v[i]) / 2;
	printf("%.10Lf\n", sum);

	return 0;
}

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

const int M = 2005;
const int N = 30005;
const int o = 15000;

bool ab[N],ac[N],bc[N];

bool match(char x,char y) {
    return x=='?' || y=='?' || x==y;
}

string a,b,c;
int la,lb,lc;

signed main() {
    ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    la=a.length();
    lb=b.length();
    lc=c.length();
    for(int i=0;i<la;i++) for(int j=0;j<lb;j++)
        if(!match(a[i],b[j])) ab[i-j+o]=1;
    for(int i=0;i<la;i++) for(int j=0;j<lc;j++)
        if(!match(a[i],c[j])) ac[i-j+o]=1;
    for(int i=0;i<lb;i++) for(int j=0;j<lc;j++)
        if(!match(b[i],c[j])) bc[i-j+o]=1;
    int ans=N;
    for(int i=-2*M;i<=2*M;i++) for(int j=-2*M;j<=2*M;j++) {
        if(!ab[i+o] && !ac[j+o] && !bc[j-i+o]) {
            ans=min(ans, max(la,max(lb+i,lc+j))-min(0,min(i,j)));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, k;
  cin >> n >> k;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];

  vvt<int> dp(n + 1, vt<int>(k + 2, 0));
  dp[0][0] = 1;
  rep(i, 0, n) {
    rep(j, 0, k + 1) {
      if(dp[i][j] == 0) continue;

      (dp[i + 1][j] += dp[i][j]) %= mod;
      (dp[i + 1][min(k, j + a[i]) + 1] -= dp[i][j]) %= mod;
      if(dp[i + 1][min(k, j + a[i]) + 1] < 0) dp[i + 1][min(k, j + a[i]) + 1] += mod;
    }

    rep(j, 0, k) (dp[i + 1][j + 1] += dp[i + 1][j]) %= mod;
  }

  cout << dp[n][k] << endl;
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll d,t,s;
    cin>>d>>t>>s;
    cout<<(s*t>=d?"Yes":"No");
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int a[210];

int main(){
	int n,ans=0; cin>>n; n*=2;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n-1;i>0;i-=2)
		ans+=min(a[i],a[i+1]);
	cout<<ans<<endl;
	return 0;
}

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

typedef long long int ll;

bool find_prime(int N){
  for(int i=2; i*i<N; i++){
    if (N%i==0) return false;
  }
    return true;
}
 
int main(){
  int N;
  cin >> N;
  bool x=false;
  while(!x){
    if (find_prime(N)){
      cout << N <<endl;
      return 0;
    }
    else N++;
  }
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

if a[0]>=0:
    f=1
else:
    f=-1

s=0
ans=0
for i in range(n):
    s+=a[i]
    if s*f<0:
        ans+=abs(s)+1
        s=f
    elif s==0:
        ans+=1
        s=f
    f*=-1


if a[0]>=0:
    f=-1
else:
    f=1
s=0
ans2=0
for i in range(n):
    s+=a[i]
    if s*f<0:
        ans2+=abs(s)+1
        s=f
    elif s==0:
        ans2+=1
        s=f
    f*=-1
    
print(min(ans,ans2))
        






Measured memory_bytes: 14468
#include <iostream>
#include <vector>

int main()
{
	unsigned int n;
	std::vector<unsigned int> p;

	std::cin >> n;
	p.resize(n);
	for (size_t i = 0; i < p.size(); i++)
	{
		std::cin >> p[i];
	}
	
	unsigned int cnt = 0;
	for (size_t i = 1; i < p.size() - 1; i++)
	{
		if((p[i - 1] < p[i] && p[i] < p[i + 1]) || 
			(p[i - 1] > p[i] && p[i] > p[i + 1]))
			cnt++;
	}
	
	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;

/*
<NAME> Dinic 最大流
<TRIGGER> Dinic
<TAG> ネットワークフロー, 最大流, graph
<*NOTE>

- $O(V^2 E)$
- `add_edge`で辺を追加して、`max_flow`で最大流を得る。

<*CODE> */
struct Dinic {
    struct edge { int to, cap, rev; };
    int V;
    vector<vector<edge>> G;
    vi itr, level;
    
    Dinic(int V) : V(V) {
        G.assign(V, vector<edge>());
    }

    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge){ to,   cap, sz(G[to  ])     });
        G[to  ].push_back((edge){ from, 0,   sz(G[from]) - 1 });
    }
    void add_edge_undirected(int a, int b, int cap) {
        G[a].push_back((edge){ b, cap, sz(G[b])     });
        G[a].push_back((edge){ a, cap, sz(G[a]) - 1 });
    }

    void bfs(int s) {
        level.assign(V, -1);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while (sz(q)) {
            int v = q.front(); q.pop();
            for (auto &e : G[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = itr[v]; i < sz(G[v]); i++) {
            edge &e  = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int ret = 0;
        int f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V, 0);
            while ((f = dfs(s, t, INF)) > 0) {
                ret += f;
            }
        }
        return ret;
    }
};

signed main() {
    int V, E;
    cin >> V >> E;
    Dinic dinic(V);
    rep(i, 0, E) {
        int va, vb, cap;
        cin >> va >> vb >> cap;
        dinic.add_edge(va, vb, cap);
    }
    cout << dinic.max_flow(0, V - 1) << endl;
}



Measured memory_bytes: 3264
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    long int N,K,S;   
    cin>>N>>K>>S;
    rep (i,K)  cout<<S<<" ";
    for (int i=K;i<N;i++){
        if (S>10000) cout<<S-1<<" ";
        else cout<<S+1<<" ";
    }
    cout<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = 99999999;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

double s(ll x){
    double res = 0;
    while(x>0){
        res += x%10;
        x/=10;
    }
    return res;
}

int main() {
    ll k,a1=1,a2=2,a3,dif=1;
    cin >> k;
    cout << 1 << endl;
    for(int i = 1;i<k;i++){
        a3 = dif + a2;
        while(a2/s(a2) > a3/s(a3)){
            a2 += dif;
            a3 += dif;
        }
        dif = a2-a1;
        cout << a2 << endl;
        a1 = a2;
        a2 = a2+dif;
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int k, s;
  cin >> k >> s;

  int sum = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int calc = s - x - y;
      if (calc >= 0 && calc <= k) sum++;
    }
  }

  cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 256
def hersCode(l, r, mod):
  if N % r == mod:
    return r
  if N % l == mod:
    return l
  ok = r
  ng = l
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if N % mid == mod:
      return mid
    if N % mid < mod:
      ok = mid
    else:
      ng = mid
  return -1


def first(l, r):
  ok = r
  ng = l
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if N // mid < mid:
      ok = mid
    else:
      ng = mid
  return ok

N = int(input())

l = first(0, N)
f = N // l
Ans = 0
for i in range(f, 0, -1):
  r = N // i
  x = hersCode(l, r, i)
  if x != -1:
    Ans += x
  l = r + 1

print(Ans)

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

int main() {
  int A, B, C, K, X;
  cin >> A >> B >> C >> K;
  X=max(A,max(B,C));
  rep(i, K){
    X*=2;
  }
  cout << A+B+C-max(A,max(B,C))+X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,a=0;
    string s;
    cin >> s;
    for(i =0; i<s.length();i++){
        if(i%2 == 0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
                a++;
            }
        }
        else{
            if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
                a++;
            }
        }
    }
    if(a == s.length()){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	int N, M;
	int INF = Integer.MAX_VALUE / 2;
	int[][] graph, memo;

	void run() {
		N = sc.nextInt(); // edge number
		M = sc.nextInt(); // vertex number
		graph = new int[N][N];
		memo = new int[N][1 << N];
		for (int i = 0; i < N; i++) {
			Arrays.fill(graph[i], INF);
			Arrays.fill(memo[i], -1);
		}
		for (int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int cost = sc.nextInt();
			graph[s][t] = cost;
		}
		int res = tsp(0, 1);
		System.out.println(res == INF ? -1 : res);
	}

	int tsp(int v, int mask) {
		if (memo[v][mask] != -1)  return memo[v][mask];
		if (mask == (1 << N) - 1) return graph[v][0];

		int res = INF;
		for (int i = 0; i < N; i++) {
			if ((mask & (1 << i)) != 0) continue;
			res = Math.min(res, graph[v][i] + tsp(i, mask | (1 << i)));
		}
		return memo[v][mask] = res;
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31564
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, M = inm()


def solve():
    d = M * 1900 + (N - M) * 100
    return d * (2 ** M)


print(solve())


Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
 
 
int main(){
    ll n; cin >> n;
    ll sum = 0;
    vl t(n);
    rep(i,n){
        cin >> t[i];
        sum += t[i];
    }
    ll m; cin >> m;
    rep(i,m){
        ll p,x; cin >> p >> x;
        p--;
        ll ans = sum - t[p] + x;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
/***** author :  C0d1ngPhenomena *****/

    #include <bits/stdc++.h>
    #define endl "\n"
    #define ll long long int
    #define TestCases int T; cin>>T; while(T--)
    #define rep(i,n) for(ll i = 0; i < n; i++)
    #define revrep(i,n) for(ll i = n-1; i >= 0; i--)
    #define vll vector<ll>
    #define vvll vector < vll >
    #define pll pair<ll, ll>
    #define mp(x,y) make_pair(x,y)
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define alld(c) c.begin(),c.end(),greater<int>()
    #define mem(a,val) memset(a,val,sizeof(a))
    #define f first
    #define s second
    #define pb push_back
    using namespace std;
    



    
    int main()
    {
        std::ios::sync_with_stdio(false);
        cin.tie(NULL);
        
        ll N;
        cin >> N;

        ll arr[5] = {0};
        string str;
        
        for (int i = 0; i < N; ++i)
        {
            cin >> str;

            if(str=="AC")
                arr[0]++;
            if(str=="WA")
                arr[1]++;
            if(str=="TLE")
                arr[2]++;
            if(str=="RE")
                arr[3]++;

        }

    cout<<"AC x "<<arr[0]<<endl;
    cout<<"WA x "<<arr[1]<<endl;
    cout<<"TLE x "<<arr[2]<<endl;
        cout<<"RE x "<<arr[3]<<endl;

        return 0;
    }







Measured memory_bytes: 3652
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        String S = sc.next();
        if (S.length() > K) S = S.substring(0, K) + "...";
        System.out.println(S);
    }
}

Measured memory_bytes: 27004
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


int main(){
    ll N, K;
    cin >> N >> K;

    queue<ll> A;
    ll a;
    ll pastA;

    if(K == 1){
        cin >> pastA;
        REP(i, N - 1){
            cin >> a;
            if(pastA < a){
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
            pastA = a;
        }
        return 0;
    }

    REP(i, K){
        cin >> a;
        A.push(a);
    }
    for(ll i = K; i < N; i++){
        cin >> a;
        pastA = A.front();
        A.pop();//cout << "i: " << i << ", pastA: " << pastA << ", a: " << a << endl;
        if(pastA < a){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        A.push(a);
    }

    return 0;
}


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



int main() {
  int64_t N,A,B;
  cin>>N>>A>>B;
  
  if(N==1){
    if(A==B){
      cout<<1<<endl;
    }
    else{
      cout<<0<<endl;
    }
  }
  else{
    if(A>B){
      cout<<0<<endl;
    }
    else if(A==B){
      cout<<1<<endl;
    }
    else{
      cout<<(B-A)*(N-2)+1<<endl;
    }
  }
  
}

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

int main() {
    long long int a, b, c;
    cin >> a;
    string s;
    cin >> s;
    b = stoi(string(s.begin(), s.end() - 3));
    c = stoi(string(s.end() - 2, s.end()));
    cout << a * b + c * a / 100 << endl;
}


Measured memory_bytes: 3628
import itertools

n,m,x=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=list(range(n))
c=[0]*(m+1)
d=[]
for i in range(1,n+1):
    for v in itertools.combinations(b,i):
        for j in v:
            for k in range(m+1):
                c[k]+=a[j][k]
        d.append(c)
        c=[0]*(m+1)
e=[]
for i in range(len(d)):
    ok=0
    for j in range(1,len(d[i])):
        if d[i][j]>=x:
            ok+=1
    if ok==m:
        e.append(i)

if len(e)==0:
    print(-1)
else:
    ans=d[e[0]][0]
    for i in e:
        ans=min(ans,d[i][0])
    print(ans)

Measured memory_bytes: 68584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

int main(){
    int H, W; 
    cin >> H >> W;
    vector<string> A(H);
    for(int i = 0; i < H; ++i){
        cin >> A[i];
    }
    int sum = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(A[i][j] == '#'){
                sum++;
            }
        }
    }
    
    if(sum == H + W - 1){
        cout << "Possible\n";
    }
    else{
        cout << "Impossible\n";
    }
}

Measured memory_bytes: 256
def findNextAnimal(oxList, swList, index):
    nextAns = oxList[index]
    before = swList[index-1]
    animal = swList[index]
    nextAnimal = ""
    if(nextAns == "o" and before == "S" and animal == "S"):
        nextAnimal = "S"
    elif(nextAns == "o" and before == "S" and animal == "W"):
        nextAnimal = "W"
    elif(nextAns == "o" and before == "W" and animal == "S"):
        nextAnimal = "W"
    elif(nextAns == "o" and before == "W" and animal == "W"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "S" and animal == "S"):
        nextAnimal = "W"
    elif(nextAns == "x" and before == "S" and animal == "W"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "W" and animal == "S"):
        nextAnimal = "S"
    elif(nextAns == "x" and before == "W" and animal == "W"):
        nextAnimal = "W"
    return nextAnimal

def checkList(oxList, swList):
    ans = 0
    if(swList[-1] == "S"):
        if(oxList[-1] == "x" and swList[-2] != swList[0]):
            ans = 1
        elif(oxList[-1] == "o" and swList[-2] == swList[0]):
            ans = 1
    elif(swList[-1] == "W"):
        if(oxList[-1] == "x" and swList[-2] == swList[0]):
            ans = 1
        elif(oxList[-1] == "o" and swList[-2] != swList[0]):
            ans = 1
            
    ans2 = 0    
    if(swList[0] == "S"):
        if(oxList[0] == "x" and swList[1] != swList[-1]):
            ans2 = 1
        elif(oxList[0] == "o" and swList[1] == swList[-1]):
            ans2 = 1
    elif(swList[0] == "W"):
        if(oxList[0] == "x" and swList[1] == swList[-1]):
            ans2 = 1
        elif(oxList[0] == "o" and swList[1] != swList[-1]):
            ans2 = 1
    
    return ans*ans2

try:
    while True:  
        n = raw_input().strip().upper()
        oxList = raw_input().strip().lower()
        ans = -1
        for s0 in ["S", "W"]:
            for s1 in ["S","W"]:
                swList = [0]*int(n)
                swList[0] = s0
                swList[1] = s1
                for i in range(2, int(n)):
                    nextAnimal = findNextAnimal(oxList, swList, i-1)
                    swList[i] = nextAnimal
                    flag = checkList(oxList, swList)
                    if(flag == 1):
                        ans = ""
                        for s in swList:
                            ans += s
        print ans
                        
except EOFError:
    pass

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

ll calcpref(ll x) {
	ll d = 1;
	while (d <= x) d *= 2;
	return d;
}

ll calc(ll a, ll b) {
	ll d = calcpref(b) / 2;
	if (d >= a) {
		ll cb = calcpref(b - d);
		ll c = d - a;
		ll full = c / cb;
		ll semi = c % cb;
		if (full * cb + cb == d)
			semi = 0;
		return (c + full * cb + semi + cb);
	} else {
		return calc(a - d, b - d);
	}
}

int main() {
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);
	ll a, b;
	cin >> a >> b;
	cout << calc(a, b) << endl;
	return 0;
}

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

 int main(){
   int a,b,c;
   cin >> a >> b >> c;
   int ans=b/a;
   if(ans>c){
     cout << c << endl;
   }else{
     cout << ans << endl;
   }
 }

Measured memory_bytes: 256
x=input()
s=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in s:
  if x.count(i)==0:
    print(i)
    exit()
print("None")

Measured memory_bytes: 3188
n = int(input())
A = [int(input()) for i in range(n)]

ans = A[0] // 2
A[0] %= 2

for i in range(1, n):
    ans += (A[i-1] + A[i]) // 2
    if A[i] == 0:
        pass
    elif A[i-1] == 1:
        if A[i] % 2 == 0:
            A[i] = 1
        else:
            A[i] = 0
    else:
        A[i] %= 2

print(ans)

Measured memory_bytes: 7072
#include<stdio.h>
#define ll long long
int main(){
    int n;
    ll d;
    scanf("%d%lld",&n,&d);
    ll x[n], y[n];
    for(int i = 0; i < n; i++)
        scanf("%lld%lld",&x[i],&y[i]);
    int ans = 0;
    d *= d;
    for(int i = 0; i < n; i++){
        ll p = x[i] * x[i] + y[i] * y[i];
        if(p <= d)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 4820
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int N;
ll a[300010], b[300010], c[300010];

ll solve() {
    priority_queue<ll, vector<ll>, greater<ll> > que0;
    ll s = 0;
    for (int i = 0; i < N; i++) {
        s += a[i];
        que0.push(a[i]);
    }
    b[N-1] = s;
    for (int i = N; i < 2*N; i++) {
        ll v = que0.top();
        if (v < a[i]) {
            que0.pop();
            que0.push(a[i]);
            s += a[i] - v;
        }
        b[i] = s;
    }

    priority_queue<ll> que;
    s = 0;
    for (int i = 3*N-1; i >= 2*N; i--) {
        s += a[i];
        que.push(a[i]);
    }
    c[2*N-1] = s;
    for (int i = 2*N-1; i >= N; i--) {
        ll v = que.top();
        if (v > a[i]) {
            que.pop();
            que.push(a[i]);
            s -= v - a[i];
        }
        c[i-1] = s;
    }

    ll res = -1e18;
    for (int i = N-1; i < 2*N; i++) {
        res = max(res, b[i] - c[i]);
    }    
    return res;
}

void input() {
    cin >> N;
    for (int i = 0; i < 3*N; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 7796
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

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

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    int N,M,K,B,C,X,Y; cin >> N;
    vector<ll> A(N);
    ll sum = 0LL;
    rep(i,N){
        cin >> A[i];
        sum+=A[i];
    }

    ll one = 0LL;
    ll two = 0LL;
    for(int i=0; i<N; i++){
        one += A[i];
        if(one >= sum/2){
            break;
        }
    }

    for(int i=N-1; i>=0; i--){
        two += A[i];
        if(two >= sum/2){
            break;
        }
    }


    cout << min(2*one-sum, 2*two-sum) << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

k,s=mii()

cnt=0

for i in range(0,k+1):
    for j in range(0,k+1):
        if 0<=s-(i+j)<=k:
            cnt+=1
print(cnt)

Measured memory_bytes: 40940