akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)
vi adj[100005];
int depth[100005];
int n,m;
int mx = 0;

int dfs(int u){
    if (depth[u]!=-1)return depth[u];
    int ans = 0;
    for (int v : adj[u]){
        ans = max(ans,1 + dfs(v));
    }
    mx = max(ans,mx);
    return depth[u]=ans;
}
void solve(){
	//write here
    memset(depth,-1,sizeof(depth));
    cin>>n>>m;
    rep(i,0,m){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
    }
    for (int i = 1 ; i <=n ; i++){
        dfs(i);
    }
    cout<<mx<<endl;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 11400
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vll a, suma;
vvll dp, flag;

ll f(ll l, ll r) {
  if (flag[l][r]) return dp[l][r];
  flag[l][r] = 1;
  if (l==r) return 0;
  ll fans = HIGHINF;
  rep(m, l, r) chmin(fans, f(l, m) + f(m+1, r));
  return dp[l][r] = fans + suma[r] - suma[l-1];
}

int main() {
  ll n; cin >> n;
  a.resize(n); REP(i, n) cin >> a[i];
  suma.resize(n+1, 0); REP(i, n) suma[i+1] = suma[i] + a[i];
  dp.resize(n+1, vll(n+1, 0)); flag.resize(n+1, vll(n+1, 0));
  cout << f(1, n) << endl;
  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
long long a,b,x,s,e;
int main()
{
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0) s=a/x;
    else s=a/x+1;
    e=b/x;
    printf("%lld",e-s+1);
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int64_t L = static_cast<int64_t>(S.length());
  reverse(S.begin(), S.end());
  vector<int64_t> N(L + 1, 0);
  unordered_map<int64_t, int64_t> m;
  int64_t d = 1;
  m[0] = 1;
  for (int64_t i = 1; i <= L; ++i) {
    const int64_t v = static_cast<int64_t>(S[i - 1] - '0');
    N[i] = (N[i - 1] + d * v) % 2019;
    if (m.find(N[i]) == m.end()) {
      m[N[i]] = 1;
    } else {
      ++m[N[i]];
    }
    d *= 10;
    d %= 2019;
  }
  int64_t result = 0;
  for (auto a : m) {
    result += a.second * (a.second - 1) / 2;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 5212
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s = sc.next();

		char now = s.charAt(0);
		int count = 0;
		for (int i = 1; i < s.length(); i++) {
			if (s.charAt(i) != now) {
				count++;
				now = s.charAt(i);
			}
		}
		System.out.println(count);

	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

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

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

  int *arr = new int[n];

  rep(i, n) {
    cin >> arr[i];
  }

  sort(arr, arr + n);
  reverse(arr, arr + n);

  int a = 0;
  int b = 0;

  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      a += arr[i];
    } else {
      b += arr[i];
    }
  }

  cout << a - b << endl;

  return 0;
}


Measured memory_bytes: 256
length_and_index = list(map(int,input().split(' ')))
input_str = list(input()[:length_and_index[0]])
input_str[length_and_index[1]-1] = chr(ord(input_str[length_and_index[1]-1])+32)
out = "".join(str(x) for x in input_str)
print(out)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

double Minkowski(int n, double x[100], double y[100], int p)
{
	double sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += pow(fabs(x[i] - y[i]),p);
	}
	sum = pow(sum, double(1) / p);
	return sum;
}

double Chebyshev(int n, double x[100], double y[100])
{
	double max = fabs(x[0] - y[0]);
	for (int i = 0; i < n; i++)
	{
		if (max <= fabs(x[i] - y[i])) max = fabs(x[i] - y[i]);
	}
	return max;
}

int main()
{
	int n;
	double x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> y[i];
	}
	cout << setprecision(6) << fixed
		<< Minkowski(n, x, y, 1) << endl
		<< Minkowski(n, x, y, 2) << endl
		<< Minkowski(n, x, y, 3) << endl
		<< Chebyshev(n, x, y) << endl;

}


Measured memory_bytes: 3476
import sys, math
from collections import defaultdict
from copy import deepcopy
import itertools
input = sys.stdin.readline
# 文字列の場合は普通のinput()を使うか下を使う
# input = sys.stdin.readline().rstrip()

