akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;

typedef vector<int> vi;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;                   
const int MAXN = 300500; 

int n, q;

vi g[MAXN];

bool u[MAXN];

ll a[MAXN];

void dfs(int v, int p) {
    for (int to : g[v]) {
        if (to == p) continue;
        a[to] += a[v];
        dfs(to, v);
    }
}

void solve() {  
    cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }

    while (q--) {
        int p, x;
        cin >> p >> x;
        a[p] += x;
    }
    
    dfs(1, 0);

    for (int i = 1; i <= n; i++) {
        cout << a[i] << ' ';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 27264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        static int N = 101;
        static int K;
        static int dp[][][] = new int[N][N][2];

        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String number = in.next(); // n
            K = in.nextInt(); // number of non-0 digits in a number
            init_dp();
            int digits[] = getDigitsFrom(number);
            out.print(digitOcc(0, 0, true, digits));
        }

        static int digitOcc(int index, int partialCount, boolean tight, int digits[])
        {
            if (partialCount > K) return 0; // fails condition
            if (index == digits.length) return boolToInt(partialCount == K); // out of boundary
            int answer = dp[index][partialCount][boolToInt(tight)];
            if (answer >= 0)
                return answer;

            answer = 0;
            for (int i = 0; i <= 9; ++i)
            {
                if (tight && (i > digits[index])) break; // forming too big number, current number exceeds n
                boolean nextTight = tight && (i == digits[index]);
                int nextCount = partialCount + boolToInt(i != 0); // checking condition over current digit
                answer += digitOcc(index + 1, nextCount, nextTight, digits);
            }
            dp[index][partialCount][boolToInt(tight)] = answer;
            return answer;
        }

        private int[] getDigitsFrom(String number)
        {
            int[] digits = new int[number.length()];
            int i = 0;
            for (char digit : number.toCharArray())
            {
                digits[i] = digit - '0';
                i++;
            }
            return digits;
        }

        static int boolToInt(boolean b)
        {
            return b ? 1 : 0;
        }

        static void init_dp()
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        dp[i][j][k] = -1;
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#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)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    string s;
    cin >> s;
    cout << string(s.size(), 'x') << endl;
    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np

