akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

ll gcd(ll a, ll b){
  if(a < b)  swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(int i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}
ll nlcm(vector<ll> numbers) {
  ll res;
  res = numbers[0];
  for (ll i = 1; i < numbers.size(); i++) {
    res = lcm(res, numbers[i]);
  }
  return res;
}

signed main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll min_c = (a + c - 1) / c * c;
  ll max_c = b / c * c;
  ll cnt_c = 0;
  if(min_c <= max_c){
    cnt_c = (max_c - min_c) / c + 1;
  }

  ll min_d = (a + d - 1) / d * d;
  ll max_d = b / d * d;
  ll cnt_d = 0;
  if(min_d <= max_d){
    cnt_d = (max_d - min_d) / d + 1;
  }

  ll cd = lcm(max(c, d), min(c, d));
  ll min_cd = (a + cd - 1) / cd * cd;
  ll max_cd = b / cd * cd;
  ll cnt_cd = 0;
  if(min_cd <= max_cd){
    cnt_cd = (max_cd - min_cd) / cd + 1;
  }
  // cout << cnt_c << " " << cnt_d << " " << cnt_cd << endl;
  cout << b - a + 1 - (cnt_c + cnt_d - cnt_cd) << endl;
  return 0;
}

Measured memory_bytes: 3660
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j]  = min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))
print(dp[N-1])

Measured memory_bytes: 56928
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/segtree>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

ll op(ll a, ll b){ 
	return max(a, b); 
}
ll e(){
	return -1;
}
int target;
bool f(ll v){ 
	return v < target;
}

int main() {
	cin>>N>>Q;
	vec a(N);
	rep(i, N) scanf("%lld", &a[i]);
	segtree<ll, op, e> seg(a);
	int t, x, l, r;
	ll v;
	rep(_, Q){
		scanf("%d", &t);
		if (t == 1) {
            scanf("%d%lld", &x, &v); --x;
            seg.set(x, v);
        } else if (t == 2) {
            scanf("%d%d", &l, &r); --l;
            printf("%lld\n", seg.prod(l, r));
        } else if (t == 3) {
            scanf("%d%d", &x, &target); --x;
			printf("%d\n", seg.max_right<f>(x) + 1);
        }
	}
}


Measured memory_bytes: 9124
#include <iostream>
using namespace std;
int main(){
  int N,M,k=0,a=0,count=0;
  cin >> N >> M;
  int food_status[M];
  for(int i=0;i<M;i++){
    food_status[i]=0;
  }
  for(int i=0;i<N;i++){
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      food_status[a-1]++;
      }
    }
for(int l=0;l<M;l++){
  if(food_status[l]==N){
    count++;
  }
}
cout<<count<<endl;
return 0;
  }


Measured memory_bytes: 256
// [abhishekvtangod]
// g++ -Wall -Wextra -Wshadow filename.cpp
#include<bits/stdc++.h>
using namespace std; 

#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)

typedef long long int ll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// oset<pair<ll,ll>> indexed_set;


#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


// 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 solve()
{
	ll a,b,c;cin>>a>>b>>c;
	swap(a,b);swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
}


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

	//ll t;cin>>t;
	//while(t--)
	//{
		solve();
	//}
	

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X[100];
  int N,K;
  cin >> N >> K;
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    ans += 2 * min(X[i],K - X[i]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// Problem : D - Moving Piece
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int c[maxN], p[maxN];

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;
	RI(i, n) cin >> p[i];
	RI(i, n) cin >> c[i];
	ll ans = -inf;
	RI(i, n) {
		int st = i;
		int len = 0;
		ll sum = 0;
		do {
			st = p[st];
			sum += c[st];
			len++;
			if (len <= k)
				ans = max(ans, sum);
			// cout << st << " " << sum << "a" << endl;
		} while (st != i);
		ll tmp = sum * (k / len);
		ll kk = k;
		kk %= len;
		st = i;
		REP(_, kk) {
			st = p[st];
			tmp += c[st];
			ans = max(ans, tmp);
		}
		ans = max(ans, tmp);
		// cout << k << " " << len << " " << sum << endl;
		ll z = (k / len) - 1;
		if (z >= 0) {
			ll tmp2 = sum * z;
			st = i;
			// cout << tmp2 << " " << i << endl;
			REP(_, len) {
				st = p[st];
				tmp2 += c[st];
				ans = max(ans, tmp2);
			}
		}
	}
	cout << ans;
	return 0;
}
 


Measured memory_bytes: 3700
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    cin>>n;
    vector<int> v1(n);
    for(int i=0;i<n;i++) cin>>v1[i];
    cout<<lexicographical_compare(v.begin(),v.end(),v1.begin(),v1.end())<<"\n";
}


