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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int x = in(), t = in();
  cout << max(0, x - t) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <unordered_map>

using namespace std;
const int INF = 0x3f3f3f3f;
//static const auto _____ = []()
//{
//	ios::sync_with_stdio(false);
//	cin.tie(nullptr);
//	return nullptr;
//}();


string LCS(const string &a, const string &b) {
    int n = a.length();
    int m = b.length();
    int dp[n + 1][m + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    int i = n;
    int j = m;
    string res(dp[i][j], ' ');
    while (dp[i][j] > 0) {
        if (a[i - 1] == b[j - 1]) {
            res[dp[i][j] - 1] = a[i - 1];
            i--;
            j--;
        } else {
            if (dp[i][j] == dp[i - 1][j]) i--;
            else j--;
        }
    }
    return res;
}

int main(int argc, char *argv[]) {
    string a, b;
    cin >> a >> b;
    cout << LCS(a, b);
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main()
{
    int n,i,j=0,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        if(m%2!=0&&i%2!=0)
            j++;
    }
    cout<<j<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n, d, x;
    cin >> n >> d >> x;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    ll ans = x;
    for(int i = 1; i <= d; ++i){
        for(int j = 0; j < n; ++j){
            if((i - 1) % a.at(j) == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;;
#define 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, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s; cin >> s;
  int a = (s[0] - '0') * 10 + s[1] - '0';
  int b = (s[2] - '0') * 10 + s[3] - '0';
  bool x = a >0 && a <= 12;
  bool y = b >0 && b <= 12;
  if(x&&y){
      cout << "AMBIGUOUS" << endl;
  }else if(x && !y){
      cout << "MMYY" << endl;
  }else if(!x && y){
      cout << "YYMM" << endl;
  }else{
      cout << "NA" << endl;
  }
}

Measured memory_bytes: 256
/*
AizuOnline A2019
Princess's Marriage
*/
#include <stdio.h>
#include <stdlib.h>

int N;
long M;
struct DP
{ int D;
  int P;};

struct DP inf[10000];

int comp_P(void *a,void *b)
{
  return (((int *)b)[1] - ((int *)a)[1]);
}
print()
{ int i;
  for(i=0;i<N;i++)
    printf("%d:%d\n",inf[i].D,inf[i].P);
}

main()
{
  int i,j;
  long sum;
  //printf("SDP:%d\n",sizeof(struct DP));

  while(EOF != scanf("%d %ld",&N,&M) && (N || M))
    {
      for(i=0;i<N;i++)
	scanf("%d %d",&(inf[i].D),&(inf[i].P));
      //print();
      qsort(&(inf[0]),N,sizeof(struct DP),(__compar_fn_t)comp_P);
      //print();
      for(i=0;i<N;i++)
	{
	  if(M < inf[i].D)
	    goto NOKORI;
	  M -=   inf[i].D;
	}
      printf("0\n");
      continue;
    NOKORI:
      sum =  (inf[i].D-M)*inf[i].P;
      for(j=i+1;j<N;j++)
	sum += inf[j].D*inf[j].P;
      printf("%ld\n",sum);
    }
    


return(0);
}

Measured memory_bytes: 800
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

int main() {
    // your code goes here
    ll n,a[100005],ans=1;
    cin >> n;
    rep(i,1,n){
    	cin >> a[i];
    	if(a[i]==0){
    		cout << 0 << endl;
    		return 0;
    	}
    }
    rep(i,1,n){
    	if(ans!=0&&(1000000000000000000-1000000000000000000%ans)/ans<a[i]) {
    		cout << -1 << endl;
    		return 0;
    	}
    	ans*=a[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int t[5 * maxn], a[maxn], lazy[5 * maxn];

int doit(int a, int b) {
    return min(a, b);
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        t[index] = 2147483647;
        return;
    }

    int mid = start + end >> 1;
    build(start, mid, index << 1);
    build(mid + 1, end, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

int query(int start, int end, int l, int r, int index = 1) {
    //Invalid range
    if (r < start or l > end)
        return 2147483647;

    //In range
    if (l <= start and end <= r) {
        return t[index];
    }

    int mid = start + end >> 1;
    return doit(query(start, mid, l, r, index << 1), query(mid + 1, end, l, r, index << 1 | 1));
}

void pUpdate(int start, int end, int point, int val, int index = 1) {
    if (start == end) {
        t[index] = val;
        return;
    }

    int mid = start + end >> 1;
    if (point <= mid)
        pUpdate(start, mid, point, val, index << 1);
    else
        pUpdate(mid + 1, end, point, val, index << 1 | 1);

    t[index] = doit(t[index << 1], t[index << 1 | 1]);
}

void rangeUpdate(int start, int end, int l, int r, int val, int index) {

}

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

    build(0, n - 1, 1);

    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;

        int x, y;
        cin >> x >> y;

        if (a == 0) {
            pUpdate(0, n - 1, x, y, 1);
        } else {
            cout << query(0, n - 1, x, y, 1) << endl;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 5276
import math
A,B,H,M=map(int,input().split())

def rad(deg):
  return math.pi*deg/180.0

def h_deg(h,m):
  return 30*h+m/2

def m_deg(m):
  return 6*m
  
def hm_rad(h,m):
  return rad(abs(h_deg(h,m)-m_deg(m)))

def get_C(A,B,h,m):
  theta = hm_rad(h,m)
  return math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
  
print(get_C(A,B,H,M))  

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

#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,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX_N=200001;

int main(){
	string s;
	cin>>s;
	int num[4];
	for(int i=0;i<4;i++){
		num[i]=s[i]-'0';
	}
	for(int i=0;i<(1<<3);i++){
		bool op[3];
		fill(op,op+3,false);
		for(int j=0;j<3;j++){
			if((i>>j)&1==1){
				op[j]=true;
			}
		}
		int sum=num[0];
		for(int j=0;j<3;j++){
			if(op[j]){
				sum+=num[j+1];
			}else{
				sum-=num[j+1];
			}
		}
		if(sum==7){
			for(int i=0;i<4;i++){
				if(i<3){
					cout<<num[i];
					if(op[i])cout<<"+";
					else cout<<"-";
				}else if(i==3){
					cout<<num[i]<<"=7"<<endl;
				}
			}
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
short N, i;
short a, min, max;
int main(){
	scanf("%hd", &N);
	scanf("%hd", &a);
	min=max=a;
	for(i=1; i<N; i++){
		scanf("%hd", &a);
		if(a<min){
			min=a;
		}else if(a>max){
			max=a;
		}
	}
	printf("%d\n", max-min);
}


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

	int a,b;
	cin >> a >> b;
	if (a == b) {
  		cout << "a == b\n";
	} else if (a > b) {
  		cout << "a > b\n";
	} else if (a < b) {
  		cout << "a < b\n";
	}
	return 0;
}

Measured memory_bytes: 1120
n = gets.to_i
a = gets.split.map {|s| s.to_i}
cnt = 0
for i in 0...n
  min = i
  for j in i...n
    min = j if a[j] < a[min]
  end
  if min != i
    t = a[i]
    a[i] = a[min]
    a[min] = t
    cnt += 1
  end
end
for i in 0...n
  print " " unless i==0
  print a[i]
end
print "\n"
puts cnt

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#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, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define MAX_V 100005

struct edge
{
  int to;
  int cost;
};

using P = pair<int, int>;
const int INF = 1e9;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s)
{
  priority_queue<P, vector<P>, greater<P>> que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.emplace(0, s);

  while (!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for(auto nv: G[v]){
      if (d[nv.to] > d[v] + nv.cost){
        d[nv.to] = d[v] + nv.cost;
        que.emplace(d[nv.to], nv.to);
      }
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> V;
  REP(i,V){
    edge eg1 = {(i+1)%V, 1};
    G[i].push_back(eg1);
    edge eg2 = {(i*10)%V, 0};
    G[i].push_back(eg2);
  }
  dijkstra(1);
  cout << d[0]+1 << '\n';
  return 0;
}


Measured memory_bytes: 9732
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
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 PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

void printClass(double d) {
    if (d <= 48) {
        cout << "light fly" << endl;
    }else if (d <= 51) {
        cout << "fly" << endl;
    }else if (d <= 54) {
        cout << "bantam" << endl;
    }else if (d <= 57) {
        cout << "feather" << endl;
    }else if (d <= 60) {
        cout << "light" << endl;
    }else if (d <= 64) {
        cout << "light welter" << endl;
    }else if (d <= 69) {
        cout << "welter" << endl;
    }else if (d <= 75) {
        cout << "light middle" << endl;
    }else if (d <= 81) {
        cout << "middle" << endl;
    }else if (d <= 91) {
        cout << "light heavy" << endl;
    }else {
        cout << "heavy" << endl;
    }
}

int main() {
    double w;
    while(cin >> w) {
        printClass(w);
    }
    return 0;
}

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

int main(){
    for(int i = 0;i < 4;i++){
        int a,b,c = 0;
        cin >> a >> b;
        if(a == 1){
            c = 6000 * b;
        }
        if(a == 2){
            c = 4000 * b;
        }
        if(a == 3){
            c = 3000 * b;
        }
        if(a == 4){
            c = 2000 * b;
        }
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	int N;
	int cnt=0;
	string s;
	cin >> N >> s;

	rep(i, N) {
		if (s[i] != s[i + 1]) {
			
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

const int MAX=3005;
int dp[MAX][MAX];

int main(){
    string s,t,out="";
    cin >> s >> t;
    int lim1,lim2,aux;
    lim1=s.size();
    lim2=t.size();
    for(int i=1;i<=lim1;i++){
        for(int j=1;j<=lim2;j++){
            if(s[i-1]==t[j-1]) aux=dp[i-1][j-1]+1;
            else aux=0;
            dp[i][j]=max(aux,dp[i-1][j]);
            dp[i][j]=max(dp[i][j],dp[i][j-1]);
        }
    }
    int i=lim1,j=lim2;
    while(i!=0 && j!=0){
        if(s[i-1]==t[j-1]){
            out+=s[i-1];
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(out.begin(),out.end());
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 38808
open Printf
open Scanf

let id x = x

let mdst (x0, y0) (x1, y1) = abs (x0 - x1) + abs (y0 - y1)

let solve mp lm =
  let rec loop0 sp x d =
    if sp = 6 then (x, d) else
      let np = if sp = 5 then 1 else sp + 1 in
      let ar0 = Array.init lm.(np) @@
                  fun i -> mdst mp.(0).(0) mp.(np).(i) in
      let rec loop1 n p ar =
        if n = 0 then (p, ar) else
          let np = if p = 5 then 1 else p + 1 in
          let nar = Array.init lm.(np) @@
                      fun i -> let rec loop2 j d =
                                 if j = lm.(p) then d
                                 else
                                   loop2 (j + 1) (min d (ar.(j) + mdst mp.(p).(j) mp.(np).(i))) in
                               loop2 0 100000 in
          loop1 (n - 1) np nar in
      let (p1, ar1) = loop1 3 np ar0 in
      let d1 = let rec loop3 i d =
                 if i = lm.(p1) then d
                 else loop3 (i + 1) (min d (ar1.(i) + mdst mp.(p1).(i) mp.(6).(0)))
               in loop3 0 100000 in
      loop0 (sp + 1) (if d1 < d then sp else if d1 = d && sp < x then sp else x) (min d d1) in
  let (mx, md) = loop0 1 0 100000 in
  if md >= 100000 then "NA" else sprintf "%d %d" mx md
        
let () =
  let rec loop () =
    let w, h = scanf "%d %d " @@ fun w h -> (w, h) in
    if w = 0 && h = 0 then ()
    else begin
        let mp = Array.make_matrix 7 1000 (-1, -1) in
        let lm = Array.make 7 0 in
        for i = 0 to h - 1 do
          let s = scanf "%s " id in
          for j = 0 to w - 1 do
            if s.[j] = 'S' then
              mp.(0).(0) <- (i, j)
            else if s.[j] = 'G' then
              mp.(6).(0) <- (i, j)
            else if s.[j] = '.' then ()
            else begin
                let atr = Char.code s.[j] - Char.code '0' in
                mp.(atr).(lm.(atr)) <- (i, j);
                lm.(atr) <- lm.(atr) + 1
              end
          done
        done;
        solve mp lm |> printf "%s\n";
        loop ()
      end
  in loop ()



Measured memory_bytes: 8244
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int A[5], B[5];
    int min_ind = 0;
    int min = 10;
    
    for(int i = 0; i < 5; i++){
        cin >> A[i];
        if(A[i] < 10){
            B[i] = A[i];
        }else if(A[i] >= 10 && A[i] < 100){
            B[i] = A[i] %10;
        }else{
            B[i] = (A[i] % 100) % 10;
        }
        if(min > B[i] && B[i] != 0){
            min = B[i];
            min_ind = i;
        }
    }
    for(int i = 0; i < 5; i++){
        if(min_ind == i){
            continue;
        }else{
            if(A[i]%10 != 0){
                A[i] = (int(A[i]/10) + 1) * 10;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 5; i++){
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    a = list(map(int, r.split()))
    #a,b,c,d = map(int, r.split())
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

    if a[0] == a[1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <numeric>
int main(void) {
	int n, m,sum=0;
	scanf("%d %d", &n, &m);
	int* arr = (int*)malloc(sizeof(int) * n);//int,n個分のサイズを確保
	//int* arr2 = new int[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
	std::sort(arr,arr+n,std::greater<int>());//範囲内の値を並び替える std::greater<int>()で大きい順に並び替える


	for (int i = 0; i < m;i++) {
		if (arr[i] < sum / (4.0 * m)) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    pos = [0, 0]
    time = 0
    flag = False

    for i in range(n):
        tmp = list(map(int, input().split()))
        time = tmp[0] - time
        dist = tmp[1] - pos[0] + tmp[2] - pos[1]
        if time < dist or (dist - time) % 2 == 1:
            flag = True
        pos = [tmp[1], tmp[2]]
        time = tmp[0]

    if flag:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  vector<pair<ll, int> > arr(M);
  int b, c;
  for(int i=0;i<M;++i) {
    cin>>b>>c;
    arr[i] = mp(c, b);
  }
  sort(arr.begin(), arr.end(), greater<pair<ll, int> >() );
  int index = 0;
  for(int i=0;i<N;++i) {
    if(index==M) break;
    if(arr[index].se==0) {
      index++;
      i--;
      continue;
    }
    if(arr[index].fi>A[i]) {
      A[i] = arr[index].fi;
      arr[index].se--;
    }
  }
  ll ans = 0;
  for(int i=0;i<N;++i) {
    ans += A[i];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5576
import itertools
import sys

N = int(input())
s = input().rstrip().split(' ')
L = [int(j) for j in s]

if len(L) < 3:
    print(0)
    sys.exit()

ans = 0

for i,j,k in itertools.combinations(L,3):
    if (i == j) or (i == k) or (j == k): continue
    if (i < j+k) and (j < i+k) and (k < i+j):
        ans += 1

print(ans)

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

int main(){
    int k,s;
    cin>>k>>s;
    int x,y,z;
    int count=0;
    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            z=s-x-y;
            if(z<=k&&z>=0) count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
//#include "bits\stdc++.h"
#include <iostream>
#include <vector>

using namespace std;
typedef long long LL;

int main()
{
    int a, n = 0;

    cin >> a;

    if (a / 100 == 1) { ++n; a -= 100; }
    if (a / 10 == 1) { ++n; a -= 10; }
    if (a == 1) ++n;


    cout << n << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()

K -= 1
i = A.index(1)

# 怒りの全探索
ans = 0
for j in range(0, N - 1, K):
    ans += 1

print(ans)


Measured memory_bytes: 13876
#include <cstdio> 
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

const int mod = 1000000007;
map<long long, int> f;

int dp(long long n)
{
	if(f[n]) return f[n];
	return f[n] = ((dp(n>>1) + dp((n-1)>>1)) % mod + dp((n-2)>>1)) % mod;
}

int main()
{
	f[1] = 2; f[2] = 4; f[3] = 5;
	long long n;
	scanf("%lld", &n);
	printf("%d\n", dp(n));
}
 



Measured memory_bytes: 256
ABK = input().split()
A = int(ABK[0])
B = int(ABK[1])
K = int(ABK[2])

tmp = A
if A < K:
  A = 0
else:
  A -= K
K = K - tmp

if K > 0:
  if B < K:
    B = 0
  else:
    B -= K

print(A,B)

Measured memory_bytes: 3064
def main():
    S = input()
    N = len(S)
    P = S[:(N-1)//2]
    Q = S[(N+3)//2 - 1:]
    M = len(P)
    K = len(Q)
    if (S[:N//2] == S[N//2 + 1:][::-1]) and \
            (P[:M//2] == P[(M//2 + 1 if M % 2 == 1 else M//2):][::-1]) and \
            (Q[:K//2] == Q[(K//2 + 1 if K % 2 == 1 else K//2):][::-1]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;

	public Graph() {
		totalVertex = 0;
	}

	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for (int i = 0; i < totalVertex; i++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			for (int j = 0; j < degree; j++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}
			adjList.add(tmp);
		}
		in.close();
	}

	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for (int i = 0; i < adjList.size(); i++) {
			for (int j = 0; j < totalVertex; j++) {
				int value = 0;
				if (!adjList.get(i).isEmpty())
					if (adjList.get(i).contains(j))
						value = 1;
				System.out.print(value);
				if (j < totalVertex - 1)
					System.out.print(" ");
			}
			System.out.println();
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}



Measured memory_bytes: 33040
n = int(input())
df = [list(map(int, input().split())) for _ in range(n)]
m = 1
for i in range(1, n+1):
    m *= i
result = 0
for i in range(n):
    for j in range(n):
        if i != j:
            result += (abs(df[i][0]-df[j][0])**2 + abs(df[i][1] - df[j][1])**2)**0.5
print(result/n)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
using Braph = vector<vector<bool>>;

/*
//深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v, Braph A, int n){
  seen[v] = true; // v を訪問済みにする

  // vから行ける各頂点 next_v について
  for(auto nv : G[v]){
    if (seen[nv]) continue; // next_v が探索済みだったらスルー
    dfs(G, nv); // 再帰的に探索
  } 
}
*/

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, X, Y;
  cin >> N >> X >> Y;
  --X, --Y;

  Graph G(N);
  G[X].push_back(Y);
  G[Y].push_back(X);
  rep(i,N-1){
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  int ans[N]{};

  priority_queue<P, vector<P>, greater<P>> que1;

  bool seen[N]{};
  rep(i,N){
    que1.push(P((int)0,i));
    seen[i] = true;

    while(!que1.empty()){
      P p = que1.top();
      que1.pop();
      int n = p.first;
      int u = p.second;
      ans[n]++;
      for(auto nv : G[u]){
        if (seen[nv]) continue; // next_v が探索済みだったらスルー
        que1.push(P(n+1, nv));
        seen[nv] = true;
      }
    }
    rep(j,N){
      seen[j] = false;
    }
  }

  rep(i,N-1){
    cout << ans[i+1]/2 << endl;
  }
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println(48 - sc.nextInt());
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 19796
N = int(input())
p = list(map(int, input().split()))
for i in range(0,N):
  if p[i] != i+1:
    p[p.index(i+1)],p[i] = p[i],p[p.index(i+1)]
    break
if p == sorted(p):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
     int a,b;
     int sum=0;
     cin>>a>>b;
     for(int i=1; i<3; i++){
          if(a>=b){
               sum+=a;
               a--;
          }
          else {
               sum+=b;
               b--;
          }
     }
     cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define min(a,b) ((a)<(b)?(a):(b))

int main(){
	long long n,b;
	scanf("%lld",&n);b=n;
	long long i,yac[5000],c=0,sum=0,ans=n-1;
	for(i=1;i*i<=n;i++){
		if(n%i==0)ans=min(ans,i+n/i-2);
	}
	printf("%lld\n",ans);
	return 0;
}


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

const int mod = 1e9 + 7;
const int MN = 200010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int fact[MN], invf[MN];
int comb(int n, int k) {
    return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;
}

int H, W, A, B;

int main() {
    fact[0] = 1;
    for(int i = 1; i < MN; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < MN; i++) {
        invf[i] = inv(fact[i]);
    }

    cin >> H >> W >> A >> B;

    int ans = 0;
    for(int i = 0; i <= H - A - 1; i++) {
        ans += 1LL * comb(B - 1 + i, B - 1) * comb(W - B - 1 + H - 1 - i, W - B - 1) % mod;
        ans %= mod;
    }
    cout << ans;
}


Measured memory_bytes: 1920
<?php
function first_check($sorted, $pre, $post) {
//    foreach ($sorted as $k => $v) {
//        if ($pre <= $v) {
//            break;
//        }
//        unset($sorted[$k]);
//    }
//    foreach (array_reverse($sorted, true) as $k => $v) {
//        if ($v <= $post) {
//            break;
//        }
//        unset($sorted[$k]);
//    }

    $keys = [];
    for ($cur = $pre; $cur <= $post; $cur++) {

        if (empty($sorted)) {
            return $keys;
        }

        do {
            $value = reset($sorted);
            if ($cur < $value) {
                continue 2;
            }
            $key = key($sorted);
            unset($sorted[$key]);

            if ($cur == $value) {
                $keys[] = $key;
            }

        } while ($sorted);
    }
    return $keys;
}

function second_check($sorted, $keys, $cur) {
    foreach ($keys as $k => $key) {
        if ($sorted[$key] != $cur) {
            unset($keys[$k]);
        }
    }
    return $keys;
}

function found(&$gems, &$state, $d, $l) {
    $keys = [];

    switch ($d) {
        case 'N':
            $keys = first_check($gems['y'], $state[1], $state[1] + $l);
            $keys = second_check($gems['x'], $keys, $state[0]);
            $state[1] += $l;
            break;
        case 'E':
            $keys = first_check($gems['x'], $state[0], $state[0] + $l);
            $keys = second_check($gems['y'], $keys, $state[1]);
            $state[0] += $l;
            break;
        case 'S':
            $keys = first_check($gems['y'], $state[1] - $l, $state[1]);
            $keys = second_check($gems['x'], $keys, $state[0]);
            $state[1] -= $l;
            break;
        case 'W':
            $keys = first_check($gems['x'], $state[0] - $l, $state[0]);
            $keys = second_check($gems['y'], $keys, $state[1]);
            $state[0] -= $l;
            break;
    }

    foreach ($keys as $key) {
        unset($gems['x'][$key]);
        unset($gems['y'][$key]);
    }
}

function process() {
    $n = fgets(STDIN);
    if ($n == 0) {
        return;
    }

    $gems = ['x' => [], 'y' => []];
    for ($i = 0; $i < $n; $i++) {
        fscanf(STDIN, "%d %d", $x, $y);
//        list($x, $y) = explode(' ', fgets(STDIN));
        $gems['x'][$i] = (int) $x;
        $gems['y'][$i] = (int) $y;
    }

    asort($gems['x']);
    asort($gems['y']);

    $state = [10, 10];
    $m = fgets(STDIN);
    for ($j = 0; $j < $m; $j++) {
        fscanf(STDIN, "%c %d", $d, $l);
//        list($d, $l) = explode(' ', fgets(STDIN));
        found($gems, $state, $d, $l);
    }

    if ($gems['x']) {
        echo 'No' . PHP_EOL;
    } else {
        echo 'Yes' . PHP_EOL;
    }

    process();
}

process();



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

int N, Y, num10, num5, num1, money;

int main() {
    cin >> N >> Y;
    Y /= 1000;
    num10 = N;  // Suppose the every bill is $10 bill.
    money = 10 * num10;

    while (money != Y) {
        int over = money - Y;

        if (over < 0) {  // Failed to match.
            cout << "-1 -1 -1" << endl;
            return 0;
        } else if (over >= 5 && num10 >= 1) {
            num10 -= 1;
            num5 += 1;
            money -= 5;
        } else if (over >= 4 && num5 >= 1) {
            num5 -= 1;
            num1 += 1;
            money -= 4;
        } else if (num5 >= 2) {
            num10 += 1;
            num5 -= 2;
            num1 += 1;
            money += 1;
        } else {
            cout << "-1 -1 -1" << endl;
            return 0;
        }
    }

    cout << num10 << " " << num5 << " " << num1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

vector<lli> to[2505];
vector<lli> rto[2505];
bool reachableFrom1[2505];
bool reachableFromN[2505];
bool ok[2505];

void dfs(lli v){
	if(reachableFrom1[v])return;
	reachableFrom1[v] = true;
	for(lli u: to[v]){
		dfs(u);
	}
}

void rdfs(lli v){
	if(reachableFromN[v])return;
	reachableFromN[v] = true;
	for(lli u: rto[v]){
		rdfs(u);
	}
}


signed main(){

	lli n,m,p;
	cin>>n>>m>>p;
	vector<tuple<lli,lli,lli>> edges;
	REP(i,0,m){
		lli a,b,c;
		cin>>a>>b>>c;
		a--,b--;
		c -= p;
		c = -c;
		edges.emplace_back(a,b,c);
		to[a].push_back(b);
		rto[b].push_back(a);
	}
	dfs(0);
	rdfs(n-1);

	REP(i,0,n)ok[i] = reachableFrom1[i] & reachableFromN[i];
	{//bellman-ford
		vector<lli> d(n,INF);
		d[0]=0;
		bool upd=true;
		lli step=0;
		while(upd){
			upd = false;
			REP(i,0,m){
				lli a,b,c;
				tie(a,b,c) = edges[i];
				if(!ok[a])continue;
				lli newD = d[a]+c;
				if(newD < d[b]){
					upd = true;
					d[b] = newD;
				}
			}
			step++;
			if(step>n){
				puts("-1");
				return 0;
			}
		}
		lli ans = -d[n-1];
		cout<<max(0LL,ans)<<endl;
	}

	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main()
{
    int nn;
    cin >> nn;
    for (int n = 1; n <= nn; n++)
    {
        int ans = 0;
        for (int x = 1; x * x + 2 * x + 3 <= n; x++)
        {
            for (int y = 1; x * x + y * y + 1 + x * y + y + x <= n; y++)
            {
                int b=x+y;
                int c=x*x+y*y+x*y-n;
                int zz = (-b+sqrt(b*b-4*c)) / 2.0;
                //if(z<=1e-3) break;
                for (int z = zz - 1; z <= zz + 1; z++)
                {
                    if (z < 1)
                        continue;
                    if (x * x + y * y + z * z + x * y + y * z + z * x == n)
                    {
                        //cout << n << " " << x << " " << y << " " << z << " " << endl;//
                        ans++;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3556
/*


*/

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

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

#define endl '\n'
#define ld long double
#define ll long long
#define PI acos(-1.0)
#define OO 1e17
#define EPS 1e-12
#define MLOG 20
#define MAX 1* 100 * 1000+5
const int mod = 1e9 + 7;
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }


void fast(){
#ifndef ONLINE_JUDGE
	freopen("E:\\Competitve\\solving\\input.txt", "r", stdin);
	freopen("E:\\Competitve\\solving\\output.txt", "w", stdout);
#endif
}
int n, k;
int w[101], v[101];

ll dp[101][MAX];
int main(){
//	fast();

	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];

	for (int i = n-1; i>=0; i--){
		for (int j = 0; j <= k; j++){
			dp[i][j] = dp[i + 1][j];
			if (j >= w[i])
				dp[i][j] = max(dp[i][j] , dp[i + 1][j - w[i]] + v[i]);
		}
	}

	cout << dp[0][k] << endl;

	return 0;

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;

int main() {
    cin >> s;
    forn(i, 8) s.pop_back();
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
//#define IORD
#define eps 1e-8
#define inf 0x3f3f3f3f
//#define mod (1000000007)

using namespace std;
typedef long long LL;
typedef pair<int,int> pp;

const int N=1e5+10;
const int maxn=N*2+10;
int n,a[N],b[N],ais[N];
LL cnt=0;

int bit[maxn+1];
int lb(int x)
{
    return x&-x;
}

int sum(int i)
{
    int s=0;
    while(i>0)
    {
        s+=bit[i];
        i-=lb(i);
    }
    return s;
}

void add(int i,int x)
{
    while(i<=maxn)
    {
        bit[i]+=x;
        i+=lb(i);
    }
}

int Che(int x)
{
    memset(bit,0,sizeof(bit));
    memset(ais,0,sizeof(ais));
    for(int i=1;i<=n;i++) ais[i]=(ais[i-1]+(a[i]>=x?1:-1));
    cnt=0;
    for(int i=0;i<=n;i++)
    {
        cnt+=sum(ais[i]+N);
        add(ais[i]+N,1);
    }
    return cnt>=1ll*(n+1)*n/4;
}

int Sol()
{
    memcpy(b,a,sizeof(a));
    sort(b+1,b+n+1);
    int l=0,r=n+1,m=(l+r)/2;
    while(l+1<r)
    {
        if(Che(b[m])) l=m;else r=m;
        m=(l+r)/2;
    }
    return b[l];
}

int main()
{
    #ifdef IORD
    freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif // IORD
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    printf("%d\n",Sol());
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string cube;
int main() {
	cin >> cube;
	int aka = 0, ao = 0;
	for (int i = 0; i < cube.size(); i++) {
		if (cube[i] == '0') {
			aka++;
		}
		else {
			ao++;
		}
	}
	cout << min(aka, ao)*2 << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    ll cnt1 = 0, cnt2 = 0;
    for(int i = 1; i <= n; i++){
        if (i % k == 0) cnt1++;
        else if (k % 2 == 0 && i % (k/2) == 0) cnt2++;
    }
    ans += cnt1 * cnt1 * cnt1;
    ans += cnt2 * cnt2 * cnt2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
<?php
list($N)=sscanf(trim(fgets(STDIN)),"%d");
$L = substr($N, -1 ,1);
if($L == 3){
    echo "bon";
}else if(($L == 0)||($L == 1)||($L == 6)||($L == 8)){
    echo "pon";
}else{
    echo "hon";
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  FOR(i,L,R+1) {
    if (i%d == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
/** @Date    : 2017-05-07 19:07:12
  * @FileName: C BFS 贪心.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;

char mp[1000][1000];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
int vis[1000][1000];
int n, m, k;
int bfs(int sx, int sy)
{
	MMF(vis);
	int ans = INF;
	queue<PII >q;
	q.push(MP(sx, sy));
	while(!q.empty())
	{
		PII nw = q.front();
		q.pop();
		int sp = min(min(nw.fi - 1, nw.se - 1), min(n - nw.fi , m - nw.se));
		ans = min(sp / k + ((sp%k)?1:0), ans);
		for(int i = 0; i < 4; i++)
		{
			int nx = nw.fi + dir[i][0];
			int ny = nw.se + dir[i][1];
			if(nx > 0 && ny > 0 && nx <= n && ny <= m && mp[nx][ny] == '.')
			{
				if(!vis[nx][ny] && abs(nx - sx) + abs(ny - sy) <= k)
					vis[nx][ny] = 1, q.push(MP(nx, ny));
			}
		}
	}
	return ans;
}

int main()
{
	while(cin >> n >> m >> k)
	{
		getchar();
		int sx = -1, sy = -1;
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
			{
				scanf("%c",&mp[i][j]);
				if(mp[i][j] == 'S')
					sx = i, sy = j;
			}
			getchar();
		}	
		int ans = bfs(sx, sy);
		printf("%d\n", ans + 1);
	}
    return 0;
}

Measured memory_bytes: 4992
n = int(input())
sl = [input() for nesya in range(n)]
sm = []
for s in sl:
  t = list(s)
  t.sort()
  sm.append(''.join(t))
d = dict()
for m in sm:
  if m in d:
    d[m] += 1
  else:
    d[m] = 1
c = 0
for v in d.values():
  c += v*(v-1)//2
print(c)

Measured memory_bytes: 26620
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  char c; cin >> c;
  cout << char(c + 1) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	std::size_t K;
	std::cin >> K;
	std::vector<int> exist(K);
	std::size_t val = 0;
	for (auto i : boost::irange(K))
	{
		val = (10 * val + 7) % K;
		if (val == 0)
		{
			std::cout << i + 1 << std::endl;
			return;
		}
		else if (exist[val])
		{
			std::cout << -1 << std::endl;
			return;
		}
		exist[val] = true;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 7156
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,d,a;
    long long mx=0;
    cin>>n>>d>>a;
    vector<pair<long long,long long> >v;
    for(int i=1;i<=n;++i){
        long long x,y;
        cin>>x>>y;
        long long z=(y-1)/a+1;
        mx=max(mx,z);
        v.push_back({x,z});
    }
    sort(v.begin(),v.end());
    long long ans=0;
    if(v[0].first+2*d>=v[n-1].first)
        ans=mx;
    else{
        int temp=0;
        for(int i=0;i<n;++i){
            temp=i;
            if(v[i].second<=0)
                continue;
            for(int j=i+1;j<n;++j)
                if(v[j].first<=v[i].first+2*d)
                    v[j].second-=v[i].second;
                else
                    break;
            ans+=v[temp].second;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6512