akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
long long mo = 1e9+7;
const int maxi=1e6+10;
int a[maxi];
vector<int> v[maxi];
int n;
string s;
int main()
{
    cin>>n;
    cin>>s;

    for  (int i=0;i<n;i++)
        a[s[i]-'a']++;


    long long ans = 1;
    for (int i=0;i<26;i++)
        ans = (ans*(a[i]+1))%mo;

    ans--;
    ans+=mo;
    ans%=mo;

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 25088
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i=0; i<n; i++) {
        int l;
        cin >> l;
        v.push_back(l);
    }
    sort(v.begin(), v.end());
    int cnt = 0;
    for (int i=n-1; i>=2; i--) {
        for (int j=i-1; j>=1; j--) {
            for (int k=j-1; k>=0; k--) {
                if (v[j] + v[k] > v[i]) {
                    cnt++;
                } else {
                    break;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3640
while True:
    m,f,r = list(map(int, input().split()))
    if m == -1 and f == -1 and r == -1:
        break
    elif  m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65 and m + f < 80:
        print("B")
    elif m + f >= 50 and m + f < 65:
        print("C")
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m + f < 30:
        print("F")



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

#define Z 15
#define N -1
#define M 31

int map[M][M];
int num[M][M];
int ans[7];

int di[6][6] = {
	{N, 2, 1, 3, 0, N},
	{2, N, 3, 1, N, 0},
	{2, 1, N, N, 3, 0},
	{2, 3, N, N, 1, 0},
	{2, N, 1, 3, N, 0},
	{N, 2, 3, 1, 0, N}
};

int dn[6][4] = {
	{5, 4, 2, 3},
	{6, 3, 1, 4},
	{6, 5, 1, 2},
	{6, 2, 1, 5},
	{6, 4, 1, 3},
	{5, 3, 2, 4}
};

int ddn[6][2] = {
	{5, 4},
	{6, 4},
	{6, 5},
	{6, 5},
	{6, 4},
	{5, 4}
};

int dd[6] = {1, -1, 1, -1, 1, -1};

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

void solve(int x, int y, int t, int f) {
	int idx = di[t-1][f-1];
	for(int i=0; i<2; ++i) {
		if(map[x][y]>map[x+dx[idx]][y+dy[idx]]) {
			solve(x+dx[idx], y+dy[idx], 7-ddn[t-1][i], idx%2?f:idx==0?t:7-t);
			return;
		}
		idx = (idx+dd[t-1]+4)%4;
	}
	if(num[x][y]>0) ans[num[x][y]]--;
	ans[t]++;
	map[x][y]++;
	num[x][y] = t;
}

int main() {
	int n, t, f;
	while(1) {
		cin >> n;
		if(!n) break;
		for(int i=0; i<M; ++i) for(int j=0; j<M; ++j) {
			map[i][j] = 0; num[i][j] = 0;
		}
		for(int i=0; i<7; ++i) ans[i] = 0;
		while(n--){
			cin >> t >> f;
			solve(Z, Z, t, f);
		}
		for(int i=1; i<=6; ++i) cout << (i==1?"":" ") <<  ans[i];
		cout << endl;
	}
	return 0;
}

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

int main() {
  string S,T;
  int N,A=0,i,now=0;
  cin >> N;
  int *H = new int[N];

  for ( i = 0; i < N; i++)
  {
    cin >> H[i];
    if (i==0)
    {
      continue;
    }
    if (H[i-1]>=H[i])
    {
      now=now+1;
      if (now>A)
      {
        A=now;
      }
    }
    else
    {
      now=0;
    }
  }
  
  cout << A << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<vector>
using namespace std;
#define ll long long
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m;
vector<int>a[100001];
char b[100001][2];
ll ans,sum[3];
void dfs(int x,int d){
	b[x][d]=1;
	for(int i=0;i<a[x].size();++i)
		if(b[a[x][i]][d^1]==0)
			dfs(a[x][i],d^1);
	return ;
}
int main(void){
	register int i,x,y;
	n=read(),m=read();
	for(i=1;i<=m;++i)
		x=read(),y=read(),a[x].push_back(y),a[y].push_back(x);
	dfs(1,0);
	for(i=2;i<=n;++i){
		if(b[i][0]&&!b[i][1])
			++sum[0];
		if(b[i][1]&&!b[i][0])
			++sum[1];
		if(b[i][1]&&b[i][0])
			++sum[2];
	}
	ans=sum[1]+sum[2];
	ans+=sum[2]*(sum[2]-1)>>1;
	ans+=sum[2]*sum[1];
	ans+=sum[2]*sum[0];
	ans+=sum[0]*sum[1];
	printf("%lld",ans-m);
	return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll x;
  cin>>x;
  ll money = 100;
  REP(i,4000) {
    if (money >= x) {
      cout<<i<<endl;
      return 0;
    }
    money *= 1.01;
  }
  return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> vec(n);
  rep(i,n) cin >> vec[i];

  int ans = 1;
  int max = vec[0];

  for(int i = 1; i < n; i++){
    if(vec[i] >= max){
      max = vec[i];
      ans++;
    }
  }

  cout << ans << endl;
}


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


int N, M;

int solve(vector<vector<int> > G){
    queue<pair<int,int>> Q;
    vector<int> used(N+2, 0);
    
    int count = 0;

    Q.push(make_pair(1,1));
    
    while(!Q.empty()){
        pair<int,int> p = Q.front(); Q.pop();
        int now = p.first;
        //cout<<now<<" <><> "<<p.second<<endl;
        if(used[now]){
            if(used[now] != p.second) return -1;
            else continue;
        }
//cout<<now<<" [][]  "<<p.second<<endl;
        used[now] = p.second;

        if(p.second == 1) count++;
        
        for(int y : G[now]){
            if(p.second == 1)Q.push(make_pair(y, p.second+1));
            else Q.push(make_pair(y, p.second-1));
        }
    }

    return count;
}

int main(void)
{

    while(true){
        vector<vector<int> > G;
        int ans;
        int u, v, n;

        
        cin>>N>>M;

        if(!N && !M) break;

        n = N;
        
        G.resize(N+1);

        for(int i = 0; i < M; i++){
            cin>>u>>v;
            G[u].push_back(v);
            G[v].push_back(u);
        }


        ans = solve(G);

        //  cout<<"count "<<ans<<endl;
        
        if(ans == -1){
            cout<<0<<endl;
        } else if(ans%2 == 0 && (n - ans)%2 == 0 && ans != n - ans){
            cout<<2<<endl;
            if(ans < (n-ans)){
                cout<<ans/2<<endl;
                cout<<(n-ans)/2<<endl;
            }else {
                cout<<(n-ans)/2<<endl;
                cout<<ans/2<<endl;
            }
        } else if(ans%2 == 0 && (n - ans)%2 == 0){
            cout<<1<<endl;
            cout<<ans/2<<endl;
        } else if(ans%2 == 0){
            cout<<1<<endl;
            cout<<ans/2<<endl;
        } else if((n-ans)%2 == 0){
            cout<<1<<endl;
            cout<<(n-ans)/2<<endl;
  
        }  else {
            cout<<0<<endl;
        }
    }
   
    return 0;
}




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

int  main()
{
  int a,b;
  int c;
  cin >> a >> b;
  c=b/2;
  
  if(a>=13)
    cout << b;
  if(6 <= a && a < 13)
    cout << c;
  if(a<6)
    cout << 0;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
 
int main(void) {
vector<int> m(13);
m[1] = m[3] = m[5] = m[7] = m[8] = m[10] = m[12] = 31;
m[4] = m[6] = m[9] = m[11] = 30;
m[2] = 28;
int a, b;
cin >> a >> b;
if (m[a] == m[b]) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

llint n;
llint a[100005];
llint ans[100005];
vector<llint> vec;
vector<P> mvec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint mx = 0;
	mvec.push_back(P(0, 0));
	for(int i = 1; i <= n; i++){
		vec.push_back(a[i]);
		if(mx < a[i]) mvec.push_back(P(a[i], i));
		mx = max(mx, a[i]);
	}
	reverse(mvec.begin(), mvec.end());
	sort(vec.rbegin(), vec.rend());
	
	llint p = 0, cnt = 0;
	for(int i = 1; i < mvec.size(); i++){
		llint sum = (mvec[i-1].first-mvec[i].first) * cnt;
		while(p < vec.size() && mvec[i].first <= vec[p]){
			sum += vec[p]-mvec[i].first;
			cnt++;
			p++;
		}
		ans[mvec[i-1].second] += sum;
	}
	
	for(int i = 1; i <= n; i++) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 5744
#include<bits/stdc++.h>
#include<vector>
using namespace std;
main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	vector<int> p;
	vector<int> neg;
	p.push_back(0);
	neg.push_back(0);
	for(int i=0;i<n;i++)
	{
		if(arr[i] > 0){
			p.push_back(arr[i]);
		}
		else if(arr[i] < 0)
		{
			neg.push_back(-1*arr[i]);
		}
		else
		{
			k -= 1;
		}
	}
	sort(neg.begin(),neg.end());
	int me =INT_MAX;
		for(int i=0;i<=k;i++)
		{
			int c1 =INT_MAX;
			if(i < p.size() && k-i < neg.size())
			{
			//	cout<<i<<" "<<k-i<<endl;
				if(p[i] < neg[k-i])
				{
					c1 = 2*p[i] + neg[k-i];
				}
				else
				{
					c1 = 2*neg[k-i] + p[i];
				}
				me = min(c1,me);
			}
		}
		cout<<me<<endl;
}

Measured memory_bytes: 1404
#include<cstdio>
int vis[105];

int main(){
	int x,n;
	scanf("%d%d",&x,&n);
	int find = -1, value = 200;
	for(int i = 1; i <= n; i++){
		int u;
		scanf("%d",&u);
		vis[u] = 1;
	}
	for(int i = 0; i <= 101; i++){
		if(!vis[i]){
			int diff = i-x;
			if(diff<0) diff *= -1;
			if(diff<value){
				find = i;
				value = diff;
			}
		}
	}
	printf("%d\n",find);
	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define f0(i,n)for(ll i=0;i<n;i++)
#define f0r(i,n)for(ll i=n-1;i>=0;i--)
#define fc(i,c,n,s)for(ll i=c;i<=n;i+=s)
#define fcr(i,c,n,s)for(ll i=n;i>=c;i-=s)
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif
	ll n,m;
	cin >> n >> m;
	cout << (m < n ? "No":"Yes") << endl;
	return 0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i=0; i<n; ++i) cin >> p[i];

  sort(p.rbegin(), p.rend());
  int x = p[0] / 2;
  int sum = 0;
  for(int i=1; i<n; ++i){
    sum += p[i];
  }
  cout << x + sum;
}  


Measured memory_bytes: 3632
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int N, A, B;
int main() {
	cin >> N >> A >> B;
	int ret = 0;
	for (int i = 1; i <= N; i++) {
		int cur = i, sum = 0;
		while (cur) sum += cur % 10, cur /= 10;
		if (A <= sum && sum <= B) ret += i;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }






int main(int argc, char* argv[])
{
	for (;;) {
		int N;
		cin >> N;
		if (cin.fail()) break;

		using N2 = array<int, 2>;
		vector<vector<N2>> T(N);
		for (int i = 0; i < N - 1; i++) {
			int u, v, w;
			cin >> u >> v >> w;
			u--, v--;
			T[u].push_back(N2{ v, w });
			T[v].push_back(N2{ u, w });
		}
		vector<int> color(N, 0);
		deque<N2> stack;
		stack.push_back(N2{ 0, 2 });
		while (!stack.empty()) {
			int i = stack.front()[0];
			int c = stack.front()[1];
			stack.pop_front();
			if (color[i] != 0) continue;
			color[i] = c;
			for (auto& nd : T[i]) {
				stack.push_back({ nd[0], (nd[1] & 1) ? ((c == 2) ? 1 : 2) : c });
			}
		};
		for (int i = 0; i < N; i++) {
			cout << (color[i] & 1) << endl;
		}
	}

	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        int[] A = new int[13];
        A[1] = 1;
        int cnt = 1;
        int idx = 0;
        while(true){
            idx++;
            if(Math.pow(6, idx) > N) break;
            else {
                cnt++;
                A[cnt] = (int) Math.pow(6, idx);
            }
        }
        idx = 0;
        while(true){
            idx++;
            if(Math.pow(9, idx) > N) break;
            else {
                cnt++;
                A[cnt] = (int) Math.pow(9, idx);
            }
        }

        //dp[i][j]:ｉパターン目までの引き落とし金額でj円ちょうど引き出すのに少なくとも必要な回数
        int[][] dp = new int[cnt+1][N+1];
        Arrays.fill(dp[0], Integer.MAX_VALUE);
        dp[0][0] = 0;
        for(int i = 1; i < cnt+1; i++){
            dp[i][0] = 0;
            for(int j = 1; j < N+1; j++){
                if(A[i] > j) dp[i][j] = dp[i-1][j];
                else dp[i][j] = Math.min(dp[i-1][j], dp[i][j - A[i]] + 1);
            }
        }
        System.out.println(dp[cnt][N]);

    }

}


Measured memory_bytes: 28244
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    bool is_poor = false;
    if(a == b && b != c) is_poor = true;
    if(a == c && a != b) is_poor = true;
    if(b == c && b != a) is_poor = true;
    if(is_poor) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

class NyaGadgetVector
{
public:
	/**
	@brief 標準入力関数
	@note
	 標準入力から入力されたsize個の値をcollectionに格納する
	**/
	template<typename T> static void InputStream(vector<T>& collection, int size)
	{
		for (int i = 0; i < size; i++)
			cin >> collection[i];
	}
	/**
	@brief 合計関数
	@note
	 collectionのstart_indexからend_indexまでの要素を合計して返す
	**/ 
	template<typename T> static T Sum(const vector<T>& collection, int start_index, int end_index)
	{
		int sum = 0;
		for (int i = start_index; i < end_index; i++)
			sum += collection[i];
		return sum;
	}
};

int main()
{
	int piece_max;  cin >> piece_max;	// コマの数
	int grid_max;	cin >> grid_max;	// 座標の数

	if (grid_max <= piece_max)
	{	// 例外処理: 座標の数 <= コマの数 のとき移動回数 = 0
		cout << 0;
		return 0;
	}

	// 座標の入力
	vector<int> grid_collection(grid_max, 0);
	NyaGadgetVector::InputStream(grid_collection, grid_max);
	sort(grid_collection.begin(), grid_collection.end());

	// 座標間の長さを計算して昇順にソート
	vector<int> grid_length_collection(grid_max - 1, 0);
	loop(i, grid_max -1)
		grid_length_collection[i] = grid_collection[i+1] - grid_collection[i];
	sort(grid_length_collection.begin(), grid_length_collection.end());

	// 答えを出力する
	// 座標間の長さを小さい方から駒の数-1だけ合計したのが答え
	cout << NyaGadgetVector::Sum<int>(grid_length_collection, 0, grid_length_collection.size() - (piece_max - 1));
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n, k;
    cin >> n >> k;
    ll v[n + 1];
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    map<ll, ll> mp;
    vector<int> w;
    ll vis = 1;
    for(int i = 1; i <= n; i++){
        if(mp[vis] == 1){
            break;
        }
        mp[vis]++;
        w.push_back(vis);
        vis = v[vis];
    }
    ll cnt = 0;
    for(int i = 0; i < w.size(); i++){
        if(w[i] != vis)
            cnt++;
        else
            break;
    }
    vector<ll> r;
    for(int i = cnt; i < w.size(); i++)
        r.push_back(w[i]);
    if(k <= cnt)
        cout << w[k];
    else
        cout << r[(k - cnt) % r.size()] << "\n";
    return 0;
}


Measured memory_bytes: 19016
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int sz = s.size();
  int c = 0;
  REP(i,sz) if(s[i]=='o') c++;
  cout << (15-sz+c>=8?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const ll LLINF = 1LL<<60;
/* -- template -- */

int main(){
    ll N; cin >> N;
    cout << (N - 1)*N/2;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[3][3];
  scanf("%s",s[0]);
  scanf("%*c%s",s[1]);
  scanf("%*c%s",s[2]);
  printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Your code here!
    char num[1001];
    int sum;
    while(1){
        scanf("%s",num);
        if(num[0]=='0') break;
        
        sum = 0;
        for(int i=0; num[i] != '\0' ; i++){
            sum += num[i] - '0';
        }
        printf("%d\n",sum);
    }
}



Measured memory_bytes: 2128
N = int(input())
A = list(map(int, input().split()))
ans = 10000
for i in range(len(A)):
    cnt = 0
    while A[i] > 0 and A[i] % 2 == 0:
        cnt += 1
        A[i] /= 2
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 2940
// コイン問題

// 額面が d1, ..., dm のコインで n 支払う
// 各コインの使用枚数は無制限

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

int main() {
    int n, m;
    while(cin >> n >> m) {
        vector<int> coin(m);
        for(auto& d: coin) cin >> d;
        sort(coin.begin(), coin.end());

        vector<int> dp(n + 1, INF);
        dp[0] = 0;
        for(const auto& d: coin)
            for(int sum = 0; sum + d <= n; ++sum) dp[sum + d] = min(dp[sum + d], dp[sum] + 1);
//             for(int sum = n; sum - d >= 0; --sum) dp[sum] = min(dp[sum], dp[sum - d] + 1);
        cout << dp[n] << endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 long double l,a,area;
 cin>>l;
 a=l/3;
 area=a*a*a;
 cout<<setprecision(8)<<area<<endl;


return 0;
}


Measured memory_bytes: 256
#125_C
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))

L=[0 for _ in range(N+1)]
R=[0 for _ in range(N+1)]
for i in range(N):
    L[i+1]=gcd(L[i],A[i])
for i in range(N-1,-1,-1):
    R[i]=gcd(R[i+1],A[i])
    
ans=0
for i in range(N):
    M=gcd(L[i],R[i+1])
    ans=max(ans,M)

print(ans)

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

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

template<int MOD> struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend istream& operator >> (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }

    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

    modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; }
    modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; }
    modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; }
    modnum operator - () { modnum res; if (v) res.v = MOD - v; return res; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }

    modnum pow(int e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    modnum inv() const {
        int g = MOD, x = 0, y = 1;
        for (int r = v; r != 0; ) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        assert(g == 1);
        assert(y == MOD || y == -MOD);
        return x < 0 ? x + MOD : x;
    }
    modnum& operator /= (const modnum& o) { return (*this) *= o.inv(); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }
};
using mn = modnum<1'000'000'007>;

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

    const int MAXV = 3e5;
    vector<mn> fact(MAXV);
    fact[0] = 1;
    for (int i = 1; i < MAXV; i++) {
        fact[i] = i * fact[i - 1];
    }

    auto ncr = [&fact](int n, int r) {
        if (r < 0 || r > n) return mn(0);
        return fact[n] / (fact[r] * fact[n-r]);
    };

    int N, M, K;
    cin >> N >> M >> K;

    mn ans = 0;
    for (int dx = 0; dx < N; dx++) {
        for (int dy = 0; dy < M; dy++) {
            int dist = dx + dy;

            mn ways = (N - dx) * (M - dy);
            if (dx && dy) ways *= 2;

            mn apps = ncr(N * M - 2, K - 2);
            ans += dist * ways * apps;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, m) for (int i = (n), i < (m); i++)

int
main(int argc, char *argv[])
{
  char s[110];
  ll k;
  scanf("%s", s);
  scanf("%lld", &k);

  int x = 0; ll r[110], z = 0;
  while (s[x] != 0) {
    int y = x;
    while (s[y] == s[x]) x++;
    r[z++] = x - y;
  }
  if (strlen(s) == 1) {
    printf("%lld\n", k /((ll)2));
  } else
  if (s[0] == s[strlen(s) - 1] && z > 1) {
    ll ans = 0;
    ans += (r[0] / 2) + (r[z - 1] / 2);
    ans += ((r[0] + r[z - 1]) / 2) * (k - 1);
    for (int i = 1; i < z - 1; i++) ans += (r[i] / 2) * k;
    printf("%lld\n", ans);
  } else if (z == 1) {
    printf("%lld\n", (r[0] * k) / 2);
  } else {
    ll ans = 0;
    for (int i = 0; i < z; i++) ans += (r[i] / 2) * k;
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 128
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  N := NextInt()
  A := make([][][]int, N)
  for i := range A {
    a := NextInt()
    A[i] = make([][]int, a)
    for j := range A[i] {
      A[i][j] = NextIntVec()
      A[i][j][0]--
    }
  }
  ans := 0
  for pat := 0; pat < 2 << uint(N); pat++ {
    P := make([]int, N)
    _p := pat
    cnt := 0
    for i := range P {
      P[i] = _p % 2
      _p /= 2
      if 0 < P[i] { cnt++ }
    }
    if cnt <= ans { continue }
    contradict := false
    for i, p := range P {
      if p < 1 { continue }
      for _, a := range A[i] {
        if P[a[0]] != a[1] {
          contradict = true
          break
        }
      }
      if contradict { break }
    }
    if !contradict { ans = cnt }
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 4864
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  double debt;
  int n;
  debt = 100000;
  cin >> n;
  for(int i=0;i < n;i++) {
    debt *= 1.05;
    debt /=1000;
    debt += 0.999;
    debt = floor(debt);
    debt *= 1000;
  }
  cout << (long long int)debt << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    vector<int>rle(1);
    for(int i=0;i<n;i++)
        if(s[i]=='R'==rle.size()%2)
            rle.back()++;
        else
            rle.push_back(1);
    int sz=rle.size()-!rle[0];
    cout<<n-max(1ll,sz-2*k)<<endl;
}


Measured memory_bytes: 1528
# -*- coding: utf-8 -*-

import math

[N, K] = [int(i) for i in input().split()]

sum = 0
list = []
for n in range(1,N+1):
    if n < K:
        x = abs(math.log2(K/n))
        x_ceil = math.ceil(x)
        sum += pow(0.5, x_ceil)/N
    else:
        x_ceil = 1
        sum += 1/N

print(sum)

Measured memory_bytes: 3060
import statistics

def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    B = [a - ai - 1 for ai, a in enumerate(A)]
    m = int(statistics.median(B))
    ans = sum([abs(b - m) for b in B])
    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int res[100][100];
    bool toright = true;
    int j = 0;
    int color = 0;
    for(int i=0; i<H; ++i) {
        if(toright) {
            while(j < W) {
                if(A[color] > 0) {
                    res[i][j] = color + 1;
                    --A[color];
                    ++j;
                } else {
                    ++color;
                }
            }
            toright = false;
            j = W-1;
        } else {
            while(j >= 0) {
                if(A[color] > 0) {
                    res[i][j] = color + 1;
                    --A[color];
                    --j;
                } else {
                    ++color;
                }
            }
            toright = true;
            j = 0;
        }   
    }

    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) cout << res[i][j] << (j!=W-1 ? ' ' : '\n');
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, string s){
  long long r = 0;
  for (auto&& x : s) {
    if (x == 'R') {
      r++;
    }
  }
  if (2*r > N) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

int main(){
  string s;
  long long N;
  scanf("%lld",&N);
  cin >> s;
  solve(N, s);
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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;

    cout << (n <= k) << endl;

    return 0;
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int a[200000];
int main(){

    int n, c=0;
    scanf("%d",&n);

    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int j=1;
    for(int i=0 ; i<n ; i++){
              if(a[i]==j){
              j++;
              c++;
         }
    }
    c==0 ? printf("-1\n") : printf("%d\n", n-c);
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

vector<lint> to[10000];
bool visited[10000];
lint N, u, v, c[10000], ans = 0;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N - 1) {
		cin >> u >> v; u--; v--;
		to[u].push_back(v);
		to[v].push_back(u);
	}
	REP(i, N) {
		cin >> c[i];
		visited[i] = false;
	}
	sort(c, c + N, greater<lint>());
	REP(i, N - 1) {
		ans += c[i + 1];
	}
	lint root;
	REP(i, N) {
		if (SZ(to[i]) == 1) root = i;
	}
	queue<lint> que;
	que.push(root);
	visited[root] = true;
	lint idx = 1;
	map<lint, lint> mp;
	mp[root] = c[0];
	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (visited[next]) continue;
			visited[next] = true;
			mp[next] = c[idx];
			idx++;
			que.push(next);
		}
	}

	cout << ans << endl;
	REP(i, N) {
		cout << mp[i] << " ";
	}
}


Measured memory_bytes: 4988
using System;
using System.Linq;

namespace agc025_b
{
    class Program
    {
        const long mod = 998244353;
        public static long calc(long x, long pow)
        {
            if (pow == 0) return 1;
            long a = calc(x, pow / 2);
            a = a * a % mod;
            if (pow % 2 == 1) a *= x;
            return a % mod;
        }
        static long[] fact;
        public static long combination(long n, long r)
        {
            return fact[n] * calc((fact[r] * fact[n - r]) % mod, mod - 2) % mod;
        }
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            fact = new long[x[0] + 100];
            fact[0] = 1;
            for (int i = 1; i < fact.Count(); i++) fact[i] = fact[i - 1] * i % mod;
            long ret = 0;
            for (int i = 0; i <= x[0]; i++)
            {
                if ((x[3] - x[1] * i) % x[2] == 0)
                {
                    long a = (x[3] - x[1] * i) / x[2];
                    if (0 <= a && a <= x[0])
                    {
                        ret += combination(x[0], i) * combination(x[0], a) % mod;
                        ret %= mod;
                    }
                }
            }
            Console.WriteLine(ret);
        }
    }
}

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

int main(){
    int n; cin >> n;
    vector <int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b = a;
    sort(a.begin(), a.end());
    int max_1 = a[n-1];
    int max_2 = a[n-2];
    rep(i,n){
        if(b[i] == max_1){
            cout << max_2 << endl;
        }else{
            cout << max_1 << endl;
        }
    }
}


Measured memory_bytes: 4796
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
using namespace std;
int gcd(int a,int b)
{
        if(b==0)
                return a;
        else
                return gcd(b,a%b);
}
int s[100005];
int main()
{
        bool flag=false;
        int n,k;
        scanf("%d%d",&n,&k);
        for(int i=0;i<n;i++)
        {
                scanf("%d",&s[i]);
                if(s[i]==k)
                        flag=true;
        }
        sort(s,s+n);
        if(k>s[n-1])
        {
                cout<<"IMPOSSIBLE"<<endl;
                return 0;
        }
        int a=s[0];
        for(int i=n-1;i>=0;i--)
        {
                a=gcd(a,s[i]);
                if(k%a==0)
                {
                        flag=true;
                        break;
                }
        }
        if(flag)
        {
                cout<<"POSSIBLE"<<endl;
        }
        else
        {
                cout<<"IMPOSSIBLE"<<endl;
        }
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		ArrayList<String> word = new ArrayList<>();
		
		for(; scanner.hasNext();)
		{
			word.add(scanner.next());
		}
		
		int len_max = 0;
		String str_len = "";
		int[] word_cnt = new int[word.size()];
		String[] str_words = new String[word.size()];
		for(int i=0; i<word.size(); i++)
		{
			word_cnt[i] = 0;
			str_words[i] = "";
		}
		
		for(int i=0; i<word.size(); i++)
		{
			String w = word.get(i);
			if(w.length() > len_max)
			{
				len_max = w.length();
				str_len = w;
			}
			for(int j=0; j<=i; j++)
			{
				if(w.equals(word.get(j)))
				{
					word_cnt[j] ++;
					str_words[j] = w;
				}
			}
		}
		
		String str_word = "";
		int word_max = 0;
		for(int i=0; i<word.size(); i++)
		{
			if(word_max < word_cnt[i])
			{
				word_max = word_cnt[i];
				str_word = str_words[i];
			}
		}
		
		System.out.println(str_word +" "+ str_len);
	}
}