Measured memory_bytes: 3104
// ※※※ 解答不能 ※※※
// WAを解消できず, 解答不能のため, 正解者のソースを勉強する方針に変更.
// pwild氏.
// https://atcoder.jp/contests/abc134/submissions/6458063
#include <bits/stdc++.h>
using namespace std;
int main(){

    int N;
    scanf("%d", &N);
    vector<int> A(N + 1), res;
    for(int i = 1; i < N + 1; i++) scanf("%d", &A[i]);
    for(int i = N; i >= 1; i--){
        for(int j = i + i; j <= N; j += i) A[i] ^= A[j];
        if(A[i]) res.push_back(i);
    }
    printf("%d\n", res.size());
    for (int x : res) printf("%d ", x);
    return 0;

}
// WA版.
// 解き直し.
// ABC 134解説.
// https://img.atcoder.jp/abc134/editorial.pdf
// #include <bits/stdc++.h>
// using namespace std;
// const int MAX = 2e5 + 1;
// int A[MAX], box[MAX];
// 
// int main(){
// 
//     // 1. 入力情報取得.
//     int N;
//     scanf("%d", &N);
//     for(int i = 1; i <= N; i++) scanf("%d", A + i);
//     
//     // 2. 解説通り.
//     for(int i = N; i >= 1; i--){
//         // i番目の箱に, ボールを入れるかどうかは, i * 2, i * 3, ～ i * [N / i]番目までを確認すれば十分.
//         int ball = 0;
//         for(int j = i * 2; j <= N; j += i) if(A[j] == 1) ball++;
//         // 偶奇で, ボールを入れるか分岐.
//         if(ball % 2 != A[i]) box[i] = 1;
//         else                 box[i] = 0;
//     }
//     
//     // 3. 判定.
//     int count = 0;
//     for(int i = 1; i <= N; i++) if(box[i] == 1) count++;
//     
//     // 4. 出力 ～ 後処理.
//     printf("%d\n", count);
//     if(count > 0) for(int i = 1; i <= N; i++) if(box[i] == 1) printf("%d ", i);
//     return 0;
// 
// }

Measured memory_bytes: 2424
import java.util.Scanner;

public class Main {

	boolean[][] map;
	boolean[][] visited;
	final int N = 12;
	int cnt;
	boolean flag;
	boolean start=false;
	
	void Land(int i, int j){
		if(i<0||j<0||i>=N||j>=N||map[i][j]==false||visited[i][j]==true){
			return;
		}
		visited[i][j] = true;
		flag = true;
		Land(i+1,j);
		Land(i,j+1);
		Land(i-1,j);
		Land(i,j-1);
	}
	
