akhauriyash/Code-Regression huggingface dataset:
#define q(x,y)(f[x]*h[y]%m*h[(x)-(y)]%m)
const z=2e5,m=1e9+7;long long H,W,A,B,i=1,f[1<<18],g[1<<18],h[1<<18],r;
main(){
for(f[0]=g[1]=1;i<z;i++)f[i]=f[i-1]*i%m;
for(i=2;i<z;i++)g[i]=g[m%i]*(m-m/i)%m;
for(h[0]=i=1;i<z;i++)h[i]=h[i-1]*g[i]%m;
for(scanf("%d%d%d%d",&H,&W,&A,&B),i=0;i<W-B;i++)r=(r+q(A+i-1,i)*q(W-i+H-A-2,H-A-1))%m;
i=!printf("%d\n",r);
}

Measured memory_bytes: 4864
S=input()
s=""
flag=1
Cflag=1
if not(S[0]=="A"):
    flag=0
s="".join((s,S[1],S[len(S)-1]))

S2=S[2:len(S)-1]
#print(S)
for i in range(len(S2)):
    if not(S2[i]=="C"):
        s="".join((s,S2[i]))
    else:
        Cflag=Cflag-1
if not(Cflag==0):
    flag=0
if s.islower()==False:
    flag=0
#print(s.islower(),Cflag,s,S[1].islower(),S[len(S)-1].islower())

if flag==0:
    print("WA")
else:
    print("AC")



Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	int a[] = { 0,1,2,1,3,1,3,1,1,3,1,3,1 };
	int x, y;
	cin >> x >> y;

	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	

    return 0;
}

Measured memory_bytes: 256
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

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

	int minR = n;
	int maxL = 1;

	for (int i = 0; i < m; i++) {
		int l, r;
		cin >> l >> r;

		if (l > maxL) maxL = l;
		if (r < minR) minR = r;
	}

	int out = minR - maxL;
	if (out < 0) {
		out = 0;
	}
	else {
		out++;
	}

	cout << out;


	//system("pause");

	return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {    
       int n,xx=0,ans=0;
       cin>>n;
       int a[n+2];
       for(int i=0;i<n;i++)
       cin>>a[i];
      // cout<<xx<<"\n";
       //int c=0;
       int mm=-1,z;
       for(int i=0;i<n-1;i++)
       {    
           if(a[i+1]<a[i])
           {
           ans+=(a[i]-a[i+1]);
           z=a[i]-a[i+1];
           a[i+1]=z+a[i+1];
           }
          // c++;
       }
       cout<<ans;
    }
 
}
// 🍪 🍪 🍪

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string N; cin >> N;

	char s = N.back();
	if(s == '2' or s == '4' or s == '5' or s == '7' or s == '9') cout << "hon" << endl;
	else if(s == '0' or s == '1' or s == '6' or s == '8') cout << "pon" << endl;
	else if(s == '3') cout << "bon" << endl;

	return 0;

}


Measured memory_bytes: 3592
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int h[] = new int[n];
            boolean tower[][] = new boolean[n][1];
            for (int i = 0; i < n; i++) {
                h[i] = Integer.parseInt(in.next());
            }
            int load[][] = new int[m * 2][2];
            for (int i = 0; i < m; i++) {
                load[i][0] = Integer.parseInt(in.next()) - 1;
                load[i][1] = Integer.parseInt(in.next()) - 1;
            }
            for (int i = m; i < m * 2; i++) {
                load[i][0] = load[i - m][1];
                load[i][1] = load[i - m][0];
            }
            int ans = 0;

            for (int j = 0; j < m * 2; j++) {
                if (h[load[j][0]] >= h[load[j][1]]) tower[load[j][1]][0] = true;
            }

            for (int i = 0; i < n; i++) {
                if (tower[i][0] == false) ans++;
            }

            // 出力
            out.println(ans);

        }

    }
}



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

