akhauriyash/Code-Regression huggingface dataset:
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 200005;

ll A[N];

ll popcount(ll x){
	ll cnt = 0;
	rep(i,0,logN){
		if(x&(1LL<<i))	cnt++;	
	}
	return cnt;
}

ll power(ll a,ll n,ll m=M){
    ll ans=1;
    while(n){
        if(n&1) ans=ans*a;
        a=a*a;
        n=n>>1;
        ans=ans%m;
        a=a%m;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    rep(i,1,N){
    	ll y = i;
    	ll cnt = 0;
    	while(y){
    		ll g = popcount(y);
    		cnt++;
    		y %= g;
    	}
    	A[i] = cnt;
    }
    ll n;
    string s;
    cin >> n >> s;
   	ll cnt = 0;
    rep(i,0,n){
    	if(s[i] == '1')	cnt++;
    }
    ll a = 0, b = 0;
    cnt--;
    rep(i,0,n){
    	if(cnt>0 and s[i] == '1'){
    		a += power(2, n-i-1, cnt);
    	}
    }
    if(cnt>0)	a %= cnt;
	cnt+=2;
    rep(i,0,n){
    	if(cnt>0 and s[i] == '1'){
    		b += power(2, n-i-1, cnt);
    	}
    }
    if(cnt>0)	b %= cnt;
    cnt--;
    rep(i,0,n){
    	if(s[i] == '1'){
    		if(cnt > 1){
    			cnt--;
    			a -= power(2, n-i-1, cnt);
    			a = (a%cnt+cnt)%cnt;
    			cout << 1 + A[a] << endl;
    			a += power(2, n-i-1, cnt);
    			a %= cnt;
    			cnt++;
    		}
    		else{
    			cout << 0 << endl;
    		}
    	}
    	else{
    		cnt++;
    		b += power(2, n-i-1, cnt);
    		b = (b%cnt+cnt)%cnt;
    		cout << 1 + A[b] << endl;
    		b -= power(2, n-i-1, cnt);
    		b %= cnt;
    		cnt--;
    	}
    }
    return 0;
}

Measured memory_bytes: 5280
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,x) = {
        let t = read_vec::<usize>();
        (t[0],t[1])
    };
    let mut an = read_vec::<i64>();
    let mut ans = 0;
    for j in 0..n-1{
        let sum = an[j] + an[j+1];
        if sum > x as i64{
            ans +=  sum - x as i64;
            an[j+1] -= std::cmp::min(sum -x as i64,an[j+1]);
            an[j] -= (sum - x as i64) - std::cmp::min(sum -x as i64,an[j+1]);
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 8444
#include<stdio.h>

int main(void)
{
  int n,ans=1;
  scanf("%d",&n);
  while(ans < n)
    {
      ans *= 2;
    }
  if(ans > n)
    {
      ans /= 2;
    }
  printf("%d\n",ans);
  return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    string s;
    ll k;
    cin >> s >> k;

    rep(i, 0, s.size())
    {
        if (26 - (s[i] - 'a') <= k && s[i] != 'a')
            k -= (26 - (s[i] - 'a')), s[i] = 'a';
        if (i == s.size() - 1)
            s[i] = 'a' + ((s[i] - 'a') + k) % 26;
    }
    cout << s << endl;
}

Measured memory_bytes: 512
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let m:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	if n == m {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
#include<cstdio>
using namespace std;
#define N 300050
#define M 10
#define mod 1000000007
int dp[N][M],t[M][2],as;
char s[N];
int main()
{
	t[1][1]=2;t[1][0]=8;
	t[2][1]=3;t[2][0]=4;
	t[3][1]=3;t[3][0]=3;
	t[4][1]=2;t[4][0]=5;
	t[5][1]=4;t[5][0]=4;
	t[6][1]=2;t[6][0]=7;
	t[7][1]=6;t[7][0]=9;
	t[8][1]=6;t[8][0]=9;
	t[9][1]=8;t[9][0]=8;
	scanf("%s",s+1);
	dp[0][1]=1;
	for(int i=1;s[i];i++)
	{
		if(s[i]!='0')for(int j=1;j<10;j++)dp[i][t[j][1]]=(dp[i][t[j][1]]+dp[i-1][j])%mod;
		if(s[i]!='1')for(int j=1;j<10;j++)dp[i][t[j][0]]=(dp[i][t[j][0]]+dp[i-1][j])%mod;
		as=(dp[i][3]+dp[i][2])%mod;
	}
	printf("%d\n",as);
}//

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Happy Birthday!
            var count = ReadLine();
            

            if (count.Max() < 9)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }            
        }

        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<stdio.h>
#define N 36
struct Card{
  char suit;
  char value;
};

main(){
  struct Card p1[N], p2[N],key;
  int i,j,y,f,l=0,mini;
  scanf("%d",&y);
  for(i = 0 ; i < y ; i++){
    scanf(" %c%c",&p1[i].suit,&p1[i].value);
  }
  for(i = 0 ; i < y ; i++){
    p2[i] = p1[i];
  }

  /*B*/
  for(i = 0 ; i < y ; i++){
    for(j = y-1 ; j > i ; j--){
      if(p1[j].value<p1[j-1].value){
	key=p1[j];
	p1[j]=p1[j-1];  
	p1[j-1]=key;
      }
    }
  }
 for(i = 0 ; i < y-1 ; i++){
   printf("%c%c ",p1[i].suit,p1[i].value);
 }
 printf("%c%c\n",p1[i].suit,p1[i].value);
 printf("Stable\n");

 /*S*/ 
 for(i = 0 ; i < y ; i++){
    mini = i;
    f = 0;
    for(j = i+1 ; j < y ; j++){
      if(p2[j].value==p2[mini].value) f=1;
      if(p2[j].value<p2[mini].value){
	mini = j;
	if(f == 1) l=1;
      }
    }
    if(mini!=i){
    key=p2[i];
    p2[i]=p2[mini];
    p2[mini]=key;
    }
  }
 for(i =0  ;i < y-1 ; i++){
   printf("%c%c ",p2[i].suit,p2[i].value);
 }
 printf("%c%c\n",p2[i].suit,p2[i].value);
 if(l == 1) printf("Not stable\n"); 
 else
   printf("Stable\n");
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int A[20000000+1], h;
 
int parent(int i){
  return i/2;
}
 
int left(int i){
  return i*2;
}
 
int right(int i){
  return i*2+1;
}
 
void maxHeap(int i){
  int l=left(i), r=right(i);
  int largest;
   
  if(l <= h && A[l] > A[i]) largest=l;
  else largest=i;
 
  if(r <= h && A[r] > A[largest]) largest=r;
 
  if(largest != i){
    swap(A[i], A[largest]);
    maxHeap(largest);
  }
}

void heapIncreaseKey(int i, int key){
  A[i]=key;

  while(i > 1 && A[parent(i)] < A[i]){
    swap(A[i], A[parent(i)]);
    i=parent(i);
  }
}

void insert(int key){
  h++;
  A[h]=INT_MIN;
  heapIncreaseKey(h, key);
}

int heapExtract(void){
  int max_val=A[1];
  A[1]=A[h];
  h--;
  maxHeap(1);

  return max_val;
}

int main(void){
  int  num;
  char com[10];
  h=1;
  
  while(true){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &num);
      insert(num);
    }
    else if(com[1] == 'x'){
      printf("%d\n", heapExtract());
    }
    else break;
    
  }
  
  
  return 0;
}



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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c,b*d),max(b*c,a*d)) << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include<math.h>
long long a[500000];
int main()
{
    for(int i=1; i<=500000; i++)
    {
        a[i]=i*(i+1)/2;
    }


        //printf("%lld     ",a[500000]);



    long long n,k;
    scanf("%lld",&n);
    k=sqrt(2*n);
    if(n>a[k]&&n<=a[k+1])
        printf("%lld\n",k+1);
    if(n>a[k-1]&&n<=a[k])
        printf("%lld\n",k);
    if(n>a[k+1]&&n<=a[k+2])
        printf("%lld\n",k+2);

    return 0;
}


