akhauriyash/Code-Regression huggingface dataset:
def A():
    c = input()
    print(chr(ord(c)+1))

def B():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    K = temp[1]
    M = temp[2]
    A = [int(k) for k in input().split()]
    ans = M*N - sum(A)
    if ans <= K:
        print(max(0, ans))
    else:
        print(-1)

from collections import defaultdict
def C():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    M = temp[1]
    penal = defaultdict(int)
    P = []
    S = []
    for i in range(M):
        temp = input().split()
        P.append(int(temp[0]))
        S.append(temp[1])
    ac_problems = set()

    for i in range(M-1, -1, -1):
        if P[i] not in ac_problems and S[i] == 'AC':
            ac_problems.add(P[i])
        elif P[i] in ac_problems:
            if S[i] == 'WA':
                penal[P[i]] += 1
            elif S[i] == 'AC':
                penal[P[i]] = 0
    
    print(len(ac_problems), sum(penal.values()))

def D():
    temp = [int(k) for k in input().split()]
    H = temp[0]
    W = temp[1]
    S = []
    for i in range(H):
        S.append(input())
    ans = 0
    directions = [(-1, 0), (0, -1), (1, 0), (0, 1)]
    def bfs(x, y):
        to_visit = [(x, y, 0)]
        visited = set()
        ret = 0
        while to_visit:
            x, y, distance = to_visit[0]
            del to_visit[0]
            if (x, y) in visited:
                continue
            visited.add((x, y))
            ret = max(distance, ret)
            for d in directions:
                if x+d[0] < H and x+d[0] >= 0:
                    if y+d[1] < W and y+d[1] >= 0:
                        if (x+d[0], y+d[1]) not in visited:
                            if S[x+d[0]][y+d[1]] == '.':
                                to_visit.append((x+d[0], y+d[1], distance+1))
        #print(memo)
        return ret

    ans = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.':
                ans = max(bfs(i, j), ans)
                
    #print(memo)

    print(ans)

def E():
    temp = [int(k) for k in input().split()]
    N = temp[0]
    K = temp[1]
    A = [int(k) for k in input().split()]
    MOD = 10**9+7

    fac = [0]*(N+1)
    fac[0] = fac[1] = 1
    inv = [0]*(N+1)
    inv[1] = 1
    facinv = [0]*(N+1)
    facinv[0] = facinv[1] = 1
    for i in range(2,N+1):
        fac[i] = fac[i-1]*i%MOD
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        facinv[i] = facinv[i-1] * inv[i] % MOD

    A.sort()

    def nCr(n, r, mod):
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return fac[n] * (facinv[r] * facinv[n-r] % mod) % mod

    maximum_sum = 0
    minimum_sum = 0
    for i in range(N):
        maximum_sum += nCr(i, K-1, MOD)*A[i]
        maximum_sum %= MOD
        minimum_sum += nCr(N-i-1, K-1, MOD)*A[i]
        minimum_sum %= MOD

    print((maximum_sum-minimum_sum)%MOD)


E()

Measured memory_bytes: 19672
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  ll a = A * X + B * Y;

  ll m = Y - X < 0 ? 0 : Y - X;
  ll b = C * (2 * X) + B * m;

  ll mm = X - Y < 0 ? 0 : X - Y;
  ll c = A * mm + C * (2 * Y);

  ll ans = min(min(a, b), c);
  COUT(ans);

  return 0;
}

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

using namespace std;

typedef long long ll;

ll mod;

ll powimod(ll x,ll n,ll mod){
    ll res=1;
    while(n){
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}

ll powi(ll x,ll n){
    ll res=1;
    while(n){
        if(n&1) res*=x;
        x*=x;
        n>>=1;
    }
    return res;
}

vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0) cout<<1;
  else if(b==0) cout<<2;
  else if(c==0) cout<<3;
  else if(d==0) cout<<4;
  else cout<<5;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
using namespace std;

int main() {
	long long a[3];
	cin >> a[0] >> a[1] >> a[2];
	if (a[0] * a[1] * a[2] % 2 == 0)cout << 0 << endl;
	else {
		sort(a, a + 3);
		cout << a[0] * a[1] << endl;
	}
	return 0;

	return 0;
}