Measured memory_bytes: 26184
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int diff = b - a;
        int A = 0;
        for (int i = diff -1; i > 0; i--) {
            A += i;
        }
        System.out.println(A-a);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21076
import sys

s = []
num = 0
for line in sys.stdin:
    if int(num) == 0:
        N, M = map(int, line.strip().split(" "))
    elif int(num) < M + 1:
        i = num - 1
        s.append(line.strip().split(" ")[1:])
    else:
        p = line.strip().split(" ")
    num += 1

#print(N, M, s, p)

state_num = pow(2, N)
clear_num = 0

for i in range(state_num):
    states = format(i, 'b').zfill(N)
    #print(states)

    all_on = True
    for j in range(M):
        sws = s[j]
        on_num = 0
        #print(sws)
        for sw in sws:
            #print(sw)
            if states[int(sw)-1] == "1":
                on_num += 1
        #print("ON",on_num)
        if on_num % 2 != int(p[j]):
            all_on = False
        #print(all_on)

    if all_on:
        clear_num += 1

print(clear_num)

Measured memory_bytes: 3192
/*
	2522:Register Phase
*/
#include	<iostream>
#include	<string>

using namespace std;

bool isbigal(char);
bool issmlal(char);
bool isnum(char);

int main(void) {
	string str;
	bool s = false, b = false, n = false;
	
	cin >> str;
	
	string::iterator it = str.begin();
	while(it != str.end()) {
		if( isbigal(*it) ) { b = true; }
		if( issmlal(*it) ) { s = true; }
		if( isnum(*it) ) { n = true; }
		it++;
	}
	if(str.size() >= 6 && b && s && n) { cout << "VALID" << endl; }
	else { cout << "INVALID" << endl; }
	
	return 0;
}

