akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    string s; cin >> s;

    bool hantei = true;

    while(s.size() > 0){
        int n = s.size();
        if(n >= 5 && s.substr(n-5,5) == "dream"){
            for(int i = 0;i < 5;i ++) s.pop_back();
            continue;
        }
        if(n >= 7 && s.substr(n-7,7) == "dreamer"){
            for(int i = 0;i < 7;i ++) s.pop_back();
            continue;
        }
        if(n >= 5 && s.substr(n-5,5) == "erase"){
            for(int i = 0;i < 5;i ++) s.pop_back();
            continue;
        }
        if(n >= 6 && s.substr(n-6,6) == "eraser"){
            for(int i = 0;i < 6;i ++) s.pop_back();
            continue;
        }

        hantei = false;
        break;

    }

    if(hantei) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(9,vector<int>(9,0));
    int k=1;
    int front,end;
    for(int i = 1; i<= n; i++){
        if(i/k < 10){
            end = i % 10;
            front = i/k;
            if(end != 0) {
                a[front-1][end-1]++;
            }
        }else{
            end = i % 10;
            k = k * 10;
            front = i/k;
            if(end != 0) {
                a[front-1][end-1]++;
            }
        }
    }
    int sum=0;
    for(int i = 0; i<9; i++){
        for(int j = 0; j<9;j++){
            sum = sum + a[i][j] * a[j][i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

const int MAXN = 2*100000;
vector<int> bit(MAXN+1);

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit.at(i);
    i -= i & -i;
  }
  return s;
}

void add(int i, int x) {
  while (i <= MAXN) {
    bit.at(i) += x;
    i += i & -i;
  }
}

int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }

  vector<int> b = a;
  sort(b.begin(), b.end());
  int mi = 0;
  int ma = n-1;


  while (mi < ma) {
    int pos = (mi+ma+1)/2;
    int now = b.at(pos);

    vector<int> c(n);
    rep(i, n) {
      if (a.at(i) < now) {
        c.at(i) = -1;
      } else {
        c.at(i) = 1;
      }
    }
    for(int i=1; i<n; i++) {
      c.at(i) += c.at(i-1);
    }
    ll ans = 0;
    add(n, 1);
    rep(i, n) {
      c.at(i) += n;
      ans += sum(c.at(i));
      add(c.at(i), 1);
    }

    rep(i, 200001) {
      bit.at(i) = 0;
    }

    /*
    debugln(now);
    rep(i, n) {
      debug(i);
      debug(c.at(i));
      cout << endl;
    }
    debugln(ans);
    */
    ll ss = n*(n+1)/2;
    ll tmp = ss/2;
    if (ss%2 == 1) {
      tmp++;
    }
    //debug(tmp);
    //debug(mi);
    //debug(ma);
    if (ans >= tmp) {
      mi = pos;
      //debugln(mi);
    } else {
      ma = pos-1;
      //debugln(ma);
    }
  }
  cout << b.at(mi) << endl;
}

Measured memory_bytes: 2180
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#define LL long long
using namespace std;
const int MaxN = 1e5;
const LL Inf = 1LL << 60;

priority_queue<LL> q2;
priority_queue<LL,vector<LL>,greater<LL> > q1;
LL sum[3 * MaxN + 5],cas[3 * MaxN + 5],a[3 * MaxN + 5];
LL sum2[3 * MaxN + 5],cas2[3 * MaxN + 5];