Measured memory_bytes: 4096
import java.util.*;

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

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        int n = r * 100 + g * 10 + b;
        
        if(n % 4 == 0){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
        
    }
}

Measured memory_bytes: 21588
import sys
N = int(input())
Info = []
for _ in range(N):
    Info.append(list(map(int,input().split())))
for X in range(101):
    for Y in range(101):
        H = None
        for x, y, h in Info:
            if h != 0:
                if H is None:
                    H = h + abs(X-x) + abs(Y-y)
                if H != h + abs(X-x) + abs(Y-y):
                    H = None
                    break
        if H is not None:
            flag = 1
            for x, y, h in Info:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    flag = 0
            if flag:
                print(*[X,Y,H])
                sys.exit()

Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
ll modinv(ll a, ll m=mod) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll 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 main() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  REP(i, K, N+2) {
    ll mn = (i-1) % mod * i % mod * modinv(2) % mod;
    ll mx = (2*N-i+1) % mod * i % mod * modinv(2) % mod;
    (ans += (mx + mod - mn + 1)) %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
 
#define X first
#define Y second
#define N 100010
#define M 11
 
typedef long long ll;
const int Mod = 1000000007;
const int INF = 1 << 30;
 
const double eps = 1e-10;
 
int cnt[N]; 

int main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    
    int n, m, x, y;
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; ++i)
    {
    	scanf("%d %d", &x, &y);
    	cnt[x]++, cnt[y]++;
	}
	bool f = true;
	for (int i = 1; i <= n; ++i) if (cnt[i] & 1) f = false;
	puts(f? "YES":"NO");
    return 0;
}