def solve(N: int, K: int, S: str):
    S = np.array(([(s=="L")*1 for s in S]))
    dif = S[:-1] - S[1:]
    lr = (dif==1).sum()
    rl = (dif==-1).sum()

    od = 0
    k_ = min(lr,rl) - K
    if lr != rl:
        od = 1

    if k_ + od <= 0:
        print(N-1)
    else:
        print(N-1-k_*2 -od)


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N){
        if((i + 1)%2 == 1 && a[i]%2 == 1)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 2*(int)1e5 + 10;

int n;
vector<vector<int>> v;

int32_t main(){_

   cin>>n;

   int x; 
   cin >> x;
   vector<int> vec;
   vec.pb(x);
   v.pb(vec);

   for (int i = 1; i < n; ++i)
   {
      cin >> x;
      int low = 0, high = sz(v)-1;
      int ans = -1;
      while(low <= high){
         int mid = (low + high) >> 1;
         if(v[mid].back() < x){
            ans = mid;
            high = mid - 1;
         }
         else{
            low = mid + 1;
         }
      }
      if(ans == -1){
         vector<int> vec;
         vec.pb(x);
         v.pb(vec);
      }
      else{
         v[ans].pb(x);
      }
   }

   cout<<sz(v);   

   return 0;
}

Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    
    vector<ll> a(n);
    for(auto &x:a) {
        cin >> x;
        if(x == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(auto x:a){
        if(x > static_cast<ll>(1e+18) / ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= x;
    }
    cout << ans << endl;
}


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

void replacer(int a, int b, char *str, char *rep) {
    int i;
    for (i=a;i<=b;i++) str[i]=rep[i-a];
}

int main(void) {
    char str[1001]={'\0'}, buf[10]={'\0'}, rep[1001]={'\0'};
    int a, b, q, i;

    scanf("%s\n%d", str, &q);
    while (q>0) {
        scanf("%s", buf);
        if (strcmp(buf, "replace")==0) {
            scanf("%d %d %s", &a, &b, rep);
            replacer(a, b, str, rep);
        }
        if (strcmp(buf, "reverse")==0) {
            scanf("%d %d", &a, &b);
            for (i=a;i<=b;i++) rep[b-i]=str[i];
            replacer(a, b, str, rep);
        }
        if (strcmp(buf, "print")==0) {
            scanf("%d %d", &a, &b);
            for (i=a;i<=b;i++) printf("%c", str[i]);
            printf("\n");
        }
        for (i=0;i<sizeof(buf);i++) buf[i]='\0';
        q--;
    }
    for (i=0;i<sizeof(str);i++) str[i]='\0', rep[i]='\0';

    return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define INF (1 << 30)
#define rep(i,n) for(int i=0; i<n; ++i)

//等比数列の和
//n桁：7*(10^(n+1) - 1) / 9
int main()
{
	int K; cin >> K;
	if (K % 2 == 0 || K % 5 == 0) {
		cout << -1 << endl;
		return 0;
	}

	int k;
	if (K % 7 == 0) k = K * 9 / 7;
	else k = K * 9;

	//10^(n+1) % k == 1
	int ans = 1;
	ll sum = 10;
	while (1) {
		ll m = sum % k;
		if (m == 1) break;
		sum = m * 10;
		++ans;
	}
	cout << ans << endl;
}



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

using namespace std;

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

  long long n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2;
  } else {
    cout << min(a - 1 + (b - a + 1) / 2, n - b + (b - a + 1) / 2);
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        if( (a == 5) && (b == 5) && (c == 7))
                printf("YES");
        else if((a == 5) && (b == 7) & c== 5)
                printf("YES");
        else if( a == 7 && b == 5 && c == 5)
                printf("YES");
        else
                printf("NO");
        return 0;
}


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

const ll MOD = 1e9 + 7;

ll prvi[100010];
ll drugi[100010];
ll fak[200010];


ll mul(ll a, ll b)
{
    a %= MOD;
    b %= MOD;
    return (a*b)%MOD;
}

ll inverz(ll a, ll st)
{
    if(st == 0) return 1;
    ll res = inverz(a, st/2);
    res %= MOD;
    res *= res;
    res %= MOD;
    if(st % 2 == 1)
    {
        res *= a;
        res %= MOD;
    }
    return res;
}

ll fakt(ll a)
{
    /*if(a < 0 || a > 100000)
    {
        cout << a;
        exit(0);
        return 1;
    }*/
    return fak[a];
}

ll pref()
{
    fak[0] = 1;
    for(ll i = 1; i <= 200000; i++)
        fak[i] = mul(fak[i-1], i);
}

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

    pref();

    ll FiMod = MOD - 1;
    //cout << mul(15, inverz(5, FiMod-1));
    ll h, w, a, b;
    cin >> h >> w >> a >> b;


    prvi[1] = 1;
    ll hTren = 1;
    ll wTren = b;
    for(int i = 2; i <= h - a; i++)
    {
        //prvi[i] = prvi[i-1]*(hTren+wTren-1)*inverz(h);
        prvi[i] = mul(prvi[i-1], hTren + wTren - 1);
        prvi[i] = mul(prvi[i], inverz(hTren, FiMod - 1));
        hTren = i;
    }
    wTren = w - b;
    hTren = h;
    //cout << hTren + wTren - 2 << "haha\n ";

    drugi[1] = fakt(hTren + wTren - 2);
    drugi[1] %= MOD;
    drugi[1] = mul(drugi[1], inverz(fakt(wTren - 1), FiMod - 1));
    drugi[1] = mul(drugi[1], inverz(fakt(hTren - 1), FiMod - 1));

    for(int i = 2; i <= h - a; i++)
    {
        //prvi[i] = prvi[i-1]*(hTren+wTren-1)*inverz(h);
        drugi[i] = mul(drugi[i-1], hTren - 1);
        drugi[i] = mul(drugi[i], inverz(hTren + wTren - 2, FiMod - 1));
        hTren = h - i + 1;
    }
    ll sum = 0;

    /*for(int i = 1; i <= h - a; i++)
    {
        cout << prvi[i] << " " << drugi[i] << "\n";
    }*/
    for(int i = 1; i <= h - a; i++)
    {
        sum += mul(prvi[i], drugi[i]);
        sum %= MOD;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define ll long long
const ll mod = 1000000007;
const int cmax = 200000;

int N;
vector<int> C,nex;
vector<ll> dp;



void next_define(){
	vector<int> prev(cmax+1,-1);
	nex.assign(N,-1);
	for(int i=0;i<N;i++){
		if(prev[C[i]] != -1){
			nex[prev[C[i]]] = i;
		}
		prev[C[i]] = i;
	}
}


int solve(){
	next_define();
	dp.resize(N);

	//for(auto u:dp) cout << u << ' ';

	dp[N-1] = 1;

	for(int i=N-2;0<=i;i--){
		if(nex[i] == -1 || nex[i] == i+1){
			dp[i] = dp[i+1];
		}else{
			dp[i] = dp[i+1] + dp[nex[i]];
			dp[i] = dp[i] % mod;
		}
	}

	cout << dp[0] << endl;
	return 0;
}


int main(){
	cin >> N;
	C.resize(N);
	for(int i=0;i<N;i++){
		cin >> C[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 100005;
#define all(v) v.begin(),v.end()

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n; 
  cin>>n;
  ll sum = 0;
  for(ll i = 1;i<=n;i++)
  {
    if(i %3==0 && i%5==0){}
    else if(i%3==0){}
    else if(i%5==0){
    }
    else sum+=i;
  }
  cout << sum;
  return 0;
 }

Measured memory_bytes: 3640
n, a, b, c, d = list(map(int, input().split()))
s = input()
if d > c:
    for i in range(a, d-1):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        print("Yes")
else:
    for i in range(a, d):
        if (s[i-1] == "#") & (s[i] == "#"):
            print("No")
            break
    else:
        for j in range(b-1, d):
            if (s[j-1] == ".") & (s[j] == ".") & (s[j+1] == "."):
                print("Yes")
                break
        else:
            print("No")

Measured memory_bytes: 3572
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int a; readV(a);
  writeln(n%500 <= a ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  if(N%2 == 0){
    cout << (N/2)*(N/2) << endl;
  }
  else{
    cout << (N/2)*((N/2)+1) << endl;
  }
  return 0;
}

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

int main(void){
    int ans = 0;
    string s;
    cin >> s;
    rep(i,s.length()){
        if(s[i]=='+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout <<ans <<endl;
    
    return 0;
}






















































Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    
    int N, M, K, S, P, Q;
    cin >> N >> M >> K >> S >> P >> Q;
    int zombie[100000] = {};
    priority_queue<pair<long long,int>> que;
    for(int i=0; i<K; i++){
        int tmp;
        cin >> tmp;
        tmp--;
        zombie[tmp] = S+1;
        que.push(make_pair(S+1, tmp));
    }
    vector<int> tonari[100000];
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        tonari[a].push_back(b);
        tonari[b].push_back(a);
    }

    while(!que.empty()){
        for(int i=0; i<tonari[que.top().second].size(); i++){
            int tmp = tonari[que.top().second][i];
            if(zombie[tmp] < que.top().first-1){
                zombie[tmp] = que.top().first-1;
                que.push(make_pair(zombie[tmp], tmp));
            }
        }
        que.pop();
    }
    //for(int i=0; i<N; i++) cout << zombie[i] << endl;

    long long cost[100000];
    for(int i=0; i<N; i++) cost[i] = LL_MAX;
    cost[0] = 0;
    que.push(make_pair(LL_MAX-0, 0));
    while(!que.empty()){
        for(int i=0; i<tonari[que.top().second].size(); i++){
            int tmp = tonari[que.top().second][i];
            if(zombie[tmp] == S+1) continue;
            int c = P;
            if(zombie[tmp] != 0) c = Q;
            if(tmp == N-1) c = 0;
            if(cost[tmp] > cost[que.top().second] + c){
                cost[tmp] = cost[que.top().second] + c;
                que.push(make_pair(LL_MAX-cost[tmp], tmp));
            }
        }
        que.pop();
    }
    cout << cost[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 11040
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
using Int = long long;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<Int> X(N), Y(N), Z(N);
    for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> Z[i];
    Int result = 0;
    for (int i = 0; i < 8; i++) {
        vector<Int> P(N);
        for (int j = 0; j < N; j++) {
            P[j] = (i&1 ? 1 : -1) * X[j] + (i&2 ? 1 : -1) * Y[j] + (i&4 ? 1 : -1) * Z[j];
        }
        sort(P.rbegin(), P.rend());
        result = max(result, accumulate(P.begin(), P.begin()+M, 0LL));
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int s = 0;  int mem = n;
    while (mem > 0) {
        s += mem % 10;
        mem /= 10;
    }
    if (n % s == 0)
    {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
bool mas(int x,int y){
  if(x<0||x>1000000) return false;
  if(y<0||y>1000000) return false;
  return true;
}
int main(){
  int m,n;
  while(cin>>m,m){
    int x[m],y[m];
    for(int i=0;i<m;i++) cin >> x[i] >> y[i];
    cin >> n;
    int rx[n],ry[n];
    for(int i=0;i<n;i++) cin >> rx[i] >> ry[i];
    int a;
    for(int i=m-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(x[j]<x[j+1]){
	  a = x[j];
	  x[j] = x[j+1];
	  x[j+1] = a;
	  a = y[j];
	  y[j] = y[j+1];
	  y[j+1] = a;
	}
      }
    }
    for(int i=m-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(y[j]<y[j+1]&&x[j]==x[j+1]){
	  a = x[j];
	  x[j] = x[j+1];
	  x[j+1] = a;
	  a = y[j];
	  y[j] = y[j+1];
	  y[j+1] = a;
	}
      }
    }
    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(rx[j]<rx[j+1]){
	  a = rx[j];
	  rx[j] = rx[j+1];
	  rx[j+1] = a;
	  a = ry[j];
	  ry[j] = ry[j+1];
	  ry[j+1] = a;
	}
      }
    }
    //for(int i=0;i<m;i++) cout << x[i] << ' ' << y[i] << endl;
    for(int i=n-1;i>=0;i--){
      for(int j=0;j<i;j++){
	if(ry[j]<ry[j+1]&&rx[j]==rx[j+1]){
	  a = rx[j];
	  rx[j] = rx[j+1];
	  rx[j+1] = a;
	  a = ry[j];
	  ry[j] = ry[j+1];
	  ry[j+1] = a;
	}
      }
    }
    for(int i=0;i<n;i++){
      int dx = rx[i] - x[0];
      int dy = ry[i] - y[0];
      int j = 1;
      int k = i+1;
      bool ok = false;
      while(k<n){
	if(!mas(dx+x[j],dy+y[j])) break;
	if(dx+x[j]!=rx[k]||dy+y[j]!=ry[k]) k++;
	if(dx+x[j]==rx[k]||dy+y[j]==ry[k]){
	  j++;
	  k++;
	}
	if(j>=m){
	  ok = true;
	  break;
	}
      }
      if(ok){
	cout << dx << ' ' << dy << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
using namespace std;
int main(void){
    int n,i,a = 100000;
    cin >> n;
    for(i = 0; i < n; i++){
        a = a + (a * 0.05);
        if(a % 1000 != 0){
            a = a - (a % 1000) + 1000;
        }
    }
    cout << a << endl;
}


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

using namespace std;
using ll = long long;

const int MAX_V = 100000;
const ll INF = ll(1e16);

int V, E;
struct edge { int to;ll cost; };
typedef pair<int, int>P;
int N;
vector<edge>G[MAX_V];
ll d[MAX_V];

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

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
int main()
{
	cin >> V >> E;
	int r;
	cin >> r;
	for (int i = 0; i < E; i++)
	{
		int s, t;
		ll d;
		cin >> s >> t >> d;
		G[s].push_back({t,d});
	}
	dijkstra(r);

	//出力
	for (int i = 0; i < V; i++)
	{
		if (d[i] == INF)
		{
			cout << "INF" << endl;
		}
		else
		{
			cout << d[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 18348
N = int(input())
a = list(int(x) for x in input().split())
plus = []
minus = []
plus = plus[::-1]
answer ="OK"
for i in range(N):
  if a[0] < 0:
    answer = i +1
    break
    
  if a[i] > 0 and not(a[i] in plus):
    plus.append(a[i])
  elif a[i] < 0 and not(a[i] in minus):
    if (-(a[i]) in plus):
      minus.append(a[i])
      if (len(plus)-1) -plus.index(-(a[i])) == minus.index(a[i]):
        del minus[minus.index(a[i])]
        del plus[plus.index(-(a[i]))]
      else:
        answer = i+1
        break
    else:
      answer = i+1
      break
  else:
    answer = i+1
    break
print(answer)


Measured memory_bytes: 5628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n < 1 || n > 200000 {
		return
	}

	a := make([]int64, 0)
	for i := 0; i < int(n); i++ {
		a = append(a, nextInt())
	}

	ans := 0
	var i int64
	i = 1
	for _, v := range a {
		if v != i {
			ans++
		} else {
			i++
		}
	}
	if int64(ans) == n {
		ans = -1
	}
	fmt.Printf("%d\n", ans)
}

func nextInt() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 32)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 7680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
using namespace std;

int m,n;

int calc(vector<bool> &p,vector<string>&v,map<vector<bool>,int> &mp){
    if(mp.find(p)!=mp.end())return mp[p];
    int mi=10000;
   for(int i=0;i<m;i++){
        vector<bool>q(n),r(n);
        for(int j=0;j<n;j++){
            if(p[j]&&v[j][i]=='1'){
                q[j] = 1;
            }else if(p[j]&&v[j][i]=='0'){
                r[j] = 1;
            }
        }
        bool flag = 0;
        for(int j=0;j<n;j++){
            if(q[j])flag = 1;
        }
        bool fflag=0;
        for(int j=0;j<n;j++){
            if(r[j])fflag = 1;
        }
        if(flag&&fflag){
            mi = min(mi,max(calc(q,v,mp),calc(r,v,mp))+1);
        }
    }
    return mp[p] = mi;
}

int main(){
    while(cin >> m >> n &&m!=0){
        vector<string>v(n);
        for(int i=0;i<n;i++){
            cin >> v[i];
        }
        map<vector<bool>,int> mp;
        vector<bool>p(n);
        mp[p]= 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(i==j)p[j] = 1;
                else p[j] = 0;
            }
            mp[p]=0;
        }
        for(int i=0;i<n;i++){
            p[i] = 1;
        }
        cout << calc(p,v,mp) << endl; 
    }
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N,Q;
    string S;
    cin >> N >> Q >> S;

    vector<i64> l(Q),r(Q);
    rep(i,0,Q){
        cin >> l[i] >> r[i];
        --l[i];
        --r[i];
    }

    vector<i64> sum(N);
    rep(i,1,S.size()){
        sum[i]=sum[i-1];
        if(S[i]=='C' and S[i-1]=='A'){
            ++sum[i];
        }
    }

    cerr << sum << endl;

    rep(i,0,Q){
        i64 ans=sum[r[i]];
        if(l[i]>0) ans-=sum[l[i]];
        cout << ans << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3408
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n;
  cin >> n;
  
  vector<double> t(n+2),v(n+2);
  
  t[0] = v[0] = v[n+1] = 0;
  REP(i,n){
    double T;
    cin >> T;
    t[i+1] = t[i] + T;
  }
  t[n+1] = t[n];
  
  REP(i,n) cin >> v[i+1];
  
  vector<double> limit(2*t[n]+2,MOD); //0.5sで区間をとる
  
  // 速度上限の初期化
  int k = 0;
  REP(i,n+2){
    while(k <= 2*t[i]){
      limit[k] = min(limit[k],v[i]);
      k++;
    }
    k--;
  }
  
//  REP(i,limit.size()) debug(limit[i]);
  
  // 範囲の右端からの上限更新
  REP(i,n+1){
    double a = 0;
    while(limit[t[i]*2+a] >= limit[t[i]*2]+(a/2) && t[i+1]-t[i] >= a/2){
      limit[t[i]*2+a] = limit[t[i]*2]+(a/2);
      a++;
    }
  }

  // 範囲の左端からの上限更新
  for(int i = n+1; i > 0; i--){
    double a = 0;
    while(limit[t[i]*2-a] >= limit[t[i]*2]+(a/2) && t[i]-t[i-1] >= a/2){
      limit[t[i]*2-a] = limit[t[i]*2]+(a/2);
      a++;
    }
  }  
  
//  REP(i,limit.size()) cout << i << ": " << limit[i] << endl; 
  
  double ans = 0; int i = 0;
  while(i < limit.size()-2){
    double cnt = 0;
    if(limit[i] == limit[i+1]){
      while(limit[i] == limit[i+1]){
        cnt++;
        i++;
      }
      ans += cnt/2*limit[i];
 //     debug(ans);
    }
    
    else if(limit[i] == limit[i+1]-0.5){
       while(limit[i] == limit[i+1]-0.5){
        cnt++;
        i++;
       }
      ans += (cnt/2*cnt/2)/2 + cnt/2*(limit[i]-cnt/2);
 //     debug(ans);
    }

    else if(limit[i] == limit[i+1]+0.5){
       while(limit[i] == limit[i+1]+0.5){
        cnt++;
        i++;
      }
      ans += (cnt/2*cnt/2)/2 + cnt/2*limit[i];
//      debug(ans);
    }
  }
    
  cout << fixed << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,int>P;
typedef pair<double,double>Pi;
typedef pair<Pi,int>PP;
int main(){
  int n,T=0;
  while(cin>>n,n){
    cout<<++T<<" ";
    double a[101],b[101],c[101];
    vector<P> v;
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i]>>c[i];
      v.push_back(P(b[i]-c[i],i));
      v.push_back(P(b[i]+c[i],i));
    }

    sort(v.begin(),v.end());
    double h=-1e9,w=0;
    double ans=0;
    vector<PP> s;
    for(int i=0;i<v.size();i++){
      bool f=1;
      ans+=(v[i].first-h)*w,h=v[i].first;
      for(int j=0;j<s.size();j++)
	if(s[j].second==v[i].second)s.erase(s.begin()+j),f=0;
 
      if(f)s.push_back(PP(Pi(a[v[i].second]-c[v[i].second],a[v[i].second]+c[v[i].second]),v[i].second));
 
      sort(s.begin(),s.end());
      w=0;
      if(s.size()){
	w=s[0].first.second-s[0].first.first;
	double pr=s[0].first.second;
	
	
	for(int j=0;j<s.size();j++){
	  if(s[j].first.first<pr)w+=max(0.0,s[j].first.second-pr);
	  else w+=s[j].first.second-s[j].first.first;
	  pr=max(s[j].first.second,pr);
	}
      }
    }
    printf("%.2f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3124
n,m = map(int, input().split())
x=[]
for i in range(m):
    p,y=map(int,input().split())
    x.append([y,p,i])
x.sort()
a=[0]*n
ans=[""]*m
for y,p,i in x:
    a[p-1]+=1
    ans[i]=str(p).rjust(6,"0")+str(a[p-1]).rjust(6,"0")
for i in ans:
    print(i)

Measured memory_bytes: 32092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int K; cin >> K;
  ll ans = 0;
  rep(i, K) rep(j, K) rep(k, K) {
    ans += gcd(i + 1, gcd(j + 1, k + 1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

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

	int index = S.length() - T.length();
	while (1) {
		if (index < 0) {
			wrln("UNRESTORABLE");
			break;
		}
		repi(i, 0, T.length()) {
			if (S[index + i] != T[i] && S[index + i] != '?') break;
			if (i == T.length() - 1) {
				repi(j, 0, index) {
					if (S[j] == '?') wr('a');
					else wr(S[j]);
				}
				wr(T);
				repi(j, index+T.length(), S.length()) {
					if (S[j] == '?') wr('a');
					else wr(S[j]);
				}
				cout << endl;
				return 0;
			}
		}
		index--;
	}


	return 0;
}

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

int main(void) {
  ll N, P;
  cin >> N >> P;

  vector<bool> isp(2000000, true);
  isp[0] = isp[1] = false;
  REP(i, 0, 2000000) {
    if (isp[i]) {
      for (ll j = i * 2; j < 2000000; j += i) {
        isp[j] = false;
      }
    }
  }
  vector<ll> p;
  REP(i, 0, 2000000) if (isp[i]) p.push_back(i);

  ll ans = 1;
  ll x = P;
  REP(i, 0, p.size()) {
    ll cnt = 0;
    while (x % p[i] == 0) {
      x /= p[i];
      cnt++;
    }
    REP(j, 0, cnt / N) {
      ans *= p[i];
    }
  }
  if (N == 1) {
    ans *= x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2676
#include <iostream>

using namespace std;

int main()
{
    long long int a,b;
    cin >> a >> b;
    if (a > 0 && b > 0) {
        cout << "Positive";
    }
    if (a <= 0 && b >= 0) {
        cout << "Zero";
    }
    if (a < 0 && b < 0) {
        if ((a + b + 1) % 2 == -1){
            cout << "Negative";
        }
        else {
            cout << "Positive";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    ll ans = 0;
    ll cnt = 0;

    for(ll i= 1; cnt < x; i++){
        cnt += i;
        ans++;
    }

    cout << ans << endl;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int ans = 0;
	queue<int> l;
	l.push(0);
	int counter = 0;
	bool flag = 1;
	rep(i, n) {
		if (s[i] == '0') {
			if (flag) {
				if (counter == k) l.pop();
				else ++counter;
			}

			flag = 0;
		}
		else {
			if (!flag) l.push(i);

			flag = 1;
		}

		ans = max(ans, i - l.front() + 1);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 512
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e3+5;



  int main()
  { 

ll n;cin>>n;
ll m;cin>>m;

n*=2;

ll ans=(n+m)/4;

chmin(ans,m/2);

d1(ans);

  return 0;

  }

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


int main(){
	vector<vector<int> > dp;
	int count = 0,n=0;
	string s;
	while(1){
		cin>>s;
		n++;
		vector<int> tmp;
		int num = (s.size()+1)/2;
		int tmpn=0;
		for(int i=0;i<s.size();i++){
			
		if(s[i]!=','){
			tmpn*=10;
			tmpn+=(s[i]-'0');
		}
		else {
			tmp.push_back(tmpn);
			tmpn=0;
			}
		}
		tmp.push_back(tmpn);	
		dp.push_back(tmp);
		
		if(num==1)count++;
		if(count==2)break;
	}
	vector<vector<int> > u(n/2),d(n/2);
	vector<int> m(n/2+1);
	for(int i=0;i<n/2;i++){
		for(int j=0;j<=i;j++){
		u[i].push_back(dp[i][j]);
		d[i].push_back(dp[n-1-i][j]);
		}
	}
	for(int i=0;i<n/2+1;i++)m[i] = dp[n/2][i];
	
	for(int i=0;i<n/2-1;i++){
		u[i+1][0]+=u[i][0];
		u[i+1][i+1]+=u[i][i];
		d[i+1][0]+=d[i][0];
		d[i+1][i+1]+=d[i][i];
		for(int j=1;j<=i;j++){
			u[i+1][j]+=max(u[i][j-1],u[i][j]);
			d[i+1][j]+=max(d[i][j-1],d[i][j]);
		}
	}
	m[0]+=u[n/2-1][0]+d[n/2-1][0];
	m[n/2]+=u[n/2-1][n/2-1]+d[n/2-1][n/2-1];
	for(int i=1;i<n/2;i++){
	m[i]+=max(u[n/2-1][i],u[n/2-1][i-1]);
	m[i]+=max(d[n/2-1][i],d[n/2-1][i-1]);
	}

	int ans = 0;
	for(int i=0;i<=n/2;i++)ans=max(ans,m[i]);
	cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt();
		int i,min=1000000,max=-1000000;
		long s=0;
		for(i=0;i<n;i++){
			int a=stdIn.nextInt();
			if(min>a)min=a;
			if(max<a)max=a;
			s+=a;
		}
		System.out.println(min+" "+max+" "+s);
	}
}


Measured memory_bytes: 42000
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mii map<int, int>
#define msi map<string, int>
#define pb push_back
#define ff first
#define ss second
#define coutp cout<<fixed<<setprecision
#define FR(n) for(int i=0;i<n;i++)
#define W(n) while(n--)
#define I(v) for(int i=0;i<v.size();i++)
#define srt(v) sort(v.begin(),v.end())
#define srtd(v) sort(v.begin(),v.end(),greater<int> ())
#define ALL(v) v.begin(),v.end()
#define IT(m) for(auto it=m.begin();it!=m.end();it++)
#define M 1000000007
#define imin INT_MIN
#define imax INT_MAX
#define SIEVE 100000

int n,m,k,a,b,mx=imin,mn=imax,mxi,mni;
double x,y;
string s,s1,s2;
vector<bool> prime(SIEVE+1,1);
vi primes;

void precomputation();
void solve();
void solvecase();
void sieve();
int pow(int, unsigned int, int);
bool miillerTest(int, int);
bool isPrime(int, int);

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	clock_t start_time = clock();
	precomputation();
	solve();
	clock_t end_time = clock();
  	double elapsed_secs = double(end_time - start_time) / CLOCKS_PER_SEC;
	cerr<<elapsed_secs<<"\n";
	return 0;

}

void solvecase(){
	cin>>n>>m>>k;
	int ans=0;
	for(int i=n;i<=m;i++)
	{
		if(i%k==0)
		{
			ans++;
		}
	}
	cout<<ans;
}

void solve(){
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++)
	{
		//cout<<"Case #"<<i<<":"<<" ";
		solvecase();
		cout<<"\n";
	}
}

void precomputation(){
}

void sieve(){
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<=SIEVE;i++){
		if(prime[i]){
			primes.pb(i);
			for(int j=i+i;j<=SIEVE;j+=i){
				prime[j]=0;
			}
		}
	}
	sort(primes.begin(),primes.end());
}

int pow(int X, unsigned int Y, int P)
{
	int res = 1;
	X = X % P;
	while (Y > 0)
	{
		if (Y & 1)
			res = (res*X) % P;
		Y = Y>>1;
		X = (X*X) % P;
	}
	return res;
}

bool miillerTest(int D, int N)
{
	int A = 2 + rand() % (N - 4);
	int X = pow(A, D, N);
	if (X == 1 || X == N-1)
	return true;
	while (D != N-1)
	{
		X = (X * X) % N;
		D *= 2;
		if (X == 1)	 return false;
		if (X == N-1) return true;
	}
	return false;
}

bool isPrime(int N, int K)
{
	if (N <= 1 || N == 4) return false;
	if (N <= 3) return true;
	int D = N - 1;
	while (D % 2 == 0)
		D /= 2;
	for (int i = 0; i < K; i++)
		if (!miillerTest(D, N))
			return false;
	return true;
}


Measured memory_bytes: 3804
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
using namespace std;
 
int main(void){
  	int N,H[100],now,result=0;
	cin>>N;
  	rep(i,N)cin>>H[i];
  	now=H[0];
	rep(i,N){
    	if(now <= H[i]){
          now=H[i];
          result++;
        }
    }
 	cout<<result<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int ans = 0;
    cin >> n;
    vector<int> a(n);
    rep (i, n) {
      cin >> a[i];
    }
    rep (i, n) {
      if (a[i] == i + 1) {
        swap(a[i], a[i + 1]);
        ans++;
      }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>

using namespace std;

int dp[110000];
int a[110];
int N, K;
int dfs(int k)
{
  if (k == 0) return 0;

  int &ret = dp[k];
  if (ret >= 0) return ret;

  ret = 0;
  for (int i = 0; i < N; i++) {
    if (k - a[i] >= 0) ret |= !dfs(k - a[i]);
  }
  return ret;
}

int main()
{
  memset(dp, -1, sizeof(dp));
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i <= K; i += 10000) dfs(i);
  if (dfs(K)) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int D;
    cin >> D;
    long long int G;
    cin >> G;
    
    vector<long long int> p(D+1, 0);
    vector<long long int> c(D+1, 0);
    for(int d=1; d<=D; d++) {
        cin >> p[d] >> c[d];
    }
    
    long long int sum;
    int pro_num;
    int min_pro_num=10000;
    for(int bit=0; bit<(1<<D); bit++) {
        sum = 0;
        pro_num = 0;
        for(int d=1; d<=D; d++) {
            if(bit & (1<<(d-1))) {
                sum += p[d]*d*100 + c[d];
                pro_num += p[d];
            }
        }

        // cout << sum << endl;
        
        if(sum>=G) {
            ;
        } else {
            for(int d=D; d>=1; d--) {
                if(bit & (1<<(d-1))) {
                    ;
                } else {
                    // cout << "calc pn ... " << endl;
                    int pn;
                    if((G-sum)%(d*100)) {
                        pn = (G-sum)/(d*100)+1;
                    } else {
                        pn = (G-sum)/(d*100);
                    }
                    // cout << "pn is " << pn << endl;
                    if(pn<p[d]) {
                        sum += pn*d*100;
                        pro_num += pn;
                        // cout << "pro_num is " << pro_num << endl;
                        break;
                    } else {
                        sum += (p[d]-1)*d*100;
                        pro_num += p[d]-1;
                    }
                }
            }
        }
        
        if(sum>=G) {
            // cout << "update min_pro_num " << endl;
            min_pro_num = min(min_pro_num, pro_num);
        }
    }

    cout << min_pro_num << endl;

    return 0;
    
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
count :: (a -> Bool) -> [a] -> Int
count = (length .) . filter
-- end of templete



main = do
    m <- getInt
    when (m/=0) $ do
        ds <- replicateM m getInts
        g <- getInt
        ns <- replicateM g getInt
        arr <- newArray (0, 1000) 0 :: IO (IOUArray Int Int)
        writeArray arr 0 1
        forM_ ds $ \[a,b] -> do
            forM_ [1000,999..0] $ \i -> do
                c <- readArray arr i
                forM_ [x | j <- [1..b], let x = i+a*j, x<=1000] $ \t -> modifyArray arr t (+c)
        forM_ ns $ \n -> readArray arr n >>= print
        main


Measured memory_bytes: 5488