int main() {
  int N;
  cin >> N;
  
  vector<string> s(N);
  rep(i, N) {
    cin >> s.at(i);  
  }
  
  int M;
  cin >> M;
  
  vector<string> t(M);
  rep(i, M) {
    cin >> t.at(i);  
  }
  
  int ans = 0;
  rep(i, N) {
    int cntN = 0;
    rep(j, N) {
      if (s.at(i) == s.at(j)) cntN++;
    }    
    int cntM = 0;
    rep(j, M) {
      if (s.at(i) == t.at(j)) cntM++;
    }
    ans = max(ans, cntN - cntM);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int a[3][3];
bool b[3][3];


int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		for (int ii = 0; ii < 3; ii++) {
			for (int jj  = 0; jj < 3; jj++) {
				if (a[ii][jj] == t) {
					b[ii][jj] = true;
				}
			}
		}
	}

	for (int i = 0; i < 3; i++) {
		bool ok = true;
		for (int j = 0; j < 3; j++) {
			if (!b[i][j]) {
				ok = false;
			}
		}
		if (ok) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	for (int j = 0; j < 3; j++) {
		bool ok = true;
		for (int i = 0; i < 3; i++) {
			if (!b[i][j]) {
				ok = false;
			}
		}
		if (ok) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (b[1][1] && b[2][2] && b[0][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (b[2][0] && b[1][1] && b[0][2]) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3068
n, m = map(int, input().split())
lr = []
for i in range(m):
	lr.append(list(map(int, input().split())))

mi = 0
ma = 100001

for i in range(m):
	if lr[i][0] > mi:
		mi = lr[i][0]
	if lr[i][1] < ma:
		ma = lr[i][1]

if ma-mi+1 >= 0:
	print(ma-mi+1)
else:
	print(0)


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

int bubbleSort(int A[], int N){
    int count = 0;
    bool flag = 1;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j=N-1; j >=1; j--){
            if (A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                count++;
                flag = 1;
            }
        }
    }
    return count;
}

int main(){
    int N, count;
    cin >> N;
    int A[100];
    for(int i=0; i<N; i++) cin >> A[i];
    count = bubbleSort(A, N);
    for(int i=0; i<N-1; i++){
        cout << A[i] << " ";
    }
    cout << A[N-1] << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int q = scanner.nextInt();
    for (int i = 0; i < q; i++) {
      long a = scanner.nextLong();
      long b = scanner.nextLong();
      System.out.println(solve(a, b));
    }
  }

  private static long solve(long a, long b) {
    if (a > b) return solve(b, a);

    if (a == b) return 2 * a - 2;
    if (a + 1 == b) return 2 * a - 2;

    long ab = a * b;
    long c = findUpperRoot(ab);
    if (c * (c + 1) >= ab) return 2 * c - 2;
    return 2 * c - 1;
  }

  private static long findUpperRoot(long n) {
    long ll = 0;
    long ul = (long) Math.sqrt(n) + 1;
    while (ll + 1 < ul) {
      long mid = (ll + ul) / 2;
      if (mid * mid < n) {
        ll = mid;
      } else {
        ul = mid;
      }
    }
    return ll;
  }
}


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

int main() {
 double a, b, X;
 cin >> a >> b >> X;
 double x = X/a;
 double t = 0;
 if (a*b/2 < x)
 {
   t =2*(a*b-x)/(a*a);
 }

 else
 {
   t = b*b/(2*x);
 }
  double ans = atan(t);
  ans = ans*180/3.14159265358979;
  printf("%2.7f",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

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

    int N, A, B; cin >> N >> A >> B;
    vector<int> P(N);
    rep(i,N) cin >> P[i];

    int first, second, third;
    first = second = third = 0;
    rep(i,N){
        if (P[i] <= A){
            first++;
        }
        else if (B+1 <= P[i]){
            third++;
        }
        else{
            second++;
        }
    }
    int ans = min({first,second, third});
    cout << ans << endl;

}

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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for(int i = 0; i < N; i++){
    cin >> H.at(i);
  }
  int ans = 0;
  float min_dif = abs(A - (T - H.at(0) * 0.006));
  for(int i = 1; i < N; i++){
    float dif = abs(A - (T - H.at(i) * 0.006));
    if(dif < min_dif){
      min_dif = dif;
      ans = i;
    }
  }
  cout << ans + 1;
  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define swap(x, y) {int z; z = y ; y = x ; x = z;}


int main()
{
	int a, b, i = 1;
	
	while(scanf("%d %d",&a ,&b))
	{
		if(a == 0 & b == 0)
		{
			break;
		}
		else
		{
			if(a > b)
			{
				swap(a, b)
			}
		}
		printf("%d %d\n",a ,b );
	}
	return 0;
}


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9+5;
int main()
{
	ll n;
	cin>>n;
	ll a,b,c;
	ll k = -1;
	vector<int> dp(3,0);
	
	for(ll d=0;d<n;d++)
	{
		vector<int> c(3);
		for(int j=0;j<3;j++) cin>>c[j];

			vector<int> new_dp(3,INF*-1);

			for(int i=0;i<3;i++)
			{
				for(int j=0;j<3;j++)
				{
					if(i!=j)
					new_dp[j] = max(new_dp[j], dp[i]+c[j]);
				}
			}
		dp = new_dp;

	}

	cout<<max({dp[0],dp[1],dp[2]})<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

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

const int N = 10000001;
bool is_prime[N];

int main() {
    rep(i, N) is_prime[i] = true;

    is_prime[0] = is_prime[1] = false;
    rep(i, N) {
        if(!is_prime[i]) continue;

        for(int j = i * 2; j < N;j += i) {
            is_prime[j] = false;
        }
    }

    while(1) {
        int n;
        cin >> n;
        if(!n) break;

        for(int i = n;i >= 0;i--) {
            if(is_prime[i] && is_prime[i - 2] && is_prime[i - 6] && is_prime[i - 8]) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 10924
N = int(input()) # 10**5
P = [int(x)-1 for x in input().split()]

# 1 4 3 5 2
# 1 2 3 4 5
# x o x o o

# 1 2 3
# x x x
# 2 1 3
# o o x
cnt = 0
i = 0
while i < N-1:
    if P[i] != i:
        i+=1
    else: # P[i] == i
        P[i],P[i+1] = P[i+1],P[i]
        cnt += 1
        i+=2
if P[N-1] == N-1:
    cnt+=1
print(cnt)


Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int ar[n],i,j;
  for(i=0;i<n;i++){
    cin>>ar[i];
  }
  int sum=0;
  sort(ar,ar+n);
  for(i=0;i<k;i++){
    sum+=ar[i];
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;

double EPS = 1e-10;


int main(){
	int r, c;
	while(cin>>r>>c){
		if(r == 0 && c == 0) break;
		if(r%2==0 || c%2==0) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

vector<int>data[200005];
vector<int>ans;

void dfs(int now,int par){
    for(int c:data[now]){
        if(c==par) continue;
        ans[c]+=ans[now];
        dfs(c,now);
    }
}

int main (){
    int n,q;
    cin >> n >> q;
    ans.resize(n,0);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        data[a].push_back(b);
        data[b].push_back(a);
    }
    rep(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        ans[p]+=x;
    }
    dfs(0,-1);
    rep(i,n){
        cout << ans[i];
        if(i!=n-1) cout << " ";
        else cout << endl;
    }
    return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007
int main(){
int N;
  cin >> N;
  string S;
  cin >> S;
  long long int ans=0;
  vector<int> SUMR(N);
  vector<int> SUMG(N);
  vector<int> SUMB(N);
  SUMR[0]=0;
  SUMR[0]=0;
  SUMR[0]=0;
  if(S[0]=='R')
    SUMR[0]=1;
  if(S[0]=='G')
    SUMG[0]=1;
  if(S[0]=='B')
    SUMB[0]=1;
  rep2(i,1, N){
  if(S[i]=='R'){
  SUMR[i]=1+SUMR[i-1];
  SUMB[i]=SUMB[i-1];
  SUMG[i]=SUMG[i-1];
  }
  if(S[i]=='G'){
  SUMG[i]=1+SUMG[i-1];
  SUMB[i]=SUMB[i-1];
  SUMR[i]=SUMR[i-1];
  }
  if(S[i]=='B'){
  SUMB[i]=1+SUMB[i-1];
  SUMR[i]=SUMR[i-1];
  SUMG[i]=SUMG[i-1];
  }
  }
  rep(i, N-2){
  rep2(j, i+1,N-1){
    if(S[i]==S[j])
      continue;
    if(S[i]=='R'){
    if(S[j]=='G'){
    ans+=SUMB[N-1]-SUMB[j];
      if(2*j-i<=N-1&&S[2*j-i]=='B')
        ans--;
    }
      else{
    ans+=SUMG[N-1]-SUMG[j];
      if(2*j-i<=N-1&&S[2*j-i]=='G')
        ans--;
      }
    }
    if(S[i]=='G'){
    if(S[j]=='R'){
    ans+=SUMB[N-1]-SUMB[j];
      if(2*j-i<=N-1&&S[2*j-i]=='B')
        ans--;
    }
      else{
    ans+=SUMR[N-1]-SUMR[j];
      if(2*j-i<=N-1&&S[2*j-i]=='R')
        ans--;
      }
    }
    if(S[i]=='B'){
    if(S[j]=='G'){
    ans+=SUMR[N-1]-SUMR[j];
      if(2*j-i<=N-1&&S[2*j-i]=='R')
        ans--;
    }
      else{
    ans+=SUMG[N-1]-SUMG[j];
      if(2*j-i<=N-1&&S[2*j-i]=='G')
        ans--;
      }
    }
  }
  }
  
  
  
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll fac[2005];
const int mod=1e9+7;
ll inv(ll b){return b==1?1:(mod-mod/b)*inv(mod%b)%mod;}
ll c(int n,int r){
	if(r==0||r==n)
		return 1;
	if(n<r)
		return 0;
	return fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod;
}
int main(){
	fac[1]=1;
	fac[0]=1;
	for(int i=2;i<=2000;i++)
		fac[i]=fac[i-1]*i%mod;
	int n,k;
	scanf("%d%d",&n,&k);
	ll ans=1;
	for(int i=1;i<=k;i++){
		ll r,b;
		//cout<<"1\n";
		r=c(n-k+1,i);
		b=c(k-1,i-1);
		ans=r*b%mod;
		printf("%lld\n",ans);
	}
	return 0;
}

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

#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

void solve()
{
    int n;
    cin >> n;
    if(n % 1000)    cout << 1000 - n%1000 << endl;
    else cout << 0 << endl;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}

Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, i, j, a, b, ans;
	string s[303];

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}

	ans = 0;

	for (a = 0; a < n; a++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				if (s[i][j] != s[(j + a) % n][(i - a + n) % n]) {
					break;
				}
			}
			if (j < n) {
				break;
			}
		}
		if (i == n) {
			ans += n - a;
		}
	}

	for (b = 1; b < n; b++) {
		for (i = 0; i < n; i++) {
			for (j = 0; j < n; j++) {
				if (s[i][j] != s[(j - b + n) % n][(i + b) % n]) {
					break;
				}
			}
			if (j < n) {
				break;
			}
		}
		if (i == n) {
			ans += n - b;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    string s; cin>>s;
    ll n=sz(s);
    if(n%2) {cout<<"No"; return 0;}
    sort(all(s));
    rep(i,0,n)
    {
        char x=s[i];
        ll c=count(all(s),x);
        if(c%2!=0)
        {
            cout<<"No"; return 0;
        }
    }
    cout<<"Yes";
    return 0;

}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

char win(char m){

	char w;

	if(m =='r'){
		w ='p';
	}else if (m =='s') {
		w= 'r';
	}else {
		w= 's';
	}

	return w;


}

char his[100010];



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

	int N,K,R,S,P;cin>>N>>K>>R>>S>>P;
	string s; cin>>s;

	int sum=0;
	for(int i=0; i<N; i++){
		if(i<K){
			char tmp =win(s[i]);
			if(tmp == 'r'){
				sum +=R;
			}else if (tmp == 's') {
				sum += S;
			}else {
				sum += P;
			}
			his[i] = tmp;
		}else {

			char tmp = win(s[i]);

			if(his[i-K] != tmp){
				char tmp =win(s[i]);
				if(tmp == 'r'){
					sum +=R;
				}else if (tmp == 's') {
					sum += S;
				}else {
					sum += P;
				}
				his[i] = tmp;
			}
		}
	}
	writeln(sum);





}




Measured memory_bytes: 592
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

string dp[1<<10][10];  //[ツ使ツ用ツつオツつスツ湘ウツ妥脳[ツ催古」ツづ可使ツづつスツ閉カツ篠堋療ア]
string data[10],tmp[10];
int edge[10][10];
int n;

int common_char(string& a, string& b){
	REP(i,1,a.size()){
		if( b.find(a.substr(i))==0 ){
			return a.size()-i;
		}
	}
	return 0;
}

int main(){

	while(scanf("%d",&n),n){
		rep(i,1<<n)rep(j,n)dp[i][j]="";
		rep(i,10)rep(j,10)edge[i][j]=0;

		set<string> st;
		rep(i,n){
			cin>>tmp[i];
			st.insert(tmp[i]);
		}
		int m = 0;
		set<string>::iterator it;
		for(it=st.begin(); it!=st.end(); it++){
			tmp[m++] = *it;
		}
		n = 0;
		rep(i,m){
			bool f = true;
			rep(j,m)if( i!=j ){
				if( tmp[j].find(tmp[i]) != string::npos ){
					f = false; break;
				}
			}
			if( f ){
				data[n++] = tmp[i];
			}
		}
		

		rep(i,n){
			rep(j,n)if( i!=j ){
				edge[i][j] = common_char(data[i], data[j]);
			}
		}

#if DEB
		rep(i,n){
			rep(j,n){
				printf("%d ",edge[i][j]);
			}
			puts("");
		}
#endif

		/*
		  0 2 5
		  6 0 2
		  6 6 0
		  */

		
		rep(i,n)dp[1<<i][i] = data[i];
		rep(i,1<<n){
#if DEB
			printf("iiiii:%d\n",i);
#endif			
			rep(j,n)if( (1<<j)&i ){
#if DEB
				printf("jjjj:%d\n",j);
#endif
				rep(k,n)if( ((1<<k)&i)==0 ){
					int sz = data[k].size() - edge[k][j];
					int next = i|(1<<k);
					string s = data[k].substr(0,sz) + dp[i][j];

#if DEB
					printf("next:%d  , i:%d,  j:%d,  k:%d   s:%s\n",next,i,j,k,s.c_str());
#endif
					
					if( dp[next][k] == "" ){  // data[k] + data[j]
						dp[next][k] = s;
						
					}else if( dp[next][k].size() >= s.size() ){
#if DEB
						printf("sz: %d, %d\n",dp[next][k].size(),s.size());
#endif
						if( dp[next][k].size() == s.size() ){
							if( dp[next][k] > s ){
								dp[next][k] = s;
							}
						}else{
#if DEB
							printf("dp.size() > s.size()    s:%s\n",s.c_str());
#endif
							dp[next][k] = s;
						}
					}
				}
			}
		}

		string ans = dp[(1<<n)-1][0];
		REP(i,1,n){
			if( ans.size()>dp[(1<<n)-1][i].size() ){
				ans = dp[(1<<n)-1][i];
			}else if( ans.size() == dp[(1<<n)-1][i].size() ){
				if( ans > dp[(1<<n)-1][i] ){
					ans = dp[(1<<n)-1][i];
				}
			}
		}
		cout << ans << endl;
		
	}
	
	return 0;
}

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

int dp[21][14];
int main() {
	int d, x; scanf("%d%d", &d, &x);
	rep(i, x) {
		string a; int p; cin >> a >> p;
		rep(j, d + 1) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (a == "D"&&j + 1 <= d)dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + p);
		}
	}
	int y; scanf("%d", &y);
	rep(i, y) {
		string b; int p; cin >> b >> p;
		rep(j, d + 1) {
			dp[x + i + 1][j] = max(dp[x + i + 1][j], dp[x + i][j]);
			if (b == "DD"&&j + 2 <= d)dp[x + i + 1][j + 2] = max(dp[x + i + 1][j + 2], dp[x + i][j] + p);
		}
	}
	printf("%d\n", dp[x + y][d]);
}

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

int main(){
    int N;
    cin>>N;
    int A[N],B[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+N);
    if(B[N-2]==B[N-1]){
        for(int i=0;i<N;i++){
            cout<<B[N-1]<<endl;
        }      
    }
    else{
         for(int i=0;i<N;i++){
             if(A[i]!=B[N-1])cout<<B[N-1]<<endl;
             else cout<<B[N-2]<<endl;
         }
    }   
return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    if(s.size()%2 == 1){
        puts("No");
        return 0;
    }
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2)) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),base=sc.nextInt(),ans=1;
		for(int i=1;i<N;i++) {
			int tmp = sc.nextInt();
			if(base<=tmp) ans++;
			if(tmp>base) base=tmp;
		}
		System.out.println(ans);
	}
}


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

int main(int argc, char *argv[])
{
    int a, b, c, d;

    std::cin >> a >> b >> c >> d;

    while(1) {
        c -= b;
        if (c <= 0) {
            std::cout << "Yes" << std::endl;
            break;
        }

        a -= d;
        if (a <= 0) {
            std::cout << "No" << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    map<char,int> mp;
    for(char c='a';c<='c';c++) mp[c]=0;
    rep(i,n){
        mp[s[i]]++;
    }
    vector<int> cnt;
    for(auto [x,y]:mp) cnt.push_back(y);
    sort(begin(cnt),end(cnt));
    if(cnt[2]-cnt[0]<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3764
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>

int main()
{
    int n, k, ans = 0;

    std::cin >> n >> k;
    std::vector<int> v(n);

    for (int i = 0; i < n; i++)
        std::cin >> v[i];

    for (int a = 0; a <= std::min(n, k); a++)
    {
        for (int b = 0; a + b <= std::min(n, k); b++)
        {
            std::vector<int> vec;
            int sum = 0;
            for (int i = 0; i < a; i++)
                vec.push_back(v[i]), sum += v[i];
            for (int j = 0; j < b; j++)
                vec.push_back(v[n - 1 - j]), sum += v[n - 1 - j];

            sort(vec.begin(), vec.end());

            for (int i = 0; i < std::min(k - (a + b), (int)vec.size()); i++)
            {
                if (vec[i] < 0)
                    sum -= vec[i];
            }
            ans = std::max(ans, sum);
        }
    }

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

Measured memory_bytes: 256
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var a, p int
	fmt.Sscan(getNextLine(scanner), &a, &p)

	fmt.Fprintln(writer, (3*a+p)/2)

	writer.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
using namespace std;
map <int ,int> mpa,mpb;

struct Point{double x,y;};

void koch(int n, Point a, Point b){
  if(n==0) return;
  Point s, t, u;
  double th=M_PI*60.0/180.0;
  
  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1,t,b);
}

int main(){
  int n;
  cin >> n;
  Point  a, b;
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n", b.x, b.y);
  return 0;
}



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

int main(){
  std::string S, T;
  std::cin >> S >> T;
  int count = 0;
  for(int i = 0 ; i < (int)S.size() ; i++){
    if(S[i] != T[i]){
      count++;
    }
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3916
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u64 = read();
    let uniq: HashSet<String> = (0..n).map(|_| read()).collect();
    println!("{}", uniq.len());
}


Measured memory_bytes: 14632
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007


int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int a, b; cin >> a>> b;
        int to = a, cur = b;
        vector<int> v;
        while ( to-- ) { v.push_back(cur++); }
        cur = b - 1, to = a - 1;
        while ( to-- ) { v.push_back(cur--); }
        sort(all(v));
        lp(i, sz(v)) cout << v[i]<< " ";
return 0;
}


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

const int maxn = 100010;
int n, x, tot, ans, a[maxn], b[maxn], c[maxn], d[maxn], fa[maxn];
bool chk[maxn];
map<int, int> mp;

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int main() {
    scanf("%d", &n), n++;
    for (int i = 1; i < n; i++) {
        scanf("%d", &a[i]);
        c[i] = a[i], x ^= a[i];
    }
    a[n] = c[n] = x, x = 0;
    sort(c + 1, c + n + 1);
    for (int i = 1; i < n; i++) {
        scanf("%d", &b[i]);
        d[i] = b[i], x ^= b[i];
    }
    b[n] = d[n] = x;
    sort(d + 1, d + n + 1);
    for (int i = 1; i <= n; i++) {
        fa[i] = i;
        if (c[i] ^ d[i]) printf("-1\n"), exit(0);
        if (!mp.count(c[i])) mp[c[i]] = ++tot;
    }
    for (int i = 1; i <= n; i++) {
        a[i] = mp[a[i]], b[i] = mp[b[i]];
        if (a[i] == b[i]) continue;
        if (i < n) ans++;
        int u = find(a[i]), v = find(b[i]);
        fa[u] = v, chk[a[i]] = chk[b[i]] = 1;
    }
    if (!ans) printf("0\n"), exit(0);
    chk[a[n]] = chk[b[n]] = 1;
    for (int i = 1; i <= tot; i++) {
        if (chk[i] && i == find(i)) ans++;
    }
    printf("%d\n", ans - 1);
    return 0;
}

Measured memory_bytes: 8576
#include<iostream>
using namespace std;
int main(){
	int m,f,r;
	for(;;){
		cin>>m>>f>>r;
		if(m==-1 && f==-1)break;
		else if(m==-1 || f==-1)cout<<"F"<<endl;
		else if(m+f<30)cout<<"F"<<endl;
		else if(m+f>=80)cout<<"A"<<endl;
		else if(m+f>=65 && m+f<80)cout<<"B"<<endl;
		else if(m+f>=50 && m+f<65)cout<<"C"<<endl;
		else if(m+f>=30 && m+f<50 && r>=50)cout<<"C"<<endl;
		else if(m+f>=30 && m+f<50 && r<50)cout<<"D"<<endl;
	}
}

Measured memory_bytes: 3108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[100010];

signed main() {
    int N, K;
    cin >> N >> K;

    vector<int> h;
    inputVector(h, N);

    REP(i, 1, N - 1) {
        dp[i] = LLONG_MAX;
        rep(j, K) {
            int pt = i - j - 1;
            if (pt < 0) break;
            dp[i] = min(dp[i], dp[pt] + abs(h[i] - h[pt]));
        }
    }

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

    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n, a, b;
  int ans;

  scanf("%d %d %d",&n, &a, &b);

  if(n<1 || n>20)return 0;
  if(a<1 || a>50)return 0;
  if(b<1 || b>50)return 0;

  if(a*n>b)ans = b;
  else ans = a*n;

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>

#include <string>

using namespace std;
int main()
{
	
	int A,B,C;
cin>>A>>B>>C;
    cout<<((A==5&&B==5&&C==7)||(A==5&&B==7&&C==5)||(A==7&&B==5&&C==5)? "YES" : "NO")<<endl;
	}


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

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);

  int x2 = 0;
  int x1 = 0;
  for (auto& xi : x) {
    cin >> xi;
    x2 += xi * xi;
    x1 += xi;
  }

  int min;
  for (int i = 1; i <= 100; ++i) {
    int total = x2 - 2 * x1 * i + n * i * i;
    if (i == 1) {
      min = total;
    }
    if (min > total) {
      min = total;
    }
  }
  cout << min << endl;
  return 0;
}


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

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    int n = b - a;
    n = n * (n + 1) / 2;
    cout << n - b << "\n";
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N, X, Y;
ll d[3000][3000];
ll ans[3000];

signed main() {
  cin >> N >> X >> Y;
  for (ll i=1; i<=N; i++)
    for (ll j=i+1; j<=N; j++)
      d[i][j] = d[j][i] = abs(i-j);
  for (ll i=1; i<=N; i++)
    d[0][i] = d[i][0] = min(d[X][i], d[Y][i]+1);
  for (ll i=1; i<=N; i++)
    for (ll j=i+1; j<=N; j++) {
      d[i][j] = d[j][i] = min(d[i][j], d[i][0]+d[0][j]);
      ans[d[i][j]]++;
    }
  for (ll k=1; k<=N-1; k++) {
    cout << ans[k] << endl;
  }
  return 0;
}


Measured memory_bytes: 46976
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 1010
 
struct Edge{
    int to,cost;
    Edge(){}
    Edge(int to,int cost) :
        to(to),cost(cost) {}
};
 
vector<Edge> G[MAX_N];
vector<int> C;
 
int solve(int v){
    int res = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        Edge e = G[v][i];
        if(C[e.to-1] > 0){
            res += e.cost;
        }else{
            res += min(e.cost,solve(e.to));
        }
    }
    return res;
}
 
int main(){
    int N,u,v,p;
    cin >> N; C.resize(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        cin >> C[i];
    }
    for(int i = 0 ; i < N-1 ; i++){
        cin >> u >> v >> p;
        G[u].push_back(Edge(v,p));
    }
    cout << solve(0) << endl;
    return 0;
}

Measured memory_bytes: 3140
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int m;cin>>m;
    cout<<48-m<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,col[205];
int main(){
	cin >> n;
	int lb = 1, ub = n+1;
	string ret1;
	cout << "?";
	for(int j=1;j<=n;j++) cout << " " << j;
	cout << endl;
	cin >> ret1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		cout << "?";
		for(int j=1;j<=n;j++) cout << " " << mid-1+j;
		cout << endl;
		string R; cin >> R;
		if(R != ret1) ub = mid;
		else lb = mid;
	}
	int F;
	if(ret1 == "Red") F = 1; else F = 0;
	{
		col[ub-1] = F;
		col[ub+n-1] = 1-F;
		for(int a=1;a<=2*n;a++){
			if(ub-1 <= a && a <= ub+n-1) continue;
			cout << "?";
			cout << " " << a ;
			for(int x=ub;x<ub+n-1;x++) cout << " " << x ;
			cout << endl;
			string x; cin >> x;
			if(x == "Red") col[a] = 1;
			else col[a] = 0;
		}
	}
	vector<int>vec,vec2;
	for(int i=1;i<=2*n;i++){
		if(ub <= i && i < ub+n-1) continue;
		if(col[i] == 0) vec.pb(i);
		else vec2.pb(i);
	}
	for(int i=ub;i<ub+n-1;i++){
		cout << "?";
		cout << " " << i ;
		for(int x=0;x<(n-1)/2;x++) cout << " " << vec[x] ;
		for(int x=0;x<(n-1)/2;x++) cout << " " << vec2[x] ;
		cout << endl;
		string x; cin >> x;
		if(x == "Red") col[i] = 1;
		else col[i] = 0;
	}
	cout << "! ";
	for(int i=1;i<=2*n;i++){
		if(col[i] == 1) cout << "R";
		else cout << "B";
	}
	cout << endl;
}


Measured memory_bytes: 724
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	string s;
	cin >> s;
	ll n = s.size(), ans = 0;
	rep(i, n) {
		if (s[i] == 'x')ans++;
	}
	if (ans >= 8)puts("NO");
	else puts("YES");
	ggr
}


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

#define INF (1e9+5)
using namespace std;
typedef long long ll;
    
ll mod = 998244353;
    
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i=0; i<n; i++) {
    int x;
    scanf("%d", &x);
    if ((i==0 && (x!=0)) || ((i!=0) && (x==0))) {
      printf("0\n");
      return 0;
    } 
    a[x]++;
  }
  
  ll ans=1;
  for (int i=1; i<a.size(); i++) {
    ll pls = 1;
    for (int j=0; j<a[i]; j++) {
      pls = (pls * a[i-1]) % mod;
    }
    ans = (ans * pls) % mod;
  }

  printf("%lld\n", ans);
}