Measured memory_bytes: 640
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1e5+5;

int arr[32][N];

void solve()
{
    int n,c;
    cin>>n>>c;

    int s,t,x;
    int mx=0;
    for(int i=0;i<n;++i)
    {
        cin>>s>>t>>x;
        arr[x][s]++;
        arr[x][t+1]--;

        mx=max(mx,t);
    }

    vi sum(c+1);
    int cnt,ans=1;
    for(int i=1;i<=mx;++i)
    {
        cnt=0;
        for(int j=1;j<=c;++j)
        {
            sum[j]+=arr[j][i];

            if(sum[j])
                ++cnt;
        }

        ans=max(ans,cnt);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 24064
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n;
vector<pair<int,int> > E;
int main()
{
	geti(n);
	int m = n%2==0?n+1:n;
	for (int i=1; i<=n; i++)
	{
		for (int j=i+1; j<=n; j++)
		{
			if (i+j!=m)
			{
				E.PB(MP(i, j));
			}
		}
	}
	putsi(E.size());
	for (auto e : E) putsii(e.FF, e.SS);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    private static int dfs(int n, int cnt) {
        if (n < 6) {
            return cnt + n;
        }
        int i = 1;
        while (i * 6 <= n) {
            i *= 6;
        }
        int j = 1;
        while (j * 9 <= n) {
            j *= 9;
        }
        cnt++;
        return Math.min(dfs(n - i, cnt), dfs(n - j, cnt));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(dfs(n, 0));
    }

}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  
  int ans = 0;
  for(int i = l; i<=r; i++){
    if(i % d == 0){
      ans++;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    str S[50];
    int cnt[50][26];
    int ans[26];
    for(int i=0; i<N;i++){
      cin>>S[i];
    }
    for(int i=0; i<N;i++){
for(int j=0; j<26;j++){
   cnt[i][j]=0;
  }
}
    for(int i=0; i<N;i++){
      for(int j=0; j<S[i].size();j++){
        cnt[i][S[i][j]-'a']++;
      }
    }

    for(int j=0; j<26;j++){
       ans[j] = cnt[0][j];
    }

    for(int i=0; i<N;i++){
      for(int j=0; j<26;j++){
        ans[j] = min(ans[j], cnt[i][j]);
      }
    }
    for(int j=0; j<26;j++){
      for(int i=0; i<ans[j];i++){
        cout<<char(j+'a');
      }
    }

    cout<<endl;
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d[N];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    s = (sum(A) * (N-1))%MOD
    bA = [[0]*61 for _ in range(N)]
    for i in range(N):
        a = A[i]
        for j in range(61):
            a, x = divmod(a, 2)
            bA[i][j] = x
    cc = [0] * 61
    for i in range(N):
        for j in range(61):
            cc[j] += bA[i][j]
    coef = 1
    for i in range(61):
        coef *= 2
        if cc[i] < 2: continue
        s = (s - coef*cc[i]*(cc[i]-1)//2)%MOD
    print((s+MOD)%MOD)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 203208
#include<bits/stdc++.h>
using namespace std;
int n,cnt[4];
double dp[303][303][303];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		cnt[x]++;
	}
	for(int k=0;k<=n;k++)
		for(int j=0;j+k<=n;j++)
			for(int i=0;i+j+k<=n;i++)
			{
				int x=n-i-j-k;
				if(x==n){dp[k][j][i]=0;continue;}
				if(k>0)dp[k][j][i]+=dp[k-1][j+1][i]*k*1.0/n;
				if(j>0)dp[k][j][i]+=dp[k][j-1][i+1]*j*1.0/n;
				if(i>0)dp[k][j][i]+=dp[k][j][i-1]*i*1.0/n;
				dp[k][j][i]=(dp[k][j][i]+1)*n*1.0/(n-x);
			}
	cout<<fixed<<setprecision(13)<<dp[cnt[3]][cnt[2]][cnt[1]];
}

Measured memory_bytes: 217344
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000009
# define pi acos(-1)
# define fi first
# define se second
using namespace std;

signed main()
{
    gok
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vector<int> v1,v2,re;
    int tm=c;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='o'&&tm>=c)
        {
            v1.push_back(i);
            tm=0;
        }
        else
        {
            tm++;
        }
        if(v1.size()==k)
            break;
    }
    tm=c;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='o'&&tm>=c)
        {
            v2.push_back(i);
            tm=0;
        }
        else
        {
            tm++;
        }
        if(v2.size()==k)
            break;
    }
   reverse(v2.begin(),v2.end());

   for(int i=0;i<v1.size();i++)
   {
      // cout<<v1[i]<<" "<<v2[i]<<endl;
       if(v1[i]==v2[i])
        re.push_back(v1[i]);
   }

   for(int i=0;i<re.size();i++)
   {
       cout<<re[i]+1<<endl;
   }






      return 0;
    }


