akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void swap(unsigned long *a, unsigned long *b) {
  unsigned long tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

unsigned long calcGcd(unsigned long a, unsigned long b) {
  unsigned long tmp;

  while (b) {
    tmp = b;
    b = a % b;
    a = tmp;
  }

  return a;
}

int main(void) {
  unsigned long a, b;
  unsigned long gcd;

  while (scanf("%lu %lu", &a, &b) != EOF) {
    if (a < b) swap(&a, &b);

    gcd = calcGcd(a, b);
    printf("%lu %lu\n", gcd, a / gcd * b);
  }

  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep2(i, N, M) for (ll i = N; i < M; i++)
#define pb push_back



typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<pll, vector<pll>, greater<pll>> greater_pq;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}
template<class T>
T getbit( T i) {
	return 1LL<<i;
}

ll sum(ll M, ll  i) {
	if (M < 0) {
		cout << "";
	};
	if (!((M >> i) % 2 )) {
		return M + (1LL << i);
	}
	else if(!atbit(M,i+1)){
		return sum(M,i+2) - getbit(i) + getbit(i+1);
	}
	else {
		return M - getbit(i)-getbit(i+1);
	}
}

int main() {
	ll N_MAX = 501;
	vvll sum(N_MAX,vector<ll>(N_MAX,0));
	vvll sum_2(N_MAX, vector<ll>(N_MAX, 0));
	vvll sum_3(N_MAX, vector<ll>(N_MAX, 0));
	ll N, M, Q;
	cin >> N >> M >> Q;
	vll L(M), R(M); 
	vll p(Q), q(Q);
	rep(i, M)cin >> L[i] >> R[i];
	rep(i, Q)cin >> p[i] >> q[i];

	rep(i, M) {
		++sum[L[i]][R[i]];
	}
	for(ll i=N_MAX-2; i>0; --i) {
		for (ll j = 1; j < N_MAX;++j) {
			sum[i][j] +=sum[i+1][j];
		}
	}
	for (ll i = N_MAX - 2; i>0; --i) {
		for (ll j = 1; j < N_MAX; ++j) {
			sum[i][j] += sum[i ][j - 1];
		}
	}
	
	
	rep(j, Q) {
		cout << sum[p[j]][q[j]] << endl;
	}
	



	return 0;
}



Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    cin >> N;
    int B[100];
    for(int i=0; i<N-1; i++){
        cin >> B[i];
    }
    
    int A[100];
    A[N-1]=B[N-2];
    A[0]=B[0];
    for(int i=N-2; i>=1; i--){
        A[i] = min(B[i],B[i-1]);
    }
    
    int ans=0;
    for(int i=0; i<N; i++){
        
        ans+=A[i];
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,f=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int l=0,r=n-1;
    vector<int>x,y;
    for(int i=n-1; i>=0; i-=2)
    {
        if(i==0)
        {
            x.push_back(arr[i]);
            break;
        }
        x.push_back(arr[i]);
        y.push_back(arr[i-1]);
    }
    reverse(y.begin(),y.end());
    for(auto i:x)
        cout<<i<<" ";
    for(auto i:y)
        cout<<i<<" ";
    cout<<endl;

    return 0;
}


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

int main()
{
 int n;
  cin>>n;
  
  long long ryu[n];
  
  ryu[0]=2;
  ryu[1]=1;
  
  for(int i=2;i<=n;i++)
  {
     ryu[i]=ryu[i-1]+ryu[i-2];
  }
  
    cout<<ryu[n]<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;

ll combi(ll n) { return n * (n - 1) / 2; }

int main() {
  ll N;
  cin >> N;
  vector<ll> as(N);
  map<ll, ll> ms;
  for(int i = 0; i < N; ++i) {
    cin >> as[i];
    ms[as[i]]++;
  }
  map<ll, ll> anss;
  ll anssTotal = 0;
  for(auto m : ms) {
    anss[m.first] = combi(m.second);
    anssTotal += anss[m.first];
  }
  for(auto a : as) {
    ll ans = anssTotal - anss[a] + combi(ms[a] - 1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 18944
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

double n;
double k;

int main(){
    cin >> n >> k;
    double ans = 0;
    for(double i = 1; i <= n; i++){
        int pw = 0;
        while(i*pow(2 , pw) < k){
            pw++;
        }
        ans += 1/pow(2 , pw);
    }
    ans *= 1/n;
    cout << fixed << setprecision(9) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;
namespace std {
	template <class M, class N>
	constexpr common_type_t<M, N> gcd(M m, N n);

	template <class M, class N>
	constexpr common_type_t<M, N> lcm(M m, N n);
}

//fixed << setprecision(10)
typedef long long ll;
#define Yes(a) a ? "Yes" : "No";
#define YES(a) a ? "YES" : "NO";
#define rep(i,n) for(int i=0;i<n;i++)

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	int n, k;
	cin >> n;
	map<int, int> g;
	rep(i, n) {
		cin >> k;
		g[k] = i + 1;
	}
	//sort(g.begin(), g.end());
	auto begin1 = g.begin(), end1 = g.end();
	for (auto itr = begin1; itr != end1; itr++) {
		cout << itr->second << ' ';
	}
	cout << endl;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s[3];
	for (int i = 0; i < 3; i++)  cin >> s[i];
	for (int i = 0; i < 3; i++) {
		cout << s[i][i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())

if (int(s[0])==0 and 1<=int(s[1])<=9) or (int(s[0])==1 and 0<=int(s[1])<=2):
    if(int(s[2])==0 and 1<=int(s[3])<=9) or (int(s[2])==1 and 0<=int(s[3])<=2):
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif(int(s[2])==0 and 1<=int(s[3])<=9) or (int(s[2])==1 and 0<=int(s[3])<=2):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>

int n, D, x;
double ans, d, s;

int main() {
	scanf("%d%d%d", &n, &D, &x);
	d = D;
	for (int i = 1; i <= n * 2; ++i) {
		int j = i / 2;
		ans += 0.25 * s * d;
		if(i % 2 == 0) {
			ans += 0.5 * d;
			s += 1.0 / (j + 1);
		}
		d += x;
	}
	s = 0;
	for (int i = n * 2; i >= 1; --i) {
		d -= x;
		int j = (n * 2 - i + 1) / 2;
		ans += 0.25 * s * d;
		if(i % 2 == 1) {
			ans += 0.5 * d;
			s += 1.0 / (j + 1);
		}
	}
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000


void maxHeapify(int i);
int H,A[MAX+1];

int main(){
  int i;
  scanf("%d",&H);

  for ( i = 1; i <= H; i++){
    scanf("%d",&A[i]);
  }
  for ( i = H/2;i >= 1; i--){
    maxHeapify(i);
  }
  for ( i = 1; i <= H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;



  
}
void maxHeapify(int i){
  int largest,r,l,tmp;
  l = i*2;
  r = i*2+1;
  // ????????????????????????????????§???????????§????????????????????¶
  if(l <= H && A[l] > A[i]){
    largest = l;
  }
  else {
    largest = i;
  }
  if (r <= H && A[r] > A[largest]){
    largest = r;
  }

  if (largest != i){// i ???????????????????????§????????´???
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest); // ?????°??????????????????
      }
}

Measured memory_bytes: 2552
#include<cstdio>
using namespace std;
int main() {
  int flag = 1;
  int flag2 = 1;
  int ans = 0;
  int c;
  int n;
  while ((c = getchar_unlocked()) >= '0') {
    n = c - '0';
    flag2 = flag;
    if (n < 4) {
      if (flag == -1) {
        ans += n + 1;
      } else {
        ans += n;
      }
      flag = 1;
    }
    else if (n > 5) {
      if (flag == 1) {
        ans += 10 - n;
      }
      else {
        ans += 9 - n;
      }
      flag = -1;
    } else if (n == 4) {
      if (flag == -1) {
        flag = 0;
        ans += 5;
      }
      else {
        flag = 1;
        ans += 4;
      }
    } else if (n == 5) {
      if (flag == 1) {
        flag = 0;
        ans += 5;
      } else {
        flag = -1;
        ans += 4;
      }
    }
  }
  if (n > 5 || (n == 5 && flag2 != 1)){
    ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
 

Measured memory_bytes: 128
// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>
#include <chrono>
#include <cmath>

#define int long long

using namespace std;


const int INF = 1e15;


signed main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (a > k) {
    cout << k << endl;
    return 0;
  }

  int x = k - a - b;
  int ans = a - max(0LL, x);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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

  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define    ll          long long int
#define    sz          200010
#define    md          1000000007
#define    py          printf("YES\n")
#define    pn          printf("NO\n")
#define    sc1(a)      scanf("%lld",&a)
#define    sc2(a,b)    scanf("%lld %lld",&a,&b)
#define    pv(a)      printf("%lld\n",a)


using namespace std;


priority_queue<ll>q;

ll num[sz];

int main()
{


    ll n,m,k,i,j,x,p,s;

    cin>>n>>k;

    for(i=1;i<=n;i++)
    {
        cin>>x;
        q.push(x);
    }
    while(k--)
    {
        p=q.top();
        q.pop();
        p=p/2;
        q.push(p);
    }

    x=0;

    while(!q.empty())
    {
         p=q.top();
         q.pop();
         x+=p;
    }

    cout<<x<<endl;


    return 0;
}


Measured memory_bytes: 1528
#include <stdio.h>
#include <string.h>

#define STRING_MAX_SIZE 1000

char post[27] = "XYZABCDEFGHIJKLMNOPQRSTUVW";

int main() {
    int i, len;
    char string[STRING_MAX_SIZE + 1];

    scanf("%s", string);
    len = strlen(string);

    for (i=0;i<len;i++) {
        string[i] = post[string[i]-0x41];
    }

    printf("%s\n", string);
}

Measured memory_bytes: 948
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int a[9];
char b[9];
int main(){
	int t;
	cin>>t;
	for(int u=0;u<t;u++){
	for(int i=0;i<9;i++)cin>>a[i];
	for(int j=0;j<9;j++)cin>>b[j];
	bool ok=false;
	for(int c00=0;c00<7;c00++){
	for(int c01=c00+1;c01<8;c01++){
	for(int c02=c01+1;c02<9;c02++){
		bool ok1=true;
		if(!(b[c00]==b[c01]&&b[c00]==b[c02]))ok1=false;
		else{
			int d[3]={a[c00],a[c01],a[c02]};
			sort(d,d+3);
			if(!(d[1]-d[0]==d[2]-d[1]&&(d[1]-d[0]==0||d[1]-d[0]==1))){
				ok1=false;
			}
		}
		if(ok1){
		for(int c10=0;c10<7;c10++){
		if(c10!=c00&&c10!=c01&&c10!=c02){
		for(int c11=c10+1;c11<8;c11++){
		if(c11!=c00&&c11!=c01&&c11!=c02){
		for(int c12=c11+1;c12<9;c12++){
		if(c12!=c00&&c12!=c01&&c12!=c02){
			bool ok2=true;
			if(!(b[c10]==b[c11]&&b[c10]==b[c12]))ok2=false;
			else{
			int d[3]={a[c10],a[c11],a[c12]};
			sort(d,d+3);
			if(!(d[1]-d[0]==d[2]-d[1]&&(d[1]-d[0]==0||d[1]-d[0]==1))){
				ok2=false;
			}
			if(ok2){
				int e[3],top=0;
				for(int i=0;i<9;i++){
					if(i!=c00&&i!=c01&&i!=c02&&i!=c10&&i!=c11&&i!=c12){
						e[top]=i;
						top++;
					}
				}
				bool ok3=true;
				if(!(b[e[0]]==b[e[1]]&&b[e[0]]==b[e[2]]))ok3=false;
				else{
				int d[3]={a[e[0]],a[e[1]],a[e[2]]};
				sort(d,d+3);
				if(!(d[1]-d[0]==d[2]-d[1]&&(d[1]-d[0]==0||d[1]-d[0]==1))){
					ok3=false;
				}
				if(ok3){
					ok=true;
				}
				}
			}
		}
		}
		}
		}
		}
		}
		}
		}
	}
	}
	}
	cout<<ok<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    
    n = n % 10;

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        printf("%s", "hon");
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        printf("%s", "pon");   
    else
        printf("%s", "bon");

    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    int n; string s;
    multiset<string> m;
    while(cin >> n) {
        scanf(",");
        cin >> s;
        m.insert(s);
    }

    cout << m.count("A") << endl;
    cout << m.count("B") << endl;
    cout << m.count("AB") << endl;
    cout << m.count("O") << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

ll n, a, b, c, d;
map<ll, ll> memo;

ll solve(ll x) {
    if (memo.count(x)) return memo[x];

    ll c2 = ((x + 1) / 2) * 2;
    ll f2 = (x / 2) * 2;
    ll c3 = ((x + 2) / 3) * 3;
    ll f3 = (x / 3) * 3;
    ll c5 = ((x + 4) / 5) * 5;
    ll f5 = (x / 5) * 5;

    ll ret = (x < 1e18 / d) ? x * d : 1e18;
    return memo[x] = min({
        ret,
        (c2 - x) * d + a + solve(c2 / 2),
        (x - f2) * d + a + solve(f2 / 2),
        (c3 - x) * d + b + solve(c3 / 3),
        (x - f3) * d + b + solve(f3 / 3),
        (c5 - x) * d + c + solve(c5 / 5),
        (x - f5) * d + c + solve(f5 / 5),
    });
}


int main() {
    int T; cin >> T;
    while (T--) {
        cin >> n >> a >> b >> c >> d;
        memo.clear();
        memo[0] = 0; memo[1] = d;
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
  
	 long long n,i,j,k,sum=0,ans=0,count=0,c1=0,c2=0,x=-1,p,mn;
	 string s;
	 cin>>s;
	 for(i=0;i<s.length();i++)
	 {
	     if(s[i]=='A')
	     count++;
	     
	 }
	 if(count==0 || count==3)
	 cout<<"No";
	 else
	 cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  string s;
  cin >> s;
  ll n = s.size() + 1;

  vll a(n, 0), b(n, 0);
  for (ll i = 1; i < n; i++) {
    if (s[i - 1] == '<') a[i] = a[i - 1] + 1;
    else a[i] = 0;
  }
  for (ll i = n - 2; i >= 0; i--) {
    if (s[i] == '>') b[i] = b[i + 1] + 1;
    else b[i] = 0;
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ans += max(a[i], b[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 8708
#include<iostream>
#include<vector>
#include<algorithm>
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<vector<int> > dp(n+1,vector<int> (3));
	for(int i=1;i<=n;i++){
		int a[3];
		cin>>a[0]>>a[1]>>a[2];
		dp[i][0]=a[0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int an = 0, ai;
  rep(i,n) {
    if(an<a[i]){
      an = a[i];
      ai = i;
    }
  }
  int l = an/2, r = (an+1)/2;
  auto d = [&](int k){ return k<=l ? l-k : k-r; };
  int ak = -1;
  rep(i,n) {
    if(i==ai) continue;
    if(d(ak)>d(a[i])) ak = a[i];
  }
  printf("%d %d\n",an,ak);
}

Measured memory_bytes: 640
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

        String s = sc.next();
        int sum = 0;
        char[] si = new char[3];
        for (int i = 0; i < 3; i++) {
            si[i] = s.charAt(i);
            if (si[i] == Integer.toString(1).charAt(0)) {
                sum++;
            }
        }
        System.out.println(sum);


    }
}






Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  for (ll i = 0; i < n-k;i++) {
    if (a[i] < a[i + k]) cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 4840
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

vector<string> stockPrices;

int main() {
	
	int i, j, k, l, n, c; cin >> n >> c;

	vector<vector<int>> d(c + 1, vector<int>(c + 1)), grid(n + 1, vector<int>(n + 1));	
	for (i = 1; i < c + 1; i++)for (j = 1; j < c + 1; j++)cin >> d[i][j];
	for (i = 1; i < n + 1; i++)for (j = 1; j < n + 1; j++)cin >> grid[i][j];
	vector<int> a0m3(c + 1, 0), a1m3(c + 1, 0), a2m3(c + 1, 0);

	for (i = 1; i < n + 1; i++)for (j = 1; j < n + 1; j++) {
		if ((i + j) % 3 == 0)a0m3[grid[i][j]]++;
		else if ((i + j) % 3 == 1)a1m3[grid[i][j]]++;
		else a2m3[grid[i][j]]++;
	}

	int ans = INF;
	for (i = 1; i < c + 1; i++)for (j = 1; j < c + 1; j++)for (k = 1; k < c + 1; k++) {
		if (i == j || i == k || j == k)continue;
		int tmp = 0;
		for (l = 1; l < c + 1; l++) {
			tmp += a0m3[l] * d[l][i] + a1m3[l] * d[l][j] + a2m3[l] * d[l][k];
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 50; int n, m, s;
const lli inf = LONG_LONG_MAX;
const int maxS = 2501;
struct Edge
{
  int to, a; lli b;
};
vector<Edge> graph[maxN];
int c[maxN]; lli d[maxN];

struct Node
{
  lli d; int i, silver;
  bool operator<(const Node &other) const { return d > other.d; }
};
lli dist[maxN][maxS + 1];
void dijkstra(int source = 0)
{
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= maxS; j++)
      dist[i][j] = inf;
  queue<Node> pq; pq.push({dist[source][s] = 0, source, s});
  while (!pq.empty())
  {
    Node u = pq.front(); pq.pop();
    if (u.d > dist[u.i][u.silver]) continue;
    for (Edge &e: graph[u.i])
      for (int j = 0; j < maxS; j++)
        if (u.silver + c[u.i]*j >= e.a)
        {
          lli newDist = dist[u.i][u.silver] + e.b + d[u.i]*j;
          int newSilver = min(maxS, u.silver + c[u.i]*j - e.a);
          if (newDist < dist[e.to][newSilver])
            pq.push({dist[e.to][newSilver] = newDist, e.to, newSilver});
          if (u.silver + c[u.i]*j - e.a > maxS)
            break;
        }
  }
}

int main()
{
  while (scanf("%d %d %d", &n, &m, &s) != EOF)
  {
    for (int i = 0; i < n; i++)
      graph[i].clear();
    s = min(s, maxS);
    for (int i = 0; i < m; i++)
    {
      int u, v, a; lli b;
      scanf("%d %d %d %lld", &u, &v, &a, &b); u--, v--;
      graph[u].push_back({v, a, b});
      graph[v].push_back({u, a, b});
    }
    for (int i = 0; i < n; i++)
      scanf("%d %lld", &c[i], &d[i]);

    dijkstra();
    for (int i = 1; i < n; i++)
      printf("%lld\n", *min_element(dist[i], dist[i]+maxS));
  }
  return 0;
}

Measured memory_bytes: 143600
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long long> a;
    vector<long long> b;
    long long x;
    for (int i = 0; i < N+1; i++)
    {
        cin >> x;
        a.push_back(x);
    }
    long long y;
    for (int i = 0; i < N; i++)
    {
        cin >> y;
        b.push_back(y);
    }
    
    long long counter = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i]>b[i])
        {
            a[i] = a[i]-b[i];
            counter = counter + b[i];
            b[i] = 0;
        }
        else
        {
            b[i]= b[i]-a[i];
            counter = counter+a[i];
            a[i] = 0;
            if (a[i+1]>b[i])
            {
                a[i+1] = a[i+1]-b[i];
                counter = counter + b[i];
                b[i] = 0;
            }else
            {
                counter = counter + a[i+1];
                b[i] = b[i] - a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int F[110][11];
    int P[110][11];
    cin >> N;
    rep(i,0,N){
        rep(j,0,10){
            cin >> F[i][j];
        }
    }
    rep(i,0,N){
        rep(j,0,11){
            cin >> P[i][j];
        }
    }
    ll ans = -1e10;
    rep(i,0,(1 << 10)){
        if(i == 0) continue;
        ll ans_tmp = 0;
        rep(j,0,N){
            int cnt = 0;
            rep(k,0,10){
                if(i >> k & 1){
                    cnt += F[j][k];
                }
            }
            ans_tmp += P[j][cnt];
        }
        ans = max(ans, ans_tmp);
    }
    print(ans);

}


Measured memory_bytes: 384
n = int(input())
lst1 = list(map(int,input().split()))
mod = 10**9+7
 
def GCD(a,b):
    if b == 0:
        return a
    else:
        return GCD(b,a%b)
def LCM(a,b):
    return (a//GCD(a,b)*b)

l = 1
for i in lst1:
    l = LCM(l,i)

ans = 0
for i in range(n):
    ans += l//lst1[i]
 
print(ans%mod)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int mod;
int dp[510][510], n;
pair <int, int> a[510];
inline int f(int x) {
    static int now = 2 * n - 1;
    while (now >= 0 && x * x + now * now > 4 * n * n) now--;
    return now + 1;
}
inline int g(int x) {
    static int now = 2 * n - 1;
    while (now >= 0 && x * x + now * now >= n * n) now--;
    return now + 1;
}
int main() {
    cin >> n >> mod;
    for (int i = 0; i < 2 * n; i++) a[i] = i >= n ? make_pair(f(i), 0) : make_pair(g(i), f(i));
    sort(a, a + n + n);
    int ans = 0;
    for (int k = 0; k <= n; k++) {
        int cnt = 0;
        memset(dp, 0, sizeof dp);
        dp[0][0] = 1;
        for (int i = 0; i < 2 * n; i++) {
            for (int j = 0; j <= k; j++) {
                if (a[i].second == 0) {
                    dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].first - j - cnt)) % mod;
                }
                else {
                    dp[i + 1][j] = (dp[i + 1][j] + 1ll * dp[i][j] * (a[i].second - n - k - (i - cnt - j))) % mod;
                    dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 1ll * dp[i][j] * (a[i].first - cnt - j)) % mod;
                }
            }
            if (a[i].second == 0) cnt++;
        }
        ans = (ans + 1ll * (k & 1 ? mod - 1 : 1) * dp[2 * n][k]) % mod;
    }
    return cout << ans << endl, 0;
}

Measured memory_bytes: 1280
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <stdio.h>
//end of libraries ;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define INF 3999999999999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , m , q , a[N] , b[N] , c[N] , d[N] , ans , u ;
vector < vector < int > > check;
vector <int> vc;
void dfs(int x){
	if(vc.size()==n) check.pb(vc);
	else if(vc.size() < n ){
	int cmax = 0;
	for(int i = 0 ; i < vc.size() ; i++) {
		cmax = max(vc[i] , cmax);
	}
	for(int i = 1 ; i <= m ; i++){
		if(i>=cmax){vc.pb(i);
				dfs(i);
				vc.pop_back();}
		}
	}
}
int main(){
fcin;
	cin >> n >> m >> q;
	for(int i = 0 ; i < q ; i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	dfs(0);
	// cout<<check.size()<<endl;
	for(int i = 0 ; i < check.size() ; i++){
		vector <int > current = check[i];
		u = 0;
		for(int j = 0 ; j < q ; j++){
			int A = a[j] - 1;
			int B = b[j] - 1;
			int C = c[j];
			int D = d[j];
			// cout<<current[B] <<" " << current[A] <<endl;
			if(current[B] - current[A] == C) u += D;
		}
		
		ans = max(ans,u);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9472
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

#define MAX_V 10000

struct edge{
	int to;
	double cost;
};

vector<edge> G[MAX_V];
double d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	
	while(true){
		long long int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;
		a--;
		b--;
		
		if(m == 0){
			break;
		}
		
		double t[100];
		
		for(int i = 0; i < n; i++){
			cin >> t[i];
		}
		
		for(int i = 0; i < MAX_V; i++){
			G[i].erase(G[i].begin(), G[i].end());
		}
		
		for(int i = 0; i < p; i++){
			int x, y, z;
			cin >> x >> y >> z;
			x--;
			y--;
			for(int j = 0; j < (1 << n); j++){
				for(int k = 0; k < n; k++){
					if(j & (1 << k)){
						edge e;
						e.to = y * (1 << n) + j - (1 << k);
						e.cost = (double)z / t[k];
						G[x * (1 << n) + j].push_back(e);
						
						e.to = x * (1 << n) + j - (1 << k);
						G[y * (1 << n) + j].push_back(e);
					}
				}
			}
		}
		
		shortest_path(a * (1 << n) + (1 << n) - 1, m * (1 << n));
		/*
		for(int j = 0; j < m; j++){
			for(int i = 0; i < (1 << n); i++){
				cout << d[j * (1 << n) + i] << " ";
			}
			cout << endl;
		}
		*/
		double ans = INF;
		for(int i = 0; i < (1 << n); i++){
			ans = min(ans, d[b * (1 << n) + i]);
		}
		
		if(ans == INF){
			cout << "Impossible" << endl;
		}else{
			printf("%.10f\n", ans);
		}
	}
	
	return 0;
}


Measured memory_bytes: 26036
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector< ii > vii;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef	vector<pair<int,pair<int,int > > > viii;
typedef long long int lli;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(a) (int)(a.size())

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define slli(n) scanf("%llid",&n)
#define lldout(n) printf("%llid\n",n)
const int N = (int)2e5 + 10;
//vvi v;
vector<vector<lli> > v;
lli cnt=0;
lli vis[N];
//int vis1[52][52],v[52][52];
int dfs(int t,int p){
	vis[t]=1;
  cnt++;
	//v[i][j]=val;
	rep(i,0,v[t].size()){
    if(v[t][i]==p){return 0;}
		if(vis[v[t][i]]==0){
			dfs(v[t][i],p);
		}
	}
	// if(v[i][j-1]==-1 and vis1[i][j-1]==0 and v[i+1][j-1]!=v[i][j] and v[i][j-2]!=v[i][j] and v[i-1][j-1]!=v[i][j])dfs(i,j-1,val);
	// if(v[i][j+1]==-1 and vis1[i][j+1]==0 and v[i][j+2]!=v[i][j] and v[i+1][j+1]!=v[i][j] and v[i-1][j+1]!=v[i][j])dfs(i,j+1,val);
	// if(v[i-1][j]==-1 and vis1[i-1][j]==0 and v[i-1][j-1]!=v[i][j] and v[i-1][j+1]!=v[i][j] and v[i-2][j]!=v[i][j])dfs(i-1,j,val);
	// if(v[i+1][j]==-1 and vis1[i+1][j]==0 and v[i+2][j]!=v[i][j] and v[i+1][j-1]!=v[i][j] and v[i+1][j+1]!=v[i][j])dfs(i+1,j,val);
	// return 0;
}
lli lcm(lli a,lli b) { return a*(b/__gcd(a,b));}
lli pow(lli x, lli y, lli p) {
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
unordered_map<lli,lli> ph;
lli vis1[200005],vis2[200005];
int main(){
  lli n,m;
	cin>>n>>m;
	lli ans=0;
	vector<vector<lli> > v1;
	v1.resize(n+2);
	rep(i,0,m){
		lli x,y;
		cin>>x>>y;
		//v1[x].pb(y);
		v1[y].pb(x);
	}
	rep(i,0,n+2){
		sort(v1[i].begin(),v1[i].end());
	}
	lli mini=0;
	rep(i,2,n+1){
		if(!v1[i].empty()){
			//cout<<i<<endl;
		int u=(upper_bound(v1[i].begin(),v1[i].end(),mini)-v1[i].begin());
		if(u!=sz(v1[i])){
			if(v1[i][u]>mini){ans+=1;mini=i-1;}
		}
	//	else {ans+=1;mini=i-1;}
		//if(u!=0){ans+=1;mini=i-1;}}
	}
}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7292
class Node():
    def __init__(self, key):
        self.key = key
        self.passed = False
        self.adj = []

    def __repr__(self):
        return "Node({}, {}, {})".format(
            self.key,
            [(a.key, w) for a, w in self.adj])


def read_inputs():
    n = int(input())
    T = [Node(i) for i in range(n)]
    for _ in range(n - 1):
        s, t, w = [int(x) for x in input().split()]
        T[s].adj.append((T[t], w))
        T[t].adj.append((T[s], w))
    return T


def furthest(T, s):

    for v in T:
        v.passed = False
    fur = -1
    fur_v = None
    S = []
    S.append((s, 0))

    while S != []:
        v, vr = S.pop()
        if vr > fur:
            fur = vr
            fur_v = v
        v.passed = True
        for a, w in v.adj:
            if not a.passed:
                S.append((a, vr + w))

    return fur, fur_v


def tree_diameter(T):
    fur, s2 = furthest(T, T[0])
    fur, fur_v = furthest(T, s2)
    return fur


def main():
    T = read_inputs()
    r = tree_diameter(T)
    print(r)


if __name__ == "__main__":
    main()



Measured memory_bytes: 50800
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll p;
vector<string> s;
vll pos;

int main() {
    fast_io; cout_precision;
    s.resize(3); pos.resize(3);
    for (ll i = 0; i < 3; i++) {
        cin >> s[i];
        pos[i] = 0;
    }
    for (p = 0; pos[p] < (ll) s[p].length(); p = s[p][pos[p]++] - 'a');
    cout << char('A' + p) << endl;
}

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

int main(){
	int n,count=0;
	cin>>n;
	bool there=true;
	vector<int> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec.at(i);
	}
	sort(vec.begin(),vec.end());
	if(n==1){
		count++;
	}
	for(int i=1;i<n+1;i++){
		if(i==n){
			if(there){
				count++;
			}
		}
		else{
			if(vec.at(i)==vec.at(i-1)){
				there=(!(there));
			}
			else{
				if(there){
					count++;
				}
				else{
					there=true;
				}
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 640
using System;

namespace ITP1_9
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] s = new int[2] { 0, 0 };
            int l = int.Parse(Console.ReadLine());

            for (int i = 0; i < l; i++)
            {
                string[] cards = Console.ReadLine().Split(' ');
                if (cards[0] == cards[1])
                {
                    s[0]++;
                    s[1]++;
                    continue;
                }
                string[] judge = new string[2];
                Array.Copy(cards, 0, judge, 0, 2); Array.Sort(judge);
                s[judge[1] == cards[1] ? 1 : 0]+=3;
            }

            Console.WriteLine("{0} {1}", s[0], s[1]);
        }
    }
}

Measured memory_bytes: 9960
#include<cstdio>
#include<algorithm>
int main(){
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
std::sort(a,a+n);
int k=0;
int ans=0;
int b=0;
for(int i=0;i<n;i++){
if(k==a[i]){
b++;
}else{
if(b<k)ans+=b;
else ans+=(b-k);
k=a[i];
b=1;
}
}
if(b<k)ans+=b;
else ans+=(b-k);
printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>

#define INF 1050000000
#define MOD 1000000007

using namespace std;



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

	long long int t = 1;

	while (t*(t + 1) / 2 < x) {
		t++;
	}

	cout << t << endl;






}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cassert>
#include<vector>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
double f(int l, int r,int u, double x) {
	if (x <= l) {
		return (double)u + (double)l - x;
	}
	else if (x <= r) {
		return (double)u;
	}
	else {
		return (double)u + x - (double)r;
	}
}
int t1[110], v[110];
int s[110], t[110], m[110];
double T[40005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> t1[i+1];
	rep(i, n)cin >> v[i+1];
	rep(i, n+1)t1[i + 1] += t1[i];
	n += 2;
	rep(i, n) {
		s[i + 1] = t1[i];
		t[i + 1] = t1[i + 1];
		m[i+1] = v[i+1];
	}
//	rep(i, n)cout << s[i] << ' ' << t[i] << ' ' << m[i] << endl;
	
	for(int i = 0; i <= t[n - 1] * 2; i++) {
		double nt = (double)i / 2;
		double ans = 2145141919;
		for (int j = 0; j < n; j++) {
			ans = min(ans, f(s[j], t[j], v[j], nt));
		}
		T[i] = ans;
	}
	double ans = 0;
	rep(i, t[n - 1] * 2+1) {
		ans += (T[i] + T[i + 1])*0.25;
	}
	printf("%.9lf\n", ans);
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;
 
const long long inf = 1e9;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

ll n, m, k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> k;
	string s;
	cin >> s;
	n = s.length();
	fr(i,0,min(k,n)) {
		cout << s[i];
	}
	if (n > k) {
		cout << "..." << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  FOR(i, K, N+2){
    ll max = N * i - (ll)i*(i-1)/2;
    ll min = (ll)i*(i-1) / 2;
    ans += max - min + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    string s;
    cin >> s;
    if(s=="ABC")
    cout << "ARC" << endl;
    else
    cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1010, MOD = (int)(1e9 + 7);
int n,m,tms,gra[N][N],num,rc,cc;
char s[N];
typedef long long ll;
ll power(ll a,int b) {
  ll ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
struct matrix {
  int mat[5][5];
  int n,m;
  matrix(int n=0,int m=0): n(n), m(m) {
    memset(mat,0,sizeof mat);
  }
  matrix operator * (const matrix& x) const {
    assert(m == x.n);
    matrix ret = matrix(n,x.m);
    for (int k = 1 ; k <= m ; ++ k)
      for (int i = 1 ; i <= n ; ++ i)
	for (int j = 1 ; j <= x.m ; ++ j)
	  (ret.mat[i][j] += 1ll * mat[i][k] * x.mat[k][j] % MOD) %= MOD;
    return ret;
  }
};
matrix power(matrix a,int b) {
  assert(a.n == a.m);
  matrix ret = matrix(a.n,a.m);
  for (int i = 1 ; i <= a.n ; ++ i)
    ret.mat[i][i] = 1;
  while (b) {
    if (b&1) ret = ret * a;
    a = a * a;
    b >>= 1;
  }
  return ret;
}
signed main() {
  scanf("%lld%lld%lld",&n,&m,&tms);
  if (!tms) return puts("1"), 0;
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%s",s+1);
    for (int j = 1 ; j <= m ; ++ j)
      gra[i][j] = (s[j] == '#'), num += (s[j] == '#');
  }
  for (int i = 1 ; i <= n ; ++ i)
    rc += gra[i][1] & gra[i][m];
  for (int i = 1 ; i <= m ; ++ i)
    cc += gra[1][i] & gra[n][i];
  matrix a = matrix(2,2), b = matrix(2,2);
  a.mat[1][1] = 1;
  a.mat[1][2] = 1;
  b.mat[1][1] = num;
  if (rc && cc) return puts("1"), 0;
  if (rc) {
    b.mat[2][2] = rc;
    for (int i = 1 ; i <= n ; ++ i)
      for (int j = 1 ; j <= m ; ++ j)
	if (gra[i][j] && gra[i][j-1])
	  -- b.mat[2][1];
  } else if (cc) {
    b.mat[2][2] = cc;
    for (int j = 1 ; j <= m ; ++ j)
      for (int i = 1 ; i <= n ; ++ i)
	if (gra[i][j] && gra[i-1][j])
	  -- b.mat[2][1];
  } else
    return printf("%lld\n",power(num,tms-1)), 0;
  a = a * power(b,tms-1);
  printf("%lld\n",(a.mat[1][1] % MOD + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const int INF = (int)1e+15;

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
            from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
            from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev){
    int n = g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q;     // a < b <-> a.weight > b.weight
    Q.push(Edge(-2, s, 0));
    while(!Q.empty()){
        Edge e = Q.top(); Q.pop();
        if(prev[e.to] != -1) continue;
        prev[e.to] = e.from;
        EACH(i, g[e.to]){
            //for(Edges::const_iterator i=g[e.to].begin(); i!=g[e.to].end(); ++i){    //マクロが使えないとき
            if(dist[i -> to] > dist[i -> from] + i -> weight){
                dist[i -> to] = dist[i -> from] + i -> weight;
                Q.push(Edge(i -> from, i -> to, dist[i -> to]));
            }
        }
    }
}
vector<int> buildPath(const vector<int> &prev, int t){
    vector<int> path;
    for(int v = t; v >= 0; v = prev[v])
        path.push_back(v);
    reverse(path.begin(), path.end());
    return path;
}

void solve(long long N, long long M, std::vector<long long> u, std::vector<long long> v, long long S, long long T){
    N++;
    Graph g(N * 3);
    for(int i = 0; i < M; ++i) {
        g[u[i]].push_back(Edge(u[i], N + v[i], 1));
        g[N + u[i]].push_back(Edge(N + u[i], 2 * N + v[i], 1));
        g[2 * N + u[i]].push_back(Edge(2 * N + u[i], v[i], 1));
    }
    vector<int> dist, prev;
    dijkstra(g, S, dist, prev);
    /*
    for(int i = 0; i < dist.size(); ++i) {
        cerr << i << ":" << dist[i] << endl;
    }
    */
    if (dist[T] == INF) {
        cout << -1 << endl;
    } else {
        cout << dist[T] / 3 << endl;
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    long long S;
    scanf("%lld",&S);
    long long T;
    scanf("%lld",&T);
    solve(N, M, std::move(u), std::move(v), S, T);
    return 0;
}


Measured memory_bytes: 27648
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  ll n;
  cin>>n;
  
  ll val=0;
  
  for(ll i=1;i*i<=n;i++){
    ll a=i;
    if(n%a==0){
      if(n/a-1>a){
        val+=n/a-1;
    }
  }
  }
  
  cout<<val<<endl;
  
}

Measured memory_bytes: 256
import heapq
INF = 10 ** 16


def dijkstra(n, town, k, start):
    d = []
    queue = []
    for i in range(n):
        d.append(INF)
    d[start] = 0
    heapq.heappush(queue, (0, start))
    # 都市kで交換した時の円またはスヌークのの最小値
    while len(queue) != 0:
        distance, v = heapq.heappop(queue)
        if d[v] < distance:
            continue
        for u in range(len(town[v])):
            if d[town[v][u][0]] > d[v] + town[v][u][k]:
                d[town[v][u][0]] = d[v] + town[v][u][k]
                heapq.heappush(queue, (d[town[v][u][0]], town[v][u][0]))

    return d


def main():
    n, m, s, t = map(int, input().split())
    s -= 1
    t -= 1
    money = 10 ** 15
    town = []

    for i in range(n):
        town.append([])
    for i in range(m):
        fro, to, a, b = map(int, input().split())
        fro -= 1
        to -= 1
        town[fro].append((to, a, b))
        town[to].append((fro, a, b))

    a = dijkstra(n, town, 1, s)
    b = dijkstra(n, town, 2, t)

    total = []
    for i in range(n):
        heapq.heappush(total, (a[i] + b[i], i + 1))
    mon, year = heapq.heappop(total)
    for i in range(n):
        while year <= i:
            mon, year = heapq.heappop(total)
        print(money - mon)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67348
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    ll mod = 1000000007;
    ll n, m;
    cin >> n >> m;
    ll a[n];
    fill(a, a + n, 0);
    rep(i, m){
        ll b;
        cin >> b;
        a[b] = 1;
    }
    ll dp[n+1];
    dp[0] = 1;
    if(a[1] == 1){
        dp[1] = 0;
    }else{
        dp[1] = 1;
    }
    for (ll i = 2; i <= n; i++){
        if(a[i] == 1) dp[i] = 0;
        else {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= mod;
        }        
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 5196
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    vector<string> W{"Sunny", "Cloudy", "Rainy"};

    string s;
    cin >> s;
    for (int i = 0; i < W.size(); ++i) {
        if (W[i] == s) {
            cout << W[(i + 1) % W.size()] << "\n";
            break; 
        }
    }

    return 0;
}

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

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

    vector<int> a(n);
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        a.at(x-1) += 1;
        a.at(y-1) += 1;
    }

    for (int i = 0; i < n; i++) {
        cout << a.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    string s; cin>>s;
    int ans=(s[0]-'0')+9*(SZ(s)-1);
    bool all9=1;
    for(int i=1;i<SZ(s);i++){
        if(s[i]!='9') all9=0;
    }
    if(!all9) ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 256