X = int(input())
x = X % 100
#print('x={}'.format(x))
A = [0] * 6
for i in range(5, 0, -1):
    A[i] = x // i
    x -= A[i] * i

#print('A={}'.format(A))

n = 0
for i, a in enumerate(A):
    n += i * a
v = sum(A)

if (X - n) % 100 != 0 or (X - n) // 100 < v:
    print(0)
else:
    print(1)

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

int main() {
    int a = 0;
    char s[4];
    char p[] = "+";
    int  P = (int)p[0];
    cin >> s;

    for(int i = 0; i<4; ++i){
    if((int)s[i] == P)
    a++;
    else
    a--;
}
    cout << a << "\n";
    return 0;
}

Measured memory_bytes: 256
// 2019/06/26
// AtCoder Beginner Contest 069 - A

import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // Input
        int n = sc.nextInt();
        int m = sc.nextInt();

        // Calc
       int ans = (n-1) * (m-1);
       // Output
       System.out.println(ans);
    }
}

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

int main() {
  string s;
  cin>>s;
  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

#define MAX 25

int main()
{
    int N, M;
    bool t[MAX][MAX];
    while (cin >> N, N) {
        int x, y;
        memset(t, 0, sizeof(t));
        for (int i = 0; i < N; i++) {
            cin >> x >> y;
            t[y][x] = 1;
        }
        cin >> M;
        char d;
        int num;
        
        map<char, int> dir = {{'W', 0}, {'S', 1}, {'E', 2}, {'N', 3}};
        const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

        x = y = 10;
        
        for (int i = 0; i < M; i++) {
            cin >> d >> num;
            for (int j = 0; j < num; j++) {
                x += dx[dir[d]], y += dy[dir[d]];
                if (t[y][x]) t[y][x] = 0;                
            }
        }
        
        bool rem = 0;
        for (int i = 0; i <= 20; i++) {
            for (int j = 0; j <= 20; j++) {
                if (t[i][j]) {
                    rem = 1;                    
                }
            }
        }
        cout << (rem ? "No" : "Yes") << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N, M; cin >> N >> M;
  
  cout << (1900*M+100*(N-M))*(1<<M) << endl;

}


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

int main() {
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N);

    ll before=0, after=0;
    for (ll i=0; i<N; ++i) {
        cin >> after;
        t.at(i)=after-before;
        before=after;
    }
    ll sum=0;
    for (ll i=0; i<N; ++i) {
        sum += min(T, t.at(i));
    }
    cout << sum+T << endl;
    return 0;
}


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよいです

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;  // A[i] がすべて偶数かどうかを判定するフラグ
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;  // 奇数があったらフラグを立てる
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; i++) {
            A[i] /= 2;
        }
        res++;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

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