Measured memory_bytes: 6664
n = int(input())
s = input()
w = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    if s[i] == '.':
        w[i] = 1
    else:
        b[i] = 1
wsum = [0 for _ in range(n+1)]
bsum = [0 for _ in range(n+1)]
for i in range(n):
    wsum[i+1] = wsum[i] + w[i]
    bsum[i+1] = bsum[i] + b[i]
ans = 10**6
for i in range(n+1):
    ans = min(ans, bsum[i]-bsum[0]+wsum[n]-wsum[i])
print(ans)

Measured memory_bytes: 22436
n, m = map(int, input().split())

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = map(int, input().split())
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

Measured memory_bytes: 77556
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX];
    fget_array(arr, num);
    int i;
    static int map[NUM_MAX+2];
    int ans = 0;
    for(i = 0; i < num; i++) {
        if(arr[i] > NUM_MAX) {
            ans++; // remove only
        } else {
            map[arr[i]]++;
        }
    }

    for(i = 0; i <= NUM_MAX; i++) {
        if(map[i] >= i) {
            ans += map[i]-i;
        } else {
            ans += map[i];
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mod 1000000007
using namespace std;
inline int read()
{
	char c=getchar(); int num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
int n,a[200005],b[200005],jc[8005],inv[8005],dp[4005][4005],ans;
inline int ksm(int a,int b)
{
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod)
	 if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline int C(int n,int m)  // 注意n,m 
{
	if (n<m) return 0;
	return 1ll*jc[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		dp[2000-a[i]][2000-b[i]]++;
	}
	jc[0]=jc[1]=1;
	for (int i=2;i<=8000;i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[0]=inv[1]=1; inv[8000]=ksm(jc[8000],mod-2);
	for (int i=7999;i>=2;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for (int i=0;i<=4000;i++)
	 for (int j=0;j<=4000;j++)
	 {
	 	if (i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
	 	if (j) dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
	 }
	for (int i=1;i<=n;i++)
	 ans=((ans+dp[2000+a[i]][2000+b[i]])%mod-C(a[i]+b[i]<<1,a[i]<<1)+mod)%mod;
	ans=ans*500000004ll%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 64512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 21;
const ll MOD = 1000000007;

int n, m;
bool a[2][MAXN], b[2][MAXN];

int solve (int x) {
    int ans = 0;
    REP (i, n) {
        for (int j=i; j<= n; j++) {
            if (j == n) {
                return 10000000;
            }
            if (a[x][j] == b[x][i]) {
                debug(x, i, j);
                for (int k=j; k>i; k--) {
                    debug(x, k);
                    swap(a[x][k], a[x][k-1]);
                    ans++;
                }
                break;
            }
        }
    }
    return ans;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    REP (i, n) {
        cin >> a[0][i];
        a[1][i] = a[0][i];
    }

    int idx = 0;
    REP (i, m) {
        int d;
        cin >> d;
        REP (j, d) {
            b[0][idx] = i&1;
            b[1][idx] = (i&1)^1;
            idx++;
        }
    }
    REP (i, n) {
        debug(a[0][i], b[0][i], b[1][i]);
    }

    cout << min(solve(0), solve(1)) << endl;
    return 0;
}



Measured memory_bytes: 3212
/*
  Fuad Ashraful Islam
  University of Asia Pacific,Bangladesh
  Date:12th April 2020
  TODO:
 */
#include<bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define pb push_back

using namespace std;
template <class T>
inline void read(T &res)
{
  res = 0; bool bo = 0; char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-');
  if (c == '-') bo = 1; else res = c - 48;
  while ((c = getchar()) >= '0' && c <= '9')
    res = (res << 3) + (res << 1) + (c - 48);
  if (bo) res = ~res + 1;
}
typedef long long ll;
const int N=1e5+1;
ll _,n,k,m,l,c,cs=1;
 

void Solve()
{
  cin>>k;
  ll sum=0LL;
  for(ll i=1;i<=k;++i)
  {
    for(ll j=1;j<=k;++j)
    {
      ll g=__gcd(i,j);
      for(ll m=1;m<=k;++m)sum+=__gcd(g,m);
    }
  }
  
  cout<<sum<<"\n";
}
int main()
{
  Solve();
  return 0;
}

Measured memory_bytes: 3624
n,m = map(int,input().split())
s = input()
s = s[::-1]

tmp = 0
sum1 = 0
ans = []

while tmp < n:
    for i in range(m, 0, -1):
        flag = False
        if tmp + i <= n:
            if s[tmp+i] == '0':
                tmp += i
                flag = True
                sum1 += 1
                ans.append(i)
                break
    if not flag:
        print(-1)
        exit()

for i in ans[::-1]:
    print(i, end = ' ')


Measured memory_bytes: 79244
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

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

func min(v1, v2 int) int {
	if v1 < v2 {
		return v1
	}
	return v2
}

func main() {
	var dp [100005]int

	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()
	var h []int
	for i := 0; i < n; i++ {
		h = append(h, nextInt())
	}

	dp[0] = 0
	for i := 1; i < n; i++ {
		dp[i] = math.MaxInt32
		for j := 1; j <= k && i-j >= 0; j++ {
			dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
		}
	}

	ans := dp[n-1]
	fmt.Println(ans)
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x[5];
    int a;
    for(int i=0; i<5; i++){
    cin >> x[i];
    if(x[i] == 0) a = i+1;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3592
/*
      author : nishi5451
      created: 11.08.2020 00:07:43
*/

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


int main(){
    ll a,b;
    string op;
    cin >> a >> op >> b;
    if(op == "+"){
        cout << a+b << endl;
    }
    else if(op=="-"){
        cout << a-b << endl;
    }
    return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner


import scala.io.StdIn._

object Main extends App {

  val Array(k,n) = readLine().split(" ").map(_.toInt)

  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val maxDis = (0 until n).foldLeft(0) { (acc, i) =>
      val dis = if(i != n-1) A(i+1) - A(i) else k - A(i) + A(0)
      Math.max(acc, dis)
    }
    k - maxDis
  }

  println(solve())

}



Measured memory_bytes: 75392
#include <stdio.h>

int main(void){
    int h,w;
    while(1){
        scanf("%d %d\n",&h,&w);//h,w scan
        if(h==0 && w==0){
            break;
        }else{
            for(int t = 0;t < h;t++){
                if(t==0 || t==h-1){
                    for(int i = 0;i < w;i++){
                        printf("#");
                    }
                }else{
                    for(int i = 0;i < w;i++){
                        if(i==0 || i==w-1){
                            printf("#");
                        }else{
                            printf(".");
                        }
                    }
                }
                printf("\n");
            }
        }
        printf("\n");
    }
    return 0; /*0?????????*/
}

Measured memory_bytes: 2592
#include <iostream>
using namespace std;
int main(){

  int n,a[2000],m,q;

  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>q;
    bool ch[4001]={1};
    for(int j=0;j<n;j++){
      for(int k=q-1;k>=0;k--) if(ch[k]) ch[k+a[j]]=1;
      if(ch[q]){
        cout<<"yes"<<endl;
        break;
      }       
    }
    if(!ch[q]) cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	vector<int>a(100002);
	vector<int>b(100001);
	rep(i, n + 1)cin >> a[i];
	rep(i, n)cin >> b[i];


	ll ans = 0;
	ll dl = 0;
	for(int i=0;i<=n;i++) {
		dl = min(a[i], b[i]);
		ans += dl;
		a[i] -= dl;
		b[i] -= dl;
		ans += min(b[i], a[i + 1]);
		a[i + 1] -= min(b[i], a[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, m = 1000; cin >> n;
  cout << ((m - (n % m)) % m) << endl;

  return 0;
}


Measured memory_bytes: 3540
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        int c = inp.nextInt();
        int d = a + b + c;
        if (d < 22) System.out.println("win");
        else System.out.println("bust");
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        int e=sc.nextInt();
        int k=sc.nextInt();

       if (e-a>k) {
         System.out.println(":(");
       }else{
         System.out.println("Yay!");       
       }



    }
}


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

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

  rep(i, N / 4 + 1) {
    rep(j, N / 7 + 1) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3588
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = Array{Int}(n)
	for i in 1:n
		a[i] = parseInt(readline())
	end
	on = 1
	flg = 0
	for i in 1:n
		if a[on] == 2
			print(i)
			flg = 1
			break
		else
			on = a[on]
		end
	end
	if flg == 0
		print(-1)
	end
end

main()

Measured memory_bytes: 122756
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	for (int i=0;i<a;i++) if (s[i]>'9'||s[i]<'0'){
		cout<<"No";
		return 0;
	}
	if (s[a]!='-'){
		cout<<"No";
		return 0;
	}
	for (int i=a+1;i<a+b;i++) if (s[i]>'9'||s[i]<'0'){
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int n;
  int ans = 0;
  string s[51], t;
  int tim[51];
  int pos;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s[i] >> tim[i];
  }
  cin >> t;
  for(int i=0; i<n; i++) {
    if(s[i] == t) {
      pos = i;
      break;
    }
  }
  for(int i=pos+1; i<n; i++) {
    ans += tim[i];
  }
  cout << ans << "\n";
}


int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args)  {
        // Here your code !
    	Scanner sc = new Scanner(System.in);

    	int rank[] = new int[9];
    	int n = sc.nextInt();

    	for(int i = 0; i < n; i++){
    		int rate = sc.nextInt();

    		if(rate <= 399){
    			rank[0]++;
    		}
    		else if(rate <= 799){
    			rank[1]++;
    		}
    		else if(rate <= 1199){
    			rank[2]++;
    		}
    		else if(rate <= 1599){
    			rank[3]++;
    		}
    		else if(rate <= 1999){
    			rank[4]++;
    		}
    		else if(rate <= 2399){
    			rank[5]++;
    		}
    		else if(rate <= 2799){
    			rank[6]++;
    		}
    		else if(rate <= 3199){
    			rank[7]++;
    		}
    		else {
    			rank[8]++;
    		}
    	}

    	int color = 0;

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

    	System.out.println(Math.max(color, 1) + " " + (color + rank[8]));
    }
}

Measured memory_bytes: 23124
#include<stdio.h>

#define N 100

void SelectionSort(int *);

int n;
int count=0;


int main(){
  int A[N+1];
  int i,m;
  
  scanf("%d", &n);
  for( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  SelectionSort(A);
  
  printf("%d\n",count);
  return 0;
}

void SelectionSort(int A[]){
  int i,j,key,m,mini,X;
  for(i=0;i<n;i++){
    mini=i;
    X=0;
    for(j=i;j<n;j++){
      if(A[j]<A[mini]){
	mini=j;
	X=1;
      }
    }
    if(X==1){
	key=A[i];
	A[i]=A[mini];
	A[mini]=key;
	count++;
    }
  }
  for ( m = 0; m <= n-1; m++ ){
    if ( m > 0 ) printf(" ");
    printf("%d", A[m]);
  }
  printf("\n");
}

Measured memory_bytes: 604
class BIT_dinamic: #0-indexed
    def __init__(self, n):
        self.tree = {}
        self.MAX = n
    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            if i in self.tree:
                s += self.tree[i]
            i -= i & -i
        return s
    def query(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= self.MAX:
            if i in self.tree:
                self.tree[i] += x
            else:
                self.tree[i] = x
            i += i & -i

   
###########################################
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n = int(input())
a = [int(i) for i in readline().split()]

sA = sorted(a)
# def zaatu(x): return bisect_left(sA, x) #xの圧縮先
# def modosu(i): return sA[i]  # 逆写像

b = BIT_dinamic(n)

from bisect import *
ans = 0
for i,ai in enumerate(a):
    j = bisect_left(sA, ai)
    ans += i - b.get_sum(j)
    b.add(j,1)

print(ans)



Measured memory_bytes: 38644
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
	int d, e;
	while (cin >> d >> e && d + e) {
		int x, y;
		double ans = 1e5;
		for (x = 0; x <= d; ++x) {
			y = d - x;
			ans = min(ans, abs(sqrt(x * x + y * y) - ( double) e));
		}
		printf("%.10f\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

Measured memory_bytes: 3636
#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)

int mod = 1e9+7;
int main()
{
    int n;
    cin >> n;
    int dp[n+1] = {0};
    dp[0] = 1;
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=i-3; j++) {
            dp[i] += dp[j];
            dp[i] %= mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int ro[1000];
int q[1000];
int no[100];
int p[100];
int main(void){
    int n,r,t;
    scanf("%d%d%d",&n,&r,&t);
    for(int i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        no[i]=p[i]%r;
    }
    for(int i=0;i<t-1;i++){
        for(int j=0;j<r;j++)ro[j]=0;
        for(int j=0;j<n;j++){
            no[j]+=p[j];
            no[j]%=r;
            ro[no[j]]++;
        }
        for(int j=0;j<r;j++){
            if(q[j]<ro[j]){
                ans+=ro[j]-q[j];
                q[j]=ro[j];
            }
        }
    }
    printf("%d\n",ans+n);
}


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl; 
}

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

using namespace std;
int main() {
    int arr[3];
    for(int i=0;i<3;i++){
        cin>>arr[i];
    }
    int temp = arr[0];
    arr[0]=arr[2];
    arr[2]=temp;

    int temp2 = arr[1];
    arr[1]=arr[2];
    arr[2]=temp2;


    cout<<arr[0]<<' '<<arr[1]<<' '<<arr[2];




}


Measured memory_bytes: 256
a,b,c,d,e,f = map(int,input().split())
"""
100a 水 <= 30
100b 水 <= 30
c 砂糖 <= 30
d 砂糖 <= 30
e 100gにとける砂糖の量
f 最大質量

全探索の時間ですか！？ 高々 30*30*1000*1000 工夫っすれば  oK.
"""
ans = 0
ansl = [a*100, 0]
for a_times in range(f//(a*100) + 1):
	a_g = a_times * a * 100
	for b_times in range(f//(b*100) + 1):
		b_g = b_times * b * 100
		for c_times in range(f//c + 1):
			c_g = c_times * c
			for d_times in range(f//d + 1):
				d_g = d_times * d
				targ = a_g+b_g+c_g+d_g
				if targ > f:
					break
				elif targ != 0:
					if (a_g+b_g)//100*e >= c_g+d_g:
						if (c_g+d_g)/targ > ans:
							ans = (c_g+d_g)/targ
							ansl = [targ, c_g+d_g]
print(*ansl)

Measured memory_bytes: 73288
n, p = map(int, input().split())
if n == 1 or p== 1:
    print(p)
    exit()
c2 = 0
while p%2 == 0:
    c2 += 1
    p//=2
c = 2**(c2//n)
i = int(p**(1/n))+1
if i%2 == 0:
    i -= 1
while i > 1:
    if p%(i**n) == 0:
        print(c*i)
        exit()
    else:
        i -= 2
print(c)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<string> s(N);
	for (Int i = 0; i < N; i++) {
		cin >> s[i];
	}

	char temp;
	vector<vector<Int>> al(N, vector<Int>(26, 0));

	Int len;
	for (Int i = 0; i < N; i++) {
		len = s[i].size();
		for (Int j = 0; j < len; j++) {
			al[i][s[i][j] - 'a']++;
		}
	}

	vector<Int> ans(26, INF);
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 26; j++) {
			ans[j] = min(ans[j], al[i][j]);
		}
	}

	for (Int i = 0; i < 26; i++) {
		for (Int j = 0; j < ans[i]; j++) {
			printf("%c", i + 'a');
		}
	}
	printf("\n");
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt(), b=fsc.nextInt(), c=fsc.nextInt(), d=fsc.nextInt();
        fsc.close();
        if(Math.abs(a-c)<=d || (Math.abs(a-b)<=d && Math.abs(b-c)<=d)) System.out.println("Yes");
        else System.out.println("No");
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n, m;
vector<string> a, b;

bool chk(int x, int y)
{
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[x + i][y + j] != b[i][j]) return false;
        }
    }
    return true;
}

int main()
{
    cin >> n >> m;
    a.resize(n);
    b.resize(m);
    bool f = false;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    
    for (int i = 0; i < (n - m + 1); ++i) {
        for (int j = 0; j < (n - m + 1); ++j) {
            if (a[i][j] == b[0][0]) f = chk(i, j);
            if (f) break;
        }
        if (f) break;
    }
        

    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
            
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
N=int(input())
S=list(map(int,input()))

ans=0

for i in range(1000):
    Num=list(map(int,str(i).zfill(3)))
    flg=[False for i in range(3)]
    
    for j in range(N):
        if S[j]==Num[0] and not flg[0]:
            flg[0]=True
            continue
        if flg[0] and S[j]==Num[1] and not flg[1]:
            flg[1]=True
            continue
        if flg[1] and S[j]==Num[2]:
            flg[2]=True
            break
    if flg[2]:
        ans+=1

print(ans)

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

string i2s(int num){
  stringstream ss;
  string str;
  ss << num;
  ss >> str;
  return str;
}

int main(){
  string str;
  int n;
  while( cin >> n,n ){
    cin >> str;

    while(n--){
    string tmp="";
      for(int i = 0 ; i < str.size() ; i++){
	int cnt = 1;
	while(str.size()-1 > i){
	  if(str[i] == str[i+1])cnt++;
	  else break;
	  i++;
	}
	tmp += i2s(cnt) + str[i];
      }
      str = "";
      str = tmp;
    }
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1364
n = int(input())
s = str(input())
White_rui = [0]
Black_rui = [0]

white = 0
black = 0
for i in range(n):
    if s[i] == '.':
        white += 1
    else:
        black += 1
    White_rui.append(white)
    Black_rui.append(black)

ans = 10**6
for i in range(n):
    white_to_black = White_rui[-1] - White_rui[i+1]
    black_to_white = Black_rui[i] - Black_rui[0]
    ans = min(ans, white_to_black+black_to_white)

print(ans)

Measured memory_bytes: 68064