akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e9+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;
int t=1;
//in t;
int tt=1;
while(t--){
int n;in n;
int k;in k;
int arr[k];
rep(i,k) in arr[i];
int diff1[k],diff2[k];
for(int i=1;i<k;i++)
{
    diff1[i-1]=arr[i]-arr[i-1];
}
diff1[k-1]=abs(arr[k-1]-(n+arr[0]%n));
int sum=0;
for(auto i:diff1) sum+=i;
//out sum;
int ans=INT_MAX;
for(int i=0;i<k;i++){
    //out (i-1+k)%k<<endl;
    ans=min(ans,sum-diff1[(i-1+k)%k]);
}
    out ans<<endl;
    return 0;
}
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 3328
def swap(a,b):
  return b,a
n,m = map(int,input().split())
arr = list(map(int,input().split()))
sum = 0
for i in arr:
  sum += i
sum = sum/(4*m)
count=0
for i in arr:
  if (i>=sum):
    count+=1
if (count>=m):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)3e3 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

string s;
int n, suff[N][3];

void solve() {
	cin >> n >> s;
	map <char, int> num = { {'R', 0}, {'G', 1}, {'B', 2} };
	suff[n - 1][num[s.back()]]++;
	for (int i = n - 2; i >= 0; i--) {
		for (int j = 0; j < 3; j++)
			suff[i][j] = suff[i + 1][j];
		suff[i][num[s[i]]]++;
	}
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] == s[j])
				continue;
			int val = -1;
			if (num[s[i]] != 0 && num[s[j]] != 0)
				val = 0;
			if (num[s[i]] != 1 && num[s[j]] != 1)
				val = 1;
			if (num[s[i]] != 2 && num[s[j]] != 2)
				val = 2;
			ans += suff[j + 1][val];
			int pos = 2 * j - i;
			if (pos < n && num[s[pos]] == val)
				ans--;
		}
	}
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 3728
# C
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
num = [i+1 for i in range(N)]

p_ord = 0
q_ord = 0
cnt = 0
for pre in itertools.permutations(num, N):
    if P == list(pre):
        p_ord = cnt

    if Q == list(pre):
        q_ord = cnt
    cnt += 1

print(abs(p_ord-q_ord))