int main()
{
	LL pp,ans;
	int n;
	while(~scanf("%d",&n)){
		ans = -Inf;
		sum[0] = 0;cas[n] = 0;
		for(int i = 1;i <= n;i++) {
			scanf("%lld",&a[i]);
			sum[i] = sum[i - 1] + a[i];
			q1.push(a[i]);
		}
		for(int i = n + 1;i <= 2 * n;i++) {
			scanf("%lld",&a[i]);
			sum[i] = sum[i - 1] + a[i];
			q1.push(a[i]);
			pp = q1.top();
			cas[i] = cas[i - 1] + pp;
			q1.pop();
		}
		for(int i = 2 * n + 1;i <= 3 * n;i++){
			scanf("%lld",&a[i]);
		}
		sum2[3 * n + 1] = 0;cas2[2 * n + 1] = 0;
		for(int i = 3 * n;i >= 2 * n + 1;i--){
			sum2[i] = sum2[i + 1] + a[i];
			q2.push(a[i]);
		}
		for(int i = 2 * n;i >= n + 1;i--){
			sum2[i] = sum2[i + 1] + a[i];
			q2.push(a[i]);
			pp = q2.top();
			cas2[i] = cas2[i + 1] + pp;
			q2.pop();
		}
		for(int i = n;i <= 2 * n;i++){
			pp = sum[i] - cas[i] - sum2[i + 1] + cas2[i + 1];
			ans = max(pp,ans);
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 11636
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, m, a[100005], cnt[100005], ans;
map<int, int>mp;
signed main() {
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
		if (!i)cnt[i] = a[i] % m;
		else cnt[i] = (cnt[i - 1] + a[i]) % m;
	}
	mp[0] = 1;
	rep(i, n) {
		ans += mp[cnt[i]];
		mp[cnt[i]]++;
	}
	cout << ans << endl;
	endre;
}

Measured memory_bytes: 5760
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
    def __init__(self, n):
        self.size = n
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
    def root(self, x):
        if self.par[x] != x:
            self.par[x] = self.root(self.par[x])
        return self.par[x]
    def unite(self, x, y):
        if self.root(x) == self.root(y):
            return
        if self.rank[x] > self.rank[y]:
            self.par[self.root(y)] = self.root(x)
        else:
            self.par[self.root(x)] = self.root(y)
        if self.rank[x] == self.rank[y]:
            self.rank[x]+=1
    def check(self, x, y):
        return self.root(x) == self.root(y)

n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    uf.unite(a,b)
    ans[a]-=1
    ans[b]-=1
co = [0 for i in range(n)]
for i in range(n):
    co[uf.root(i)]+=1
for i in range(n):
    ans[i] += co[uf.root(i)]-1
for i in  range(k):
    c,d = map(int,input().split())
    if uf.check(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
for i in range(n):
    if i == n-1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double              lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;
const lf EPS = 1e-9;

struct pt {
  lf x, y;
  pt( ) { }
  pt( lf x, lf y ) : x( x ), y ( y ) { }
};

inline lf x( pt P ) { return P.x; }
inline lf y( pt P ) { return P.y; }

istream& operator >> ( istream& in, pt& p ) {
  lf x,y; in >> x >> y;
  p = pt(x,y); return in;
}

ostream& operator << ( ostream& out, const pt& p ) {
  out << double(p.x) << " " << double(p.y);
  return out;
}

pt operator + ( const pt& A, const pt& B ) {
  return pt( x(A)+x(B), y(A)+y(B) );
}

pt operator - ( const pt& A, const pt& B ) {
  return pt( x(A)-x(B), y(A)-y(B) );
}

pt operator * ( const lf& B, const pt& A ) {
  return pt( x(A)*B, y(A)*B );
}

pt operator * ( const pt& A, const lf& B ) {
  return pt( x(A)*B, y(A)*B  );
}

pt operator / ( const pt& A, const lf& B ) {
  return { x(A)/B, y(A)/B };
}

inline lf dot( pt A, pt B ) {
  return x(A)*x(B) + y(A)*y(B);
}

inline lf cross( pt A, pt B ) {
  return x(A)*y(B) - y(A)*x(B);
}

inline lf norm( pt A ) {
  return x(A)*x(A) + y(A)*y(A);
}

inline lf abs( pt A ) {
  return sqrt( norm(A) );
}

inline lf dist ( pt A, pt B ) { return abs( B - A ); }

inline bool same ( lf a, lf b ) {
  return a+EPS > b && b+EPS > a;
}

inline bool samePt ( pt A, pt B ) {
  return same ( x(A), x(B) ) && same ( y(A), y(B) );
}

lf distToLine (pt p, pt A, pt B, pt &c) {
  lf u = dot( p-A , B-A ) / norm( B-A );
  c = A + u*( B-A );
  return dist( p , c );
}

bool circleLineIntersection( pt c, lf r, pt A, pt B, pt &p1, pt &p2 ) {
  pt t;
  lf u = distToLine( c, A, B, t );
  if( u > r+EPS ) {
    return false;
  }
  pt v = (B-A)/abs(B-A);
  lf d = sqrt(r*r - u*u);
  p1 = t + d*v;
  p2 = t - d*v;
  return true;
}

int q;
pt c, p1, p2;
lf r;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif
  cout << fixed << setprecision(8);
  cin >> c >> r >> q;
  for( int i = 0; i < q; ++i ) {
    pt A,B; cin >> A >> B;
    if( circleLineIntersection( c, r, A, B, p1, p2 ) ) {
      if( same( p1.x, p2.x ) ) {
        if( p1.y > p2.y+EPS ) {
          swap( p1,p2 );
        }
      }
      if( p1.x > p2.x+EPS ) {
        swap( p1,p2 );
      }
      cout << p1 << " " << p2 << '\n';
    }
    else {
      assert( false );
    }
  }
  return 0;
}

Measured memory_bytes: 3308
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++) {
			A[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		int[] B = A.clone();
		Arrays.sort(B);
		int max = B[N-1];
		int nextmax = B[N-2];
		for(int i=0;i<N;i++) {
			if(A[i]==max) {
				System.out.println(nextmax);
			} else {
				System.out.println(max);
			}
		}
	}
}


Measured memory_bytes: 61760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h1,m1,h2,m2,k;cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << h2*60+m2-h1*60-m1-k << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
bool xre, yre, xyre;

void print(int X, int Y) {
    if(xyre) swap(X, Y);
    if(xre) X = -X;
    if(yre) Y = -Y;
    cout << X << ' ' << Y << endl;
} 

int main() {
    long long K, X, Y;
    cin >> K >> X >> Y;

    xre = (X < 0), yre = (Y < 0);
    X = abs(X); Y = abs(Y);
    xyre = (X < Y);
    if(X < Y) swap(X, Y);

    long long D = X + Y;
    if(D == K) {
        cout << 1 << endl;
        print(X, Y);
        return 0;
    }

    int n = (D + K - 1) / K;
    if(n == 1) n = 2;
    if((n * K - D) % 2) {
        if(K % 2) {
            ++n;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    long long resid = n * K - D;

    if(n == 3) {
        cout << 3 << endl;
        long long a = resid / 4;
        long long b = resid / 2 - a;
        for(int i=1; i<=n; ++i) {
            long long l = K * i;
            if(l <= b) print(-l, 0);
            else if(l <= b + Y + a) print(-b, l -b);
            else if(l <= b + Y + a + b + X) print(-b + l - b - Y - a, Y + a);
            else print(X, Y);
        }
        return 0;
    }

    cout << n << endl;
    int a = resid / 2;
    for(int i=1; i<=n; ++i) {
        long long l = i * K;
        if(l <= Y + a) print(0, l);
        else if(l <= Y + a + X) print(l - Y - a, Y + a);
        else print(X, Y + a - (l - Y - a - X));
    }
}

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

#define ll long long int
#define ull unsigned long long int
#define Max 1000005
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pi acos(-1.0)
#define pb push_back
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define endl '\n'

#define sc(n) scanf("%d",&n)
#define scan(n) scanf("%lld",&n)
/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define fi first
#define se second

struct HASH{
size_t operator()(const pair<int,int>&x)const{
return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
}
};


//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
typedef tuple<ll,ll,ll>tpl;
typedef unordered_map<pair<int,int>,int,HASH>u_map;

int main()
{
    ll n,x,t;
    cin>> n>> x>> t;
    int d=n/x;
    if(n%x!=0)d++;
    cout<<d*t<<endl;
}
/*
    remember:
    ll vs int
    array size
    case for 1 2 3 
*/



Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
using namespace std;
#define mod 1000000007

int main(void) {
	// your code goes here
	int n,i,a[100001],cost=0;
	cin >>n;
	a[0]=0;
	for(i=1;i<=n;i++) {
		cin >> a[i];
		cost+=abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	cost+=abs(a[n]);
	for(i=1;i<=n;i++){
		if((a[i+1]-a[i])*(a[i]-a[i-1])>=0) cout << cost << endl;
		else cout << cost-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]) << endl;
	}
	return 0;
}


Measured memory_bytes: 1664
from collections import deque


def main():
    N = int(input())
    S = input()
    before_char = None
    merged_chars = deque()
    for i, c in enumerate(S):
        if c != before_char and before_char is not None:
            merged_chars.append(before_char)
        before_char = c
        if i == N - 1:
            merged_chars.append(c)
    print(len(merged_chars))


if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;

int sm(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int ans = 1000000;
    for (int i = 1; i < n; i++) {
        ans = min(ans, sm(i) + sm(n - i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}
int solve(string a, string b){
	int n = a.size(),ans = 0;
	for(int i{0};i < n;i++)ans += a[i] != b[i];
	return ans;
}
void testcase(){
	string s,t;
	cin >> s >> t;
	int n = s.size(),m = t.size(),ans = 1e9;
	for(int i{0};i + m <= n;i++)ans = min(ans,solve(t,s.substr(i,m)));
	cout << ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3588
number = input()
lis = number.split()


for num in range(len(lis)-1):
    add = int(lis[num]) + int(lis[num+1])
    pull = int(lis[num]) - int(lis[num+1])
    product = int(lis[num]) * int(lis[num+1])


mostbig = max([add,pull,product])
print(mostbig)


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

int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int main(){
  int64_t a,b,c,d;
  cin >> a >> b >> c >> d;
  int64_t cnt;
  int64_t l = lcm(c,d);
  cnt = b/c - (a-1)/c + b/d - (a-1)/d - b/l + (a-1)/l;
  cout << b - a + 1 - cnt << endl;
  return 0;
}



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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        int ans = int.MaxValue;
        int blackcount = S.Count(_ => _ == '#');
        int whitecount = S.Count(_ => _ == '.');

        int black = 0;
        int white = whitecount;
        ans = black + white;
        for (int i = 0; i < N; i++)
        {
            if (S[i] == '#') black++;
            else white--;
            ans = Math.Min(ans, black + white);
        }
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28432
#include<stdio.h>

int main()
{
    int i,h,m,s,t;

    while(scanf("%d%d%d",&h,&m,&s),h+m+s+3){
        t=7200-(h*3600+m*60+s);
        for(i=0;i<2;i++){
            h=t/3600;
            m=(t%3600)/60;
            s=t%60;
            printf("%.2d:%02d:%0.2d\n",h,m,s);
            t*=3;
        }   
    }   
    return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
		char[] S = sc.next().toCharArray();

 		int[] d = new int[N];
		d[0] = 0;
		int count = 0;
		for(int i=1; i<N; i++){
			if(S[i]=='C' && S[i-1]=='A'){
				count++;
			}
			d[i] = count;
		}

		for(int i=0; i<Q; i++){
			int l = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());
			System.out.println(d[r-1]-d[l-1]);
		}
		
		
		
		sc.close();
	}

	
}


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

int n;
const int F[]={1,3,9,27,81,243,729,2187,6561,19683,59049,177147,531441};
const int N=555555;
const int L=13;
char op[N*3]={'\0'};
int fn[L][N*3];
int ins[3][N*3];
int p[N];
int m;
int main(){
	scanf("%d",&n);
	int x=F[n];
	scanf("%s",op);
	m=strlen(op);
	int d=0;
	for(int i=0;i<m;i++){
		if(op[i]=='R'){
			d++;
		}
	}
	int s=d+2*x;
	fn[0][0]=0;
	for(int i=1;i<s;i++){
		fn[0][i]=i;
	}
	for(int i=1;i<=n;i++){
		// cerr<<"n="<<i<<endl;
		bool qaq=false;
		int it=0;
		for(int k=0;k<3;k++){
			for(int j=0;j<F[i-1];j++){
				ins[k][j]=k*F[i-1]+j;
				// cerr<<ins[k][j]<<endl;
			}
		}
		for(int j=0;;j++){
			if(j>=m||op[j]=='R'){
				int a=F[i]+it;
				if(a>=s){
					break;
				}
				for(int k=0;k<3;k++){
					int f=qaq?k==1?2:k==2?1:0:k;
					// cerr<<f<<" << "<<a<<endl;
					if(F[i-1]+it<s)ins[f][F[i-1]+it]=a;
					a=ins[f][fn[i-1][it]];
					// cerr<<f<<" >> "<<a<<endl;
				}
				// cerr<<"it="<<it<<" "<<a<<endl;
				fn[i][it]=a;
				it++;
			}
			else{
				qaq^=1;
			}
		}
	}
	stack<int> ans;
	for(int i=0;i<x;i++){
		ins[0][i]=i;
	}
	for(int i=0;i<d+x;i++){
		int out=ins[0][fn[n][i]];
		if(i+x<s){
			ins[0][i+x]=out;// pipe
		}
		ans.push(out);
	}
	for(int i=0;i<x;i++){
		p[ans.top()]=i;
		ans.pop();
	}
	for(int i=0;i<x;i++){
		printf("%d ",p[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 85320
/*
"Won't stop until I'm phenomenal."
- Phenomenal, Eminem
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;

ll binmodulo(ll x, ll y){
    x%=mod1;
    if(!x) return 0;
    ll res = 1;
    while(y){
        if(y&1){
            res = res*x%mod1;
        }
        y/=2;
        x = x*x%mod1;
    }
    return res;
}

ll ncrr(ll n, ll r){
    //cout<<n<<" "<<r<<endl;
    if(n-r < r)
        r = n-r;
    ll x = 1;
    ll y = 1;
    for(int i = 1; i <= r; i++){
        x = x*(n+1-i)%mod1;
        y = y*i%mod1;
    }
  //  cout<<x<<" "<<y<<endl;
    return x*binmodulo(y,mod1-2)%mod1;
}

int main(){
    Shazam;
    ll x,y; cin>>x>>y;
    if((x+y)%3){
        cout<<0<<endl;
        return 0;
    }
    ll n = (x+y)/3;
    ll r = n/2;
    if(n<=x&&x<=2*n && n<=y && y <= 2*n)
        cout<<ncrr(n, (abs(x-2*n)+abs(y-n))/2)<<endl;
    else
        cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[200005],b[200005],n,k,t[200005];
bool check(int mid){
	FOR(i,1,n)t[i]=mid/b[i];
	int sum=0;
	FOR(i,1,n){
		sum=sum+max(0ll,a[i]-t[i]);
	}
	return sum<=k;
}
signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	cin>>n>>k;
	FOR(i,1,n)cin>>a[i];
	FOR(i,1,n)cin>>b[i];
	sort(a+1,a+n+1);sort(b+1,b+n+1,greater<int>());
	int l=0,r=1000000000000000000,mid,ans=-1;
	while(r>=l){
		mid=(l+r)>>1;
		if(check(mid)){
			ans=mid;r=mid-1;
		}else l=mid+1;
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 4992
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int a[N];
    void main()
    {
        int n=qread();
        int A=0,B=0,C=0;ll ans=1;
        fo(i,1,n)
        {
            int now=qread();bool x=A==now,y=B==now,z=C==now;
            if(x and y and z){C++;ans=ans*3%MOD;}
            else if(x and y and !z){B++;ans=ans*2%MOD;}
            else if(!x and y and z){C++;ans=ans*2%MOD;}
            else if(x)A++; else if(y)B++;else if(z)C++;
            else if(!x and !y and !z)
                ans=0;
            if(A>B)swap(A,B);if(A>C)swap(A,C);if(B>C)swap(B,C);
            // printf("(%d,%d,%d)\n",A,B,C);
        }
        write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 256
m, d=map(int, input().split())
ans=0

for i in range(1, m+1):#M月までの計算
    for j in range(10, d+1):
        d1=int(str(j)[0])
        d10=int(str(j)[1])
        if d1>=2 and d10>=2 and d1*d10==i:
            ans=ans+1

print(ans)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b) {return a/gcd(a,b)*b; }
template<class T> bool isPrime(T num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (T i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

using namespace std;

int a,b,c;
int n,m,h,cnt,ans;
string s,t;

main()
{
        cin>>h>>n;
        rep(i,n)
        {
            cin>>a;
            h-=a;
            if(h<=0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
input()
s = input()

l = 0
r = s[1:].count('E')
x = l + r

for i in range(1, len(s)):
  if s[i - 1] == 'W':
    l += 1

  if s[i] == 'E':
    r -= 1
  x = min(x, l + r)

print(x)


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,sum = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    if(sum + K < sum * 2){
      sum += K;
    }else{
      sum *= 2;
    }
  }
  cout << sum << endl;
}

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

using namespace std;

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

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

void sub()
{
    const auto N(cin2var<size_t>());
    const auto As(cin2vec<int>(N));
    const auto Bs(cin2vec<int>(N));
    const auto Cs(cin2vec<int>(N));
    size_t satisfaction_degrees = 0;
    int prev_index = N * 2;
    for (const auto a : As) {
        const auto index = a - 1;
        satisfaction_degrees += Bs[index];
        if (prev_index + 1 == index) {
            satisfaction_degrees += Cs[index - 1];
        }
        prev_index = index;
    }
    cout << satisfaction_degrees << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    sub();
    return 0;
}

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

int main(){
    int n;
    string str, s1;
    string order;
    int a, b;
    cin >> str;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> order >> a >> b;
        if (order == "print") {
            for (int i = a; i <= b; i++) {
                cout << str[i];
            }
        cout << "\n";
        } else if (order == "reverse") {
            for (int i = a, j = b; i < j; i++, j--) swap(str[i], str[j]);
        } else if (order == "replace") {
            cin >> s1;
            str.replace(a, b-a+1, s1);
        }
    }
    return 0;
}


Measured memory_bytes: 3200
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
 	//鬼の座標
    long a = sc.nextLong();
    //鬼のはやさ
    long v = sc.nextLong();
    //逃げる人の座標
    long b = sc.nextLong();
    //はやさ
    long w = sc.nextLong();
    //秒数
    long t = sc.nextLong();
    
    //逃げる人の方が早い時
    if(v <= w){
      System.out.print("NO");
    }
    //鬼の方が早い
    if(v > w){
      long dist = Math.abs(a - b);
      long dif = v - w;
      if(dist <= dif * t){
        System.out.print("YES");
      }else{
        System.out.print("NO");
      }
    }
  }
}


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

using namespace std;
typedef long long ll;

int main() {
    int m;
    cin >> m;
    ll digit = 0;
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        ll d, c;
        cin >> d >> c;
        digit += c;
        sum += d * c;
    }
    cout << digit + (sum - 1) / 9 - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
ll dp[105][130];
int main(){
    int h,w,k; cin >>h >> w >> k;
    dp[0][0] = 1;
    REP(i,h){
        REP(j,pow(2,w-1)){
            bool isok = true;
            REP(k,w-2){
                if(j>>k & j>>(k+1)) {
                    isok = false; 
                    break;
                }
            }
            if(!isok) continue;
            REP(k,w){
                dp[i+1][k] += dp[i][k];
            }
            REP(k,w-1){
                if(j>>k & 1){
                        dp[i+1][k] += dp[i][k+1] - dp[i][k];
                        dp[i+1][k+1] += dp[i][k] - dp[i][k+1];
                }
            }
            REP(k,w){
                dp[i+1][k] = dp[i+1][k] % (ll)(1e9+7);
            }
        }
    }
    
    cout << dp[h][k-1] << endl; 




}

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

int main(){
  double x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  printf("%f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
 
  return 0;
}


Measured memory_bytes: 3292
/* (1) o     => o
 * (2) oxo   => o ; The number of inner x is odd.
 * (3) oxoxo => o ; The number of inner x is even.
 * (4) ox    => o ; The number of x is odd.
 * (5) oxox  => o ; The number of x is even
 * (6) x     => x
 * (7) xox   => x ; The number of inner o is odd.
 * (8) xoxox => x ; The number of inner o is even.
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  char c[ 51 ];

  scanf ( "%s", c );
  puts ( c[ 0 ] == 'o'
      || c[ strlen ( c ) - 1 ] == 'o'
       ? "o" : "x" );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

void solve(){
  ll h,w; cin>>h>>w;
  auto A=make_v(h,w,0);
  auto B=make_v(h,w,0);
  rep(i,h)rep(j,w) cin>>A[i][j];
  rep(i,h)rep(j,w) cin>>B[i][j];
  const ll ofs=12800;
  auto dp=make_v(h,w,bitset<2*ofs+1>(0));
  ll x=abs(A[0][0]-B[0][0]);
  dp[0][0].set(ofs+x);
  dp[0][0].set(ofs-x);
  
  rep(i,h)rep(j,w){
    if(i==0 && j==0) continue;
    ll x=abs(A[i][j]-B[i][j]);
    bitset<2*ofs+1> S;
    if(i>0) S|=dp[i-1][j];
    if(j>0) S|=dp[i][j-1];
    dp[i][j]=(S<<x)|(S>>x);
  }
  rep(i,ofs+1){
    if(dp[h-1][w-1].test(i+ofs)){
      cout<<i<<"\n";
      return;
    }
  }
}

Measured memory_bytes: 20736
#include <stdio.h>
#include <stdlib.h>
struct Node{
  int depth;
  int p;//parent
  int l,r; 
} ;
struct Node *tree;
int main(){
  
  int i,j,n,d,id,c,a,x,y;
  
  scanf("%d",&n);
  tree = malloc(sizeof(struct Node)*n);
  
  for(i=0;i<n;i++){
    tree[i].p = tree[i].l = tree[i].r = -1;
  }
    for(i=0;i<n;i++){
    scanf("%d%d",&id,&d);
   
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	tree[id].l = c;
	tree[c].p = id;
	a = c;
      }else{
	tree[a].r = c;
	tree[c].p = id;
	a = c;
      }
    }
  }
  
  for(i=0;i<n;i++){
    x=0;
    y=i;
    while(tree[y].p>-1){
      y = tree[y].p;
      x++;
    }
    tree[i].depth = x; 
  }

  
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].p,tree[i].depth);
    if(tree[i].p == -1)printf("root, ");
    else if(tree[i].l == -1)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    if(tree[i].l != -1){
      printf("%d",tree[i].l);
      a = tree[i].l;
      while(1){
	if(tree[a].r == -1)break;
	printf(", %d",tree[a].r);
	a = tree[a].r;
      }
    }
    printf("]\n"); 
  }
  

  free(tree);
  
  
  return 0;
  }




Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> v;
    rep(i,n){
        int a;
        cin >> a;
        v.push_back(a);
    }
    ll ans = 0;
    vector<P> p;
    rep(i,m){
        int b, c;
        cin >> b >> c;
        p.push_back(P(c,b));
    }
    sort(p.begin(), p.end(), greater<P>());
    int now = 0;
    rep(i,m){
        rep(j,p[i].second){
            if(now == n)break;
            v.push_back(p[i].first);
            now++;
            
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    rep(i,n){
        // cout << v[i] << ' ';
        ans += v[i];
    }

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


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

Int N, M, V, P;
vector<Int> A(100010);

bool saiyou(int X){ //スコアがX番目の問題が採用されうるか
    if(X <= P-1) return true;
    if(A[X] + M < A[P-1]) return false;

    Int votes = 0;
    rep(i,N){
        if(i<=P-2) votes += M;
        else if(i >= X) votes += M;
        else votes += A[X]+M - A[i];
    }

    return votes >= M*V;
}

int main(){
    cin >> N >> M >> V >> P;
    rep(i,N) cin >> A[i];

    sort(A.begin(), A.begin()+N, greater<Int>());
    
    int l=0, r = N;
    while(r-l>1){
        int mid = (l+r)/2;
        if(saiyou(mid)) l = mid;
        else r = mid;
    }

    cout << r << endl;
}


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

int n;
int b[3][110],arr[3][110];

int dfs(int x,int y)
{
    int p,q;
    p = arr[x][y];
    q = arr[x][y];
    
    if(x == 2 && y == n)
    {
        return arr[x][y];
    }
    if(y + 1 <= n)
    {
        if(b[x][y + 1] > 0)
        {
            p += b[x][y + 1];
        }
        else
        {
            b[x][y + 1] = dfs(x,y + 1);
            p += b[x][y + 1];
        }
    }
    
    if(x + 1 <= 2)
    {
        if(b[x + 1][y] > 0)
        {
            q += b[x + 1][y];
        }
        else
        {
            b[x + 1][y] = dfs(x + 1,y);
            q += b[x + 1][y];
        }
    }
    
    if(p > q)
    {
        b[x][y] = p;
        return b[x][y];
    }
    else
    {
        b[x][y] = q;
        return b[x][y];
    }
}

int main()
{
    cin>>n;
    for(int i = 1; i <= 2;i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cin >> arr[i][j];
        }
    }
    cout << dfs(1,1);
    return 0;
}


Measured memory_bytes: 504
def main(a, b, x):
    if x > b:
        return 0
    elif x == b:
        return 1

    minimum, maximum = None, None

    for i in range(a, b + 1):
        if i % x == 0:
            minimum = i
            break

    for i in range(b, a - 1, -1):
        if i % x == 0:
            maximum = i
            break

    if minimum != None or maximum != None:
        if minimum != None and maximum != None:
            # 普通の / 除算だと3で割ったときに大きくずれる。
            return (maximum - minimum) // x + 1
        else:
            return 1
    else:
        return 0


def main_b(a, b, x):
    """解説を読んだ。単純なことだった。
    """
    def count(n):
        if n == -1:
            return 0
        else:
            return n // x + 1

    return count(b) - count(a-1)


if __name__ == "__main__":
    a, b, x = [int(x) for x in input().split()]
    print(main_b(a, b, x))


Measured memory_bytes: 3064
from sys import stdin

input = stdin.readline

N = int(input())

txy = [[int(j) for j in input().split()] for i in range(N)]


def main():
    pt = 0
    px = 0
    py = 0

    flg = False

    for t, x, y in txy:
        d = abs(x - px) + abs(y - py)
        dt = t - pt
        # 到達 あるいは 通過
        # 距離と時間の偶奇が一致 戻れる
        if d <= dt and d % 2 == dt % 2:
            pt = t
            px = x
            py = y
        # 到達しない
        # 戻れない
        else:
            break
    else:
        # break しなかった 完走
        flg = True

    print("Yes" if flg else "No")
    return


main()


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

int main() {
    long long N; cin >> N;
    long long amt = 0;
    for (long long i = 1000;; i += 1000) {
        if (i < N) continue;
        else {
            amt = i - N;
            break;
        }
    }
    cout << amt << "\n";
    return 0;
}

Measured memory_bytes: 3620
import math
n = int(input())
x = list(map(int, input().split()))
def average(line):
    return sum(line)/len(line)
ave_x = average(x)
p_1 = math.floor(ave_x)
p_2 = math.ceil(ave_x)
power_1 = 0
power_2 = 0
for i in range(len(x)):
    power_1 += (x[i]-p_1)**2
    power_2 += (x[i]-p_2)**2
print(min(power_1,power_2))

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

int main(){
	string s;
	cin >> s;
	int num[26] = {0};
	for(int i=0; i<s.size(); i++){
		if(s[i]=='a') num[0]++;
		if(s[i]=='b') num[1]++;
		if(s[i]=='c') num[2]++;
		if(s[i]=='d') num[3]++;
		if(s[i]=='e') num[4]++;
		if(s[i]=='f') num[5]++;
		if(s[i]=='g') num[6]++;
		if(s[i]=='h') num[7]++;
		if(s[i]=='i') num[8]++;
		if(s[i]=='j') num[9]++;
		if(s[i]=='k') num[10]++;
		if(s[i]=='l') num[11]++;
		if(s[i]=='m') num[12]++;
		if(s[i]=='n') num[13]++;
		if(s[i]=='o') num[14]++;
		if(s[i]=='p') num[15]++;
		if(s[i]=='q') num[16]++;
		if(s[i]=='r') num[17]++;
		if(s[i]=='s') num[18]++;
		if(s[i]=='t') num[19]++;
		if(s[i]=='u') num[20]++;
		if(s[i]=='v') num[21]++;
		if(s[i]=='w') num[22]++;
		if(s[i]=='x') num[23]++;
		if(s[i]=='y') num[24]++;
		if(s[i]=='z') num[25]++;
	}
	if(num[0]==0){
		cout << 'a' << endl;
		return 0;
	}
	if(num[1]==0){
		cout << 'b' << endl;
		return 0;
	}
	if(num[2]==0){
		cout << 'c' << endl;
		return 0;
	}
	if(num[3]==0){
		cout << 'd' << endl;
		return 0;
	}
	if(num[4]==0){
		cout << 'e' << endl;
		return 0;
	}
	if(num[5]==0){
		cout << 'f' << endl;
		return 0;
	}
	if(num[6]==0){
		cout << 'g' << endl;
		return 0;
	}
	if(num[7]==0){
		cout << 'h' << endl;
		return 0;
	}
	if(num[8]==0){
		cout << 'i' << endl;
		return 0;
	}
	if(num[9]==0){
		cout << 'j' << endl;
		return 0;
	}
	if(num[10]==0){
		cout << 'k' << endl;
		return 0;
	}
	if(num[11]==0){
		cout << 'l' << endl;
		return 0;
	}
	if(num[12]==0){
		cout << 'm' << endl;
		return 0;
	}
	if(num[13]==0){
		cout << 'n' << endl;
		return 0;
	}
	if(num[14]==0){
		cout << 'o' << endl;
		return 0;
	}
	if(num[15]==0){
		cout << 'p' << endl;
		return 0;
	}
	if(num[16]==0){
		cout << 'q' << endl;
		return 0;
	}
	if(num[17]==0){
		cout << 'r' << endl;
		return 0;
	}
	if(num[18]==0){
		cout << 's' << endl;
		return 0;
	}
	if(num[19]==0){
		cout << 't' << endl;
		return 0;
	}
	if(num[20]==0){
		cout << 'u' << endl;
		return 0;
	}
	if(num[21]==0){
		cout << 'v' << endl;
		return 0;
	}
	if(num[22]==0){
		cout << 'w' << endl;
		return 0;
	}
	if(num[23]==0){
		cout << 'x' << endl;
		return 0;
	}
	if(num[24]==0){
		cout << 'y' << endl;
		return 0;
	}
	if(num[25]==0){
		cout << 'z' << endl;
		return 0;
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000000+7;

int main() {
  int n;
  cin>>n;
  vector<int> H;
  rep(i,n){
    long h;
    cin>>h;
    H.push_back(h);
  }
  vector<int> done(n,false);
  
  bool ans=true;
  for(int i=n-1;i>0;--i){
    if(H[i]<H[i-1]){
      H[i-1]--;
      if(H[i]<H[i-1]){
        ans=false;
        break;
      }
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
    
}


Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int h[N];
    int dp[N];
    fill(dp, dp + N, INT_MAX);
    dp[0] = 0;
    for (int &content : h) {
        cin >> content;
    }
    for (int i = 0; i < N; i++) {
        for (int k = 1; k <= K; k++) {
            if (i + k < N) {
                dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
            }
        }
    }
    cout << dp[N - 1] << endl;

}

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

// theater.cpp
// author: Seong Yong-ju ( @sei40kr )
// Copyright (c) 2017 Seong Yong-ju

#define DEBUG(x) cout << #x << ": " << x << endl

#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); --i)

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)

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

using namespace std;

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

  int n;
  cin >> n;
  int ans = 0;
  REP(i, n) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;

int dp[1011][10011];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll h,n; cin >> h >> n;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<=h;j++){
			dp[i][j]=1e9;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=h;j++){
			if(dp[i][j]==1e9)continue;
			if(dp[i+1][j]>dp[i][j]){
				dp[i+1][j]=dp[i][j];
			}
			if(dp[i+1][min(h,j+a[i])]>dp[i][j]+b[i]){
				dp[i+1][min(h,j+a[i])]=dp[i][j]+b[i];
			}
			if(dp[i][min(h,j+a[i])]>dp[i][j]+b[i]){
				dp[i][min(h,j+a[i])]=dp[i][j]+b[i];
			}
		}
	}
	cout << dp[n-1][h] << endl;
}

Measured memory_bytes: 39424
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>

using namespace std;


int main() {

    int N;
    cin >> N;
    vector<long> vs;

    long currentMinV = 1000000001;
    int currentMinVPosition;

    for (int i = 0; i < N; i++) {
        long A;
        cin >> A;
        vs.push_back(A);

        if (currentMinV > A) {
            currentMinV = A;
            currentMinVPosition = i;
        }


    }

    int numOfLivingM = N;

    while (numOfLivingM != 1) {

        for (int i = 0; i < N; i++) {

            if (i == currentMinVPosition) {
                continue;
            }

            if (vs[i] > 0) {
                vs[i] %= currentMinV;

                if (vs[i] <= 0) {
                    numOfLivingM -= 1;
                } else {

                    if (currentMinV > vs[i]) {
                        currentMinV = vs[i];
                        currentMinVPosition = i;
                    }

                }
            }
        }
    }

    cout << currentMinV << "\n";

    return 0;
}

Measured memory_bytes: 1400