akhauriyash/Code-Regression huggingface dataset:
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READAR(A,N);
    ll pref=0;
    ll ans=0;
    ll fact=1;
    FORI(i,1,N)
    {
        fact=(fact*i)%MOD;
        pref=(pref+modInverse(i))%MOD;
        ans=(ans+((A[i]-A[i-1])*pref)%MOD)%MOD;
    }
    ans=(ans*fact)%MOD;
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


   
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
long long S,X1,Y1,X2,Y2;
int main(){
	scanf("%lld",&S);
	if(S==1000000000000000000)
		return puts("0 0 1000000000 0 0 1000000000"),0;
	X1=Y2=sqrt(S);
	if(S-X1*Y2>1e9)Y2++;
	S-=X1*Y2;
	X2=-1,Y1=S;
	printf("1 0 %lld %lld %lld %lld\n",X1+1,Y1,X2+1,Y2);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctype.h>
using namespace std;

int main ()
{
    char a1,b1,c,d;
    scanf(" %c%c%c%c", &a1, &b1, &c, &d);
    int a = (c-'0') *10 +(d-'0');
    int b = (a1-'0') *10 +(b1-'0');
    if((a>12 || a==0)&& (b >12 || b==0))
        printf("NA\n");
    else if((a>12 || a==0) &&b<=12&&b>0)
            printf("MMYY\n");
    else if(a <=12 &&a>0&& (b >12 || b==0))
            printf("YYMM\n");
    else if(a <=12 &&a>0&&b <=12&&b>0)
            printf("AMBIGUOUS\n");
        return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by E SAMEER KUMAR on 09/04/20.
//  Copyright © 2020 E SAMEER KUMAR. All rights reserved.

#include <bits/stdc++.h>
using namespace std;
int get(int i,map<int,int>& dp,map<int,vector<int>>& graph,int from){
    if(dp[i]!=-1){
        return dp[i];
    }
    int dis=0;
    for(int j=0;j<graph[i].size();j++){
        if(graph[i][j]!=from){
            dis=max(dis,1+get(graph[i][j],dp,graph,i));
        }
    }
    dp[i]=dis;
    return dis;
    return 0;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    map<int,vector<int>> graph;
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        graph[u].push_back(v);
    }
    map<int,int> dp;
    for(int i=1;i<=n;i++){
        dp[i]=-1;
    }
    int ans=0;
    for(int i=0;i<=n;i++){
        if(dp[i]!=-1){
            ans=max(ans,dp[i]);
        }
        else{
            dp[i]=get(i,dp,graph,-1);
            ans=max(ans,dp[i]);
        }
    }
    /*for(auto x: dp){
        cout<<x.first<<" to  "<<x.second<<endl;
    }
    cout<<"---"<<endl;*/
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 21376
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll A, B, N;
    scanf("%lld %lld %lld", &A, &B, &N);

    ll m = min(B - 1, N) * A / B;

    printf("%lld", m);
}


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

#define hell                         1000000007
#define lcm(a,b)                     ((a*b)/__gcd(a,b))
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	ll a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) ret("bust")
	ret("win")	
	
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    double N;
    cin >> N;
    cout << 0.5+(int)N%2/N/2.0;
    return 0;
}


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

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}

void solve(long long N, vector<long long> A){
	long long res = A[0], x, y;
	for(int i = 1 ; i <= N-1 ; i++){
		res = extgcd(res, A[i], x, y);
	}
	printf("%lld\n", res);
}

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


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

ll solve() {
    ll N, K, a;
    cin >> N >> K;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
    }
    ll ans = (N+K-3)/(K-1);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main () {
	string str;
	cin >> str;
	int kupc[4];
	fill(kupc, kupc + 4, 0);
	for (unsigned int i = 0; i < str.size(); i++) {
		switch(str[i]) {
		case 'K': kupc[0]++; break;
		case 'U': kupc[1]++; break;
		case 'P': kupc[2]++; break;
		case 'C': kupc[3]++; break;
		}
	}
	cout << *(min_element(kupc, kupc + 4)) << endl;
	return 0;
}