Measured memory_bytes: 256
_ =  input()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sums = sum(B)
C = list(map(int, input().split()))

bonus = 0
for i, no in enumerate(A):
    
    if i == len(A) - 1:
        break
    elif no + 1 == A[i + 1]:
        bonus += C[no - 1]

print(sums + bonus)
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> h(n);
  ll zero=0;
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for(ll i=0;i<101;i++) {
    for(ll j=0;j<101;j++) {
      ll th;
      bool flag=true;
      for(ll k=0;k<n;k++) {
        if(h[k]!=0) {
          th=h[k]+abs(x[k]-i)+abs(y[k]-j);
          break;
        }
      }
      for(ll k=0;k<n;k++) {
        if(h[k]!=max(th-(abs(x[k]-i)+abs(y[k]-j)),zero)) {
          flag=false;
          break;
        }
      }
      if(flag) {
        cout << i << " " << j << " " << th << endl;
        return 0;
      }
    }
  }
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n >> m >> l;
  rep(i,0,l)cin >> d[i];
  vector<vector<int> > vec(l);
  rep(i,0,n){
    int a,b;
    cin >> a >> b;
    a--;
    vec[a].pb(b);
  }
  //puts("!!!!!!!!");
  rep(i,0,l){
    sort(all(vec[i]),greater<int>());
  }
  // puts("!!!!!!");

  vi ans;
  rep(i,0,l){
    ll p = min((ll)d[i],(ll)vec[i].sz);
    rep(j,0,p)ans.pb(vec[i][j]);
  }
  
  // puts("!!!!!!");
  sort(all(ans),greater<int>());
  ll p = 0;
  rep(i,0,m)p += ans[i];
  //puts("ans");
  print(p);
  return 0;
}


Measured memory_bytes: 8156
#include<stdio.h>