	void Search(){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				flag = false;
				Land(i,j);
				if(flag){
					cnt++;
				}
			}
		}
	}
	
	void run(){
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()){
			if(start){
				stdIn.nextLine();
			}
			start = true;
			map = new boolean[N][N];
			visited = new boolean[N][N];
			for(int i=0;i<N;i++){
				char[] line = stdIn.nextLine().toCharArray();
				for(int j=0;j<N;j++){
					if(line[j]=='1'){
						map[i][j] = true;
					}
				}
			}
			cnt = 0;
			Search();
			System.out.println(cnt);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

ans=0
chk=[0]*N
for n in range(N):
  c=T[n]
  if n>=K and T[n-K]==c and chk[n-K]==0:
    chk[n]=1 # not used
    continue
  if c=='r':
    ans+=P
  elif c=='s':
    ans+=R
  else:
    ans+=S

print(ans)

Measured memory_bytes: 10000
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll culc(string x){
    string now = "";
    ll sum = 0;
    for (int i = 0; i < x.length(); i++) {
        if(x[i] == '+'){
            sum += stoll(now);
            now = "";
        }else if(i == x.length()-1){
            now = now + x[i];
            sum += stoll(now);
        }else{
            now = now + x[i];
        }
    }
    // std::cout << sum << std::endl;
    return sum;
}


int main(){
    string s;
    std::cin >> s;
    ll result = 0;
    for (int i = 0; i < (1<<(s.length()-1) ); i++) {
        string str = "a";
        str[0] = s[0];
        for (int j = 1; j < s.length(); j++) {
            if( i & (1<<(j-1)) ){
                str = str + "+"+ s[j];
            }else{
                str = str+s[j];
            }
        }
        // std::cout << str << std::endl;
        result += culc(str);
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
	int sum = 0;
	int p;
	for (int i=0; i<5; i++) {
		cin >> p;
		if(p < 40) { p = 40; }
		sum += p;
	}
	cout << sum / 5 << endl;
	return 0 ;
}

Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn=3e3+15; 
ll n,mod;
ll g[maxn][maxn],c[maxn][maxn];
ll mul(ll a,ll b,ll p)
{
	ll r=0;
	for (;b;b>>=1,a=(a+a)%p) if (b&1) r=(r+a)%p;
	return r;
}
ll qpow(ll a,ll b,ll p)
{
	ll r=1;
	for (;b;b>>=1,a=mul(a,a,p)) if (b&1) r=mul(r,a,p);
	return r;
}
int main()
{
	scanf("%lld%lld",&n,&mod);	
	for (int i=1;i<=n;i++)
	{
		c[i][0]=c[i][i]=1;
		for (int j=1;j<i;j++)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	for (int i=0;i<=n;i++)
	{
		g[i][0]=1;
		for (int j=1;j<=i;j++)
			g[i][j]=(g[i-1][j-1]+g[i-1][j]*(j+1)%mod)%mod;	
	}
	ll ans=0;
	for (int i=0;i<=n;i++)
	{
		ll k=c[n][i];
		if (i&1) k=(mod-k)%mod;
		ll x=qpow(2,n-i,mod-1);//欧拉定理，注意模数
		x=qpow(2,x,mod);
		ll kind=qpow(2,n-i,mod);
		ll cnt=0,y=1;
		for (int j=0;j<=i;j++)
		{
			cnt=(cnt+(g[i][j]*y%mod))%mod;
			y=kind*y%mod;
		} 
		ans=(ans+(k*cnt%mod*x%mod))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int L[20][222222],R[20][222222];

int N,V;
int X[222222];


int dp1[1<<18];
int dp2[1<<18];


int acc[222222];

signed main(){
    cin>>N>>V;
    rep(i,N)cin>>X[i];
    rep(k,20){
        rep(i,N){
            L[k][i]=i;
            if(i&&X[i]-X[i-1]<=(V>>k))L[k][i]=L[k][i-1];
        }
        for(int i=N-1;i>=0;i--){
            R[k][i]=i;
            if(i+1!=N&&X[i+1]-X[i]<=(V>>k))R[k][i]=R[k][i+1];
        }
    }

    rep(i,1<<18){
        rep(j,18){
            if(i>>j&1)continue;
            if((V>>j)==0)chmax(dp1[i|(1<<j)],dp1[i]);
            else if(dp1[i]==N)dp1[i|(1<<j)]=N;
            else chmax(dp1[i|(1<<j)],R[j+1][dp1[i]]+1);
        }
    }

    rep(i,1<<18)dp2[i]=N-1;
    rep(i,1<<18){
        rep(j,18){
            if(i>>j&1)continue;
            if((V>>j)==0)chmin(dp2[i|(1<<j)],dp2[i]);
            else if(dp2[i]==-1)dp2[i|(1<<j)]=-1;
            else chmin(dp2[i|(1<<j)],L[j+1][dp2[i]]-1);
        }
    }

    rep(i,1<<18){
        int j=(1<<18)-1-i;

        if(dp1[i]>dp2[j]){
            acc[0]++;
            continue;
        }


        if(R[0][dp1[i]]>=dp2[j]){
            acc[L[0][dp1[i]]]++;
            acc[R[0][dp1[i]]+1]--;
        }
    }

    rep(i,N){
        acc[i+1]+=acc[i];
        if(acc[i]){
            puts("Possible");
        }
        else{
            puts("Impossible");
        }
    }
    return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long

void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}

const int MAX = 2e5 + 5;

int n;

int a[MAX];

ll dp[MAX][3]; // dp[N][K] holds the maximum sum of choosing N / 2 element and skipping at most K elements

ll solve(int idx, int k)
{
    if (idx > n)
    {
        return k ? -1e17 : 0;
    }
    
    ll &ret = dp[idx][k];

    if (~ret)
    {
        return ret;
    }
    ret = -1e17;

    if (k) // you can skip k elements in the serius
    {
        ret = max(ret, solve(idx + 1, k - 1));
    }
    ret = max(ret, solve(idx + 2, k) + a[idx]);
    return ret;

}

int main(int argc, char const *argv[])
{
    file();
    
    cin>>n;

    memset(dp, -1, sizeof(dp));
    
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }

    cout<<solve(0, (n & 1) + 1);
        

}

Measured memory_bytes: 15312
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

ll dp[100010];
int n,k;

int main() {
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];

  dp[0] = 0;
  
  // loop
  for (int i = 1; i < n; ++i) {
    dp[i] = INF;
    for (int s = 1; s <= k; ++s) {
      if (i - s >= 0) {
        dp[i] = min(dp[i], dp[i - s] + abs(h[i] - h[i - s]));
      } else {
        break;
      }
    }
  }

  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
from scipy.sparse.csgraph import floyd_warshall
h,w=map(int,input().split())
s=[input() for _ in range(h)]
n=w*h
e=[[0]*n for _ in range(n)]
d=[(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
  for j in range(w):
    if s[i][j]==".":
      for x,y in d:
        ni,nj=i+x,j+y
        if 0<=ni<h and 0<=nj<w and s[ni][nj]==".":
          e[w*i+j][w*ni+nj]=1
ans=floyd_warshall(e)
INF=float("inf")
print(int(max(max(a if a != INF else 0 for a in a) for a in ans)))

Measured memory_bytes: 17980
def main():
    N, M = map(int, input().split())
    li_max = 0
    ri_min = 10 ** 5
    for i in range(M):
        li, ri = map(int, input().split())
        if li > li_max:
            li_max = li
        if ri < ri_min:
            ri_min = ri
    ans = ri_min - li_max + 1
    if ans < 0:
        ans = 0
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44520
n = int(input())
A = list(map(int, input().split()))

flag = True

for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            flag = False
            break

if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
n, k = map(int, input().split())
lst = []
tmp = []
count = 0
for i in range(k):
    d = int(input())
    a = input().split()
    lst.append(a)
for i in range(k):
    tmp.extend(lst[i])
for j in range(1, n+1):
        if str(j) not in tmp:
            count +=1
print(count)




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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++)
    {
        if(i%2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    std::cout << alice - bob << "\n";
}

Measured memory_bytes: 256
#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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vpii = vector<pair<int, int>>;

int main()
{
  int n;
  cin >> n;
  int min_cnt = 0, max_cnt = 0;
  vi vec(8, 0);
  vi a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    if (a[i] / 400 < 8)
      vec[a[i] / 400]++;
    if (a[i] / 400 >= 8)
      max_cnt++;
  }
  for (int i = 0; i < 8; i++)
  {
    if (vec[i] != 0)
    {
      min_cnt++;
      max_cnt++;
    }
    
  }
  if(min_cnt==0){min_cnt++;}
  cout << min_cnt << " " << max_cnt << endl;
}


Measured memory_bytes: 3608
fun main(args: Array<String>) {
    val len = getInt()
    val s = getInts().toSet()
    if (len == s.size) println("YES")
    else println("NO")
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }

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

int main() {
  int N; cin >> N;
  int cnt = 0;
  bool ans = true;
  for (int i = 0; i < N; ++i) {
    string s; cin >> s;
    if (s[0] == 'A') {
      ++cnt;
    } else {
      --cnt;
      if (cnt < 0) ans = false;
    }
  }
  cout << ( (ans && !cnt) ? "YES" : "NO" ) << endl;
  return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



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


    {
        if(b-a==c-b)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    dbg cout <<ans<<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;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  bool flag = false;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; b <= m; b++) {
      if (a * (m - b) + b * (n - a) == k) flag = true;
    }
  }
  // for (int a = 0; a <= n; a++) {
  //   int b = (a * m - k) / (n - 2 * a);
  //   if (a * (m - b) + b * (n - a) == k) flag = true;
  // }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const double eps = 0.00001;
const int MOD = 1000000007; //998244353
const int INF = 1070000055;
const long long LINF = 1223372000000000555;
const int N = 1050555;
const int M = 6525;

ll a[N];
ll suf[N];

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

    ll sum = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }

    for (int i = n; i >= 1; i--){
        suf[i] = suf[i+1] + a[i];
        suf[i] %= MOD;
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++){
        ans += a[i] * suf[i+1];
        ans %= MOD;
    }

    cout << ans;

}


int main() {
    ios_base::sync_with_stdio(false);
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 6776
A, B, C, D = map(int, input().split())
counter = 1
while A > 0 and C > 0:
    if counter % 2 == 1:
        '''T 攻击'''
        C -= B
    elif counter % 2 == 0:
        A -= D
    counter += 1
if A <= 0:
    print('No')
else:
    print('Yes')

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

int main() {
  int a,b;
 
  cin >> a>>b ;
  
  if (a <6){
    cout <<"0" <<endl;
  }
  else if (a<13){
    cout << b/2 << endl;
  }
  
else{
   cout << b <<endl;
 }
}

  




Measured memory_bytes: 256
import itertools
n, m, q = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(q)]
r = 0
for A in itertools.combinations_with_replacement(range(m), n):
    s = 0
    for i in range(q):
        if A[x[i][1] - 1] - A[x[i][0] - 1] == x[i][2]:
            s += x[i][3]
    r = max(r, s)
print(r)

Measured memory_bytes: 9060
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())



n, m = li()
edge = dict()
graph = [[] for _ in range(n)]
visited = [False]*n
par = [-1]*n
outs = [0]*n

for _ in range(m):
    a, b = li_()
    edge[(a, b)] = 0
    edge[(b, a)] = 0
    graph[a].append(b)
    graph[b].append(a)

def dfs(graph, visited, par, root, cur):

    for nex in graph[cur]:
        if visited[nex]:
            continue

        else:
            visited[nex] = True
            par[nex] = cur

            dfs(graph, visited, par, root, nex)

    if cur == root:
        return

    for neighbor in graph[cur]:
        if neighbor == par[cur]:
            continue

        if edge[(cur, neighbor)] != 0:
            continue

        edge[(cur, neighbor)] = 1
        edge[(neighbor, cur)] = -1

        outs[cur] += 1

    if outs[cur] % 2:
        edge[(cur, par[cur])] = 1
        edge[(par[cur], cur)] = -1
        outs[cur] += 1

    else:
        edge[(cur, par[cur])] = -1
        edge[(par[cur], cur)] = 1
        outs[par[cur]] += 1


if m % 2:
    print(-1)

else:
    visited[0] = True
    dfs(graph, visited, par, 0, 0)

    for (src, dst), val in edge.items():
        if val == 1:
            print(src+1, dst+1)


Measured memory_bytes: 216128
using System;
using System.Collections;

class Program {
    static void Main (string[] args) {
        string[] S = Console.ReadLine ().Split (' ');
        long A = long.Parse (S[0]);
        long B = long.Parse (S[1]);
        long N = long.Parse (S[2]);

        long x = Math.Min (N, B - 1);

        long ans = (long) Math.Floor ((double) A * (double) x / (double) B) - A * (long) Math.Floor ((double) x / (double) B);

        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 27532
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vvll vector<vll>
#define wh(t) while(t--)
#define fi(n) for(ll i = 0; i < n; i++)
#define fj(n) for(ll j = 0; j < n; j++)
#define fu(i,s,e) for(ll i = s; i <=e; i++)
#define fd(i,s,e) for(ll i = s; i >=e; i--)
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fr first
#define se second
#define sll stack<ll>
#define qll queue<ll>
using namespace std;
const ll M = 1e9+7;
//const ll M = 998244353;

ll pmp(ll x,ll n){ll a = 1;while(n > 0){if(n & 1) a = (a * x)%M;x = (x * x)%M;n = n>>1;}return a;}

void solve(){
	ll n;
	cin >> n;
	vll a(4,0);
	fi(n){
		string s;
		cin >> s;
		if(s=="AC") a[0]++;
		if(s=="WA") a[1]++;
		if(s=="TLE") a[2]++;
		if(s=="RE") a[3]++;
	}
	cout << "AC x " << a[0] << endl;
	cout << "WA x " << a[1] << endl;
	cout << "TLE x " << a[2] << endl;
	cout << "RE x " << a[3] << endl;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	#endif
	ll t;
	t = 1;
	// cin >> t;
	wh(t){
		solve();
	}
	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    int n;
    cin>>n;
    vi v(n);
    map<ll,ll> m;
    ll sum=0;
    rep(i,n){
        cin>>v[i];
        m[v[i]]++;
        sum+=v[i];
    }
    ll q;
    cin>>q;
    rep(i,q){
        ll b,c;
        cin>>b>>c;
        ll count=m[b];
        m.erase(m.find(b));
        sum-=b*count;
        sum+=c*count;
        m[c]+=count;
        fin(sum);
    }
    
}

Measured memory_bytes: 7468
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
        signed main() {
    int n,d,x;
    cin>>n>>d>>x;
    int ans=x,a;
    for(int i=0;i<n;i++){
            cin>>a;
            ans+=1+(d-1)/a;
    }
    cout<<ans;
      }

        


Measured memory_bytes: 256
// 1_7_C
#include<stdio.h>

int main(void){
	int r, c, i, j, rawSum, columnSum;
	int sheet[101][101];
	
	scanf("%d %d", &r, &c);

	for(i = 0; i < r; i++){
		rawSum = 0;
		for(j = 0; j < c; j++){
			scanf("%d", &sheet[i][j]);
			rawSum += sheet[i][j];
		}
		sheet[i][j] = rawSum;
	}

	for(j = 0; j < c+1; j++){
		columnSum = 0;
		for(i = 0; i < r; i++){
			columnSum += sheet[i][j];
		}
		sheet[i][j] = columnSum;
	}

	for(i = 0; i < r+1; i++){
		for(j = 0; j < c; j++){
			printf("%d ", sheet[i][j]);
		}
		printf("%d\n", sheet[i][j]);
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
   ll r;
   cin >> r;
   ll ans=3*r*r;
   cout << ans << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    a1 = [int(i) for i in input().split()]
    a2 = [int(i) for i in input().split()]
    a3 = [int(i) for i in input().split()]
    a =[]
    a.extend(a1)
    a.extend(a2)
    a.extend(a3)
    n = int(input())

    for  i in range(n):
        b = int(input())
        if b in a:
            a[a.index(b)] = 0
    ans = []
    ans.append(a[0] + a[1] + a[2] )
    ans.append(a[3] + a[4] + a[5] )
    ans.append(a[6] + a[7] + a[8] )

    ans.append(a[0] + a[3] + a[6] )
    ans.append(a[1] + a[4] + a[7] )
    ans.append(a[2] + a[5] + a[8] )

    ans.append(a[0] + a[4] + a[8] )
    ans.append(a[2] + a[4] + a[6] )

    if 0 in ans:
        print("Yes")
    else:
        print("No")





Measured memory_bytes: 3064
L, R = map(int, input().split())

if R-L >= 2019:
    print(0)
    exit()

flag = True
ans = 2020

for i in range(L, L+2018):
    if flag:
        for j in range(i+1, R+1):
            if i > R:
                flag = False
                break
            ans = min(((i % 2019) * (j % 2019)) % 2019, ans)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}
#define NUM_MAX 200000
#define BUF_MAX (NUM_MAX+50)

int check(char *str1, char *str2, int len) {
    int i;
    char map[256] = {0};
    for(i = 0; i < len; i++) {
        if(!map[str1[i]]) {
            map[str1[i]] = str2[i];
            continue;
        }
        if(map[str1[i]] != str2[i]) return 0;
    }
    return 1;
}

int main(void) {
    static char sstr[BUF_MAX];
    static char tstr[BUF_MAX];
    get_str(sstr, BUF_MAX);
    get_str(tstr, BUF_MAX);

    // start == len
    int len = strlen(sstr);
    int flag = 1;
    flag &= check(sstr, tstr, len);
    flag &= check(tstr, sstr, len);
    printf("%s\n", flag ? "Yes" : "No");
    return 0;
}

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

#define ll long long
#define met(a, x) memset(a,x,sizeof(a))
#define inf 0x3f3f3f3f
#define ull unsigned long long
#define mp make_pair

using namespace std;
const int mod = 998244353;
const int N = 3e5 + 10;
const int M = 1e6 + 10;
ll a[100];

bool cmp(ll x, ll y) {
    return x > y;
}

ll C[300][300];

void init() {
    met(C, 0);
    C[0][0] = 1;
    for (int i = 1; i <= 50; i++) {
        C[i][0] = 1;
        for (int j = 1; j <= i; j++)
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    int n, l, r;
    cin >> n >> l >> r;
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        sort(a + 1, a + 1 + n, cmp);
        double ans=0;
        for(int i=1;i<=l;i++){
            ans+=a[i]*1.0;
        }
        ans/=l;
        int num=0,cnt=0;
        for(int i=1;i<=n;i++){
            if(a[i]==a[l]){
                num++;
                if(i<=l){
                    cnt++;
                }
            }
        }
        ll sum=0;
        if(cnt==l){
            for(int i=l;i<=r;i++){
                sum+=C[num][i];
            }
        }else{
            sum+=C[num][cnt];
        }
        cout<<fixed<<setprecision(10)<<ans<<endl<<sum<<endl;
    
    return 0;
}

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

int max(int a, int b) {
  return a > b ? a : b;
}

int main(void) {
  int i, j, k, n;
  scanf("%d", &n);
  int c[n], s[n], f[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%d%d%d", &c[i], &s[i], &f[i]);
  }
  for(i = 0; i < n; ++i) {
    int ans = 0;
    for(j = i; j < n - 1; ++j) {
      ans = max(ans, s[j]);
      ans = (ans + f[j] - 1) / f[j] * f[j];
      ans += c[j];
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
using namespace std;

int main(){
	int a,b,c,d,e,f,g,h;
	cin >>a>>b>>c>>d>>e>>f>>g>>h;
	cout <<max(a+b+c+d,e+f+g+h) << endl;
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);

int32_t main(){
	fastio();
	int n , p;
	cin >> n >> p;
	string s;
	cin >> s;
	int ans = 0;
	
	if( p == 2 || p == 5){
		for(int i = 0; i < n; i++){
			if((s[i]-'0')%p == 0) ans += (i + 1);
		}
		cout << ans;
		return 0;
	}
	int sum = 0;
	map<int,int>f;
	reverse(all(s));
	f[0] = 1;
	for(int i = 0; i < n; i++){
		sum  =  (s[i] - '0')  * mod_pow(10,i,p) + sum;
		sum %= p;
		f[sum]++;
	}
	for(auto i:f){
		int k = i.ss;
		ans += (k * ( k - 1)) /2;
	}
	cout << ans;
}

Measured memory_bytes: 4180
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll t, a;
    for(int i = 0; i < n; i++)
    {
        ll l, r;
        cin >> l >> r;
        if(!i)
        {
            t = l;
            a = r;
        }
        else
        {
            if(t > l && a <= r)
            {
                ll time = t / l;
                if(t % l) time++;
                t = l * time;
                a = r * time;
            }
            else if(t <= l && a > r)
            {
                ll time = (a / r);
                if(a % r) time++;
                t = l * time;
                a = r * time;
            }
            else if(t > l && a > r)
            {
                ll time = t / l;
                if(t % l) time++;
                ll tmp = a / r;
                if(a% r) tmp++;
                time = max(time, tmp);
                t = l * time;
                a = r * time;
            }
            else if(t <= l && a <= r)
            {
                t = l;
                a = r;
            }
        }
        //cout << t << ' ' << a << endl;
    }
    cout << t + a << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	unsigned long long int a, b, x, m, n; cin >> a >> b >> x;
	if (a%x == 0) { m = a / x; }
	else { m = a / x + 1; }
	n = b / x;
	cout << n - m + 1 << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int N=19;
int n,a[N],i;
ll ans,f[66000][N][N];
ll solve(int x,int l,int r,int u,int v){
	if(l==r)return 1ll*(u+v)*a[l];
	ll&ans=f[x][l][r];
	if(ans<1ll<<40)return ans;
	for(int i=l;i<=r;++i){
		ll nw=1ll*(u+v)*a[i];
		if(l<i)nw+=solve(x<<1,l,i-1,u,u+v);
		if(i<r)nw+=solve(x<<1|1,i+1,r,u+v,v);
		if(nw<ans)ans=nw;
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	ans=a[1]+a[n];
	memset(f,1,sizeof f);
	if(n>2)ans+=solve(1,2,n-1,1,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 186368
// ITP_1_10_D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

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

    int n;
    cin>>n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        x[i]=s;
    }
     for(int i=0;i<n;i++){
        int s;
        cin>>s;
        y[i]=s;
    }
    double ans1=0,ans2=0,ans3=0,ans4;
    for(int i=0;i<n;i++){
        ans1+=abs(x[i]-y[i]);
    }
    for(int i=0;i<n;i++){
        ans2+=pow(x[i]-y[i],2);
    }
    ans2=sqrt(ans2);
    for(int i=0;i<n;i++){
        ans3+=pow(abs(x[i]-y[i]),3);
    }
    //cout<<ans3<<endl;
    double sisu=1.0/3.0;
    ans3=pow(ans3,sisu);
    ans4=abs(x[0]-y[0]);
    for(int i=1;i<n;i++){
        int num=abs(x[i]-y[i]);
        if(ans4<num) ans4=num;
    }
    cout<<ans1<<endl;
    cout<<ans2<<endl;
    cout<<ans3<<endl;
    cout<<ans4<<endl;
    return 0;
}


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

int main(){
	int n, d, temp;
	cin >> n >> d;
	vector< vector<long long> > v(n, vector<long long> (d));
	for (int i=0; i <n; i++){
			for(int j = 0; j<d; j++){
				cin >> temp;
				v[i][j] = temp;
		}
	}
	//for (auto x: v) 
	//	for (auto y: x) cout << y << endl;
	int count = 0;
	for (int i=0; i<n; i++){
		for (int j = i+1; j <n; j++){
			long long sum = 0;
			for (int k = 0; k<d; k++){
				sum += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
			}
			if (ceil(sqrt((float)sum)) == sqrt((float)sum)) count++;
		}
	}
	cout << count;
 }


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    int a[100001], N, x;
    while(~scanf("%d%d", &N, &x))
    {
        long long sum = 0;
        for(int i=0; i<N; i++)
        {
            scanf("%d", &a[i]);
            if(a[i] > x)
            {
                sum += a[i] - x;
                a[i] = x;
            }
        }
        for(int i=1; i<N; i++)
        {
            int t = a[i] + a[i-1];
            if(t > x)
            {
                a[i] -= t - x;
                sum += t - x;
            }
        }
        printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	int n,m;
	int buf;
	int ans;
	int sum = 0;
	cin >> n >> m;
	for(int i = 0;i <= m-1;i++){
		cin >> buf;
		sum += buf;
	}
	ans = n - sum;
	if(ans < 0){
		cout << -1;
		return 0;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

int K;
void bfs() {
	int cnt = 0;
	queue<ll> que;
	for (int i = 1; i <= 9; i++) {
		cnt++;
		if (cnt == K) {
			cout << i;
			return;
		}
		que.push(i);
	}
	while (true) {
		ll x = que.front();
		que.pop();
		for (int i = max(0ll, (x % 10) - 1); i <= min(9ll, (x % 10 ) + 1); i++) {
			cnt++;
			if (cnt == K) {
				cout << x * 10 + i;
				return;
			}
			que.push(x * 10 + i);
		}
	}
}
int main()
{
	cin >> K;
	bfs();
}

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

int w, h;
vector< vector< int > > field, cnt;

int rec(int y, int x, int px){
	if(x < 0 || x > w - 1) return 0;
	if(y >= h) return 1;
	if(cnt[y][x] != -1) {
		if(field[y][x] == 2 && px != x) return 0;
		return cnt[y][x];
	}
	
	if(field[y][x] == 1) return cnt[y][x] = 0;
	else if(field[y][x] == 0) return cnt[y][x] = rec(y + 1, x - 1, x) + rec(y + 1, x, x) + rec(y + 1, x + 1, x);
	else{
		cnt[y][x] = rec(y + 2, x, x);
		
		if(px == x) return cnt[y][x];
		else return 0;
	}
}

int main(){
	
	while(cin >> w >> h, w){
		field.resize(h);
		cnt.resize(h);
		for(int i = 0; i < h; ++i){
			field[i].resize(w);
			cnt[i].resize(w);
			for(int j = 0; j < w; ++j){
				cin >> field[i][j];
				cnt[i][j] = -1;
			}
		}
		
		for(int i = 0; i < w; ++i){
			cnt[h - 1][i] = (field[h - 1][i] == 1 ? 0 : 1);
		}
		
		int sum = 0;
		for(int i = 0; i < w; ++i){
			sum += rec(0, i, i);
		}
		
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
N = int(input())
S = [("R", "G", "B").index(c) for c in input()]

sums = [[0] * (N + 1) for _ in range(3)]
for i, c in enumerate(S):
    for x in sums:
        x[i+1] = x[i]
    sums[c][i+1] += 1

ans = 0
for i in range(N - 2):
    si = S[i]
    for j in range(i + 1, N - 1):
        sj = S[j]
        if si == sj:
            continue
        sk = (set(range(3)) - {si, sj}).pop()
        count = sums[sk][N] - sums[sk][j+1]
        if j - i <= N - (j + 1):
            count -= (sums[sk][j+1+j-i] - sums[sk][j+1+j-i-1])
        ans += count
print(ans)

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

using namespace std;
using ll=long long;
int main()
{
    ll ans=0;
    int n;cin >>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 3624
program sample
implicit none
integer(8) :: i,j,maxdivision
integer(8) :: x,y,count
real(8),allocatable :: a(:),b(:)

read(*,*) x,y

allocate(a(x))

read(*,*) a

count=0

do i=1,x-1
	if (a(i)+a(i+1)>y) then
	count = count+a(i)+a(i+1)-y
	a(i+1)=y-a(i)
		if (a(i+1)<0) then
		a(i)=a(i)+a(i+1)
		a(i+1) = 0
		end if
	end if
end do

write(*,*) count
!write(*,*) a

end program sample

Measured memory_bytes: 3980
nom=Array.new(3) { Array.new(3,0) }
nom[0][0],nom[0][1],nom[0][2]=gets.split.map!(&:to_i)
nom[1][0],nom[1][1],nom[1][2]=gets.split.map!(&:to_i)
nom[2][0],nom[2][1],nom[2][2]=gets.split.map!(&:to_i)
n=gets.to_i
ans=0
s=Array.new(n)
for i in 0..n-1
  s[i]=gets.to_i
  for j in 0..2
      for k in 0..2
        if nom[j][k]==s[i]
          nom[j][k]="x"
        end
      end
  end
end
for i in 0..2
  if nom[0][i]=="x" && nom[1][i]=="x" && nom[2][i]=="x"
    ans=1
  elsif nom[i][0]=="x" && nom[i][1]=="x" && nom[i][2]=="x"
    ans=1
  end
end
if nom[0][0]=="x" && nom[1][1]=="x" && nom[2][2]=="x"
  ans=1
elsif nom[0][2]=="x" && nom[1][1]=="x" && nom[2][0]=="x"
  ans=1
end
if ans==1
  puts "Yes"
else
  puts "No"
end


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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int A[100003], B[100003], C[100003];
int X[100003], Y[100003], Z[100003];

int main()
{
	// freopen("input.in", "r", stdin);

	int n, k; scanf("%d %d", &n, &k);
	for(int i = 1; i <= n; i++)
	{
		A[i] = k+i-1;
		B[i] = k+n+i-1;
		C[i] = k+2*n+i-1;
	}

	if(n&1 || 1)
	{
		int mid = (n+1)/2;
		for(int i = 1; i <= mid; i++)
			X[i] = A[i], Y[i] = B[i+mid-(n&1)], Z[i] = C[i*2-1];
		for(int i = mid+1; i <= n; i++)
			X[i] = A[i], Y[i] = B[i-mid], Z[i] = C[(i-mid)*2];

		for(int i = 1; i <= n; i++)
		{
			if(Z[i] < X[i]+Y[i])
			{
				printf("-1\n");
				return 0;
			}
		}
		for(int i = 1; i <= n; i++)
			printf("%d %d %d\n", X[i], Y[i], Z[i]);

	}
}

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

int main(){
int N;
  cin>>N;
 int answer=0;

  for(int c=1; c<=N; c+=2){
    int num=0;
   for(int x=1; x<=c; x++){
    if(c%x==0){num++;}
   }
    if(num==8){answer++;}
  }
   cout<<answer<<endl;
}

Measured memory_bytes: 384
n = int(input())
h = [int(x) for x in input().split()]
h.reverse()

flag = True

for i in range(1, n):
    if h[i - 1] >= h[i]:
        continue
    elif h[i] == h[i - 1] + 1:
        h[i] -= 1
    else:
        flag = False
        break

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


Measured memory_bytes: 14252