akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt() * (-1);
            int index = upperBound(list, value);
            if (list.size() == index) {
                list.add(value);
            } else {
                list.set(index, value);
            }
        }
        
        System.out.println(list.size());
    }
    
    public static int upperBound(List<Integer> list, int target) {
        // 初めてのtarget超過のindexを返す
        // {1, 3, 3, 7} target: 3 -> 3
        
        int left = 0;
        int right = list.size();
        
        while (left < right) {
            int center = (left + right) / 2;
            if (list.get(center) <= target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
}

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

int main(){
	int N;
	int M;
	int L;
	int O;
	int ans;
	cin >> N;
	
	if(1<=N && N<10){
		ans=N;
	} else if(1<=N && N<100){
		ans=9;
	} else if(100<=N && N<1000){
		ans=N-90;
	} else if(1000<=N && N<10000){
		ans=909;
	} else if(10000<=N && N<100000){
		ans=N-9090;
	} else if(N==100000){
		ans=90909;
	}
	cout << ans << endl;
	
	return 0;
}
	

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=1e6+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);
ll n;cin>>n;
vvll gr(maxn);
vll p(maxn,0ll);
vll cnt(maxn,0ll);
for(ll i=2;i<maxn;i++){
if(p[i]!=0)continue;
gr[i].pb(i);
for(ll t=i+i;t<maxn;t+=i){
    gr[t].pb(i);
    p[t]=1;
}
}
// forl(t,0,20)cout<<p[t]<<" ";


ll c[2];
c[0]=0;c[1]=0;
ll b[n];
forl(i,0,n)cin>>b[i];
ll x=b[0];
forl(i,0,n){
    x=gcd(x,b[i]);
}
c[1]=(x==1);
ll ch=0;
if(c[1]==1){
forl(i,0,n){
    if(ch)break;
    for(auto x:gr[b[i]]){
        cnt[x]++;
        if(cnt[x]==2){ch++;break;}
    }
}

if(ch==0){c[0]=1;}
}




if(c[0]==1){
    cout<<"pairwise coprime";
}
else if(c[1]==1){
    cout<<"setwise coprime";
}
else{cout<<"not coprime";
}



return 0;
}





  