Measured memory_bytes: 1188
/**
 *    author        : Saurav Paul 
 *    created       : August 06, 2020 10:20 PM
 *    Problem Name  : A - Frog 1
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_a
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    const int INF = 1e9+90 ;

    vector<int> v(n), dp(n, INF) ;
    for(auto &x : v) cin >> x;

    dp[0] = 0 ;
    for(int i = 1 ; i < n ; i++){
        dp[i] = min(dp[i], abs(v[i]-v[i-1]) + dp[i-1]) ;
        if(i-2 >= 0) 
            dp[i] = min(dp[i], abs(v[i]-v[i-2]) + dp[i-2]) ;
    }

    cout << dp[n-1] << endl ;

    return 0 ;
}


Measured memory_bytes: 4004
import math
a = [int(input()) for i in range(5)]
sum = 0
r =10
for i in range(5):
  if a[i] % 10 ==0:
    sum+=a[i]
  elif a[i] % 10 !=0:
    r = min(r,a[i]%10)
    sum+= (10*math.ceil(a[i]/10))
print(sum-10+r)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    string S;
    cin >> N  >> S;    
   
    string t = "No";
    if (N%2==0 && S.substr(0,N/2)==S.substr(N/2,N/2))
    {
      t ="Yes";
    }
    cout << t << endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

const int max_n=100001;
vector<int> vi[max_n];
vector<pint> bridge;
vector<int> articulation;
int ord[max_n],low[max_n];
bool used[max_n];
void lowlink_dfs(int v,int par,int &cur_ord){
    used[v]=true;
    ord[v]=cur_ord++;
    low[v]=ord[v];

    bool isArticulation=false;
    int ctree=0;
    rep(i,vi[v].size()){
        if(!used[vi[v][i]]){
            ++ctree;
            lowlink_dfs(vi[v][i],v,cur_ord);
            low[v]=min(low[v],low[vi[v][i]]);
            if(par!=-1&&ord[v]<=low[vi[v][i]]) isArticulation=true;
            if(ord[v]<low[vi[v][i]]) bridge.pb(mp(min(v,vi[v][i]),max(v,vi[v][i])));
        }
        else if(vi[v][i]!=par){
            low[v]=min(low[v],ord[vi[v][i]]);
        }
    }
    if(par==-1&&ctree>1) isArticulation=true;
    if(isArticulation) articulation.pb(v);
}
int main(){
    int n,m,sr,ds;
    cin>>n>>m;
    rep(i,m){
        cin>>sr>>ds;
        vi[sr].pb(ds);
        vi[ds].pb(sr);
    }
    int ord=0;
    rep(i,n){
        if(!used[i]) lowlink_dfs(i,-1,ord);
    }
    sort(bridge.begin(),bridge.end());
    /*rep(i,articulation.size()){
        cout<<articulation[i]<<endl;
    }*/
    rep(i,bridge.size()){
        cout<<bridge[i].first<<" "<<bridge[i].second<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
	int N, H, B[100000];
	int amax = 0;
	int cnt = 0;
	cin >> N >> H;
	for (int i = 0; i < N; i++){
		int a;
		cin >> a >> B[i];
		amax = max(a, amax);
	}
	sort(B, B + N);
	for (int i = N - 1; i >= 0; i--){
		if (B[i]>=amax) {
			H -= B[i];
			cnt++;
		}
		if (H <= 0){
			cout << cnt << endl;
			return 0;
		}
	}
	cout << cnt + (H + amax - 1) / amax << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	static Scanner scn = new Scanner(System.in);
	public static void main(String[] args) {
		int a=0;
		int b=0;
		int c=0;
		int d=0;
		int n = scn.nextInt();
		for(int i=0;i<n;i++) {
			String s=scn.next();
			if(s.equals("AC")) {
				a+=1;
			}else if(s.equals("WA")) {
				b++;
			}else if(s.equals("TLE")) {
				c++;
			}else if(s.equals("RE")) {
				d++;
			}
		}System.out.print("AC x ");
		System.out.println(a);
		System.out.print("WA x ");
		System.out.println(b);
		System.out.print("TLE x ");
		System.out.println(c);
		System.out.print("RE x ");
		System.out.println(d);
	}
}

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