Measured memory_bytes: 640
n,k = map(int,input().split())
s = input()
times = [1]
list_ans = []
for i in range(n-1):
        if s[i] != s[i+1]:
                times.append(i+2)
len_times = len(times)
for i in range(2*k+1):
        times.append(n+1)
for i in range(len_times):
        if s[times[i]-1] == "0":
                list_ans.append(times[i+2*k] - times[i])
        else:
                list_ans.append(times[i+2*k+1] - times[i])
print(max(list_ans))

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

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll h,a;
    cin >> h >> a;
    ll sum = 0;
    for(ll i=0;i<a;++i){
    	ll x;
    	cin >> x;
    	sum+=x;
    }
    if(sum >= h){
    	cout << "Yes" << endl;
    }
    else{
    	cout << "No" << endl;
    }

	return 0;
}

Measured memory_bytes: 256
import collections
import sys
n,m,k = map(int,sys.stdin.readline().split())
parent = range(0, n+1)
sizes = [1] * (n + 1)
hd = [1] * (n + 1) 

def f(parent, u):
	if parent[u] != u:  parent[u] = f(parent, parent[u])
	return parent[u]

for _ in range(m):
	a,b = map(int,sys.stdin.readline().split())
	pa,pb = f(parent, a), f(parent, b)
	hd[a] +=1
	hd[b] +=1

	if pa != pb:
		if sizes[pa] <= sizes[pb]: pa,pb = pb,pa
		parent[pb] = pa
		sizes[pa] += sizes[pb]
		