Measured memory_bytes: 9068
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int n;
    int sum = 0;
    int d[100];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    for (int i = 0; i < n - 1;i++) {
        for (int j = i + 1; j < n; j++) {
            sum += d[i]*d[j]; 
        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



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


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

int main(){
	INIT;
	ll n;
	cin>>n;
	vector<ll> a(n);
	rep(i, n) cin>>a[i];
	sort(all(a));
	ll res = a[0];
	rep(i, n-1) if(abs(a[i]*2-a[n-1])<abs(res*2-a[n-1])) res = a[i];
	//cout<<res<<" "<<a[n-1]<<endl;
	cout<<a[n-1]<<" "<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(void) {
  int i, j, match_max_length, match_count;
  string S, T;
  // get input
  cin >> S >> T;
  // string matching
  match_max_length = 0;
  for(i = 0; i < S.size() - T.size() + 1; i++) {
    match_count = 0;
    for(j = 0; j < T.size() && i + j < S.size(); j++) {
      if(S[i + j] == T[j]) {
        match_count++;
      }
    }
    if(match_max_length < match_count) {
      match_max_length = match_count;
    }
  }
  // disp answer
  cout << T.size() - match_max_length << endl;
  
  return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys

def f(n: int):
    if(n%2 == 0):
        return int(n/2)
    else:
        return 3*n+1

def solve(s: int):
    a = [s]
    # for i in range(1,10):
    #     a.append(f(a[i-1]))
    # print(a)
    while(True):
        t = f(a[-1])
        if(t in a):
            print(len(a)+1)
            sys.exit(0)
        else:
            a.append(t)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  # type: int
    solve(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
int main(){
      ll n,m;
      cin>>n>>m;
      ll a[n],b[m];
      rep0(i,n){
            cin>>a[i];
      }
      rep0(j,m){
            cin>>b[j];
      }
      sort(a,a+n);
      sort(b,b+m);
      rep1(i,n-1){
            if(a[i]==a[i-1]){
                  cout<<0<<endl;
                  return 0;
            }
      }
      rep1(j,m-1){
            if(b[j]==b[j-1]){
                  cout<<0<<endl;
                  return 0;
            }
      }
      int d[n*m+1];
      fill(d,d+m*n+1,0);
      rep0(i,n) d[a[i]]++;
      rep0(j,m) d[b[j]]++;
      ll c[n][m];
      rep0(i,n)rep0(j,m) c[i][j]=min(a[i],b[j]);
      int e[n*m+1];
      fill(e,e+n*m+1,0);
      rep0(i,n)rep0(j,m) e[c[i][j]]++;
      int pos=0;
      ll ans=1;
      ll mod=1e9+7;
      for(int now=n*m;now>=1;now--){
            if(d[now]==2){
                  pos+=(e[now]-1);
            }
            if(d[now]==1){
                  ans=(ans*(e[now]))%mod;
                  pos+=(e[now]-1);
            }
            if(d[now]==0){
                  ans=(ans*pos)%mod;
                  pos--;
            }
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 15872
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;

main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(rng(a));
    for (int i = 0 ; i < n; i++){
        if (k < a[i]){
            cout << i;
            return 0;
        }
        k -= a[i];
    }
    if (k)
        cout << n - 1;
    else
        cout << n;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vector<mat> dp(300, mat(300, vec(301, -1)));
ll dfs(int i, int j, int k){
    if(i >= j) return i == j;
    if(dp[i][j][k] != -1) return dp[i][j][k];
    ll res = 0;
    if(S[i] == S[j]){
        res = dfs(i + 1, j - 1, k) + 2;
    }else{
        res = max(dfs(i, j - 1, k), dfs(i + 1, j, k));
        if(k != 0) res = max(res, dfs(i + 1, j - 1, k - 1) + 2);
    }
    return dp[i][j][k] = res;
}

int main() {
    cin>>S>>K;
    N = S.size();
    cout<<dfs(0, N - 1, K)<<endl;
}

Measured memory_bytes: 215552
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long LL;
const int MAXN = 1e7 + 5;

LL divs[MAXN];
int cnt;

int Prime(LL x) {
	for (LL i = 2; i * i <= x; i++) {
		if (x % i == 0) return 0;
	}
	return 1;
}

int main() {
	LL a, b;
	cin >> a >> b;
	LL c = __gcd(a, b);
	int ans = 0;
	for (LL i = 1; i * i <= c; i++) {
		if (c % i == 0) {
			divs[++cnt] = i;
			if (i * i != c) divs[++cnt] = c / i;
		}
	}
	for (int i = 1; i <= cnt; i++) {
		if (Prime(divs[i])) ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8
import sys
from collections import deque
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = False

def main():
    N,K = LMIIS()
    S = input().strip()
    nums = []
    count = 0
    conti = '0'
    for s in S:
        if s == conti:
            count += 1
        else:
            conti = s
            nums.append(count)
            count = 1
    nums.append(count)
    nums.append(0)
    

    i = 0
    tmpsum = sum(nums[:2*K])
    max_c = tmpsum
    for i in range(2*K+1,len(nums),2):
        tmpsum = tmpsum - nums[i- 2*K -1] - nums[i- 2*K] + nums[i-1] + nums[i]
        max_c = max(max_c,tmpsum)
    
    tmpsum = sum(nums[1:2*K+2])
    max_c = max(max_c,tmpsum)
    for i in range(2*K+3,len(nums),2):
        tmpsum = tmpsum - nums[i- 2*K -2] - nums[i-2*K -1] + nums[i-1] + nums[i]
        max_c = max(max_c,tmpsum)

    print(max_c)
        


if __name__ == '__main__':
    main()

Measured memory_bytes: 45936
use proconio::input;
use std::cmp;
fn main() {
    input!(n: usize, m: usize, x: i32, a: [[i32; m + 1]; n],);
    let mut ans = i32::max_value();
    for i in 0..(1 << n) {
        let mut cost = 0;
        let mut sum = vec![0; m];
        for j in 0..n {
            if ((i >> j) & 1) == 0 {
                continue;
            }
            cost += a[j][0];
            for k in 0..m {
                sum[k] += a[j][k + 1];
            }
        }
        let mut ok = true;
        for j in 0..m {
            if sum[j] < x {
                ok = false;
            }
        }
        if ok {
            ans = cmp::min(ans, cost);
        }
    }
    if ans != i32::max_value() {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2196
use std::io;

fn main() {
    let nm = read_vec::<i32>();
    let a_vec = read_vec::<i32>();

    let mut n = nm[0];

    for i in &a_vec {
        n = n - i;
    }
    if n < 0 {
        println!("-1");
    } else {
        println!("{}", n);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 2248
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define price first
#define drinks second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < ll , ll >

using namespace std;

const int N = 100005;
const ll M = 1000000007;
const lb PI = acos(-1);

ll n , m;
pii a[N];

bool inline cmp(pii a , pii b)
{
    return a.price < b.price;
}

int main()
{
    ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

    ll i , money = 0;

    cin >> n >> m;

    for(i = 1 ; i <= n ; i++)
        cin >> a[i].price >> a[i].drinks;

    sort(a + 1 , a + n + 1 , cmp);

    for(i = 1 ; i <= n && m ; i++)
    {
        if(m >= a[i].drinks)
            m -= a[i].drinks , money += a[i].drinks * a[i].price;
        else money += m * a[i].price , m = 0;
    }

    cout << money;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}
ll pow1(ll n,ll i)
{
    ll p=1;
    for(int j=0;j<i;j++)
    {
        p*=n;
    }
    return p;
}
int main()
{
    __FastIO;

    ll n,s=0;
    cin>>n;
    for(int i=1; i<=3; i++)
    {
        s+=pow1(n,i);
    }
    cout<<s<<endl;
    return 0;
}




Measured memory_bytes: 3640
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <iostream>
 
using namespace std;
 
int N;
double ans = 0.0;
vector<vector<double>> dp;
 
 
double coins_alt(vector<double>& v, int i, int tail_size)
{ 
  if (i == v.size())
  { 
    return 1.0;
  }
  double ans = 0.0;
  if (tail_size < N/2)
  { 
    if (dp[i+1][tail_size+1] == -1.0)
    { 
      dp[i+1][tail_size+1] = coins_alt(v, i+1, tail_size+1);
    }
    ans = (1.0 - v[i]) * dp[i+1][tail_size+1];
  }
  if (dp[i+1][tail_size] == -1.0)
  {
    dp[i+1][tail_size] = coins_alt(v, i+1, tail_size);
  }
  ans += v[i] * dp[i+1][tail_size];
  return ans;
}
 
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  std::cin >> N;
 
  dp = vector<vector<double>>(N+1, vector<double>(N+1, -1.0));
 
  vector<double> head(N, 0.0);
 
  for (auto& p : head)
  {
    std::cin >> p;
  }
 
  auto ans = coins_alt(head, 0, 0);
 
  std::cout << std::setprecision(10) << ans;
 
  return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#define WMAX 100000

using namespace std;

int n, k, b;
long long dp[3][WMAX+10], sol;

int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; i++)
        {   b = 1 - b;
            long long w, v;
            cin >> w >> v;
            for(int j=1; j<w; j++) dp[b][j] = dp[1-b][j];
            for(int j=w; j<=k; j++) dp[b][j] = max(dp[1-b][j], dp[1-b][j-w] + v);
        }
    for(int j=1; j<=k; j++) sol = max(sol, dp[b][j]);
    cout << sol << '\n';
    return 0;
}


Measured memory_bytes: 1792
import itertools

n = input()
l = list(map(int, input().split()))
ls = sorted(set(l))
ans = 0
for p in itertools.combinations(ls, 3):
    if p[0] + p[1] > p[2]:
      ans += l.count(p[0]) * l.count(p[1]) * l.count(p[2])
print(ans)

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

using ll = long long;


int N;
int A[51];
int B[51];

bool check(bool used[51]){
    // それぞれの数値についてチェック
    for(int i = 0; i < N; i++){
        bool d[2][51] = {};
        d[0][A[i]] = true;
        // for(int j = 0; j < 51; j++) d[0][j] = used[j];
        int prv = 0;
        int nxt = 1;
        for(int j = 50; j >= 1; j--){
            if(!used[j]) continue;
            memset(d[nxt], 0, sizeof(d[nxt]));
            for(int k = 0; k <= 50; k++){
                if(d[prv][k]){
                    d[nxt][k % j] = true;
                }
            }
            for(int k = 0; k <= 50; k++){
                d[nxt][k] |= d[prv][k];
            }
            swap(prv, nxt);
        }
        if(!d[prv][B[i]])
            return false;
    }
    return true;
}

int main(){

    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> A[i];
    for(int i = 0; i < N; i++)
        cin >> B[i];

    bool used[51] = {};

    int true_cnt = 0;
    for(int k = 50; k >= 1; k--){
        used[k] = false;
        for(int i = 1; i < k; i++) used[i] = true;
        // used[k]=falseでも作れる場合、この桁はfalse確定
        if(check(used)){
            used[k] = false;
            true_cnt++;
        }
        else{
            used[k] = true;
        }
    }

    if(true_cnt == 0){
        cout << -1 << endl;
        return 0;
    }

    ll sum = 0;
    for(int k = 50; k >= 1; k--){
        if(used[k])
            sum += (1LL << k);
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 256
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int N;
        int[] A, B;
        N = sc.NextInt();

        int min = int.MaxValue;

        long sum = 0;
        
        for (int i = 0; i < N; i++)
        {
            int a = sc.NextInt();
            int b = sc.NextInt();
            sum += a;

            if (a > b)
            {
                min = Math.Min(min, b);
            }
        }

        if (min == int.MaxValue)
        {
            Console.WriteLine(0);
        }
        else
        {
            Console.WriteLine(sum-min);
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 17232
#include<stdio.h>
#include<math.h>
int main()
{
	int n,a[]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	scanf("%d",&n);
	printf("%d",a[n]);
	return 0;
}

Measured memory_bytes: 128
//
//  sublime text 3,
//  emre yazicioglu
//

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

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> a >> b;
  if(a > 0 && a < 10 && b > 0 && b < 10)
    cout << a * b;
  else
    cout << -1;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll amari=n%(a+b);
  ll ans=(n-amari)/(a+b)*a;
  if(amari>=a) ans+=a;
  else ans+=amari;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
struct Node {
  int k;
  struct Node *r,*l,*p;
};
typedef struct Node* node;
node root;
node NIL;

void insert(int);
void inorder(node);
void preorder(node);
node find(node,int);
node treeminimum(node);
node treesuccessor(node);
void treedelete(node);

int main (){

 int n,i,x;
  char com[20];
  scanf("%d",&n);
  root = NIL;
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(com[0]=='f'){
      scanf("%d",&x);
      node t=find(root,x);
      if(t!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='d'){
      scanf("%d",&x);
      treedelete(find(root,x));
    }
  }
  return 0;
}
void insert(int k){
  node y=NIL;//xの親
  node x=root;
  node z;
  
  z=(node)malloc(sizeof(struct Node));

  z->k = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x != NIL){
   y=x;//親を設定
    if( z->k < x->k )
      x = x->l;//左の子へ
    else x = x->r;//右の子へ
  }
  z->p = y;
  
  if(y==NIL)
    root = z;
  else {
    if( z->k < y->k ){
      y->l = z;
    }
    else
      y->r = z;
  }
}
void inorder(node u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d",u->k);
  inorder(u->r);
}
void preorder(node u){
  if(u==NIL)return;
  printf(" %d",u->k);
  preorder(u->l);
  preorder(u->r);
}
node find(node u,int k){
  while(u!=NIL && k!=u->k){
    if( k < u->k ) u=u->l;
    else u=u->r;
  }
  return u;
}
node treeminimum(node x){
  while(x->l!=NIL){
    x=x->l;
  }
  return x;
}
node treesuccessor(node x){
  if(x->r!=NIL)return treeminimum(x->r);
  node y=x->p;
  while(y!=NIL&&x==y->r){
    x=y;
    y=y->p;
  }
  return y;
}
void treedelete(node z){
  node y,x;
  if(z->l==NIL||z->r==NIL)y=z;
  else y= treesuccessor(z);

  if(y->l!=NIL)
    x=y->l;
  else x=y->r;

  if(x!=NIL) x->p=y->p;

  if(y->p==NIL) root=x;
  else if(y==y->p->l) y->p->l=x;
  else y->p->r=x;

  if(y!=z) z->k=y->k;

  free(y);
}
    



Measured memory_bytes: 20452
#include<cstdio>
#include<algorithm>
using namespace std;

const int N=1e5+5;
const int mod=1e9+7;

int n,a[N],foo[N],bar[N];

int fp(int x){
	return 1ll*foo[x%N]*bar[x/N]%mod;
}

pair<int,int>solve(int l,int r,int h){
	int mn=1<<30,cnt=0,x=1,y=1;
	for(int i=l;i<=r;++i)
		if(a[i]<mn)mn=a[i],cnt=1;
		else if(a[i]==mn)++cnt;
	if(cnt==r-l+1)
		x=fp(r-l+1)-2,y=fp(mn-h);
	else{
		int z=r-l+1;
		for(int i=l,j=0;i<=r;++i){
			if(!j&&a[i]>mn)j=i;
			if(j&&(i==r||a[i+1]==mn)){
				auto res=solve(j,i,mn);
				x=(res.first+2ll*res.second)*x%mod;
				y=1ll*res.second*y%mod;
				z-=i-j+1;j=0;
			}
		}
		x=(x+mod-y)%mod;
		x=(1ll*x*fp(z)+1ll*y*(fp(z)-2))%mod;
		y=1ll*y*fp(mn-h)%mod;
	}
	return make_pair(x,y);
}

int main(){
	foo[0]=1;foo[1]=2;
	for(int i=2;i<N;++i)foo[i]=1ll*foo[i-1]*foo[1]%mod;
	bar[0]=1;bar[1]=(foo[N-1]<<1)%mod;
	for(int i=2;i<N;++i)bar[i]=1ll*bar[i-1]*bar[1]%mod;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	auto ans=solve(1,n,0);
	printf("%d\n",(ans.first+ans.second)%mod);
	return 0;
}


Measured memory_bytes: 896
import math
a = [0]*5
for i in range(5):
    a[i] = int(input())

total = 100000
for i1 in range(5):
    for i2 in range(5):
        if i1 == i2: continue
        for i3 in range(5):
            if i1 == i3 or i2 == i3: continue
            for i4 in range(5):
                if i1 == i4 or i2 == i4 or i3 == i4: continue
                for i5 in range(5):
                    if i1 == i5 or i2 == i5 or i3 == i5 or i4 == i5: continue
                    temp = math.ceil(a[i1]/10)*10
                    temp += math.ceil(a[i2]/10)*10
                    temp += math.ceil(a[i3]/10)*10
                    temp += math.ceil(a[i4]/10)*10
                    temp += a[i5]
                    if total > temp:
                        total = temp

print(total)


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

int n;
vector<int> graph[10000];
int c[10000];
int idx_c = 0;
int d[10000];

void dfs(int cur, int parent) {
  if (idx_c >= n || d[cur] != -1) {
    return;
  }
  d[cur] = c[idx_c];
  ++idx_c;
  for (int to: graph[cur]) {
    if (to == parent) {
      continue;
    }
    dfs(to, cur);
  }
}

int main() {
  cin>>n;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i=0; i<n; i++) {
    cin>>c[i];
  }
  sort(c, c + n);
  reverse(c, c + n);
  for (int i=0; i<n; i++) d[i] = -1;
  dfs(0, -1);
  long long m = 0;
  for (int i=1; i<n; i++) m += c[i];
  cout<<m<<endl;
  for (int i=0; i<n; i++) {
    cout<<d[i];
    if (i != n-1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
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 keta(x: i64) -> i64{
    let mut y:i64 = x;
    let mut count:i64 = 0;
    while y!=0{
	y /= 10;
	count+=1;
    }
    count
}

//main function
fn main() {
    let n: i64 = read();
    let mut sum: i64 = 0;
    let mut exp: i64 = 10;
    let mut count = 1;
    for _i in 0..keta(n){
	if count % 2 != 0{
	    if n < exp {
		if exp == 10 {
		    sum += n;
		}else{
		    sum += n-exp/10+1;
		}
	    }else {
		sum += exp*9/10;
	    }
	    exp *= 100;
	}
	count += 1;
    }
    println!("{}",sum);
}


Measured memory_bytes: 4352
import 'dart:io';

main(List<String> args){
  int n = int.parse(stdin.readLineSync());
  int ans = 0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
      ans+=i;
    }
  }
  print(ans);
}

Measured memory_bytes: 13100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<std::string> S){
  std::map<string, int> mp;
  int mx = 0;
  for (const auto s: S) {
    mp[s]++;
    mx = max(mx, mp[s]);
  }
  for (const auto& k : mp) {
    if (k.second == mx) std::cout << k.first << std::endl;
  }
}

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


Measured memory_bytes: 26752
#include<stdio.h>
int main()
{
   int pair[100][2];
   int i   = -1;
   int n   =  0;
   int ans =  0;
   int j, k, l;
   
   do {
      ++i;
      scanf("%d %d", &pair[i][0], &pair[i][1]);
   } while (pair[i][0] != 0 || pair[i][1] != 0);
   n = i;
   
   for (i = 0; i < n; ++i){
      ans = 0;
	  for (j = 1; j <= pair[i][0]; ++j) {
         for (k = j + 1; k <= pair[i][0]; ++k){
            for (l = k + 1; l <= pair[i][0]; ++l){
                  if ((j + k + l) == pair[i][1])
                     ++ans;
            }
         }
      }
      printf("%d\n", ans);
      
   }
   return 0;
}

Measured memory_bytes: 1844
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL H, W, K;
std::vector<std::vector<LL>>memo;

LL dp(LL h, LL w)
{
	if (w < 0 || W <= w) return 0;
	if (h == H)
	{
		if (w == K - 1) return 1;
		return 0;
	}
	if (memo[h][w] != -1) return memo[h][w];
	LL left = 0, str = 0, right = 0;
	for (LL bit = 0; bit < (1LL << (W - 1)); ++bit)
	{
		std::vector<LL>pos;
		rep(k, W - 1)
		{
			if (bit&(1LL << k)) pos.push_back(k);
		}
		bool akan = false;
		rep(i, std::max<LL>(pos.size() - 1, 0))
		{
			if (pos[i] + 1 == pos[i + 1])
			{
				akan = true;
				break;
			}
		}
		if (akan) continue;
		int flag = -1;
		for (auto i : pos)
		{
			if (i == w - 1) flag = 0;
			if (i == w) flag = 1;
		}
		if (flag == 0) ++left;
		if (flag == -1) ++str;
		if (flag == 1) ++right;
	}
	LL res1 = (dp(h + 1, w - 1)*left) % mod;
	LL res2 = (dp(h + 1, w)*str) % mod;
	LL res3 = (dp(h + 1, w + 1)*right) % mod;
	return memo[h][w] = (res1 + res2 + res3) % mod;
}

int main()
{
	in >> H >> W >> K;

	memo.resize(H);
	rep(i, memo.size()) memo[i].resize(W, -1);

	out << dp(0, 0) << std::endl;
	return 0;
}


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

template<unsigned long long SIZE> class unionFind{
    protected:
        long long uni[SIZE];
        long long diff_weight[SIZE];
    public:
        unionFind(){
            for(int i=0;i<SIZE;i++){
                uni[i]=-1;
                diff_weight[i]=0;
            }
        }
        unsigned long long root(unsigned long long a){
            if(a>=SIZE) throw std::range_error("与えられたインデックスが木の範囲外です");
            if(uni[a]<0) return a;
            else{
                unsigned long long r=root(uni[a]);
                diff_weight[a]+=diff_weight[uni[a]];
                return uni[a]=r;
            }
        }
        long long weight(unsigned long long a){
            root(a);
            return diff_weight[a];
        }
        long long diff(unsigned long long a, unsigned long long b){
            if(isSame(a,b)) return weight(b)-weight(a);
            else return INT64_MAX;
        }
        unsigned long long count(unsigned long long a){
            return -uni[root(a)];
        }
        bool merge(unsigned long long a, unsigned long long b, long long w=1){
            w+=weight(a);  w-=weight(b);
            a=root(a);  b=root(b);
            if(a==b) return false;
            if(uni[a]>uni[b]){
                swap(a, b);
                w=(-w);
            }
            uni[a]+=uni[b];
            uni[b]=a;
            diff_weight[b]=w;
            return true;
        }
        bool isSame(unsigned long long a,unsigned long long b){
            return root(a)==root(b);
        }
};

int memo[501][500*500];
int r_memo[501];
bool checked[501];

int solve(int n){
    if(n == 2){
        memo[2][0*n+1] = 1;
        return 1;
    }
    if(n == 3){
        memo[3][0*n+1] = memo[3][0*n+2] = 1;
        memo[3][1*n+2] = 2;
        return 2;
    }
    if(checked[n]){
        return r_memo[n];
    }

    int r1 = solve(n/2);
    int r2 = solve((n+1)/2);

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if((i+j)%2 == 1) memo[n][i*n+j] = 1;
            else if(i%2 == 1){
                memo[n][i*n+j] = memo[n/2][(i/2)*(n/2)+(j/2)] + 1;
            }else{
                memo[n][i*n+j] = memo[(n+1)/2][(i/2)*((n+1)/2)+(j/2)] + 1;
            }
        }
    }

    r_memo[n] = 1+max(r1, r2);
    checked[n] = true;

    return 1+max(r1, r2);
}
int main(){
    int n;
    cin >> n;
    
    solve(n);

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(j!=i+1) cout << " ";
            cout << memo[n][i*n+j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 24960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new  InputStreamReader(System.in));
       int n=Integer.parseInt(br.readLine());
       String misnomer ="Hoshino";
       String rightName = "Hoshina";
       while(n-->0) {
           System.out.println(br.readLine().replaceAll(misnomer, rightName));
       }
    }
}


Measured memory_bytes: 24356
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int X = scanner.nextInt();

        int max = 100004;
        boolean[] primes = new boolean[max];

        for (int i = 1 ; i < max ; i++) {
            primes[i] = true;
        }

        for (int i = 2 ; i < max ; i++) {
            if (primes[i]) {
                int c = i * 2;
                while (c < max) {
                    primes[c] = false;
                    c += i;
                }
            }
        }

        for (int i = X ; i < max ; i++) {
            if (primes[i]) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 36452
n=int(input())
s=input()

x=[0]*n
for c in "abcdefghijklmnopqrstuvwxyz":
  b,e=s.find(c),s.rfind(c)
  if b!=e:
    for i in range(b,e+1):
      x[i]+=1

print(max(x))


Measured memory_bytes: 2940
////////////////////////////////////////
//                                       //
//      Gagan_Sharma : DTU               // 
//                                       //                   
///////////////////////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int     long long
// #define mp      make_pair
#define eb      emplace_back
#define pb      push_back
#define ss      second
#define ff      first
#define IOS     ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod     998244353
#define MOD     (1000*1000*1000+7)
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define v1d     vector<int>
#define v2d     vector<vector<int>>
#define vip     vector<pair<int,int> >
#define v1s     vector<string>
#define pa      pair<int,int>
#define print(v) for(auto i:v)cout<<i<<" ";cout<<"\n";
#define endl    '\n'
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i+1];
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)  v.begin(),v.end()
#define mxpq priority_queue <int>
#define mnpq priority_queue<int,vector<int>,greater<int>>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
#define T pair<int,pa>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
 
void read(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    #ifndef ONLINE_JUDGE
         freopen("input.txt",  "r",  stdin);
         freopen("output.txt", "w", stdout);
    #endif
}
 
void solve(){
    string s;cin>>s;
    for(auto i:s){
        if(i == '7'){
            cout<<"Yes\n";return ;
        }
    }
    cout<<"No\n";
 
}
 
int32_t main(){
    // read();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    
 
 
    return 0;
}                      

Measured memory_bytes: 3596
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, H;
  cin >> N >> H;
  vector<int> a(N), b(N);
  for (int i=0; i<N; i++)
    cin >> a.at(i) >> b.at(i);
  int amax = 0;
  for (int i=0; i<a.size(); i++)
    if (amax < a.at(i))
      amax = a.at(i);
  sort(b.begin(), b.end(), greater<int>());
  
  int i=0;
  while (true) {
    if (H > 0 && i < b.size() && b.at(i) > amax) {
      H -= b.at(i);
      i++;
    } else {
      if (H < 0) {
        cout << i << endl;
        break;
      }
      i += H / amax;
      if (H % amax == 0) cout << i << endl;
      else cout << i + 1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 1024
import std.stdio,std.string,std.conv;

int main()
{
	int n;
	int field[16][16];

	while((n = readln.chomp.to!int) != 0)
	{
		foreach(i;0..16)
		{
			foreach(j;0..16)
			{
				field[i][j] = 0;
			}
		}

		int x = n/2;
		int y = n/2+1;
		field[y][x] = 1;

		int count = 2;
		while(true)
		{
			if(count > n*n)
			{
				break;
			}

			x++;
			y++;

			if(x >= n)
			{
				x = 0;
			}
			if(y >= n)
			{
				y = 0;
			}
			if(x < 0)
			{
				x = n-1;
			}
			if(y < 0)
			{
				y = n-1;
			}
			if(field[y][x] == 0)
			{
				field[y][x] = count;
				count++;
			}
			else
			{
				x -= 2;
			}
		}

		foreach(i;0..n)
		{
			foreach(j;0..n)
			{
				writef("%4d",field[i][j]);
			}
			writeln;
		}
	}
	return 0;
}

Measured memory_bytes: 1068
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>
#include<set>
#include<string>
#include <sstream>
#include <algorithm>
#include <math.h>

using namespace std;

int count(long int a){
    int count = 0;
    while(a != 0){
        a = a / 10;
        count+=1;
    }
    return count;
}

int main(){
    long n;
    long ans = 1000000000;
    cin >> n;
    for (long i=1; i*i <= n ; i++) {
        if(n % i == 0){
            
            long b = n / i;
            if( ans > max(count(i),count(b))){
                ans = max(count(i),count(b));
            }
        }
    }
    cout << ans << endl;

    return 0;
}




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

const int MaxN = 100 + 10 + 1;
bool mark[MaxN];
vector<int> tree[MaxN];
vector<int> lp;
int deg[MaxN];

pair<int, int> lp_dfs(int v,int par) {
  pair<int, int> ret = {0, v};
  for(auto u : tree[v])
    if(u != par) 
    {
      pair<int, int> w = lp_dfs(u, v);
      ret = max(ret, {w.first + 1, w.second});
    }
  return ret;
}

bool fill_dfs(int v, int par, int other) {
  if(v == other) {
    lp.push_back(v);
    return true;
  }
  for(auto u : tree[v])
    if(u != par && fill_dfs(u, v, other))
    {
      lp.push_back(v);
      return true;
    }
  return false;
}

void get_longest_path() {
  pair<int, int> tt = lp_dfs(1, 0);
  pair<int, int> ww = lp_dfs(tt.second, 0);
  lp.clear();
  fill_dfs(tt.second, 0, ww.second);
}

void deg_dfs(int v, int par, int h = 0) {
  deg[h] = max(deg[h], (int) tree[v].size());
  for(auto x : tree[v])
    if(x != par) deg_dfs(x, v, h + 1);
}

int main() {
  int n; scanf("%d", &n);
  for(int i = 1; i < n; i++) {
    int x,y;
    scanf("%d %d", &x, &y);
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  get_longest_path();
  unsigned long long len = (lp.size() + 1) / 2, leaves = 1e19L + 1ll;
  if(lp.size() % 2) {
    int cent = -1;
    unsigned long long lvs = 1;
    for(auto x : tree[cent = lp[lp.size() / 2]]) {
      deg_dfs(cent, x);
      deg_dfs(x, cent);
      for(int i = 0; i < MaxN; i++)
        if(deg[i] > 1) lvs *= deg[i] - 1;
      lvs <<= 1;
      leaves = min(leaves, lvs);
      lvs = 1;
      memset(deg, 0, sizeof deg);
    }
    deg_dfs(cent, 0);
    deg[0]++;
    for(int i = 0; i < MaxN; i++)
      if(deg[i] > 1) lvs *= deg[i] - 1;
    leaves = min(leaves, lvs);
  } else {
    int cent1 = lp[lp.size() / 2];
    int cent2 = lp[lp.size() / 2 - 1];
    deg_dfs(cent1, cent2);
    deg_dfs(cent2, cent1);
    unsigned long long lvs = 1;
    for(int i = 0; i < MaxN; i++)
      if(deg[i] > 1) lvs *= deg[i] - 1;
    lvs <<= 1;
    leaves = min(leaves, lvs);
  }
  printf("%llu %llu\n", len, leaves);
  return 0;
}


Measured memory_bytes: 256