int main(){
    int a, b, c;

    cin >> a >> b >> c;

    if(a == b && b == c){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

    
    

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a;
  cin >> a;
  ll ans = a + a * a + a * a * a;
  cout << ans << endl;

  return 0;
}


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

int main(){

	int i, n, s[1000];
	int sum;
	double mean, powsum;


	while(1){

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


		mean = (double)sum / (double)n; 
		powsum = 0;
		for(i=0; i<n; i++ ){
			powsum += pow( s[i]-mean, 2);
		}


		printf( "%f\n", sqrt(powsum/n) );

	}

	return 0;

}

Measured memory_bytes: 636
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll M =1e9+7;
const int N = 1e5+7;



void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

    
int main()
{
    int x;
    scf(x);
    
    if(x%7==0)
    x/=7;
    
    if(x%2==0||x%5==0)
    prin(-1);
    
    else
    {
        ll m=9*x,v=1,f=1;
        
        rep(i,1,x+1)
        {
            v*=10; 
            
            if(v%m==1)
            {prin(i);
            f=0;
            break;}

            v%=m;
        }

        if(f)
        prin(-1);
        
    }
}

Measured memory_bytes: 3812
import sys
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        k = n-i-j
        if i*10000+j*5000+k*1000==y:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

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

long long gcd(long long x, long long y)
{
    if (x < y)
        swap(x, y);
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

int main()
{
    long long a, b;
    cin >> a >> b;
    long long g = gcd(a, b);
    cout << a * b / g << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
using namespace std;

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
#define adde(x, y) { e[++z].v = y; e[z].nxt = h[x]; h[x] = &e[z]; }
#define addrev(u, v) { adde(u, v); adde(v, u); }
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define FO(x) { freopen("#x.in", "r", stdin); freopen("#x.out", "w", stdout); }
inline int read() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x >= 0
{
	if(x < 10)
	{
		putchar(x + '0');
		return ;
	}
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 510
int n;
bool zhi(int x)
{
	for(int i = 2; i <= sqrt(x); i ++)
		if(x % i == 0)
			return false;
	return true;
}
int ss[2 * maxn], tot;
LL a[maxn][maxn];
inline LL gcd(LL x, LL y)
{
	return x == 0 ? y : gcd(y % x, x);
}
inline LL lcm(LL x[])
{
	LL ret = 0;
	for(int i = 0; i < 4; i ++)
		if(x[i])
			ret = ret == 0 ? x[i] : ret / gcd(ret, x[i]) * x[i];
	return ret;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	if(n == 2)
		return cout << "4 7\n23 10" << endl, 0;
	for(int i = 2; tot <= 2 * n + 10; i ++)
		if(zhi(i))
			ss[++tot] = i;
	for(int k = 2; k <= 2 * n; k += 2)
		for(int i = max(1, k - n); i <= min(n, k - 1); i ++)
			a[i][k - i] = ss[k / 2];
	int u = n & 1 ? n - 1 : n - 2;
	int cur = n + 1;
	for(int k = u; k >= -u; k -= 2, cur ++)
		for(int i = max(1, 1 - k); i <= min(n, n - k); i ++)
			a[i][i + k] *= ss[cur];
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			if(i + j & 1)
			{
				LL tmp[4] = {a[i - 1][j], a[i][j - 1], a[i + 1][j], a[i][j + 1]};
				a[i][j] = lcm(tmp) + 1;
			}
	for(int i = 1; i <= n; i ++)
	{
		for(int j = 1; j <= n; j ++)
			cout << a[i][j] << ' ';
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		map<int,int>cr,wr;
		int n , k;
		cin >> n >> k;
		int ca =0 ;
		for(int i =0 ;i < k;i++){
			int x ;
			string s;
			cin>>x>>s;
			if(s=="AC"){
				cr[x]++;
				if(cr[x]==1)ca++;
			}
			else{
				if(cr[x]==0)wr[x]++;
			}

		}
		int w= 0;
		for(auto i : wr){
			if(cr[i.fi])w+=i.se;
		}
		cout <<ca<<" "<<w<<endl;
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

Measured memory_bytes: 8064
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("avx")
 
// timus 219263UI
//    (><)
 
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <assert.h>  
#include <string.h>
#include <algorithm>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
 
#define y1 needtrainharder
#define f first
#define s second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define alln(x, y) x, x + y
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s) if(fopen(task".in", "r"))freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"
 
const int inf = 1e9 + 5;  
const ll infll = 1e18 + 5ll;  
const long double eps = 1e-9;
const int maxn = 1e5 + 100;
const ll maxlog = 21;
const int P = 97;
const int mod = 1e9 + 7;   

string s;
map<char,bool> cnt;

int main() {
  file(task); 
  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba")
    cout << -1, gg;
  char ch = '?';
  for (int i = 0; i < s.sz(); ++i)
    cnt[s[i]] = 1;
  for (char i = 'a'; i <= 'z'; ++i)
    if (cnt[i] == 0) {
      ch = i;
      break;
    }
  if (ch == '?') {
    string t = s, ans;
    next_permutation(all(s));
    for (int i = 0; i < s.sz(); ++i) {
      ans.pb(s[i]);
      if (s[i] != t[i])
        break;
    }
    cout << ans;
  } else {
    cout << s << ch;
  }
  return 0;
}                
/*




*/  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define X first
#define Y second

void read(LL &x)
{
	char c=getchar(); x=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
}

const int N=1000;
int T;
LL n,m;
pair<LL,LL> ex[90][90]; //excellent

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j,k;
	ex[1][0]=make_pair(1,2);
	for (i=1;i<87;i++)
	{
		for (j=0;j<i;j++)
			ex[i+1][j]=make_pair(ex[i][j].Y,ex[i][j].X+ex[i][j].Y);
		ex[i+1][i]=make_pair(ex[i][0].X+ex[i][0].Y,ex[i][0].X+ex[i][0].X+ex[i][0].Y);
	}

	scanf("%d",&T);
	while (T--)
	{
		LL cnt=0;
		read(n); read(m);
		if (n>m) swap(n,m);
		for (k=2;k<=87;k++)
			if (ex[k][0].X>n||ex[k][0].Y>m) break;
		k--;
		for (i=0;i<k;i++)
		{
			if (ex[k][i].X<=n&&ex[k][i].Y<=m)
				cnt+=1+((m-ex[k][i].Y)/ex[k][i].X);
			if (ex[k][i].X<=m&&ex[k][i].Y<=n)
				cnt+=1+((n-ex[k][i].Y)/ex[k][i].X);
		}
		cnt+=k==1&&n>=1&&m>=1;
		cnt+=k==1&&n>=2&&m>=2;
		printf("%d %lld\n",k,cnt%1000000007);
	}
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;


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

	string ans = "No";
	if (a + b >= c) {
		ans = "No";
	} else {
		int64_t hidari = 4 * (a * b);
		int64_t migi = (c - (a + b)) * (c - (a + b));
		if (hidari < migi) {
			ans = "Yes";
		} else {
			ans = "No";
		}
	}

	cout << ans << endl;
}



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

int main(){
  int n, k, d;
  cin >> n >> k;
  vector<int> people(n);
  for(int i=0;i<k;i++){
  	cin >> d;
    vector<int> vec(d);
    for(int j=0;j<d;j++){
      cin >> vec.at(j);
      people.at(vec.at(j)-1)++;
    }
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(people.at(i)==0){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
    


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e17

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll ball[111111], dp[111111][333];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m, k;
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i++){
		cin >> ball[i];
		dp[i][1]=ball[i];
	}
	deque <ii> cur;
	for(int j = 2; j <= k; j++){
		cur.clear();
		for(int i = 1; i <= n; i++){
			while(!cur.empty()){
				if(i-cur[0].fi>m){
					cur.pop_front();
				}
				else{
					break;
				}
			}
			if(i<j){
				dp[i][j]=-INF;
			}
			else{				
				dp[i][j]=cur[0].se+j*ball[i];
			}
			while(!cur.empty()){
				if(dp[i][j-1]>cur[cur.size()-1].se){
					cur.pop_back();
				}
				else{
					break;
				}
			}
			cur.pb(mp(i,dp[i][j-1]));
		}
	}
	ll ans = -INF;
	for(int i = 1; i <= n; i++){
		ans=max(ans,dp[i][k]);
	}
	cout <<ans<<'\n';
	return 0;
}


Measured memory_bytes: 263168
import sys
input = sys.stdin.readline
N, K, Q = map(int, input().split())
a = list(map(int, input().split()))
ta = a + []
res = pow(10, 10)
bs = pow(10, 10)
for x in sorted(set(a)):
  t = [[]]
  for i in range(N):
    if ta[i] == bs:
      if t[-1] != []:
        t.append([])
    else: t[-1].append(a[i])
  tt = []
  for i in range(len(t)):
    t[i].sort()
    for j in range(len(t[i]) - K + 1):
      tt.append(t[i][j])
  #print(tt, t, x)
  if len(tt) < Q: break
  tt.sort()
  res = min(res, tt[Q - 1] - tt[0])
  #print(res, tt, t)
  for i in range(N):
    if a[i] == x:
      ta[i] = bs
  #print(ta, t)
print(res)


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

int main() {
    int H,W;
    cin>>H>>W;
    rep(i,W+2) {
        cout<<"#";
    }
    cout<<endl;
    rep(i,H) {
        string C;
        cin>>C;
        cout<<"#"+C+"#"<<endl;
    }
    rep(i,W+2) {
        cout<<"#";
    }
    cout<<endl;


}

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

using namespace std;

class Watch {
public:
	explicit Watch(int X) : X(X), startA(0), curA(0), startB(X), curB(X), up(true) {}
	int query(int time, int a){
		int cur = calcStart_(a) + (up ? -time : time);
		if(cur <= 0) return 0;
		if(cur >= X) return X;
		return cur;
	}
	int progress(int time){
		if(up){
			curA -= time;
			curB -= time;
			if(curB <= 0){
				startA = startB;
				curA = curB = 0;
			} else if(curA <= 0){
				startA -= curA;
				curA = 0;
			}
		} else {
			curA += time;
			curB += time;
			if(curA >= X){
				startB = startA;
				curA = curB = X;
			} else if(curB >= X){
				startB -= curB - X;
				curB = X;
			}
		}
		up = !up;
	}
private:
	int calcStart_(int a){
		if(a <= startA) return curA;
		if(a >= startB) return curB;
		return curA + a - startA;
	}
private:
	const int X;
	int startA, curA, startB, curB;
	bool up;
};

int main(){
	int X, K;
	while(cin >> X >> K){
		vector<int> times;
		times.push_back(0);
		for(int i=0;i<K;i++){
			int a; cin >> a;
			times.push_back(a);
		}
		times.push_back(1000000007);
		Watch watch(X);
		int timeIdx = 0;
		int Q; cin >> Q;
		for(int i=0;i<Q;i++){
			int t, a; cin >> t >> a;
			while(t >= times[timeIdx+1]){
				watch.progress(times[timeIdx+1] - times[timeIdx]);
				++timeIdx;
			}
			cout << watch.query(t - times[timeIdx], a) << endl;
		}
	}
}

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

#define LIMIT 1000000007 //10^9+7

namespace /* combination.cpp */{
  namespace /* modinv.cpp */{
    namespace /* extGCD.cpp */{
      long long extGCD(long long a, long long b, long long &x, long long &y) {
          if (b == 0) {
              x = 1;
              y = 0;
              return a;
          }
          long long d = extGCD(b, a%b, y, x);
          y -= a/b * x;
          return d;
      }
    }
    long long modinv(long long a, long long p){
      long long x, y;
      extGCD(a, p, x, y);
      return (x>0? x: x+p);
    }
  }
  long long l_fac(long long n){
    if(n<0) return -1;
    long long ans = 1;
    for(long long i=1; i<=n; i++){
      ans *= i;
      ans %= LIMIT;
    }
    return ans;
  }
  long long l_nPr(long long n, long long r){
    long long ans = 1;
    for(long long i=0; i<r; i++){
      ans *= (n-i);
      ans %= LIMIT;
    }
    return ans;
  }
  long long l_nCr(long long n, long long r){
    return l_nPr(n, r) * modinv(l_fac(r), LIMIT) % LIMIT;
  }
}


namespace /* COMfast.cpp */{
  #define COMMAX 1000000 //0.15sで構築可能
  long long fac[COMMAX], finv[COMMAX], inv[COMMAX];
  // テーブルを作る前処理
  void COMinit() {
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < COMMAX; i++){
          fac[i] = fac[i - 1] * i % LIMIT;
          inv[i] = LIMIT - inv[LIMIT%i] * (LIMIT / i) % LIMIT;
          finv[i] = finv[i - 1] * inv[i] % LIMIT;
      }
  }

  // 二項係数計算
  long long COM(int n, int k){
      if (n < k) return 0;
      if (n < 0 || k < 0) return 0;
      return fac[n] * (finv[k] * finv[n - k] % LIMIT) % LIMIT;
  }
}

#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"


int main(){
  COMinit();
  int N,K;cin>>N>>K;
  ll a, b, ans;
  for(int i=1; i<=K; i++){
    a = l_nCr(K-1, i-1);
    //a = COM(K-1, i-1) % LIMIT;
    b = l_nCr(N-K+1, i);
    //b = COM(N-K+1, i) % LIMIT;
    //debug2(a,b);
    ans = a * b % LIMIT;
    cout<<ans<<endl;
  }
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	string s, t;
	cin >> s >> t;

	ll cnt = 0;
	rep( i, (ll)s.length() ) {
		if ( s[i] != t[i] ) {
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m,a,b,c,d,e;
string s,w;

int main(){
	cin >> n >> m >> a >> b;
	
	cout << (n>m?m*a+(n-m)*b:n*a) << endl;
	return 0;
}


Measured memory_bytes: 256
s = input().replace('BC', 'D')
s = s.replace('B', 'C')
l = [x for x in s.split(sep='C') if x != '']
ans = 0
for subs in l:
    numA = 0
    for c in subs:
        if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA

print(ans)

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

#include <cmath>

using namespace std;

int main(void)
{
  int N;
  cin >> N;
  vector<int> v(pow(2,N));
  for(int i = 0; i < pow(2, N); i++) cin >> v[i];

  for(int i = N; i >= 1; --i){
    for(int j = 0; j < pow(2,N-1); j++){
      v[j] = max(v[2*j], v[2*j+1]) - min(v[2*j], v[2*j+1]);
    }
  }

  cout << v[0] << endl;

  return 0;
}

Measured memory_bytes: 1280
# coding: utf-8

input_num = input().split(" ")
a = int(input_num[0])
b = int(input_num[1])
c = int(input_num[2])
k = int(input())

output = 0
maxnum = max([a,b,c])
new_list = [a,b,c]
new_list.remove(maxnum)
for i in new_list:
    output += i

for i in range(k):
    maxnum = maxnum * 2

output += maxnum

print(output)

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

int main() {
	map<int, int> A;
	int N, x;

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

	for (int i = 0; i < N; i++) {
		cout << A[i] <<" ";
	}

	return 0;
}


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

int main(void){
    string s[3]; 
    for(int i=0; i<3; i++){
        cin >> s[i];
    }

    for(int i=0; i<3; i++) cout << s[i][i];
    cout << endl;
}

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

int main() {
  int r, D;
  vector<int> x(2011);
  cin >> r >> D >> x.at(2000);
  for (int i=2000; i<2010; i++) {
    x.at(i+1)=r*x.at(i)-D;
  }
  for (int j=2001; j<2011; j++) {
    cout << x.at(j) << endl;
  }
}


Measured memory_bytes: 3500
'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(' ').map(Number))

  const n = input[0]
  const cards = input[1]
  const sums = [0]
  // 累積和
  for (let i = 0; i < n; i++) {
    sums.push(sums[i] + cards[i])
  }

  let min = Number.MAX_SAFE_INTEGER
  const total = sums[n]
  for (let i = 1; i < n; i++) {
    let tmp = Math.abs(total - sums[i] - sums[i])
    min = Math.min(min, tmp)
  }

  console.log(min)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 37940
import Control.Monad
import Control.Applicative
import System.IO
import Data.List

main = do
  inputs <- getContents
  let xs = read <$> lines inputs :: [Int]
  let three = go xs
  mapM putStrLn $ show <$> three

go :: [Int] -> [Int]
go xs = let
  ys = sort xs
  in take 3 $ reverse ys 

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

int main() {
	int N;
  	int i1, i2, i3, i4;
  
  	cin >> N;

  	i1 = N/1000;
  	i2 = (N - i1 * 1000)/100;
  	i3 = (N - i1 * 1000 - i2 * 100)/10;
  	i4 = N - i1 * 1000 - i2 * 100 - i3 * 10;

  	if ( i2 == i3 && (i1 == i2 || i3 == i4)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
using System;
        using System.Linq;
        using System.Collections.Generic;
        using static System.Math;

        public class Program
        {
            public static void Main(string[] args)
            {
            int num = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int scoreA = 0;
            int scoreB = 0;

            for (int i = 0; i < input.Length ; i++)
            {
                scoreA += input.Max();
                input[Array.IndexOf(input, input.Max())] = 0;
                scoreB += input.Max();
                input[Array.IndexOf(input, input.Max())] = 0;
            }

            Console.WriteLine(scoreA - scoreB);
            }
        }

Measured memory_bytes: 13396
#include <iostream>

using namespace std;

int main() {
    int money[] = { 0, 6000, 4000, 3000, 2000 };
    int s, n;
    for (int i = 0; i < 4; i++) {
        cin >> s >> n;
        cout << money[s] * n << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin>>n>>m;
    ll ans = 0;
    if(n >= 2) {
    	ans += (n * (n - 1)) / 2;
    }
    if(m >= 2) {
    	ans += (m * (m - 1)) /2;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100000000
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)			//counts no of ones in binary representation
#define w(t) 	int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	fast;
	ll n,x,y,z;
	string s,t;
	cin>>s>>t;
	n=s.length();
	ll cnt=0;
	forn(i,n){
		if(s[i]!=t[i])	cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin.get();
	float x=(n-1)*1.0/(k-1); 
	int ans=ceil(x);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::LinkedList;

fn main() {
    let n: usize = read();
    let mut list = LinkedList::new();

    for _ in 0..n {
        let command: String = read();
        match &*command {
            "insert" => {
                let data: i32 = read();
                list.push_front(data);
            },
            "delete" => {
                let data: i32 = read();
                let mid = list.iter().position(|&x| x == data);
                if let Some(mid) = mid {
                    let mut s = list.split_off(mid);
                    s.pop_front();
                    list.append(&mut s);
                }
            },
            "deleteFirst" => {
                list.pop_front();
            },
            "deleteLast" => {
                list.pop_back();
            }
            _ => {},
        }
    }

    println!("{}", list.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(" "));
}

/// 空白まで読み取り指定の型に変換する関数
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 35648
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
#define fir first
#define sec second
typedef long long ll;
////////////////////////////////////////////////////////////

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

	if( s <= "2019/04/30" ) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	ret 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cstdio>
#include <cmath>

using namespace std;

array<int, 5000> need;

int K = 0;
int tmp = 0;
int mid = 0;

bool BisectionMethod()
{
    if (tmp + need[mid] < K) return true;
    else return false;
}

int main()
{
    int N;
    if (scanf("%d%d", &N, &K) < 2) return 0;

    int num = N;
    int ans = 0;

    for (int i = 0; i< N; i++)
    {
        if (scanf("%d", &tmp) < 1) return 0;

        // greater than or equal to K
        // no need
        if (tmp >= K) num--;
        else
        {
            // candidate
            need[ans] = tmp;
            ans++;
        }
    }

    // ascending
    sort(need.begin(), need.begin() + ans);

    tmp = 0;
    while (num >= 2)
    {
        // add in from the bigger one
        tmp += need[num - 1];

        if (need[num - 2] + tmp < K)
        {
            num--;
            continue;
        }

        // need all
        if (need[0] + tmp >= K)
        {
            ans = 0;
            break;
        }

        // find unnecessary numbers
        // bisection method
        int under = 0;
        int upper = num - 2;

        while (under + 1 < upper)
        {
            // Bisection Method
            // [under, upper]
            // to narrow the range
            mid = (under + upper) / 2;

            bool flg = BisectionMethod();

            if (flg) under = mid;
            else upper = mid;
        }

        ans = ans - (num - upper);
        num = upper;
    }
    printf("%d\n", ans);
    return 0;
}

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

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int l, r, d;
	cin >> l >> r >> d;
	
	int L = l;
	l = (l / d);
	r = (r / d);
	if(l*d < L)l++;
	
	cout << r - l + 1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3684
import heapq
# v:頂点数, s:始点, path[i]:[[cost,to]...] i=fromの隣接リスト
def dijkstra(v,s,path):
    inf = float('inf')

    # 距離をinfで初期化
    d = [inf for i in range(v)]
    d[s] = 0

    # sへの距離は0
    q = [[0,s]]
    heapq.heapify(q)

    # 距離が最小の頂点から更新していけば
    # p[1]から行ける
    while q:
        p = heapq.heappop(q)

        # 頂点p[1]までの距離がheapないのp[1]までの距離より小さい場合、continue
        if d[p[1]]<p[0]:
            continue

        # 頂点p[1]から伸びる、全ての辺の距離を確認
        for i in range(len(path[p[1]])):
            # 頂点p[1]から行ける頂点の距離がp[1]までの距離とp[1]からの距離の和より小さい場合 -> 距離を更新し、heapに追加
            if d[path[p[1]][i][1]] > d[p[1]] + path[p[1]][i][0]:
                d[path[p[1]][i][1]] = d[p[1]]+path[p[1]][i][0]
                heapq.heappush(q,[d[path[p[1]][i][1]], path[p[1]][i][1]])
    return d

def path_recovery(e,d,path):
    # 経路
    route = [e]
    # 残りの距離
    a = d[e]
    while a!=0:
        for i in range(len(path[e])):
            if d[path[e][i][1]]+path[e][i][0]==a:
                route.append(path[e][i][1])
                a -= path[e][i][0]
                e = path[e][i][1]
                break
    route.reverse()
    return route

class UnionFind:
    # 初期化
    def __init__(self, n):
        # 根なら-size, 子なら親の頂点
        self.par = [-1] * n
        # 木の高さ
        self.rank = [0] * n

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 異なる集合に属する場合のみ併合
        if x != y:
            # 高い方をxとする。
            if self.rank[x] < self.rank[y]:
                x,y = y,x
            # 同じ高さの時は高さ+1
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            # yの親をxとし、xのサイズにyのサイズを加える
            self.par[x] += self.par[y]
            self.par[y] = x

    # 同集合判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # 集合の大きさ
    def size(self, x):
        return -self.par[self.find(x)]

n = int(input())

l = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    # dijkstraのlibraryに合わせるため、距離1を追加
    l[a-1].append([1,b-1])
    l[b-1].append([1,a-1])

d = dijkstra(n,0,l)

p = path_recovery(n-1,d,l)

x = p[(len(p)-1)//2]
y = p[(len(p)-1)//2+1]

for i in range(len(l[x])):
    if l[x][i][1]==y:
        l[x].pop(i)
        break
for i in range(len(l[y])):
    if l[y][i][1]==x:
        l[y].pop(i)
        break

u = UnionFind(n)

for i in range(len(l)):
    for j in range(len(l[i])):
        u.unite(i,l[i][j][1])


if u.size(0)>u.size(n-1):
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 113056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        System.out.println( Math.min(C, B/A) );
    }
}


Measured memory_bytes: 21332
// atcoder/abc074/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    vector<int> x(n);
    cin >> x;
    int sum = 0;
    for (int i = 0; i < x.size(); ++i) {
      int mn = min(x[i], abs(x[i] - k));
      sum += mn + mn;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 256
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    for i in range(H):
        if i % 2 == 0:
            for j in range(W):
                if j % 2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
                
        else:
            for j in range(W):
                if j % 2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
        print()
    print()


Measured memory_bytes: 7004
import numpy as np

N,Q = map(int,input().split())
S = []
for c in str(input()):
    S.append(c)

a = np.zeros(N)
   
for i in range(1,N):
    if (S[i-1] == "A")and(S[i] == "C"):
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]
        
for i in range(Q):
    l, r = map(int, input().split())
    print(int(a[r-1] - a[l-1]))

        
    
            
        
    
    
    





Measured memory_bytes: 20764
import math
import cmath
def cross_product(a,b):
    return (a.conjugate()*b).imag
L = []
try:
    while True:
        x,y = map(float,input().split(','))
        L.append(complex(x,y))
except EOFError:
    pass
N = len(L)
S = 0
for i in range(1,N-1):
    a,b,c = L[0],L[i],L[i+1]
    S += abs(cross_product(b-a,c-a))/2
print(S)


Measured memory_bytes: 5688
N=gets.to_i
A=gets.split.map &:to_i
s=A.map{|i|i.abs}.inject :+
x=A.min{|l,r|l.abs<=>r.abs}.abs
p(A.count{|i|i<0}.odd? && A.all?{|i|!i.zero?} ? s-2*x : s)

Measured memory_bytes: 11396