for _ in range(k):
	c,d = map(int,sys.stdin.readline().split())
	pc,pd = f(parent, c), f(parent, d)
	if (pc == pd):
		hd[c] += 1
		hd[d] += 1

print ' '.join([str(sizes[f(parent,u)] - hd[u])  for u in range(1, n+1)])

Measured memory_bytes: 42780
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
vector<int> t;
int u[20000];
void make_table(){
  for(int i=0;i*i<=20000;i++){
    t.push_back(i*i);
  }
  for(int i=0;i<(int)t.size();i++){
    int I=t[i];
    for(int j=i;j<(int)t.size();j++){
      int J=t[j];
      if(I+J>=20000)break;
      u[I+J]++;
    }
  }
}

int main(){
  make_table();
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>n>>m;
    int d=n*n+m*m;
    int ans=0,flg=0;
    for(int i=1;i<=d;i++){
      if(d%i!=0)continue;
      ans+=u[i]*u[d/i];
      if(ans>=3){
	flg=1;break;
      }
    }
    if(flg){
      cout<<'C'<<endl;
    }else cout<<'P'<<endl;

  }
  return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<vector>

using namespace std;


int main(){


	int N;

	cin >> N;

	vector<vector<int>> DP(N,vector<int>(3,0));
	vector<vector<int>> A(N,vector<int>(3,0));

	//input

	for(int i=0;i<N;i++){
		cin >> A[i][0] >> A[i][1] >> A[i][2];
	}

	//initialization!
	DP[0][0] = A[0][0];
	DP[0][1] = A[0][1];
	DP[0][2] = A[0][2];

	for(int i=1;i<N;i++){

		DP[i][0] = max(DP[i-1][1],DP[i-1][2])+A[i][0];

		DP[i][1] = max(DP[i-1][0],DP[i-1][2])+A[i][1];

		DP[i][2] = max(DP[i-1][1],DP[i-1][0])+A[i][2];

	}

	cout << max(DP[N-1][0],max(DP[N-1][1],DP[N-1][2])) << endl;

	return 0;

}

Measured memory_bytes: 14028