Measured memory_bytes: 96592
#include<bits/stdc++.h>
using namespace std;
int s[105];
int dp[10005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    dp[0]=1;
    for(int i=0;i<n;i++)
        for(int j=10000;j>=s[i];j--){
            dp[j]+=dp[j-s[i]];
        }
    for(int i=10000;i>=0;i--){
        if(dp[i]&&i%10!=0)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    printf("0\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {

	int n, tmppoint;
	string tmpcityname;
	pair<pair<string, int>, int> restruant[100];
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> tmpcityname >> tmppoint;
		restruant[i] = make_pair(make_pair(tmpcityname, tmppoint * -1), i) ;
	}
	sort(restruant, restruant + n);
	for (int i = 0; i < n; i++){
		cout << (restruant[i].second + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int a,b,c,x,y;
    std::cin >> a >>b >> c>> x>> y;
    long long int z=abs(x-y);
    long long int ans=0;;
    if(x>y){
        ans=min(a*x+b*y,min(c*y*2+z*a,c*x*2));
    }else{
        ans=min(a*x+b*y,min(c*x*2+z*b,c*y*2));
    }
    std::cout << ans << std::endl;
}


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

int main() {
	int x, y, s;

	for (int h = 0;; h++) {
		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0)break;

		vector<int> a(s);
		int max = 0;
		for (int i = 1; i < s; i++)
			a[i] = i*(100 + x) / 100;
		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if (a[i] + a[j] == s) {
					int b = i*(100 + y) / 100;
					int c = j*(100 + y) / 100;
					int d = b + c;
					if (d > max)max = d;
				}
			}
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[999999];
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++)
	{
//		cout<<s[i]<<" ";
		if(s[i]!='h'||s[i+1]!='i')
		{
			cout<<"No";
			return 0;
		}
		else
		{
			i+=1;
		}
	}
	cout<<"Yes";
 } 

Measured memory_bytes: 256
program cell_inversion
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, i, d(200000) = 0, l = 0, r = 0
  character(200000) :: s
  integer(8) :: ans
  read(*,*) n
  read(*,*) s
  if (s(1:1) == "W" .or. s(2*n:2*n) == "W") then
    write(*,'(i0)') 0
    stop
  end if
  l = 1
  r = 0
  do i = 2, 2*n
    if (s(i:i) == s(i-1:i-1)) then
      d(i) = 1-d(i-1)
    else
      d(i) = d(i-1)
    end if
    if (d(i) == 0) then
      l = l+1
    else
      r = r+1
    end if
  end do
  if (l /= r .or. d(2*n) == 0) then
    write(*,'(i0)') 0
    stop
  end if
  ans = 1_8
  do i = 1, n
    ans = mod(ans*int(i,8),md)
  end do
  l = 0
  r = 0
  do i = 1, 2*n
    if (d(i) == 1) then
      if (l <= r) then
        write(*,'(i0)') 0
        stop
      end if
      ans = mod(ans*int(l-r,8),md)
      r = r+1
    else
      l = l+1
    end if
  end do
  write(*,'(i0)') ans
end program cell_inversion

Measured memory_bytes: 1548
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  get(N);
  bitset<200001> a;
  int A;
  FOR(i, N) {
    cin >> A;
    a[i] = A;
  }
  vector<int> ans(N);
  for (int i = N - 1; i >= 0; --i) {
    if (a[i] == 1) {
      ans[i] = 1;
      for (int j = 1; j * j <= i + 1; ++j) {
        if ((i + 1) % j == 0) {
          a[j - 1] = ~a[j - 1];
          if (j * j != i + 1)
            a[(i + 1) / j - 1] = ~a[(i + 1) / j - 1];
        }
      }
    }
  }
  vector<int> ret;
  FOR(i, N) {
    if (ans[i] == 1)
      ret.push_back(i + 1);
  }
  cout << ret.size() << endl;
  FOR(i, ret.size()) {
    if (i == ret.size() - 1) {
      cout << ret[i] << endl;
    } else {
      cout << ret[i] << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 2424
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int code;
    while(code = getchar()){
        if(code == EOF) break;
        if(code >= 'A' && code <= 'Z'){
            printf("%c", code | 0x20);
            continue;
        }
        if(code >= 'a' && code <= 'z'){
            printf("%c", code & ~0x20);
            continue;
        }
        printf("%c", code);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

void solve()
{

}

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

    /*int t;
    cin>>t;
    while(t--)
        solve();
    */
    int cnt5=0,cnt7=0;
    for(int i=0;i<3;++i){
        int a;
        cin>>a;
        if(a==5)cnt5++;
        else if(a==7)cnt7++;
    }
    if(cnt5==2&&cnt7==1)cout<<"YES";
    else cout<<"NO";

    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll ans = 0;
  if( d > 0 ) {
    ans = ans + 1LL * min(d,a);
    d -= min(d,a);
  }
  if( d > 0 ) {
    ans = ans + 0;
    d -= min(d,b);
  }
  if( d > 0 ) {
    ans = ans - 1LL * min(d,c);
    d -= min(d,c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>

using namespace std;  
int main()              
{	
	long long a,b,c,i;
	cin >>  a >> b >> c;	
	for (i = 1; i <= c; i++){
		if (i % 2 != 0){
			if (a % 2 != 0){
				a--;	
				b += a / 2;
				a = a / 2;
			}
			else {
				b += a / 2;
				a = a / 2;
			}
		}
		else {
			if (b % 2 != 0){
				b--;	
				a += b / 2;
				b = b / 2;
			}
			else {
				a += b / 2;
				b = b / 2;
			}

		}
	}
	cout <<  a << " " << b << endl;
}


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

int n;
int a[100];

void printArray(){
    for(int i = 0; i < n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
}

void insertionSort(){
    int v,j;
    printArray();
    for(int i = 1; i < n; i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        printArray();
    }
}

void bubbleSort(){
    int cnt = 0;
    int flag = 1;
    while(flag){
        flag = 0;
        for(int j = n-1; j > 0; j--){
            if(a[j] < a[j-1]){
                swap(a[j],a[j-1]);
                flag = 1;
                cnt++;
            }
        }
    }
    printArray();
    cout << cnt << endl;
}

void selectionSort(){
    int cnt = 0;
    int minj;
    for(int i = 0; i < n; i++){
        minj = i;
        for(int j = i; j < n; j++){
            if(a[j] < a[minj])
                minj = j;
        }
        swap(a[i],a[minj]);
        if(i != minj) cnt++;
    }
    printArray();
    cout << cnt << endl;
}

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

    //insertionSort();
    //bubbleSort();
    selectionSort();
    
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a > k){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);ll n,m; cin>>n>>m;
    ll sum=0;
    vector<ll> v;
    for(int i=1;i<=n;i++){
        ll a; cin>>a;
        v.push_back(a);
        sum+=a;
    }
    ll cnt=sum/(4*m);
    if(sum%(4*m)==0) cnt--;
    ll f=0;
    sort(v.rbegin(),v.rend());
    for(int i=0;i<v.size();i++){
        ll val=v[i];
        if(val<=cnt) break;
        f++;
    }
    if(f>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0) {
				break;
			}
			for(int i = 0; i < H; ++i) {
				for(int j = 0; j < W; ++j) {
					System.out.print((i + j) % 2 == 0 ? "#" : ".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 35652
cards = [[False for i in range(14)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

n = int(input())

for i in range(n):
    x = list(map(str,input().split()))
    cards[pattern.index(x[0])][int(x[1])] = True

for i2 in range(4):
    for j in range(1,14):
        if cards[i2][j] == False:
            print(pattern[i2],j)


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

typedef long long int ll;
ll a, b, c, d;

ll gcd(ll x, ll y)
{
    while(x!=y)
    {
        if(x>y) x=x-y;
        else
            y=y-x;
    }
    return x;
}

ll solve()
{
	ll num1 = a / c;
	ll num2 = b / c;
	ll cnt1 = num2 - num1;
	if(a%c == 0) cnt1++;

	ll num3 = a / d;
	ll num4 = b / d;
	ll cnt2 = num4 - num3;
	if(a%d == 0) cnt2++; 

	ll g = c * d / gcd(c, d);
	ll num5 = a / g;
	ll num6 = b / g;
	ll cnt3 = num6 - num5;
	if(a%g == 0) cnt3++;

	//cout << "1 " << cnt1 << endl;
	//cout << "2 " << cnt2 << endl;
	//cout << "3 " << cnt3 << endl;
	return b - a + 1 - (cnt1 + cnt2 - cnt3);
}


int main()
{
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	printf("%lld\n", solve());
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,x,y,a[2002][2002],val[2002];
void solve(){
    cin>>n>>x>>y;
    rep(i,1,n+1){
        rep(j,1,n+1){
            a[i][j]=abs(i-j);
        }
    }
    a[x][y]=1;
    a[y][x]=1;
    rep(i,1,n+1){
        rep(j,1,n+1){
            a[i][j]=min(a[i][j],a[i][x]+1+a[y][j]);
            a[i][j]=min(a[i][j],a[i][y]+1+a[x][j]);
        }
    }
    rep(i,1,n+1){
        rep(j,1,n+1){
            val[a[i][j]]++;
        }
    }
    rep(i,1,n) cout<<val[i]/2<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 15872
n=int(input())
a=[int(input()) for _ in range(n)]
if a[0]!=0:
  print(-1)
  exit()
a.reverse()
pre=a[0]
tmp=pre
ans=0
for ai in a[1:]:
  if ai>=pre:
    ans+=tmp
    pre=ai
    tmp=ai
  elif ai+1==pre:
    pre=ai
  else:
    print(-1)
    exit()
ans+=tmp
print(ans)




Measured memory_bytes: 18448
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i, N) { cin >> h[i]; }
    sort(all(h));
    int left = 0, right = K - 1;
    int ans = inf;
    while (right >= 0 && right < N) {
        ans = min(ans, h[right] - h[left]);
        right++, left++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
#define INF (1LL << 60)
using namespace std;
int n, u[3], mode, tar; long long d, x[30], y[30], ret, seg[33554432], val[14348907]; pair<long long, long long> t[2][14348907];
inline void rec(int pos, long long a, long long b) {
	if (pos == tar) {
		if (b <= 0) t[mode][u[mode]++] = make_pair(a, b);
		return;
	}
	rec(pos + 1, a + x[pos], b + y[pos]);
	rec(pos + 1, a - x[pos], b - y[pos]);
	rec(pos + 1, a, b);
}
inline long long query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return INF;
	if (a <= l && r <= b) return seg[k];
	long long lch = query(a, b, k << 1, l, (l + r) >> 1);
	long long rch = query(a, b, (k << 1) + 1, (l + r) >> 1, r);
	return min(lch, rch);
}
int main() {
	scanf("%d%lld", &n, &d);
	for (int i = 0; i < n; i++) scanf("%lld%lld", &x[i], &y[i]);
	mode = 0; tar = n / 2; rec(0, 0, 0);
	mode = 1; tar = n; rec(n / 2, 0, 0);
	sort(t[1], t[1] + u[1]);
	for (u[2] = 1; u[2] <= u[1]; u[2] <<= 1);
	for (int i = 0; i < u[1]; i++) val[i] = t[1][i].first;
	for (int i = 0; i < u[1]; i++) seg[i + u[2]] = t[1][i].second;
	for (int i = u[2]; i >= 1; i--) seg[i] = min(seg[i << 1], seg[(i << 1) + 1]);
	for (int i = 0; i < u[0]; i++) {
		int pl = lower_bound(val, val + u[1], -t[0][i].first - d) - val;
		int pr = upper_bound(val, val + u[1], -t[0][i].first + d) - val;
		long long res = query(pl, pr, 1, 0, u[2]);
		ret = max(ret, -t[0][i].second - res);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 405068
#!/usr/bin/env python3
#ABC100 D

from itertools import *

N,M = map(int,input().split())

cakes = [list(map(int,input().split())) for _ in range(N)]

pm = (1,-1)
if M == 0:
    print(0)
else:
    ans = -1
    for a in product(*[pm] *3):
        cakes.sort(key = lambda y:sum(list(map(lambda x: x[0]*x[1],zip(a,y)))))
        x,y,z = zip(*cakes[:M])
        ans = max(ans,abs(sum(x))+abs(sum(y))+abs(sum(z)))
    print(ans)


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

double A, B;
double wotA, wotB;
int dA, dB;
double wtA, wtB;
bool wot = false;
int i=0;
int ans = -1;

int main(){
    cin >> A >> B;
    
    wotA = A / 0.08;
    wotB = B / 0.10;

    /*cout << wotA << endl;
    cout << wotB << endl;*/

    dA = wotA;
    dB = wotB;

    wotA = wotA - (wotA - dA);
    wotB = wotB - (wotB - dB);      
    double init = max(wotA, wotB);
    int a, b;

    while(!wot) {
        a = init * 0.08;
        b = init * 0.10;

        /*cout << a << endl;
        cout << b << endl;*/


        if(a > A and b > B) break;
        else if(a == (int)A and b == (int)B){
            wot = true;
            ans = init;
            break;
        }
        else{
            init += 1.0;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>

int get_sum_of_digit(std::string x){
    int sum = 0;
    
    for(int i = 0; i < x.size(); i++){
        sum += x[i] - '0';
    }
    return sum;
}

int main(){
    std::string x;
    
    while(1){
        std::cin >> x;
        if(x[0] == '0') break;
        
        int sum_of_digit = get_sum_of_digit(x);
        std::cout << sum_of_digit << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3172
import sys
N=int(input())

for k in range(1,10**9):
  if N==k*(k+1)//2:
    break
  elif N<k*(k+1)//2:
    print("No")
    sys.exit(0)
  
print("Yes")
print(k+1)

cnt=1
set_list=[set() for _ in range(k+1)]
for i in range(k+1):
  for j in range(i+1,k+1):
    #print(i,j)
    set_list[i].add(cnt)
    set_list[j].add(cnt)
    cnt+=1
#print(set_list)
  
for i in range(k+1):
  print(k,*set_list[i])

Measured memory_bytes: 26664
import sys
sys.setrecursionlimit(10**7)
N=int(input())
def f(x):
    if x==0:
        return "0"
    if x%2==1:
        return f((1-x)//2)+"1"
    else:
        return f((-x)//2)+'0'
if N==0:
    print('0')
    sys.exit()
print(f(N)[1:])

Measured memory_bytes: 38512
from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    R = [[] for i in range(N + 1)]

    for i in range(M):
        A, B = map(int, input().split())
        R[A].append(B)
        R[B].append(A)

    P = [-1] * (N + 1)
    P[1] = 0
    Q = deque()
    Q.append(1)

    while Q:
        v = Q.popleft()
        for r in R[v]:
            if P[r] == -1:
                P[r] = v
                Q.append(r)
    print('Yes')
    for p in P[2:]:
        print(p)
main()

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

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	
	double ad = (h*60.0+m)/720.0;
	double bd = m/60.0;
	double diff = min(abs(bd-ad),1.0-abs(bd-ad));

	double ansans = a*a + b*b - 2.0*a*b*cos(diff*2.0*M_PI);
	double ans = sqrt(ansans);

	printf("%.12lf",ans);
}


Measured memory_bytes: 4216
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		
		int a=0;
		int b=0;
		
		for(int i=0;i<str.length();i++)
		{
			if(str.charAt(i)=='A')
			{
				a++;
			}
			else
			{
				b++;
			}
		}
		
		if(a==3||b==3)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}
		
	}
	
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(void){
  double a, b, t;
  cin >> a >> b >> t;
  t += 0.5;
  t /= a;
  t = floor(t);
  cout << t * b << endl;
  return 0;
}


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

using namespace std;

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

  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1];

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[10001],sum;

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		while(a[i]%2==0){a[i]>>=1;++sum;}
	}
	cout<<sum<<"\n";
	return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
    string s,str;
    cin>>s>>str;
    ll l1,l2;
    l1=((int)s.size()+MOD)%MOD;
    l2=((int)str.size()+MOD)%MOD;
   	if(l1==l2){
   		int pp0=0;
   		for (int i = 0; i < l1; ++i)
   		{
   			if(s[i]!=str[i]){
   				pp0=1;
   				if(s[i]<str[i])
   					cout<<"LESS"<<endl;
   				else
   					 cout<<"GREATER"<<endl;

   				break;
   			}
   		}
   		if(pp0==0)
   			cout<<"EQUAL"<<endl;
   	}else if (l1<l2)
   	cout<<"LESS"<<endl;
   	else 
   		cout<<"GREATER"<<endl;
 	return 0;

   }

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

vector<int> g[100005];
int d[100005];

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

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for (int i = 0; i < n; i++)
        d[i] = -1;
    d[0] = 0;
    queue<int> q;
    q.push(0);

    while (!q.empty())
    {
        int v = q.front();
        q.pop();

        for (int i = 0; i < g[v].size(); i++)
        {
            int u = g[v][i];
            if (d[u] == -1)
            {
                d[u] = v;
                q.push(u);
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
    {
        cout << d[i] + 1 << endl;
    }
}

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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		String test = br.readLine();
		
		String[] res1 = test.split(" ");
		int[] x1 = new int [res1.length];
		
		for(int i = 0; i < res1.length; i++){
			x1[i] = Integer.parseInt(res1[i]);
		}
		
		if(x1[0] < x1[1]){
			System.out.println("a < b");
		}else if(x1[0] > x1[1]){
			System.out.println("a > b");
		}else {
			System.out.println("a == b");
		}
		
	}
}

Measured memory_bytes: 17088
n, x, y = map(int, input().split())
x -= 1
y -= 1
GRAPH = [[0]*n for _ in range(n)]

def shortest_path(i, j):
    if i <= x <= y <= j:
        return min(j-i, x-i+j-y+1)
    elif x <= i <= y <= j:
        return min(j-i, i-x+j-y+1)
    elif x <= i <= j <= y:
        return min(j-i, i-x+y-j+1)
    elif i <= x <= j <= y:
        return min(j-i, x-i+y-j+1)
    else:
        return j-i


ans = [0]*(n-1)
for i in range(n):
    for j in range(i+1, n):
        path = shortest_path(i, j)-1
        ans[path] += 1
print(*ans, sep="\n")

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

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int size = getSize(N);
		if (size == 0) {
			System.out.println(NO);
			return;
		}
		StringBuilder sb = new StringBuilder();
		sb.append(YES).append("\n");
		sb.append(size + 1).append("\n");

		int[][] S = new int[size + 1][size];
		int index = 1;
		for (int i = 0; i <= size; i++) {
			for (int j = 0; j < size; j++) {
				if (i == 0) S[i][j] = index++;
				else {
					if (j < i) {
						S[i][j] = S[j][i - 1];
					} else {
						S[i][j] = index++;
					}
				}
			}
		}
		for (int i = 0; i <= size; i++) {
			sb.append(size).append(" ");
			for (int j = 0; j < size; j++) {
				sb.append(S[i][j]).append(" ");
			}
			sb.append("\n");
		}

		System.out.println(sb.toString());
	}

	private static int getSize(long a) {
		int k = 0, i = 1;

		while (a > 0) {
			a -= i;
			i++;
			k++;
		}
		if (a == 0) return k;
		else return 0;
	}
}


Measured memory_bytes: 31740
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int sum[100100],ne[100100][3];
lint dp[100100];
int main()
{
	string s;cin>>s;
	int n=s.size(),f=0;
	rep(i,n-1){
		if(s[i]==s[i+1]) f=1;
	}
	if(f<1){
		cout<<1<<endl;return 0;
	}
	sum[0]=0;
	rep(i,n){
		sum[i+1]=sum[i];
		if(s[i]=='a') sum[i+1]++;
		else sum[i+1]+=2;
		sum[i+1]%=3;
	}
	rep(i,3){
		ne[n][i]=n+1;
		for(int j=n;j>0;j--){
			if(sum[j]==i) ne[j][i]=j;
			ne[j-1][i]=ne[j][i];
		}
	}
	memset(dp,0,sizeof(dp));dp[0]=1;
	lint out=0,mo=1000000007;
	rep(i,n){
		rep(j,2){
			int nex=ne[i+1][(sum[i]+j+1)%3];
			dp[nex]+=dp[i];dp[nex]%=mo;
		}
		if(i>0 && sum[i]==sum[n]){
			out+=dp[i];out%=mo;
		}
	}
	out+=dp[n];
	cout<<out%mo<<endl;
}


Measured memory_bytes: 2816
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if(W > V):
    print('NO')
    exit(0)
# 相対速度、距離
S = V - W
D = abs(A - B)
if(D > S * T):
    print('NO')
    exit(0)
else:
    print('YES')


Measured memory_bytes: 9204
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int s[3];
	while(cin>>n>>m){
		if(!n)break;
		a=n*n+m*m;
		s[0]=1e9;
		for(i=1;i<=150;i++){
			b=a-i*i;
			if(b<0)break;
			b=(int)sqrt(b-1.0)+1;
			if(i==n && b==m)b++;
			if(i>=b)continue;
			c=b*b+i*i;
			if(a==c && n>=i){
				b++;
				c=b*b+i*i;
			}
			if(a==c){s[1]=i,s[2]=b;break;}
			if(c<s[0]){s[0]=c,s[1]=i,s[2]=b;}
		}
		cout<<s[1]<<" "<<s[2]<<endl;
	}
}



Measured memory_bytes: 3200
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ok=0;
    if(abs(a-c)<=d) ok++;
    
        if(abs(a-b)<=d&&abs(b-c)<=d) ok++;
    if(ok==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    
}

Measured memory_bytes: 256
# dpC - Vacation
# 配るDP
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = A[0]
    for i in range(n - 1):  # i-th day
        for j in range(3):  # yesterday
            for k in range(3):  # today
                if j != k:
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[i + 1][k])
    print(max(dp[-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 40228
#include<bits/stdc++.h>
#define m_p make_pair
#define itll map<ll,ll>::iterator
using namespace std;
typedef long long ll;
ll isp[1000010];
vector<ll> primes;
const ll mod = 1000000007;
int main()
{
	ll n;
	cin>>n;
	map<ll,ll> mp;
	isp[0] = isp[1] = 1;
	for(ll i = 2;i<=n;i++)
	{
		if(!isp[i])
			primes.push_back(i);
		for(ll j = i*i;j<=n;j+=i)
			isp[j] = 1;
	}
	if(n == 1)
	{
		cout<<"1\n";
		return 0;
	}
	ll all = 1;
	for(ll i = n;i>=2;i--)
	{
		ll tmp = i;
		for(int j=0;j<primes.size();j++)
		{
			ll cnt = 0;
			while(tmp%primes[j] == 0)
			{
				tmp/=primes[j];
				cnt++;
			}
			mp[primes[j]]+=cnt;
		}
	}
	for(itll it = mp.begin();it!=mp.end();it++)
	{
		all*=(it->second+1);
		all%=mod;
	}
	cout<<all<<endl;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(n) fori(somethingStupid,1,(n))


using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;


void solve(){
    fori(i, 0, 4){
        int temp; cin >> temp;
        if (temp == 0){
            cout << i+1;
            return;
        }
    }
}

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

    int t = 1;
    if (tests){
        cin >> t;
    }
    rep(t) solve();
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  string n;
  cin>>n;
  int N=atoi(n.c_str());
  int v=0;
  for(int i=0;i<n.size();i++){
    v+=(int)(n[i]-'0');
  }
  if(N%v==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100005
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int Q;
  scanf("%d", &Q);

  int l[MAX], r[MAX];
  rep(i, 0, Q) scanf("%d %d", &l[i], &r[i]);

  int np[MAX] = {0};
  int n[MAX] = {0};
  np[1] = 1;
  for ( int i = 2; i <= 100000; i++ ) {
    if ( np[i] ) continue;
    for ( int j = i+i; j <= 100000; j += i ) 
      np[j] = 1;
    if ( np[(i+1)/2] == 0 ) n[i] = 1;
  }

  
  int sum[MAX];
  sum[1] = 0;
  for ( int i = 1; i <= 100000; i++ ) {
    sum[i + 1] = sum[i] + n[i];
  }

  rep(i, 0, Q) {
    printf("%d\n", sum[r[i]+1] - sum[l[i]]);
  }
  return 0;
}


Measured memory_bytes: 2560
N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf_friend = UnionFind(N)
uf_block = UnionFind(N)

es_friend = [0 for _ in range(N)]
es_block = [0 for _ in range(N)]

for i in range(M):
    uf_friend.union(AB[i][0]-1, AB[i][1]-1)
    es_friend[AB[i][0]-1] += 1
    es_friend[AB[i][1]-1] += 1
for i in range(K):
    uf_block.union(CD[i][0]-1, CD[i][1]-1)
for i in range(K):
    if uf_friend.same(CD[i][0]-1, CD[i][1]-1):
        es_block[CD[i][0]-1] += 1
        es_block[CD[i][1]-1] += 1


ans = [0 for _ in range(N)]
for i in range(N):
    ans[i] = uf_friend.size(i) - es_friend[i] - es_block[i] - 1

print(" ".join(list(map(str, ans))))


Measured memory_bytes: 69840
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

int main() {
  int n, l;

  scanf("%d %d\n", &n, &l);
  
  int sum = (n * l) + n * (n - 1) / 2;
  
  int m = numeric_limits<int>::max();
  bool negate = false;
  for (int i = 0; i < n; i++) {
    int x = abs(l + i);
    if (x <= m) {
      m = abs(l + i);
      negate = ((l + i) >= 0) ? false : true;
    }
  }

  sum += negate ? m : -m;
  
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
 
// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
using namespace __gnu_pbds;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
const int INF = 2e9;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;
const int maxn = 1e5 + 7;

int func(int a, int d)
{
    d = abs(d);
    int low = -1e16 / d, high = 1e16 / d;
    while(low <= high)
    {
        int mid = (low + high) / 2;
        int val = a + mid * d;
        if(val < 0)
            low = mid + 1;
        else
        if(val >= d)
            high = mid - 1;
        else
        {
            low = mid;
            break;
        }
    }
    int val = a + low * d;
    assert(val >= 0 && val < d);
    return val;
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n, x, d;
    cin >> n >> x >> d;
    map<int, vector<pair<int, int>>> mp;
    if(d == 0)
    {
        if(x)
            cout << n + 1;
        else
            cout << 1;
        cout << endl;
        return 0;
    }
    for(int k = 0; k <= n; k++)
    {
        int smn, smx, s, l;
        smn = k * (k - 1) / 2;
        smx = k * (2 * n - k - 1) / 2;
        s = k * x + smn * d;
        l = k * x + smx * d;
        int m = func(k * x, d);
        if(d < 0)
            swap(s, l);
        mp[m].pb({s, l});
    }
    for(auto &it: mp)
        sort(it.second.begin(), it.second.end());
    int ans = 0;
    for(auto &it: mp)
    {
        int l = it.second[0].first, r = it.second[0].second;
        for(int i = 1; i < it.second.size(); i++)
        {
            int nl = it.second[i].first, nr = it.second[i].second;
            if(nl <= r)
                r = max(r, nr);
            else
            {
                ans += (r - l) / abs(d) + 1;
                l = nl;
                r = nr;
            }
        }
        ans += (r - l) / abs(d) + 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	while (1) {
		int n; cin >> n;
		if (n == 0) return 0;
		vector<int> w(n);
		for (int i = 0; i < n; ++i) cin >> w[i];
		vector<vector<int> > dp(n, vector<int>(n, 0));
		for (int i = 0; i < n-1; ++i) {
			if (abs(w[i] - w[i+1]) <= 1) dp[i][i+1] = 2;
		}
		for (int d = 2; d < n; ++d) {
			for (int i = 0; i < n-d; ++i) {
				if (dp[i+1][i+d-1] == d-1 and abs(w[i] - w[i+d]) <= 1) dp[i][i+d] = d+1;
				else {
					for (int j = i; j < i+d; ++j) {
						dp[i][i+d] = max(dp[i][i+d], dp[i][j] + dp[j+1][i+d]);
					}
				}
			}
		}
		cout << dp[0][n-1] << "\n";
	}
}


Measured memory_bytes: 3280
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_B&lang=ja
//Matrix Chain Multiplication
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
	//std::ifstream in("./test/sample-1.in");
	std::ifstream in("./input.txt");
	std::cin.rdbuf(in.rdbuf());
#else
	cin.tie(0);
	ios::sync_with_stdio(false);
#endif
  ll n; cin>>n;
  vector<pair<ll,ll>> rcn(n);
  for(auto&& rc:rcn){
   cin>>rc.first>>rc.second;
  }
	vector<vector<ll>> dp(n,vector<ll>(n+1,-1));
  auto dfs = [&](auto&& self, ll l, ll r)->ll{
    if(l+1>=r)return 0;
		if(dp[l][r]>=0)return dp[l][r];
    ll ret=INT64_MAX;
    FOR(k,l+1,r){
      ll mulnum = rcn.at(l).first * rcn.at(k).first * rcn.at(r-1).second;
      chmin(ret, self(self,l,k)+self(self,k,r) + mulnum);
    }
		dump(l,r,ret);
		dp[l][r]=ret;
    return ret;
  };

	ll ans=dfs(dfs,0,n);
	cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}


ll n,a,b;

ll f(ll x){
	ll A=1,B=1;
	for(int i=0;i<x;i++){
		(B*=i+1)%=mod;
		(A*=n-i)%=mod;
	}
//	cout<<A<<' '<<B<<endl;
	return Div(A,B);
}

int main(){
	cin>>n>>a>>b;
	cout<<(Pow(2,n)-1-f(a)-f(b)+3*mod)%mod<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main()
{
    int n;
    int a, b, c, d;
    string s;
    cin >> n;
    cin >> a >> b >> c >> d;
    cin >> s;
    a--, b--, c--, d--;
    if (c < d)
    {
        bool right_b = true;
        for (int i = b; i <= d - 1; i++)
        {
            if (s.substr(i, 2) == "##")
            {
                right_b = false;
                break;
            }
        }
        if (right_b)
        {
            // s[d] = '#';
            bool right_a = true;
            for (int i = a; i <= c - 1; i++)
            {
                if (s.substr(i, 2) == "##")
                {
                    right_a = false;
                    break;
                }
            }
            if (right_a)
                cout << "Yes" << endl;
            else{
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        bool right_b = true;
        for (int i = b + 1; i <= d - 1; i++)
        {
            if (s.substr(i, 2) == "##")
            {
                right_b = false;
                break;
            }
        }
        if (right_b)
        {
            bool can_jump = false;
            int pos;
            for (int i = b; i <= d; i++)
            {
                if (s.substr(i - 1, 3) == "...")
                {
                    can_jump = true;
                    pos = i;
                    break;
                }
            }
            if (can_jump)
            {
                s[pos] = '#';
                // cout << s << endl;
                bool right_a = true;
                for (int i = a + 1; i <= c - 1; i++)
                {
                    if (s.substr(i, 2) == "##")
                    {
                        right_a = false;
                        break;
                    }
                }
                if (right_a)
                {
                    cout << "Yes" << endl;
                }
                else
                {
                    cout << "No" << endl;
                }
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 888