int main(){
    long long int n, a, b;
    cin >> n >> a >> b;

    long long int amax = (n-1) * b + a;
    long long int amin = (n-1) * a + b;
    cout << max(0LL, amax - amin + 1) << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int year = sc.nextInt();
        int number = year / 100;
        StringBuilder sb = new StringBuilder();
        sb.append("ai1333");
        for(int i = 0; i < number;i++){
            sb.append("3");
        }
        System.out.println(new String(sb));
        
    }
}



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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pair<pii,vector<int>> a, pair<pii,vector<int>> b){
    if(a.first.first*b.first.second==a.first.second*b.first.first)
        return a.first.second>b.first.second;
    return a.first.first*b.first.second<a.first.second*b.first.first;
}

const int mod = 1e9 + 9;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}
vl dp(1e7+1);
int main(){
    fastio;
    int n;string a,b;
    cin>>n;
    cin>>a>>b;
    f(i,0,n)cout<<a[i]<<b[i];
    cout<<endl;
}

Measured memory_bytes: 78336
ni = lambda: int(input())
nl = lambda: list(map(int, input().split()))
nm = lambda: map(int, input().split())

n, m, x, y = nm()
xmax = max(nl()+[x])
ymin = min(nl()+[y])

if xmax < ymin:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
import sys
from collections import Counter
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    H=[int(input())for _ in range(n)]
    H.sort()
    ans=10**9
    for i in range(n-k+1):
        ans=min(ans,H[i+k-1]-H[i])
    print(ans)
if __name__=='__main__':
    main()

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

int main(){
    int H,W;
    char c[21][21];
    int check[21][21];
    int i,j;
    queue<pair<int,int>> que;
    cin >> H >> W;
    int ans = 0;
    for(i=0;i<H;i++)for(j=0;j<W;j++)cin >> c[i][j];
    for(i=0;i<H;i++)for(j=0;j<W;j++){
        if(c[i][j]=='#')continue;
        else{
        for(int k=0;k<H;k++)for(int l=0;l<W;l++)check[k][l]=-1e9;
        check[i][j]=0;
        que.push(pair<int,int> (i,j));
        	while(!que.empty()){
		        int x = que.front().first;
		        int y = que.front().second;
		        int dx[4] = {1,-1,0,0};
		        int dy[4] = {0,0,1,-1};
		        que.pop();
		        for(int k=0;k<4;k++){
			        if(c[x+dx[k]][y+dy[k]]=='.' && check[x+dx[k]][y+dy[k]]==-1e9){
				        check[x+dx[k]][y+dy[k]]=check[x][y]+1;
				        que.push(pair<int,int> (x+dx[k],y+dy[k]));
			    }
		        }
	        }
    for(int k=0;k<H;k++)for(int l=0;l<W;l++)if(check[k][l]>ans)ans=check[k][l];
    }}
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)cin >> a[i];
  int sum = 0;
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      sum += a[i]*a[j];
    }
  }
  cout << sum << endl;
  return 0;
}

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

int main(void) {
    int N, M;
    cin >> N >> M;

    priority_queue<ll> que;
    for (int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        que.push(A);
    }

    for (int i = 0; i < M; i++)
    {
        ll front = que.top();
        que.pop();
        front /= 2;
        que.push(front);
    }
    
    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }

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


Measured memory_bytes: 4304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		int[][] dp = new int[s.length + 1][13];

		int m = 1_000_000_007;

		dp[0][0] = 1;
		for (int i = 0; i < s.length; i++) {
			int a = (s[i] == '?') ? -1 : s[i] - '0';
			for (int j = 0; j < 10; j++) {
				if (a != -1 && a != j) continue;
				for (int k = 0; k < 13; k++) {
					dp[i + 1][(k * 10 + j) % 13] = (dp[i + 1][(k * 10 + j) % 13] + dp[i][k]) % m;
				}
			}
		}

		//for (int i = 0; i < dp.length; i++) {
		//	for (int j = 0; j < 13; j++) {
		//		System.out.print(dp[i][j]);
		//		System.out.print(" ");
		//	}
		//	System.out.println();
		//}
		System.out.println(dp[s.length][5]);
	}
}


Measured memory_bytes: 32628
n = int(input())
s = input()
l_cnt = 0
r_cnt = 0
l_ans = 0
for i in s:
    if i == ')':
        if l_cnt:
            l_cnt -= 1
        else:
            l_ans += 1
    else:
        l_cnt += 1