int main(void)
{
  int a,b;
  int a_345=0;
  int b_345=0;
  scanf("%d %d",&a,&b);

  int temp=0;
  int keta1=0;
  int keta2=0;
  int keta3=0;
  int keta4=0;
  int keta5=0;
  int count =0;

  for(int i=a; i<=b; i++){

    temp = i;
    keta1 = temp%10; temp/=10;
    keta2 = temp%10; temp/=10;
    keta3 = temp%10; temp/=10;
    keta4 = temp%10; temp/=10;
    keta5 = temp%10;
    if((keta1 == keta5)&&(keta2 == keta4)){
      count ++;
    }
//    printf("%d %d %d %d %d ",keta1,keta2,keta3,keta4,keta5);
  }

  printf("%d",count);

    return 0;

}



Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>/*The header <string> and
<string.h> does not contain the useful
function 'memset' and 'memcpy'.*/
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<utility>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#define int long long
using namespace std;
int N,M,X[1010],Y[1010],Z[1010],A[1010],ans;
signed main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)
		cin>>X[i]>>Y[i]>>Z[i];
	for(int i=0;i<8;i++)
	{
		for(int j=0;j<N;j++)
		{
			A[j]=0;
			if(i%2)
				A[j]+=X[j];
			else	A[j]-=X[j];
			if((i/2)%2)
				A[j]+=Y[j];
			else	A[j]-=Y[j];
			if((i/4)%2)
				A[j]+=Z[j];
			else	A[j]-=Z[j];
		}
		sort(A,A+N,greater<int>());
		int sc=0;
		for(int j=0;j<M;j++)
			sc+=A[j];
		ans=max(ans,sc);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define JUDGE(x) (strstr(change, x))
int main(){
  int i, j;
  char str[100] = {}, change[100] = {};
  while(gets(str) != NULL){
    for(i = 0;i < 26;i++){
      for(j = 0;j < strlen(str);j++){
	if(str[j] >= 'a' && str[j] <= 'z')
	  change[j] = str[j] + i > 'z' ? str[j] + i - 26 : str[j] + i;
	else 
	  change[j] = str[j];
      }
      if(JUDGE("this") || JUDGE("the") || JUDGE("that")){
	puts(change);
	break;
      }
    }
    memset(str, '\0', sizeof(str));
    memset(change, '\0', sizeof(change));
  }
  return 0;
}

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

using namespace std;

vector<vector<int>> G(8,vector<int>(8));
// vector<bool> visited(8,false);
int ans;
int n, m;


int main(void){
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--,b--;
        G[a][b]++;
        G[b][a]++;
    }
    
    ans = 0;
   
   vector<int> ord(n);
   for (int i = 0; i < n; i++) ord[i] = i;
   
   do{
       
       if (ord[0] != 0) break;
       
       bool check = true;
       
       for (int i = 0; i +1 < n; i++){
           int from = ord[i];
           int to = ord[i+1];
           
           if (G[from][to]) continue;
           else check = false;
       }
       
       if (check) ans++;
       
   } while (next_permutation(ord.begin(),ord.end()));
    
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

/*void out(ll x,ll y, ll n){
  	rep(i, n){
      	cout<<(x+i)%n<<" "<<(y+i)%n<<", ";
    }
}*/

int main(){
    ll N, M;
    cin>>N>>M;
    if(N%2==0)N--;
    ll A=1; 
    ll B=(N+1)/2;
    ll C=N;
    ll D=B+1;
    ll Count=0;
    while(B-A>0){
        cout<<A<<" "<<B<<endl;
      	//out(A,B, N);
      	//cout<<endl;
        Count++;
        if(Count==M)return 0;
        A++; B--;
    }
    while(C-D>0){
        cout<<D<<" "<<C<<endl;
      	//out(C,D, N);
      	//cout<<endl;
        Count++;
        if(Count==M)return 0;
        C--; D++;
    }
}

Measured memory_bytes: 3640
from math import ceil
N=int(input())
a=list(map(int,input().split()))
c=0
e=0
d=0

for i in range(N):
    if a[i]%4==0:
        c=c+1
    if a[i]%2==1:
        e=e+1
    else:
        d=d+1

if (d-c)==0:
    if e<=c+1:
        print("Yes")
    else:
        print("No")
else:
    if e+1<=c+1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 62576
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

int N;

int main(){
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int ans = 10000000000000;

	for (int i = 0; i < N; i++) {
		int tmpans = 0;
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			tmpans++;
		}
		ans = min(ans, tmpans);

	}
	print(ans);





	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <climits>
#include <cstdlib>
using namespace std;
class card
{
public:
    char pic;
    int num;
};
void bubbleSort(vector<card> &c,int n)
{
    for(int i = 0;i < n;i++)
    {
        for(int j = n - 1;j > i;j--)
        {
            if(c.at(j).num < c.at(j - 1).num)
            {
                card t = c.at(j - 1);
                c.at(j - 1) = c.at(j);
                c.at(j) = t;
            }
        }
    }
}
void selectionSort(vector<card> &c,int n)
{
    for(int i = 0;i < n;i++)
    {
        int minj = i;
        for(int j = i;j < n;j++)
        {
            if(c.at(j).num < c.at(minj).num)
            {
                minj = j;
            }
        }
        card t = c.at(i);
        c.at(i) = c.at(minj);
        c.at(minj) = t;
    }
}
bool checkStable(vector<card> b,vector<card> a)
{
    string s;
    int n = 0;
    for(int i = 0;i < a.size();i++)
    {
        if(n == 0)
        {
            n = a.at(i).num;
            s = a.at(i).pic;
        }
        else if(n == a.at(i).num)
        {
            s += a.at(i).pic;
        }
        else
        {
            string t;
            for(int j = 0;j < b.size();j++)
            {
                if(b.at(j).num == a.at(i - 1).num)
                {
                    t += b.at(j).pic;
                }
            }
            if(s != t)
            {
                return false;
            }
            s.clear();
            s = a.at(i).pic;
            n = a.at(i).num;
        }
    }
    return true;
}
int main()
{
    int n;
    cin >> n;
    vector<card> b,c;
    for(int i = 0;i < n;i++)
    {
        string s;
        card t;
        cin >> s;
        t.pic = s.at(0);
        t.num = atoi(&s.at(1));
        b.push_back(t);
    }
    copy(b.begin(),b.end(),back_inserter(c));
    bubbleSort(c,n);
    for(int i = 0;i < n;i++)
    {
        cout << c.at(i).pic << c.at(i).num;
        if(i + 1 != n)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
    if(checkStable(b,c))
    {
        cout << "Stable";
    }
    else
    {
        cout << "Not stable";
    }
    cout << endl;
    c.clear();
    copy(b.begin(),b.end(),back_inserter(c));
    selectionSort(c,n);
    for(int i = 0;i < n;i++)
    {
        cout << c.at(i).pic << c.at(i).num;
        if(i + 1 != n)
        {
            cout << " ";
        }
        else
        {
            cout << endl;
        }
    }
    if(checkStable(b,c))
    {
        cout << "Stable";
    }
    else
    {
        cout << "Not stable";
    }
    cout << endl;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll n; cin >> n;
    ll ans = 1;
    vector <ll> prime_cnt(n + 1);
    rep(i, n + 1){
        if (i == 0) continue;
        auto res = prime_factorize(i);
        for (auto p: res){
            prime_cnt.at(p.first) += p.second; 
        }
    }

    rep(i, n + 1){
        ans = ans * (prime_cnt.at(i) + 1) % 1000000007;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] nq = RIntAr();
            string s = RSt();

            int cnt = 0;
            bool aFlg = false;

            int[] cnts = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'C' && aFlg == true)
                {
                    cnt++;
                    aFlg = false;
                }
                cnts[i] = cnt;

                if (s[i] == 'A') aFlg = true; else aFlg = false;
            }

            for (int k = 0; k < nq[1]; k++)
            {
                int[] vs = RIntAr();
                Console.WriteLine(cnts[vs[1] - 1] - cnts[vs[0] - 1]);
            }

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 17940
import java.util.Scanner;
public class Main
{
   public static void main(String[] args)
   {
      Scanner scanner = new Scanner(System.in);

      int num1 = scanner.nextInt();
      int num2 = scanner.nextInt();
      int num3 = scanner.nextInt();
      int num4 = scanner.nextInt();
      int num5 = scanner.nextInt();
      
      if (num1 == 0)
      {
         System.out.println(1);
      }
      
      else if (num2 == 0)
      {
         System.out.println(2);
      }
      
      else if (num3 == 0)
      {
         System.out.println(3);
      }
      
      else if (num4 == 0)
      {
         System.out.println(4);
      }
      
      else
      {
         System.out.println(5);
      }
   }
}

Measured memory_bytes: 35728
# abc057 B
n, m = gets.split.map(&:to_i)
ab = n.times.map {
  gets.split.map(&:to_i)
}
cd = m.times.map {
  gets.split.map(&:to_i)
}

ab.each do |(a,b)|
  ind = 1
  min = (a - cd[0][0]).abs + (b - cd[0][1]).abs
  cd.each.with_index(1) do |(c,d), i|
    if min > ( r = ( (a - c).abs + (b - d).abs ) )
      min = r
      ind = i
    elsif min == r
      ind = i if i < ind
    end
  end
  p ind
end



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


int main(){
	LL a, b;cin >> a >> b;
    LL ans = 1;
	if(a<=0&&0<=b) {
		cout << "Zero" << endl;
		return 0;
	}
	if(0<a||(b-a)%2!=0) {
		cout << "Positive" << endl;
		return 0;
	}
	if((b-a)%2==0){
		cout << "Negative" << endl;
		return 0;
	}	
	return 0;
}












Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
bool fail;
int main(){
	cin >> n;
	rep(i,n){
		int a; cin >> a;
		if(a%2 == 0 && a%3 != 0 && a%5 != 0) fail = 1;
	}
	puts(fail?"DENIED":"APPROVED");
}

Measured memory_bytes: 256
X = int(input())

if 400<=X<=599:
    print('8')
elif 600<=X<=799:
    print('7')
elif 800<=X<=999:
    print('6')
elif 1000<=X<=1199:
    print('5')
elif 1200<=X<=1399:
    print('4')
elif 1400<=X<=1599:
    print('3')
elif 1600<=X<=1799:
    print('2')
else:
    print('1')

Measured memory_bytes: 9148
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int h, w;
char c[1010][1010];
int memo[1010][1010];
queue<P> que;
int f[] = { 0,1,0,-1 };
int g[] = { 1,0,-1,0 };
signed main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> c[i][j];
			if (c[i][j] != '#')memo[i][j] = INF;
		}
	}
	rep(i, h) {
		rep(j, w) {
			if (c[i][j] == '#')que.push(make_pair(i, j));
		}
	}
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		rep(i, 4) {
			int nh = p.first + f[i], nw = p.second + g[i];
			if (nh < 0 || h <= nh || nw < 0 || w <= nw || memo[nh][nw] != INF)continue;
			memo[nh][nw] = memo[p.first][p.second] + 1;
			que.push(make_pair(nh, nw));
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, memo[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 19380
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
INF=10**9+7
ans=0
for i in range(60):
    o=0
    for j in range(n):
        if a_list[j]%2==0:
            o+=1
        a_list[j]=a_list[j]>>1
    t=o*(n-o)
    ans=(ans+t*2**i)%INF
print(ans)

    


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

bool is_prime(int n){
    if(n < 2){
        return false;
    }
    for(int i = 2; i < (int)sqrt(n) + 1; i++){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int N; cin >> N;
    vector<ll> a(N,0);
    for(int i = 0; i < N; i++) cin >> a.at(i);
    
    vector<ll> s(N+1,0);
    map<ll,ll> nums;
    for(int i = 0; i < N; i++) s.at(i+1) = s.at(i) + a.at(i);
    for(int i = 0; i < N+1; i++) nums[s.at(i)]++;
    
    ll ans = 0;
    for(auto it : nums){
        ll num = it.second;
        ans += num * (num - 1) / 2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int sum=0;
  int count=0;
  while(sum<b)
  {
    sum+=(a-1);
    count++;
  }
  if((b-1)%(a-1)==0)
    cout<<count-1;
  else
    cout<<count;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

struct Point{
	double x;
	double y;
};

void koch(double d,struct Point a,struct Point b){
	
	if(d==0){
		return;
	}
	
	struct Point s,t,u;
	
	s.x=(2*a.x+b.x)/3;
	s.y=(2*a.y+b.y)/3;
	t.x=(a.x+2*b.x)/3;
	t.y=(a.y+2*b.y)/3;
	u.x=(t.x-s.x)*cos(M_PI*60/180)-(t.y-s.y)*sin(M_PI*60/180)+s.x;
	u.y=(t.x-s.x)*sin(M_PI*60/180)+(t.y-s.y)*cos(M_PI*60/180)+s.y;

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

int main(){

	int n;
	scanf("%d",&n);
	
	struct Point a,b;
	a.x=0;
	a.y=0;
	b.x=100;
	b.y=0;
	
	printf("%.8lf %.8lf\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8lf %.8lf\n",b.x,b.y);
	
	return 0;

}


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


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

    string s;
    cin >> s;
    int count = 0, ans = 0;
//    bool flag = false;
    for (char c : s) {
        if (c == 'R') {
            count += 1;
            ans = max(ans, count);
        } else {
            count = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;

namespace 水色コーダーに俺はなった{
    class Inonoa{

        /* ここに書け */
        static void Main(){
            long cost_yasu = long.MaxValue;
            long[] nmx = ILongs();

            int n = (int)nmx[0];
            int m = (int)nmx[1];
            long x = nmx[2];

            long[][] ca_ij = ILongLongs(n);

            long[][] results = new long[2<<n][];
            for(int i=0;i<results.Length;i++){
                results[i] = new long[m+1];
            }

            for(int i=0;i< (2<<n); i++){
                for(int j=0;j<n;j++){
                    if(((i>>j)&1)==1){
                        for(int k=0;k<m;k++){
                            results[i][k+1] += ca_ij[j][k+1];
                        }
                        results[i][0] += ca_ij[j][0];
                    }
                }
                bool enough = true;
                for(int k=0;k<m;k++){
                    if(results[i][k+1]<x){
                        enough = false;
                        break;
                    }
                }
                if(enough){
                    if(results[i][0]<cost_yasu){
                        cost_yasu = results[i][0];
                    }
                }
            }

            WriteLine(cost_yasu<long.MaxValue ? cost_yasu : -1);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

int sum(vector<int> A){
    int s = 0;
    for(int x : A) s += x;
    return s;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int vote = sum(A) / (4 * M);
    if(sum(A) % (4 * M) != 0) vote ++;
    int count = 0;
    for(int x : A){
        if(x >= vote) count ++;
    }
    
    if(count < M) cout << "No" << endl;
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

vi vec = {111,222,333,444,555,666,777,888,999};
rep(i,9) {
    if(vec[i] >= N) {
        cout << vec[i] << endl;
        return 0;
    }
}

return 0;
}

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

using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


//強連結を知りたいとき、深さを知りたいとき、他
int max_len;
struct DirectedGraph{
    int V;

    vector<vector<int>> to;
    vector<vector<int>> from;

    vector<int> vs;
    vector<int> depth;
    vector<bool> used;
    vector<int> cmp;

    void dfs(int v){
        used[v]=true;
        for(auto t:to[v]) if(!used[t]) dfs(t);
        vs.push_back(v);//帰りがけ
    }
    //k:始点,rdfsがkに戻る→強連結成分
    int r_dfs(int v,int k){
        int ret=0;
        used[v]=true;
        cmp[v]=k;
        for(const auto t:from[v]){
            if(!used[t]) r_dfs(t,k);
            depth[v]=max(depth[v],depth[t]+1);
        }
    }
    DirectedGraph(int V) : V(V),
        to(vector<vector<int>>(V)),
        from(vector<vector<int>>(V)),
        cmp(vector<int>(V)),
        depth(vector<int>(V))
        {}
    
    void add_edge(int from_,int to_){
        to[from_].push_back(to_);
        from[to_].push_back(from_);
    }


    //強連結成分:任意の2頂点を行き来できる部分グラフ
    //順方向帰りがけdfsと逆方向行き止まりまでdfs
    //強連結成分分解O(|V|+|E|)
    int scc_num=-1;
    //scc_num:強連結成分の個数を返す
    int scc(){
        used=vector<bool>(V,false);
        vs.clear();
        for(int v=0;v<V;v++) if(!used[v]) dfs(v);
        used=vector<bool>(V,false);
        scc_num=0;
        for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]){
            max_len=max(max_len,r_dfs(vs[i],scc_num++));
        }
        return scc_num;
    }

    bool isCyclic(){
        return (scc_num!=V);
    }

    //sccの後潰してトポロジカル順序のグラフを作る
    DirectedGraph makeTopologicalGraph(){
        DirectedGraph TG(scc_num);
        rep(s,V) for(auto t:to[s]){
            if(cmp[s]!=cmp[t]) TG.add_edge(cmp[s],cmp[t]);
        }
        return TG;
    }
};


int main(){
    int n;
    cin>>n;
    DirectedGraph g(n*n+1);

    rep(i,n){
        int a[n-1];
        rep(j,n-1){
            cin>>a[j];
            a[j]--;
        }
        //n進数2桁的なノリ
        rep(j,n-1) a[j]=min(i,a[j])*n+max(i,a[j]);
        rep(j,n-2) g.add_edge(a[j],a[j+1]);
    }
    int s=g.scc();
    if(g.isCyclic()){
        cout<<-1<<endl;return 0;
    }
    int ans=0;
    for(auto x:g.depth){ans=max(ans,x);}cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 92144
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
const double eps=0.00000001;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
map<ll,ll> prime_factor(ll x){
    map<ll,ll> m;
    ll sq=(ll)sqrt(x) + 1;
    vector<ll> v_prime=vectorprime(sq);
    
    ll tmp=x;
    rep(i,sz(v_prime)){
        ll count=0;
        while(tmp % v_prime[i] == 0){
            tmp /= v_prime[i];
            count++;
        }
        if(count != 0) m[v_prime[i]]=count;
        if(tmp==1) break;
    }
    
    if(tmp != 1) m[tmp]=1;
    return m;
}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    map<ll,ll> m=prime_factor(N);
    for(auto it=m.bg;it!=m.ed;it++){
        ll tmp=(it->b);
        ll i=0;
        while(((1+i)*i)<=2*tmp){
            i++;
        }
        ans+=(i-1);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 4496
# -*- coding:utf-8 -*-
"""
.....A
B.....
を連結させればABは一個増える

(例)
...A
B...
B..A
が一個ずつある時、

...A B..A B...
とやる2が正解で、

...A B... B..A
とやると1で不正解

"""
def solve():
    N = int(input())

    ans = 0
    b_start = 0
    a_end = 0
    ryouhou = 0
    for i in range(N):
        s = input()
        ans += s.count("AB")
        
        if s[0] == "B" and s[-1] == "A":
            ryouhou += 1
        elif s[0] == "B":
            b_start += 1
        elif s[-1] == "A":
            a_end += 1
    
    # まず、ryouhouを可能な限りつなげる
    if ryouhou > 0:
        ans += ryouhou - 1

        # 両端にb_startとa_endをくっつけれるならそうする
        if b_start > 0:
            b_start -= 1
            ans += 1
        if a_end > 0:
            a_end -= 1
            ans += 1
    
    # 残ったb_startとa_endでABを作る
    ans += min(b_start, a_end)

    print(ans)
   
        

if __name__ == "__main__":
    solve()


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int f(int x) {
  int ret = 0;
  while (x) {
    x %= __builtin_popcount(x);
    ++ret;
  }
  return ret;
}

int binpow(long long b, long long e, int mod) {
  if (!e) return 1;
  if (e%2) return b*binpow(b, e-1, mod)%mod;
  return binpow(b*b%mod, e/2, mod);
}

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') ++cnt;
  }
  int x1 = 0, x0 = 0;
  for (int i = 0; i < n; ++i) {
    (x0 *= 2) %= (cnt+1);
    if (cnt > 1) (x1 *= 2) %= (cnt-1);
    if (s[i] == '0') continue;
    (x0 += 1) %= (cnt+1);
    if (cnt > 1) (x1 += 1) %= (cnt-1);
  }
  for (int p, x, i = 0; i < n; ++i) {
    if (s[i] == '1') {
      if (cnt == 1) {
	cout << "0\n";
	continue;
      }
      p = binpow(2, n-i-1, cnt-1);
      x = (x1-p+cnt-1) % (cnt-1);
    } else {
      p = binpow(2, n-i-1, cnt+1);
      x = (x0+p) % (cnt+1);
    }
    cout << 1+f(x) << "\n";
  }
}

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


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
main()
{
 map<int,int>mp;
    mp[1]=1;mp[2]=2;mp[3]=1;mp[5]=1;mp[7]=1;mp[8]=1;mp[10]=1;mp[12]=1;mp[4]=3;mp[6]=3;mp[9]=3;mp[11]=3;
    int x,y;cin>>x>>y;
    if(mp[x]==mp[y])puts("Yes");
      else puts("No");
    }

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n];
        boolean isSame = false;
        boolean isUpperValue = false;
        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
            if(a[i] > k){
                isUpperValue = true;
            }else if(a[i] == k){
                isSame = true;
                break;
            }
        }
        System.out.println((isSame || isUpperValue && k % gcd(a) == 0) ? "POSSIBLE" : "IMPOSSIBLE");
    }
    
    private static long gcd(long a, long b){
        while (b > 0)
        {
            long temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }

    
    private static long gcd(long[] input){
        long result = input[0];
        for(int i = 1; i < input.length; i++)
        {
            result = gcd(result, input[i]);
        }
        return result;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
            return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int l,r,d;
  cin >> l >> r >> d;

  int ans=0;
  for(int i=l;i<=r;i++) if(i%d==0)  ans++;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;

inline int read(){
	int x;
	scanf(" %d",&x);
	return x;
}

int n,m,ans;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	ans=(1900*m+100*(n-m));
	forr(i,0,m){
		ans*=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  ll a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a);
  vector<ll> t(b);
  for (int i = 0; i < a; i++)
    cin >> s[i];
  for (int i = 0; i < b; i++)
    cin >> t[i];
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());

  ll que;
  for (int i = 0; i < q; i++) {
    vector<ll> yontori(6, INFL);
    cin >> que;
    auto its = lower_bound(s.begin(), s.end(), que);
    auto itt = lower_bound(t.begin(), t.end(), que);
    // cout << que << endl;
    yontori[0] = max(*its - que, *itt - que);  // ずっと右
    yontori[1] =
        (abs(*its - que) * 2 + abs(*(itt - 1) - que));  // 右のS行って左のT
    yontori[2] =
        (abs(*(its - 1) - que) * 2 + abs(*itt - que));  // 左のS行って右のT
    yontori[3] = max(abs(*(its - 1) - que), abs(*(itt - 1) - que));  // ずっと左
    yontori[4] =
        (abs(*itt - que) * 2 + abs(*(its - 1) - que));  // 右のT行って左のS
    yontori[5] =
        (abs(*(itt - 1) - que) * 2 + abs(*its - que));  // 左のT行って右のS

    if (its == s.end()) {  // 右にsがない
      yontori[0] = INFL;
      yontori[1] = INFL;
      yontori[5] = INFL;
    }
    if (itt == t.end()) {  // 右にtがない
      yontori[0] = INFL;
      yontori[2] = INFL;
      yontori[4] = INFL;
    }
    if (its == s.begin()) {  // 左にsがない
      yontori[2] = INFL;
      yontori[3] = INFL;
      yontori[4] = INFL;
    }
    if (itt == t.begin()) {  // 右にsがない
      yontori[1] = INFL;
      yontori[3] = INFL;
      yontori[5] = INFL;
    }

    // cout << yontori[0] << " " << yontori[1] << " " << yontori[2] << " "
    //      << yontori[3] << " " << yontori[4] << " " << yontori[5] << endl;

    cout << *min_element(yontori.begin(), yontori.end()) << endl;
    // return 0;
  }
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string t; cin >> t;
  int n = t.size();
  rep(i,n){
    if(t[i] == '?')t[i] = 'D';
  }
  cout << t;
  
  return 0;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i = 0; i < n; i++)
#define for1(i,n) for(int i = 1; i <= n; i++)
#define ford(i,n) for(int i = n-1; i >= 0; i--)
#define fore(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;


const  int MAXn= 3e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;


int main(){
        int n,m;
        cin>>n>>m;
        vi arr[100005];
        forn(i,n){
			int a,b;
			cin>>a>>b;
			arr[a].pb(b);
    }
    ll ans=0;
    priority_queue<int> q;
    for1(i,m){
		for(auto x: arr[i])
			q.push(x);
			if(!q.empty()){
				ans += q.top();
				q.pop();
			}
		}
	cout<<ans;
}	


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

int main(){
  vector<int> v(5);
  rep(i,5)cin>>v.at(i);
  sort(v.begin(),v.end());
  int k; cin>>k;
  int d=v.at(4)-v.at(0);
  if(d>k)cout<<":(";
  else{cout<<"Yay!";}
}

Measured memory_bytes: 256
/*
Kaushal Jalan
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop int t;cin>>t;while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define mod 1000000007
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
   // c_p_c();
    int n;
    cin>>n;
    int f=0;
    while(n)
    {
        int d=n%10;
        if(d==7)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string max(string a, string b){
    
    if(a.size() > b.size()) return a;
    else if(a.size() < b.size()) return b;

    for(int i = 0; i < a.size(); i++){
        if(a[i] > b[i]) return a;
        else if(a[i] < b[i]) return b;
    }

    return a;
}

int main(){

    while(1){
        int w, h; cin >> w >> h;
        if(w == 0 || h == 0) break;

        vector<vector<char> > matrix(h, vector<char> (w));
        vector<vector<string> > dp(h, vector<string> (w, ""));
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> matrix[i][j];
            }
        }

        //dp

        string ans = "";
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(matrix[i][j] < '0' || '9' < matrix[i][j]) continue;

                if(i == 0 && j == 0){ 
                    dp[i][j] = matrix[i][j];
                    if(dp[i][j] == "0") dp[i][j] = "";
                    ans = max(ans, dp[i][j]);
                    continue;
                }

                if(i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j] + matrix[i][j]);
                if(j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1] + matrix[i][j]);

                if(dp[i][j] == "0") dp[i][j] = "";

                ans = max(ans, dp[i][j]);
            }
        }

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


Measured memory_bytes: 3268
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int a;
    cin>>a;
    if(a%2==0){
        cout<<a<<endl;
    }
    else{
        cout<<a*2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256