akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void)
{
    while (true) {
        int m, f, r;
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
            break;
        char grade;
        if (m == -1 || f == -1)
            grade = 'F';
        else if (m + f >= 80)
            grade = 'A';
        else if (m + f >= 65)
            grade = 'B';
        else if (m + f >= 50 || (m + f >= 30 && r >= 50))
            grade = 'C';
        else if (m + f >= 30)
            grade = 'D';
        else
            grade = 'F';
        
        cout << grade << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    restaurants = []
    for _ in range(N):
        s, p = input().split()
        restaurants.append((s.strip(), int(p)))

    rank = sorted(restaurants, key=lambda x: (x[0], -x[1]))
    for a in rank:
        print(int(restaurants.index(a)) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    int d, g;
    scanf("%d%d", &d, &g);
    int p[20], c[20];
    for (int i = 0; i < d; i++) {
        scanf("%d%d", &p[i], &c[i]);
    }
    int ans = 1000;
    for (int fs = 0; fs < (1 << d); fs++) {
        int count = 0;
        int points = 0;
        for (int i = 0; i < d; i++) {
            if (fs & (1 << i)) {
                count += p[i];
                points += (i+1) * 100 * p[i] + c[i];
            }
        }
        if (points >= g) {
            ans = min(ans, count);
            continue;
        }
        for (int i = d-1; i >= 0; i--) {
            if (fs & (1 << i)) {continue;}
            int x = (i+1) * 100;
            if (points + x * (p[i] - 1) >= g) {
                int st = (g - points) % x == 0 ? (g - points) / x : (g - points) / x + 1;
                points += st * x;
                count += st;
                break;
            }
        }
        if (points >= g) {
            ans = min(ans, count);
            continue;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 128
import sys
I = lambda:[int(x) for x in sys.stdin.readline().split()]
N,K = I()
Z = [I() for _ in range(N)]
Z.sort()

INF = 10**20
ans = INF

for i in range(N):
    for j in range(i+K-1,N):
        l = sorted(t[1] for t in Z[i:j+1])
        ans_tmp = [(Z[j][0]-Z[i][0])*(v-u) for u,v in zip(l,l[K-1:])]
        ans = min(ans,*ans_tmp)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    bool ok = false;
    rep(i, 100){
        rep(j, 100){
            ok |= (4 * i + 7 * j == n);
        }
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;

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

    Graph G(N);
    map<int, P> num2edge;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        num2edge[i] = P(a, b);
    }

    int K = 0;
    rep(i, N)
    {
        int size = G.at(i).size();
        K = max(K, size);
    }
    cout << K << endl;

    // data structure for BFS
    // <node, color> のペアをキューで管理
    vector<int> dist(N, -1); // initialize all nodes as unvisited
    queue<P> que;

    dist[0] = 0;
    que.push(P(0, 0));
    map<P, int> edge2color;

    while (!que.empty()) {
        int pv = que.front().first;
        int pc = que.front().second;
        que.pop();

        int nc = 1;
        for (int nv : G[pv]) {
            if (dist[nv] != -1)
                continue;
            dist[nv] = dist[pv] + 1;

            if (nc == pc)
                nc++;
            que.push(P(nv, nc));
            edge2color[P(pv, nv)] = nc;
            edge2color[P(nv, pv)] = nc;
            nc++;
        }
    }
    rep(i, N - 1)
    {
        cout << edge2color.at(num2edge.at(i)) << endl;
    }
}

Measured memory_bytes: 25216
N = int(input())
p = list(map(int, input().split()))

a = [(i + 1) * N for i in range(N)]
b = [(N - i) * N for i in range(N)]

for i, pi in enumerate(p):
    a[pi - 1] += i

print(' '.join(map(str, a)))
print(' '.join(map(str, b)))

Measured memory_bytes: 7232
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+50;
struct str{
    string a;
    int cnt;
}s[maxn];
bool cmp(str a,str b){
    if(a.cnt==b.cnt)
        return a.a<b.a;
    return a.cnt>b.cnt;
}
int main(){
    std::ios::sync_with_stdio(false);
    int n,len=1;
    map<string,int>mp;
    cin>>n;
    for(int i=0;i<n;i++){
        string a;
        cin>>a;
        int x=mp[a];
        if(x) s[x].cnt++;
        else{
            s[len].a=a;
            s[len].cnt=1;
            mp[a]=len++;
        }
    }
    sort(s,s+len,cmp);
    int mx=s[0].cnt;
    for(int i=0;i<len;i++){
        if(s[i].cnt==mx)
            cout<<s[i].a<<endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 27008
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <unordered_map>

#define div 1000000000+7

using ll = long long;
using namespace std;

void solve() {
    int r, g, b;
    cin >> r >> g >> b;
    int num = r * 100 + g * 10 + b;
    if(num%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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


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

int main(){
  // 入力
  int N;
  cin >> N;

  int page;
  if (N%2==0) {
    page = N/2;
  } else {
    page = N/2 + 1;
  }


  cout << page << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main(){
	int n, a[2000];
    ll k;
	int memo[2001][2000];
	cin >> n >> k;
	for(ll i = 0; i < n; i++) cin >> a[i];
	ll ans = LLONG_MAX;
	for(int i = 0; i <= n; i++){
		ll cnt = 0;
		for(int j = 0; j < n; j++){
			if(i == 0) memo[i][j] = a[j];
			else if (i > j) memo[i][j] = min(memo[i - 1][j], a[j - i + n]);
			else memo[i][j] = min(memo[i - 1][j], a[j - i]);
			cnt += memo[i][j];
		}
		cnt += i * k;
		if(cnt < ans) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}


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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Calc(string s) {
        int n = s.Length;
        for (int i = 0; i < n; i++) {
            if (i+1 < n) {
                if (s[i] == s[i+1]) {
                    Console.WriteLine("{0} {1}", i+1, i+2);
                    return;
                }
            }
            if (i+2 < n) {
                if (s[i] == s[i+2]) {
                    Console.WriteLine("{0} {1}", i+1, i+3);
                    return;
                }
            }
        }
        Console.WriteLine("-1 -1");
    }

    static void Main() {
        var s = Console.ReadLine();
        Calc(s);
    }
}

Measured memory_bytes: 3032
#include <iostream>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;
//void inputer();
int p[100];
int N;
int ans = 0;

int main() {
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> p[i];
	}
	for (int i = 0; i < N - 2;i++) {
		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2] || p[i] > p[i + 1] && p[i + 1] > p[i + 2]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  #include <iostream>
  #include <math.h>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <iomanip>

  //#include <tuple>

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

  int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if(u == s) a--;
    else if (t == u) b--;
    
    cout << a << " " << b << endl;

  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 5000005
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;


int main() {
    int a,b,c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size() == 2)
        cout << "Yes";
    
    else
    {
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>

using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmax(T &a, T b)
{
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int N, K;
  vector<int> p;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int p_i;
    cin >> p_i;
    p.push_back(p_i);
  }

  vector<double> P;
  for (auto &&p_itr : p) {
    double ev = 0.0;
    ev = (1 + (p_itr - 1) * 0.5);
    P.push_back(ev);
  }

  double sum = accumulate(P.begin(), P.begin() + K, 0.0);
  double max_num = sum;

  for (int i = 0; i < N - K; i++) {
    sum = sum - P[i] + P[i + K];
    chmax(max_num, sum);
  }

  cout << fixed << setprecision(8) << max_num;

  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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


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

	int x,y;
	cin>>x>>y;
	int group[12]={1,3,1,2,1,2,1,1,2,1,2,1};
	if(group[x-1]==group[y-1]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

//****************************don't use int!!!!!!!****************************//
//***************************code starts here!!!!!****************************//


int main() {
    IOS

    int n, m;
    cin >> n >> m;

    vector<pll > ab(n);
    for (int i = 0; i < n; ++i) {
        cin >> ab[i].first >> ab[i].second;
    }

    sort(all(ab), [](pll l, pll r) {
        return l.first < r.first;
    });
    multiset<ll> earns;
    ll cur_i = 0;
    ll ans = 0;
    for (int day = 1; day <= m; ++day) {
        while (cur_i < n && ab[cur_i].first <= day) {
            earns.insert(ab[cur_i].second);
            ++cur_i;
        }

        if (earns.size() != 0) {
            ans += *prev(earns.end());
            earns.erase(prev(earns.end()));
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   string S;
   cin >> S;

   if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) cout << "Bad" << endl;
   else cout << "Good" << endl;
   return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;
string S;

int main() {

	cin >> N >> S;

	unordered_set<string> able;

	for (auto ritr = S.rbegin(); ritr != S.rend(); ++ritr) {
		unordered_set<string> add;
		char t[2] = {};
		t[0] = *ritr;
		add.insert(t);
		for (auto a : able) {
			if (a.size() < 3)
				add.insert(*ritr + a);
		}
		for (auto a : add) {
			able.insert(a);
		}
	}

	int ans = 0;
	for (auto a : able) {
		if (a.size() == 3) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
/*
Reference : https://www.geeksforgeeks.org/maximum-product-subsequence-size-k/
 
 
*/
#include <bits/stdc++.h> 
using namespace std; 
 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
bool sortbysecdesc(const pair<int,int> &a, 
                   const pair<int,int> &b) 
{ 
       return a.second>b.second; 
} 
 
/*
Mistakes
 
- while using pairs make sure you comparator datatype it's int by default change it as per the need
- Modify comparator if you want to
*/
#define f first
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll64 int64_t
#define pb push_back
#define pll pair<long long int,long long int>
#define pi pair<int,int>
#define mi map<int,int>
#define ll long long int
#define mll map<long long int,long long int>
#define umi unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define vpi vector<pair<int,int>>
#define vpll vector<pair<long long int,long long int>>
#define mod 1000000007
#define fp(i,x,n) for(int i=x;i<n;i++)
#define fn(i,x,n) for(int i=x;i>n;i--)
#define fpm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define asort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysec)
#define asort_vp_first(vect) sort(vect.begin(), vect.end())
#define dsort_vp_first(vect) sort(vect.begin(), vect.end(), sortinrev) 
#define dsort_vp_second(vect) sort(vect.begin(), vect.end(), sortbysecdesc)
#define vi vector<int>
#define vll vector<long long int>
#define c(x) cout<<x<<endl;
#define M 1000000007
using namespace std; 
#define int long long int
 
 
signed main()
{
    int n;
    cin>>n;
   int a[n],b[n];
   fp(i,0,n)
   cin>>a[i];
   
   fp(i,0,n)
   cin>>b[i];
   reverse(b,b+n);
   
   fp(i,0,n)
   {
       if(a[i]!=b[i])
       continue;
       
       bool ok = false;
       fp(j,0,n)
       {
           if(i==j)
           continue;
           
           if(a[i]!=b[j] && a[j]!=b[i])
           {
               swap(b[i],b[j]);
               ok = true;
               break;
           }
           
       }
       if(!ok)
       {
           cout<<"No"<<endl;
           return 0;
       }
   }
   cout<<"Yes"<<endl;
   fp(i,0,n)
   cout<<b[i]<<" ";
   
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,ans;
P x[100005];
int main(void){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i].F>>x[i].S;
		x[i].F+=x[i].S;
	}
	sort(x,x+n,greater<P>());
	for(int i=0;i+1<n;i+=2){
		ans+=x[i].F-x[i].S;
		ans-=x[i+1].S;
	}
	if(n%2==1)ans+=x[n-1].F-x[n-1].S;
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define N 40010
#define int long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus; 
}
//int a[N];
signed main()
{
	int n = read(), ans(0);
	int tmp;
	int min = 1e9;
	rep(i, 1, n)
	{
		tmp = read();
		if(tmp <= min)
		{
			ans ++;
			min = tmp;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *

input=sys.stdin.readline

def f(n):
    mi=-1
    r = [inf]*n
    for _ in range(n):
        a = -int(input())
        i = bisect_right(r, a)
        r[i]=a
        if i>mi:
            mi=i
    print(mi+1)

n = int(input())
inf=10**10
f(n)


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

int main() {
    int n, m;
    cin >> n >> m;
    if(n >= m){
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    for(int i = 0; i < m; ++i){
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    vector<int> dist(m - 1);
    for(int i = 0; i < m - 1; ++i){
        dist[i] = x[i + 1] - x[i];
    }
    sort(dist.begin(), dist.end());
    int ans = 0;
    for(int i = 0; i < m - n; ++i){
        ans += dist[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;



void solve() {
    int n, k; scanf("%d %d", &n, &k);
    ll sum = 0;
    for (int i = k; i <= n+1; i++) {
        ll minimum = ((ll)(i)*(i-1))/2;
        ll maximum = ((ll)(2*n-i+1)*(i))/2;
        sum += (maximum-minimum+1);
    }
    cout << sum % mod;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3256
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

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

using namespace std;

int main(){

	int n;
	while(true){

	cin >> n;

	if(cin.fail()) break;

	int x=0; int y=0; int s=0;
	REP(i,0,n){
		REP(a,0,9){
		REP(b,0,9){
		if(a+b==i) x++;
		}
		}
		REP(c,0,9){
		REP(d,0,9){
		if(c+d==n-i) y++;
		}
		}

		s+=x*y;
		x=0; y=0;
	}

	cout << s << endl;

	}

	return 0;
}

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

typedef long long ll;
const ll INF = (ll)1e18;

ll n, s;

int main() {
    cin >> n >> s;
    ll res = INF;
    if(n == s) res = n + 1;
    for(int b = 2; b <= (int)1e6; b++) {
        ll sum = 0, cn = n;
        while(cn > 0) {
            sum += cn % b;
            cn /= b;
        }
        if(sum == s) res = min((ll)b, res);
    }
    for(int d = 1; d <= (int)1e6; d++) {
        if((n - s) % d != 0) continue;
        ll curb = (n - s) / d + 1;
        if(curb <= (int)1e6) continue;
        ll sum = n / curb + n % curb;
        if(sum == s) res = min(curb, res);
    }
    cout << (res == INF ? -1 : res) << endl;
}

Measured memory_bytes: 256
// Something on It

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    string s;
    cin >> s;
    int res = 700;

    if (s[0] == 'o') {
        res += 100;
    }
    if (s[1] == 'o') {
        res += 100;
    }
    if (s[2] == 'o') {
        res += 100;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
a = 2, 3, 5

def f(n):
  m = memo.get(n)
  if m is None:
    s = {(0, 0, 0)}.union(*({(n // p, p, c), (-(-n // p), p, c)} for p, c in zip(a, b)))
    m = min(f(x) + abs(x * p - n) * d + c for x, p, c in s)
    memo[n] = m
  return m

t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> b(n);
    REP(i,n)cin >> b[i];
    vector<int32> ans;
    while(!b.empty()){
        bool flg = false;
        FORR(i,(int32)b.size()-1,0){
            if(b[i] == i+1){
                ans.pb(b[i]);
                b.erase(b.begin() + i);
                flg = true;
                break;
            }
        }
        if(!flg){
            ANS(-1);
            return 0;
        }
    }
    reverse(ALL(ans));
    REP(i,n){
        if(ans[i] > i+1){
            cout << -1 << endl;
            return 0;
        }
    }
    REP(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  if (k & 1) {
    printf("%lld\n", 1LL * (n / k) * (n / k) * (n / k));
  } else {
    long long ans = 0;
    long long num_1 = max(0LL, 1LL * (n - k) / k + 1);
    long long num_2 = max(0LL, 1LL * (n - k / 2) / k + 1);
    for (int i = k / 2; i <= n; i += k / 2) {
      if (i % k == 0) {
        ans += num_1 * num_1;
      } else {
        ans += num_2 * num_2;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 128
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
 
    static char[] xx = new char[] {'S','H','C','D'};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String in = sc.next();
            if(in.equals("0")) break;
            char[] x = in.toCharArray();
            int sum = 0;
            for(int i = 0; i < x.length; i++) {
                sum += x[i] - '0';
            }
            System.out.println(sum);
             
        }
 
    }
}


Measured memory_bytes: 26284
#include<stdio.h>
int main()
{
	int n=0;
	scanf("%d", &n);
	long long int tep[25] = { 0 };
	char c[n][11] = { 0 };
	for (int i = 0; i<n; i++)
	{
		scanf("%s", c[i]);
		if (c[i][0] == 'M')
			tep[0]++;
		if (c[i][0] == 'A')
			tep[1]++;
		if (c[i][0] == 'R')
			tep[2]++;
		if (c[i][0] == 'C')
			tep[3]++;
		if (c[i][0] == 'H')
			tep[4]++;
	}
	long long int ans = 0;
	ans += tep[0] * tep[1] * tep[2];
	ans += tep[0] * tep[1] * tep[3];
	ans += tep[0] * tep[1] * tep[4];
	ans += tep[1] * tep[2] * tep[3];
	ans += tep[4] * tep[2] * tep[3];
	ans += tep[0] * tep[3] * tep[2];
	ans += tep[0] * tep[4] * tep[2];
	ans += tep[1] * tep[3] * tep[4];
	ans += tep[1] * tep[2] * tep[4];
	ans += tep[0] * tep[3] * tep[4];
	printf("%lld\n", ans);
}

Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int hash[100010] = {};
    REP(i, n){
        int a;
        cin >> a;
        hash[a]++;
    }

    int ans = 0;
    REP(i, 99998){
        ans = max(ans, hash[i] + hash[i + 1] + hash[i + 2]);
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Dish> list = new ArrayList();
        long total_point = 0;
        for (int i = 0; i < N; i++) {
            long a = scan.nextLong();
            long b = scan.nextLong();
            Dish d = new Dish(i, a, b);
            list.add(d);
            total_point += b;
        }
        list.sort(new DishComparator());
        int limit = N / 2;
        if (N % 2 == 1) {
            limit += 1;
        }
        long answer = 0;
        for (int i = 0; i < N; i++) {
            if (i % 2 == 1) {
                continue;
            }
            Dish dish = list.get(i);
            answer += dish.A + dish.B;
        }
        System.out.println(answer - total_point);
    }
    class DishComparator implements Comparator<Dish> {
        @Override
        public int compare(Dish o1, Dish o2) {
            long p1 = o1.A + o1.B;
            long p2 = o2.A + o2.B;
            if (p1 != p2) {
                return -Long.compare(p1, p2);
            }
            return Integer.compare(o1.id, o2.id);
        }
    }
    class Dish {
        int id;
        long A;
        long B;
        Dish(int id, long A, long B) {
            this.id = id;
            this.A = A;
            this.B = B;
        }
    }
}


Measured memory_bytes: 97780
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

ll n,k,x,y;

int main(){
  ll ans=0;
  ll s=0;
  cin >> s;
  if (s<=2){
    cout<<0<<endl;
    return 0;
  }
  
  vi a(s+1,1);//dp繊維
  vi b(s+1,0);//dp繊維
  a[0]=0;
  a[1]=0;
  a[2]=0;



   ll cnt=0;
  for(ll i=0;i<s+1;i++){//くりかえし
    ans=(a[s]+ans)%MOD;

    for(ll j=3+cnt*3;j<s+1;j++){
      ll gk=0;
      for(ll k=0;k<=j-3;k++){
        gk+=a[k];
      }
      b[j]=gk%MOD;
    }

    for(ll j=0;j<s+1;j++){
      a[j]=b[j];
      b[j]=0;
    }
    
  }





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

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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

using namespace std;

signed main(){
	int n,m; cin >> n >> m;
	vector<int> a(n),b(m);
	for(int i = 0; i < n; i++)cin >>a[i];
	for(int i = 0; i < m; i++)cin >> b[i];
	vector<int> v(n,0);
	for(int i = 0; i < m; i++){
		int idx = 0;
		for(int j = 0; j < n; j++){
			if(a[j] <= b[i]){
				idx = j;
				break;
			}
		}
		v[idx]++;
	}
	int ans = 0, c = 0;
	for(int i = 0; i < n; i++){
		if(v[i] > c){
			ans = i;
			c = v[i];
		}
	}
	cout << ans+1 << endl;



	return 0;
}




Measured memory_bytes: 3116
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    int a,b;
    fi>>a>>b;
    if (a <= 0 && 0 <= b)
        halt("Zero");
    int m = abs(a - b) + 1;
    if (a < 0 && (m&1))
        halt("Negative");
    halt("Positive");
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e5 + 5;
const int logn = log2(maxn) + 1;
const int mod = 1e9 + 7;
map<ii,int> mmap;
int n , h , w;
int res[10];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".INP", "r")) {
        freopen(taskname".INP", "r", stdin);
        freopen(taskname".OUT", "w", stdout);
    }
    cin >> h >> w >> n;
    for(int i = 0 ; i < n ; ++i){
        int x , y;cin >> x >> y;
        for(int j = -1 ; j <= 1 ; ++j){
            for(int t = -1 ; t <= 1 ; ++t){
                if(x + j > 1 && x + j < h && y + t > 1 && y + t < w){
                    mmap[mp(x + j , y + t)]++;
                }
            }
        }
    }
    for(auto c : mmap){
        res[c.second]++;
    }
    cout << 1ll * (h - 2) * (w - 2) - mmap.size() << '\n';
    for(int i = 1 ; i <= 9 ; ++i)cout << res[i] << endl;
}


Measured memory_bytes: 56576
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),t[]=new int[100],m,p,x,i,j,s;
		for(i=0;i<n;i++) t[i]=stdIn.nextInt();
		m=stdIn.nextInt();
		for(i=0;i<m;i++) {
			p=stdIn.nextInt();
			x=stdIn.nextInt();
			s=0;
			for(j=0;j<n;j++) {
				if(j==p-1) s+=x;
				else s+=t[j];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <cmath>
using namespace std;
#define pi M_PI
#include <vector>

int main(){
    string n;
    cin >> n;
    if(n.at(0) == n.at(2)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define N 1000010
using namespace std;
int fa[N];
int get(int x,int y,int z){return (x-1)*6+y*3+z;}
int find(int x){return fa[x]==x?fa[x]:(fa[x]=find(fa[x]));}
int u[N],v[N],w[N];
bool can[2][N];
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
int main()
{
	int n,m,t,mod;
	scanf("%d%d%d%d",&n,&m,&t,&mod);
	int g=0;
	for(int i=1;i<=m;i++) scanf("%d%d%d",&u[i],&v[i],&w[i]);
	for(int i=2;i<=m;i++) g=gcd(g,abs(w[i]-w[1]));
	if(!g) g=mod;
	mod=gcd(mod,g*3);
	for(int i=0;i<=6*n;i++) fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int l=(w[i]-w[1]%g)/g,x,y;
		for(int p=0;p<=1;p++)
			for(int q=0;q<=2;q++)
			{
				int nq=(2*q+l)%3;
				x=get(u[i],p,q);
				y=get(v[i],1-p,nq);
				fa[find(x)]=find(y);
				x=get(v[i],p,q);
				y=get(u[i],1-p,nq);
				fa[find(x)]=find(y);
			}
	}
	for(int i=0,j=w[1]%g;i<mod*2;i++,j=j*2%mod) can[i&1][j]=true;
	while(t--)
	{
		int s,t,l;
		scanf("%d%d%d",&s,&t,&l);
		bool ans=0;
		for(int p=0;p<=1 && !ans;p++)
			for(int q=0;q<=2 && !ans;q++)
			if(find(get(s,p,q))==find(get(t,0,0))) ans=can[p][(l+w[1]%g+(3-q)*g)%mod];
		puts(ans?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int count = 0;
  // ここにプログラムを追記
  for (int i = A; i <= B; i++) {
    int n1 = i / 10000;
    int n2 = i / 1000 - n1 * 10;
    int n4 = i / 10 - (i / 100) * 10;
    int n5 = i - (i / 10) * 10;
	if ((n1 == n5)&&(n2 == n4)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
mod = 10**9+7
P = 13
 
dp = [[0 for _ in range(P)] for _ in range(N)]
 
# 1桁目だけ事前計算
if S[N-1] == '?':
    tmp = [0 for _ in range(P)]
    for i in range(10):
        tmp[i % P] = 1
    dp[0] = tmp
else:
    dp[0][int(S[N-1]) % P] = 1
 
for i in range(1, N):
    k = N-i-1
    if S[k] == '?':
        base = pow(10, i, P)
        for j in range(10):
            r = base*j % P
            for m in range(P):
                dp[i][(m+r)%P] = (dp[i][(m+r)%P] + dp[i-1][m]) % mod
    else:
        r = pow(10, i, P) * int(S[k]) % P
        for j in range(P):
            dp[i][(j+r)%P] = max(dp[i][(j+r)%P], dp[i-1][j])
 
print(dp[-1][5])


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

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

  string w;
  cin >> w;
  int dic[26] = {};
  for (auto i : w) dic[i-'a']++;

  rep(i, 26) {
    if (dic[i]%2 == 1) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

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

int main(){
  int N,K,x;
  int t=0;
  cin >> N >> K;
  for(int i=0; i<N;i++){
    cin >> x;
    if (K-x>= x){
      t += x;
    }
    else if( K-x<x){
      t += K-x;
    }
  }
  cout << t*2;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    s = input().strip()
    import collections
    q = collections.deque(s)
    ans = 0
    while q:
        s, t = q[0], q[-1]
        if s == t:
            q.popleft()
            if q:
                q.pop()
        elif s == "x" and t != "x":
            ans += 1
            q.popleft()
        elif s != "x" and t == "x":
            ans += 1
            q.pop()
        else:
            print(-1)
            return
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> edges(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }

  vector<int> D(N, -1), from(N, -1);
  D[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (auto e : edges[v]) {
      if (D[e] != -1) continue;
      D[e] = D[v] + 1;
      from[e] = v;
      que.push(e);
    }
  }
  bool ok = true;
  for (int i = 0; i < N; i++) {
    if (D[i] == -1) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
      cout << from[i] + 1 << endl;
    }
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 10604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(x<a)cout<<"NO"<<endl;
	else if(a<=x&&x<=a+b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
// ABC125_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf  = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    cout << (C/A)*B << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_N = 1e5 +6;

int a[MAX_N];
int b[MAX_N];

vector<int> edg[MAX_N];
bool visit[MAX_N];

void dfs(int id) {
    visit[id]=1;
    for (int i:edg[id]) {
        if (!visit[i]) dfs(i);
    }
}

int main (){
    int n;
    scanf("%d",&n);
    vector<int> v;
    int kirino=0;
    multiset<int> st;
    for (int i=1;n>=i;i++) {
        scanf("%d",&a[i]);
        v.push_back(a[i]);
        kirino ^= a[i];
        st.insert(a[i]);
    }
    int cnt=0;
    bool meruru = 0;
    for (int i=1;n>=i;i++) {
        scanf("%d",&b[i]);
        v.push_back(b[i]);
        if (st.find(b[i]) != st.end()) {
            cnt++;
            st.erase(st.find(b[i]));
            if (b[i] == kirino) {
                meruru = 1;
            }
        }
        else {
            if (b[i] != kirino) {
                cnt = -2*n;
            }
            else {
                meruru = 1;
            }
        }
    }
    if (cnt <= n-2) {
        puts("-1");
        return 0;
    }
    sort(v.begin(),v.end());
    v.resize(unique(v.begin(),v.end()) - v.begin());
    int dif=0;
    for (int i=1;n>=i;i++) {
        a[i] = lower_bound(v.begin(),v.end(),a[i]) - v.begin()+1;
        b[i] = lower_bound(v.begin(),v.end(),b[i]) - v.begin()+1;
        if (a[i] != b[i]) {
            edg[a[i] ].push_back(b[i]);
            edg[b[i] ].push_back(a[i]);
            dif++;
        }
    }
    int cc=0;
    for (int i=1;v.size()>=i;i++) {
        if (edg[i].size() != 0 && !visit[i]) {
            dfs(i);
            cc++;
        }
    }
    if (cc==0) meruru=0;
    printf("%d\n",dif+cc-meruru);
}


Measured memory_bytes: 11380
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

long long GCD(long long a, long long b) {
	if(a % b == 0){
		return b;
	} else {
		return GCD(b, a % b);
	}
}

int main(){
    int N;
    cin >> N;
    long long ans;
    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        if(i == 0)ans = A[i];
        else ans = GCD(ans, A[i]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int a[101], ruio = 0, hideo = 0;
	for (int i = 1; i <= 4; i++) {
		scanf("%d", &a[i]);
		ruio += a[i];
	}
	printf("%d\n%d\n", ruio / 60, ruio % 60);
	return 0;
}

Measured memory_bytes: 2704
# coding: utf-8
import itertools

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

sum=0
for i in range(N):
    for j in range(i+1,N):
        sum += pow(pow(town[i][0]-town[j][0],2)+pow(town[i][1]-town[j][1],2),0.5)
print(sum/len(list(itertools.combinations(town, 2)))*(N-1))


Measured memory_bytes: 3060
//y15-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int p,m,c;
    cin >> p >> m >> c;
    cout << p+m+c << endl;
    return 0;
}


Measured memory_bytes: 3100
N = int(input())
S = [ord(i) - 97 for i in input()]
Q = int(input())

# 添字が1から始まることに注意
class BinaryIndexedTree() :
  def __init__(self, N) :
    self.size = N
    self.tree = [0] * (N + 1)
      
  def sum(self, i) :
    s = 0
    while i > 0 :
      s += self.tree[i]
      i -= i & -i
    return s
      
  def add(self, i, x) :
    while i <= self.size :
      self.tree[i] += x
      i += i & -i
      
alph = [BinaryIndexedTree(N + 10) for _ in range(26)]
for i in range(N) :
  alph[S[i]].add(i + 1, 1)

for _ in range(Q) :
  type, x, y = input().split()
  if type == '1' :
    x = int(x)
    s = S[x - 1]
    alph[s].add(x, -1)
    alph[ord(y) - 97].add(x, 1)
    S[x - 1] = ord(y) - 97
  else :
    x, y = int(x), int(y)
    ret = 0
    for i in range(26) :
      if alph[i].sum(y) - alph[i].sum(x - 1) > 0 :
        ret += 1
    print(ret)

Measured memory_bytes: 145564
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int l,r,d;
    cin>>l>>r>>d;
    int cnt=0;
    rep1(i,l,r){
        cnt+=(i%d==0);
    }
    cout<<cnt<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3652