bool isbigal(char c) {
	if('A' <= c && c <= 'Z') {
		return true;
	}
	return false;
}

bool issmlal(char c) {
	if('a' <= c && c <= 'z') {
		return true;
	}
	return false;
}

bool isnum(char c) {
	if('0' <= c && c <= '9') {
		return true;
	}
	return false;
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> P;
#define INF 1e9

int di[4]={0,0,1,-1};
int dj[4]={1,-1,0,0};


int main()
{
int h,w;
int ch,cw;
int dh,dw;

cin>>h>>w;
cin>>ch>>cw;
ch--;cw--;
cin>>dh>>dw;
dh--;dw--;
vector<string>s(h);
rep(i,h)cin>>s[i];
deque<P>q;

vector<vector<int>> dist(h,vector<int>(w,INF));
dist[ch][cw]=0;

q.emplace_back(ch,cw);

while(!q.empty())
{
int i=q.front().first;
int j=q.front().second;
int d=dist[i][j];
q.pop_front();


for(int v=0;v<4;v++)
{
int ni=i+di[v];
int nj=j+dj[v];
if(ni<0||ni>=h||nj<0||nj>=w)continue;
if(s[ni][nj]=='#')continue;
if(dist[ni][nj]<=d)continue;
dist[ni][nj]=d;
q.emplace_front(ni,nj);
}

for(int ei=-2;ei<=2;ei++)
{
for(int ej=-2;ej<=2;ej++)
{
int ni=i+ei;
int nj=j+ej;
if(ni<0||ni>=h||nj<0||nj>=w)continue;
if(s[ni][nj]=='#')continue;
if(dist[ni][nj]<=d+1)continue;
dist[ni][nj]=d+1;
q.emplace_back(ni,nj);
}


}

}

int ans=dist[dh][dw];
if(ans==INF)cout <<-1;
else cout <<ans;
}

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n, a, b, c;
  cin >> a >> b >> c >> n;
  long long sum = 0;
  if(a > n){
    sum += n;
    cout << sum << endl;
  }else{
    sum += a;
    n -= a;
    if(b > n){
      cout << sum << endl;
    }else{
      n -= b;
      sum -= n;
      cout << sum << endl;
    }
  }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll p,q,r;cin>>p>>q>>r;
  print(min({p+q,q+r,r+p}));
  return 0;
}

Measured memory_bytes: 3624
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll x ;
	cin>> x ;
	ll i;
	ll amount=100;
	for(i=0;i<=1000000;i++){
		ll ps=(amount/100);
		amount+=ps;
		if(amount==x){
			break;
		}
		if(amount>x)break;
	}
	cout<<i+1<<endl;
	return 0;
}

Measured memory_bytes: 3604
a = []
for i in range(5):
    a.append(int(input()))
a.sort(reverse=True)

time = 0
max_wait = 0
for item in a:
    if item % 10 != 0:
        wait = 10 - (item % 10)
        item += wait
        max_wait = max(wait, max_wait)
    time += item

time -= max_wait
print(time)

Measured memory_bytes: 3064
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]) {
        Scanner kb = new Scanner(System.in);
        int n = kb.nextInt(), m = kb.nextInt();
        System.out.println((n*(n-1))/2+(m*(m-1))/2);
    }
}


Measured memory_bytes: 22612