print(l_ans*'(' + s + l_cnt*')')

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  int max = 0;
  rep(i, n) {
    rep(j, n) {
      if (abs(a.at(i) -a.at(j)) > max) {
        max = abs(a.at(i) - a.at(j));
      }
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Colorful Leaderboard
            int n = int.Parse(Console.ReadLine());
            var a = ReadLine();
            var rank = new int[9];

            foreach(var ai in a)
            {
                int index = ai / 400;

                if (index > 7)
                {
                    rank[8]++;
                }
                else
                {
                    rank[index]++;
                }
            }

            int min = 0;

            for(int i = 0; i < 8; i++)
            {
                if (rank[i] > 0)
                {
                    min++;
                }
            }

            int max = min + rank[8];

            //全員スコアが3200以上の可能性もある
            if (min == 0)
            {
                min = 1;
            }

            Console.WriteLine("{0} {1}", min, max);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

const ll mod = ll(1e9) + 7;
const int INF = 1<<29;

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n);
    rep(i,n){
        vector<int> g(n,INF);
        queue<int> q;
        q.push(i);
        g[i] = 0;
        while (!q.empty()){
            int r = q.front(); q.pop();
            ans[g[r]]++;
            if (r>0 && g[r-1]==INF){
                g[r-1] = g[r] + 1;
                q.push(r-1);
            }
            if (r+1<n && g[r+1]==INF){
                g[r+1] = g[r] + 1;
                q.push(r+1);
            }
            if (r==x && g[y]==INF){
                g[y] = g[r] + 1;
                q.push(y);
            }
            else if (r==y && g[x]==INF){
                g[x] = g[r] + 1;
                q.push(x);
            }
        }
    }
    for (int i=1;i<n;i++){
        cout << ans[i]/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
#define MAX_N 200009
using ll = long long;

vector<int> a;
vector<int> to[MAX_N];
int dp[MAX_N];
int ans[MAX_N];

void dfs(int v, int p=-1) {
  int i = lower_bound(dp, dp+MAX_N, a[v]) - dp;
  int old = dp[i];
  dp[i] = a[v];
  ans[v] = i;
  if (p != -1) ans[v] = max(ans[v], ans[p]);
  for (auto u : to[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  dp[i] = old;
}

int main() {
  int n;
  cin >> n;
  a = vector<int>(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    to[s].push_back(t);
    to[t].push_back(s);
  }
  rep(i,MAX_N) dp[i] = INF;
  dp[0] = -INF;
  dfs(0);
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return(0);
}


Measured memory_bytes: 30828
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e20);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }


int main() {

    std::vector<long long> sequence;
    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;
    vll A(X), B(Y), C(Z);
    rep(i, X)  cin >> A[i];
    rep(i, Y)  cin >> B[i];
    rep(i, Z)  cin >> C[i];
    sort(A.begin(), A.end(), std::greater<ll>());
    vll BC(Y * Z);
    int count = 0;
    rep(i, Y) {
        rep(j, Z) {
            BC[count] = B[i] + C[j];
            count++;
        }
    }
    sort(BC.begin(), BC.end(), std::greater<ll>());
    count = 0;
    vll T(std::min(K, int(BC.size())) * X);
    rep(i, X) {
        rep(j, std::min(int(BC.size()), K)) {
            T[count] = A[i] + BC[j];
            count++;
        }
    }
    sort(T.begin(), T.end(), std::greater<ll>());

    rep(i, K)
        cout << T[i] << endl;
    
}

Measured memory_bytes: 31616
import qualified Data.ByteString.Char8 as B
import qualified Data.IntMap as M
import Data.List
import Data.Char

main :: IO ()
main = do
    [_, m] <- readInts
    as <- readInts
    print $ solve m as

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve m =  M.foldl' (+) 0
     . fmap (\x -> x * (x - 1) `div` 2)
     . foldr (M.alter $ return . maybe 1 succ)  M.empty
     . map (`mod` m)
     . scanl' (+) 0


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

int main() {
    int k,s,l=0,c=0;
    cin>>k>>s;

    for (int i=0;i<=k;i++){
      for (int j=0 ;j<= k;j++){
      l=s-(i+j) ;
      
        if(0<= l && l <= k )
            c++;
      }
    }
  cout <<c<<"\n";
  return 0;
}

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

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

int h,w,d,n;
string grid[55];
bool vis[55][55];
bool exist[55][55];

void dfs(int y,int x){
  if(vis[y][x])return;
  vis[y][x] = true;

  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(grid[ny][nx]=='#')continue;
    dfs(ny,nx);
  }
}

int main(){
  cin >> h >> w >> d >> n;
  rep(i,h)cin >> grid[i];

  rep(i,h)rep(j,w){
    vis[i][j] = false;
    exist[i][j] = (grid[i][j]!='#');
  }

  rep(i,h)rep(j,w){
    if(grid[i][j] == 'D')dfs(i,j);
  }

  int r[55];
  rep(i,d)cin >> r[i];
  while(n--){
    int x,y,s;
    cin >> x >> y >> s;

    rep(i,h)rep(j,w){
      int dify = abs(i-y), difx = abs(j-x);
 
      bool f = true;
      if(s>0){
	if(dify<=r[s-1] && difx<=r[s-1])f = false;
      }
 
      if(f){
	if(s<d){
	  if(dify>r[s] || difx>r[s])f = false;
	}
      }
      exist[i][j] &= f;
    }
    //rep(i,h){rep(j,w)cerr << exist[i][j]; cerr << endl;} cerr << endl;
  }

  bool ok=false, ng = false;
  rep(i,h)rep(j,w){
    if(vis[i][j] && exist[i][j])ok = true;
    if(!vis[i][j] && exist[i][j])ng = true;
  }

  if(ok && ng)cout << "Unknown" << endl;
  if(ok && !ng)cout << "Yes" << endl;
  if(!ok && ng)cout << "No" << endl;
  if(!ok && !ng)cout << "Broken" << endl;
}

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

int main() {
	int A,B,H,M;
	cin >> A >> B >> H >> M;

	double A_pos=M_PI*(30.*H+M/2.)/180.;
	double B_pos=M_PI*(6.*M)/180.;

	double d=pow(A*A+B*B-2*A*B*cos(abs(A_pos-B_pos)),0.5);

	cout << fixed << setprecision(12) << d << endl;
	return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 17
#define INF 1e9+7

using namespace std;

int n,ar[N][N];
ll dp[(1 << N)];
bool vis[(1 << N)];
bool vis2[(1 << N)];
ll value[(1<<N)];

bool ison(ll mask,ll i)
{
    return (mask >> i)&1;
}

ll get_val(ll mask)
{
    if(vis2[mask])
        return value[mask];
    vis2[mask] = true;
    ll res=0;

    rep(i,0,n)
        if(ison(mask,i))
            rep(j,0,i)
                if(ison(mask,j))
                    res+=ar[i][j];

    return value[mask]=res;
}

ll solve(int mask)
{
    if(vis[mask])
        return dp[mask];

    vis[mask] = true;

    ll res = 0;

    for(int sub = mask;sub >= 0;sub = (sub-1)&mask)
    {
        ll cur = solve(mask^sub)+get_val(sub);

        res = max(res,cur);

        if(sub == 0)
            break;
    }

    return dp[mask] = res;
}

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

    cin >> n;

    rep(i,0,n)
    {
        rep(j,0,n)
        {
            cin >> ar[i][j];
        }
    }

    cout << solve((1 << n)-1);

    return 0;
}


Measured memory_bytes: 1536
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()


def solve():

    S = input()
    N = len(S)
    gr = itertools.groupby(list(S))
    ans = [0 for _ in range(N)]

    s = 0
    for k, g in gr:
        g = list(g)
        if k == 'R':
            rlen = len(g)
        elif k == 'L':
            llen = len(g)
            if rlen % 2 == 0:
                ans[s + rlen - 1] += rlen // 2
                ans[s + rlen] += rlen // 2
            elif rlen % 2 == 1:
                ans[s + rlen - 1] += (rlen // 2) + 1
                ans[s + rlen] += rlen // 2
            if llen % 2 == 0:
                ans[s + rlen - 1] += llen // 2
                ans[s + rlen] += llen // 2
            elif llen % 2 == 1:
                ans[s + rlen - 1] += (llen // 2)
                ans[s + rlen] += (llen // 2) + 1
            s += rlen + llen

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 11244
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>

using namespace std;

int main() {
    int K;
    cin >> K;
    vector<vector<int>> g(K + 1, vector<int>(K + 1));
    for(int i = 1; i <= K; i++) {
        for(int j = 1; j <= K; j++) {
            g[i][j] = __gcd(i, j);
        }
    }
    long long sum = 0;
    for(int i = 1; i <= K; i++) {
        for(int j = 1; j <= K; j++) {
            for(int k = 1; k <= K; k++) {
                sum += __gcd(i, g[j][k]);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3756
s = input()

cnt = 0
ans = 0

if len(s) == 1:
    cnt = 0
else:
    l = 0
    k = 0
    while True:
        if s[l] == s[-k-1]:
            l += 1
            k += 1
            if l + k >= len(s)-1:
                break
        elif s[l] == 'x':
            l += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        elif s[-k-1] == 'x':
            k += 1
            cnt += 1
            if l + k >= len(s)-1:
                break
        else:
            ans = -1
            break

if ans == -1:
    print(ans)
else:
    print(cnt)


Measured memory_bytes: 3316
//%std
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out = 0, fh = 1;
	char jp = getchar();
	while ((jp > '9' || jp < '0') && jp != '-')
		jp = getchar();
	if (jp == '-')
		fh = -1, jp = getchar();
	while (jp >= '0' && jp <= '9')
		out = out * 10 + jp - '0', jp = getchar();
	return out * fh;
}
void print(int x)
{
	if (x >= 10)
		print(x / 10);
	putchar('0' + x % 10);
}
void write(int x, char c)
{
	if (x < 0)
		putchar('-'), x = -x;
	print(x);
	putchar(c);
}
int lcm(int x, int y)
{
	return x / __gcd(x, y) * y;
}
int main()
{
	int x = read();
	int k = lcm(360, x);
	if ((k / 360) & 1)
		write(k / x, '\n');
	else
		write(lcm(720, x) / x, '\n');
	return 0;
}


Measured memory_bytes: 3532
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << (X - Z) / (Y + Z) << endl;
}


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

int main()
{
  vector<vector<int>> a(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      cin >> a[i][j];
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++)
    cin >> b[i];
  
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < n; k++)
      {
        if (a[i][j] == b[k])
        {
          a[i][j] = -1;
        }
      }
    }
  for (int i = 0; i < 3; i++)
  {
    if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1)
    {
       cout << "Yes" << endl;
       return 0;
    } 
  }
  for (int i = 0; i < 3; i++)
  {
    if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1)
    {
       cout << "Yes" << endl;
       return 0;
    } 
  }
  if (a[1][1] == -1 && a[2][2] == -1 && a[0][0] == -1)
  {
    cout << "Yes" << endl;
    return 0;
  }
  if (a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a=0,ans=0;
	cin >> n;
	vector<int>vec(n); 
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
		a = max(a, vec[i]);
	}
	rep(i, a) {
		rep(j, n) {
			if (vec[j] > 0) {
				ans++;
				while (j<n&&vec[j] > 0) {
					vec[j]--;
					j++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

cnt = 0
if s[0] == "A":
  a = 1
  f = 1
else:
  f = 0
  a = 0

for i in s[1:]:
  if i == "A":
    if f == 1:
      a += 1
    else:
      a = 1
    f = 1
  elif i == "B":
    if f == 1:
      f = 2
    else:
      f = 0
      a = 0
  else:
    if f == 2:
      cnt += a
      f = 1
    else:
      a = 0
      f = 0

print(cnt)

Measured memory_bytes: 3500
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/26/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string S;
  cin >> S;
  set<char> as;
  for (char c = 'a'; c <= 'z'; c++)
    as.insert(c);
  for (auto c : S)
    as.erase(c);
  if (not as.empty()) {
    S.push_back(*as.begin());
  } else {
    int i = S.size()-1;
    while (i >= 0 and as.upper_bound(S[i]) == as.end()) {
      as.insert(S[i--]);
    }
    if (i < 0) {
      cout << -1 << endl;
      return 0;
    } else {
      S[i] = *as.upper_bound((S[i]));
      S.resize(i+1);
    }
  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

ll dp[3010][3010]={};

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  string s;cin>>s;

  dp[0][1]=1;

  rep(i,1,n){
    rep(j,1,n+1){
      if(s[i-1]=='<'){
        dp[i][j]+=dp[i-1][j-1];
      }else{
        dp[i][j]+=mod+dp[i-1][i]-dp[i-1][j-1];
      }
      dp[i][j]%=mod;

      dp[i][j]+=dp[i][j-1];
      dp[i][j]%=mod;
    }
  }

  cout<<dp[n-1][n]%mod<<ENDL;
} 
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 70784
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)




class unionfind
{
private:
    vector<long long> par;
    vector<long long> rank;
public:
    unionfind(long long n);
    long long find(long long x);
    void unite(long long x, long long y);
    bool same(long long x, long long y);
};

// 初期化
unionfind::unionfind(long long n){
    for (long long i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
    }
}

// 木の根を求める
long long unionfind::find(long long x) {
    if (par[x] == x) {
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unionfind::unite(long long x, long long y) {
    x = find(x);
    y = find(y);
    if (x == y)return;
    
    if (rank[x] < rank[y]) {
        par[x] = y;
    }
    else {
        par[y] = x;
        if (rank[x] == rank[y]) {
            rank[x]++;
        }
    }
}

// xとyが同じ集合に属していたらtrue
bool unionfind::same(long long x, long long y) {
    return find(x) == find(y);
}

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> p(n);
    REP(i, n){
        cin >> p[i];
        p[i]--;
    }
    
    unionfind uni(n);
    REP(i, m){
        int x, y;
        cin >> x >> y;
        x--;y--;
        
        uni.unite(x, y);
    }
    
    int ans = 0;
    REP(i, n){
        if(uni.same(i, p[i]))ans++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 2420
#pragma GCC optimize("-Ofast")

#include <bits/stdc++.h>

#define ll long long

signed main(){
    /* 入力の受け取り */
    ll s;
    std::cin >> s;

    /*
    3点のうち1つを原点に固定し((x1,y1)=(0,0))、
        s = |x2y3 - x3y2|
    なる(x2,y2),(x3,y3)を決定する.
    case 1: s = 1e18のとき
        x2 = y3 = 1e9, x3 = y2 = 0とすればよい.
    case 2: s <= 1e9 のとき
        x3 = y2 = 0, x2 = 1, y3 = sとすればよい.
    case 3: そうでないとき
            s = s1 * 1e9 + s2
        と上半分の桁と下半分の桁に分割する.(0 <= s1,s2 < 1e9)
            y3 = 1e9, x2 = s1 + 1
            x3 = 1, y2 = 1e9 - s2
        とすればよい. 
     */
     ll x2,y2,x3,y3;
     if (s == (ll)1e18){ // 上記のcase 1
         x2 = y3 = (ll)1e9;
         x3 = y2 = 0;
     }
     else if (s <= (ll)1e9){ // 上記のcase 2
        x3 = y2 = 0;
        x2 = 1;
        y3 = s;
     }
     else{ // 上記のcase 3
        ll s1,s2;
        s1 = s / ((ll)1e9);
        s2 = s % (ll)1e9;
        y3 = (ll)1e9;
        x2 = s1 + 1;
        x3 = 1;
        y2 = (ll)1e9 - s2;
     }

    /* 答えの出力 */
    std::cout << "0 0 " << x2 << " " << y2 << " " 
                << x3 << " " << y3 << std::endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        scanner.close();

        int l = b - a;
        int x = l * (1 + l) / 2;
        int result = x - b;

        System.out.println(result);

        // System.out.println(System.currentTimeMillis() - startTime);
    }
}

Measured memory_bytes: 22228
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

@njit((i8,i8[:]), cache=True)
def main(N,A):
  Amax = A.max()
  lis = np.zeros(Amax+1, np.int64)
  table = np.full(Amax+1,Amax+1,np.int64)
  for i in range(2, Amax+1):
    table[i::i] = np.minimum(table[i::i],i)
  for i in range(N):
    p = A[i]
    while p>1:
      q = table[p]
      lis[q]+=1
      while p%q==0:
        p //= q
  setwise = False
  for i in range(Amax+1):
    if lis[i]==N:
      return 'not'
    if 2<=lis[i]<N:
      setwise=True
  if setwise==True:
    return 'setwise'
  return 'pairwise'

N = int(input())
A = np.array(list(map(int, input().split())))
print(main(N,A)+' coprime')


Measured memory_bytes: 216948
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/);
for (let i = 0; i < input.length; i++) {
    let [a, b] = input[i].split(' ').map(Number);
     if (a === 0 && b === 0) {
        break;
         }
    for (let j = 0; j < a; j++) {
        console.log('#'.repeat(b));
    }
    console.log('');
}



Measured memory_bytes: 18188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  cin>>n;
  vector<int> d(n);
  for(int i=0; i<n; i++)
    cin>>d.at(i);
  sort(d.begin(),d.end());
  for(int i=0; i<n-1; i++)
    if(d.at(i)==d.at(i+1))cnt++;
  cout<<n-cnt<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, x; cin >> n >> x;
    if(x <= 1 || x >= 2*n - 1){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int ans[2*n-1];
    if(n == 2){
        for(int i=0;i<3;i++) ans[i] = (i + 1);
    }else if(x == 2){
        ans[n-2] = 3;
        ans[n-1] = 2;
        ans[n] = 1;
        ans[n+1] = 4;
        int val = 5;
        for(int i=0;i<2*n-1;i++){
            if(i >= n-2 && i <= n+1) continue;
            ans[i] = val++;
        }
    }else{
        // x >= 3
        ans[n-2] = x - 1;
        ans[n-1] = x;
        ans[n] = x + 1;
        ans[n+1] = x - 2;
        int val = 1;
        for(int i=0;i<2*n-1;i++){
            if(i >= n-2 && i <= n+1) continue;
            if(val == x - 2) val = x + 2;
            ans[i] = val++;
        }
    }
    for(int a: ans) cout << a << endl;
}

Measured memory_bytes: 2304
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iterator>
#include <fstream>
#include <cstddef>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (1<<30);
const ll NEGA=-INF*10000; 


ll ans = 0;
int p[200000];
int n,m;
int cnt=0;

int main() 
{
  
   int x;
   cin>>x;
 int exp[1000];
   fill(exp,exp+1000,1001);
   exp[0]=1;
   int p=1;
   for(int i=2;i<32;++i){
      int j=i*i;
      while(j<=x){
        exp[p++]=j;
        j*=i;
      }
   }
   sort(exp,exp+p);
   cout<<exp[p-1]<<endl;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;
using li=list<int>;
using lil=list<ll>;
using lis=list<string>;
using fli=forward_list<int>;
using fll=forward_list<ll>;
using fls=forward_list<string>;
using si=stack<int>;
using sl=stack<ll>;
using ss=stack<string>;
using qi=queue<int>;
using ql=queue<ll>;
using qs=queue<string>;
using pqi=priority_queue<int>;
using pql=priority_queue<ll>;
using pqs=priority_queue<string>;
using dqi=deque<int>;
using dql=deque<ll>;
using dqs=deque<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define repr(i, n) for(int i = (n); i >= 0; i--)
#define repr2(i, a, n) for(int i = (n); i >= (a); i--)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

template<typename T,typename U>
void Printarray2(T f,U n){
  for(int i=0;i<n;i++) cout<<f[i]<<endl;
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b;cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* UnionFind */

struct UnionFind{
  vector<int> data;
  UnionFind(int s):data(s, -1) {}

  int root(int x){
    if(data[x] < 0) return x;
    return data[x] = root(data[x]);
  }

  bool set(int x, int y){
    x = root(x); y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  bool check(int x, int y){
    return root(x) == root(y);
  }

  int size(int x){
    return -data[root(x)];
  }
};

int main() {
  int N, M;

  scanf("%d%d", &N, &M);

  UnionFind uf(N);

  int ans = N;

  for (int i=0; i<M; i++) {
    int X, Y, Z;
    scanf("%d%d%d", &X, &Y, &Z);
    ans -= uf.set(X-1, Y-1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640