akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
    cin >> n >> m >> l;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            for (int k = 0; k < l; k++)
            {
                c[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cout << (j == 0 ? "" : " ") << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include <map>
using namespace std;
 
int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,a; cin >> n;
    map<int,int> cnt;
    for(int i=0; i < n; ++i) cin >> a, ++cnt[a];

    // kinds of a = 3
    // a1 ^ a3 = a2 => 
    // a2 ^ a4 = a3 => a2 = a3 ^ a4 => *a1 = a4*
    // a3 ^ a5 = a4 => *a2 = a5*
    // a4 ^ a6 = a5 => *a3 = a6*
    // => a1 = a4 = a7 = ..., a2 = a5 = a8 = ..., a3 = a6 = a9 = ...
 
    bool ok = false;

    vector<pair<int,int>> tmp;
    for(auto c : cnt) {
        tmp.push_back(c);
    }

    if(n%3==0 && tmp.size() == 3 && (tmp[0].first ^ tmp[1].first ^ tmp[2].first) == 0
            && tmp[0].second == tmp[1].second && tmp[1].second == tmp[2].second) ok = true;
    if(n%3==0 && tmp.size() == 2 && tmp[0].first == 0 
            && tmp[0].second == n/3 && tmp[1].second == n/3*2) ok = true;

    if(cnt[0] == n) ok = true;
 
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

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

void bubbleSort(vector<int> A, int N) {
    bool flg = true;
    int count = 0;
    while (flg) {
        flg = false;
        for (int i = N - 1; 1 <= i; i--) {
            if (A[i] < A[i-1]) {
                swap(A[i], A[i-1]);
                flg = true;
                count++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;
    cout << count << endl;
}

int main() {

    int n;
    cin >> n;

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

    bubbleSort(A, n);

    return 0;

}


Measured memory_bytes: 3168
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::VecDeque;
fn main() {
    let h: usize = read();
    let w: usize = read();
    let map: Vec<Vec<char>> = (0..h).map(|_| read()).map(|s: String| s.chars().collect()).collect();
    let mut q: VecDeque<(usize, usize)> = VecDeque::new();
    let mut dist: Vec<Vec<isize>> = (0..h).map(|_| (0..w).map(|_| -1).collect()).collect();
    dist[0][0] = 0;
    q.push_back((0,0));
    let mut black: usize = 0;
    for i in 0..h {
        for j in 0..w {
            if map[i][j] == '#' {
                black += 1;
            }
        }
    }
    while !q.is_empty() {
        let (vy, vx) = q.pop_front().unwrap();
        if vy > 0 && dist[vy-1][vx] == -1 && map[vy-1][vx] == '.' {
            dist[vy-1][vx] = dist[vy][vx] + 1;
            q.push_back((vy-1, vx));
        }
        if vy < h-1 && dist[vy+1][vx] == -1 && map[vy+1][vx] == '.' {
            dist[vy+1][vx] = dist[vy][vx] + 1;
            q.push_back((vy+1, vx));
        }
        if vx > 0 && dist[vy][vx-1] == -1 && map[vy][vx-1] == '.' {
            dist[vy][vx-1] = dist[vy][vx] + 1;
            q.push_back((vy, vx-1));
        }
        if vx < w-1 && dist[vy][vx+1] == -1 && map[vy][vx+1] == '.' {
            dist[vy][vx+1] = dist[vy][vx] + 1;
            q.push_back((vy, vx+1));
        }
    }
    if dist[h-1][w-1] == -1 {
        println!("-1");
    } else {
        println!("{}", (h*w) as isize - dist[h-1][w-1] - 1 - black as isize);
    }
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int need[10] = {0, 2,5,5,4,5,6,3,7,6};
const int N = 10005;
string dp[N];
void chmax (string& s, string t) {
  if ((int) s.size() < (int) t.size()) s = t;
  else if ((int) s.size() < (int) t.size()) return;
  for (int i = 0; i < (int) s.size(); i++) {
    if (s[i] != t[i]) {
      if (t[i] > s[i]) {
        s = t;
        return;
      } else {
        return;
      }
    }
  }
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //string test = "74";
  //chmax(test, "47");
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];
  dp[0] = "";
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + need[a[j]] <= n && (i == 0 || dp[i] != "")) {
        chmax(dp[i + need[a[j]]], dp[i] + (char) (a[j] + '0'));
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 27392
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    for(int i=n;i>0;i--){
        if(s.substr(s.size()-i)==t.substr(0,i)){
            cout<<n*2-i<<endl;
            return 0;
        }
    }
    cout<<2*n<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
volatile int N;
//int N=0;
int KIMOCHI(int a,int b)
{
	//int N;
	// A
	if(a<b){
		if(a+b<=N){
			if(a%3==0){
				return 3;
			}
			else{
				return a%3;
			}
		}
		else{
			//int cy=N-b+1;
			if((N-b+1)%3==0){
				return 3;
			}
			else{
				return (N-b+1)%3;
			}
		}
	}
	// B
	else {
		//int cy;
		//cy=N-a+1;
		if(a+b<=N){
			if(b%3==0){
				return 3;
			}
			else{
				return b%3;
			}
		}
		else{
			if((N-a+1)%3==0){
				return 3;
			}
			else{
				//不安↓
				return (N-a+1)%3;
			}
		}
	}
}

int main(void)
{
	//int N;
	int a,b,cy;
	int K,i;
	scanf("%d%d",&N,&K);
	for(i=0;i<K;i++){
		scanf("%d%d",&a,&b);
		//不安↓
		printf("%d\n",KIMOCHI(a,b));
	}
	return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=1,anss=0,a,b,c,d,e,f,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0,mizu,satou;
double gendo,noudo,cmpnoudo;
string s;

vector<int> z;

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

       cin >> a >> b >> c >> d >> e >> f;
      // gendo=(double)(100*e)/(100+e);
      // Cout(gendo);
       for(int i=0;100*a*i<=f;i++){
           for(int j=0;100*a*i+100*b*j<=f;j++){
               for(int k=0;100*a*i+100*b*j+c*k<=f;k++){
                   for(int l=0;100*a*i+100*b*j+c*k+d*l<=f;l++){
               mizu=100*a*i+100*b*j;
               satou=c*k+d*l;
             //  cout << mizu << " " << satou << endl;
               
              // if(satou==0){
                //   noudo=0;
               //}
              // else{
               noudo=(double)(100*satou)/(mizu+satou);
               //}
               //Cout(noudo);
               //Cout(satou);
               if(mizu!=0 && mizu+satou<=f &&  1.0*100*satou/mizu<=e &&1.0*satou/(satou+mizu)>=1.0*anss/ans){
                   if(noudo>100){
                       continue;
                   }
                   else{
                   //if(cmpnoudo<noudo){
                      // cmpnoudo=noudo;
                      ans=satou+mizu;
                      anss=satou;
                     //cout << ans << " " << anss << endl;
                   }
                  // }
               }
           }
       }
           }
       }
       cout << ans << " " << anss << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main() {
    long long n, c;
    cin >> n >> c;
    vector <long long> a;
    vector <long long> b;

    vector <long long> pr1 (n,0);
    vector <long long> pr2 (n,0);
    vector <long long> pr3 (n,0);
    vector <long long> le1 (n,0);
    vector <long long> le2 (n,0);
    vector <long long> le3 (n,0);
    long long t1, t2;
    for (int i=0; i<n; i++){
        cin >> t1 >> t2;
        a.push_back(t1);
        b.push_back(t2);
    }
    long long kal = 0;
    long long cur1 = 0;
    long long cur2 = 0;
    long long maxx = 0;
    for (int i=0; i<n; i++) {
        if (i == 0) {
            cur1 = b[i] - a[i];
            cur2 = b[i] - 2 * a[i];
        }
        else {
            cur1 += b[i] - a[i] + a[i - 1];
            cur2 += b[i] - 2 * a[i] + 2 * a[i - 1];
        }
        pr1[i] = cur1;
        if (cur1 > maxx){
            maxx = cur1;
        }
        pr2[i] = cur2;
        pr3[i] =  maxx;
    }
    cur1 = 0;
    cur2 = 0;
    maxx = 0;
    for (int i=0; i<n; i++){
        if (i == 0) {
            cur1 = b[n-i-1] - (c - a[n-i-1]);
            cur2 = b[n-i-1] - 2*(c - a[n-i-1]);
        }
        else {
            cur1 += b[n-i-1] - (c -a[n-i-1]) + (c - a[n-i]);
            cur2 += b[n-i-1] - 2*(c-a[n-i-1]) + 2*(c -a[n-i]);
        }
        le1[i] = cur1;
        if (cur1 > maxx){
            maxx = cur1;
        }
        le2[i] = cur2;
        le3[i] =  maxx;
    }

    for (int i=0; i<n; i++){
        if (pr1[i] > kal){
            kal = pr1[i];
        }
        if (le1[i] > kal) {
            kal = le1[i];
        }
    }
    for (int i=0; i<n-1; i++){
        if (pr2[i] + le3[n-i-2] > kal){
            kal = pr2[i] + le3[n-i-2];
        }
        if (le2[i] + pr3[n-i-2] > kal){
            kal = le2[i] + pr3[n-i-2];
        }
    }
    cout << kal;
    return 0;
}

Measured memory_bytes: 6768
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define pb            push_back
#define fi            first
#define se            second
#define PI            (acos(-1.0))
#define repp(i,a,n)   for(int i=a;i<n;i++)
#define rep(i,n)      for(int i=0;i<n;i++)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define w(t)          int t;cin>>t;while(t--)
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;
/*---------------------------------------------------------------------*/

const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n,k;
    cin>>n>>k;
    si s;
    for(int i=1;i<=n;i++)
        {
            s.insert(i);
        }
    while(k--)
    {
        int x;
        cin>>x;
        while(x--)
        {
            int y;
            cin>>y;
            s.erase(y);
        }
    }
    cout<<SZ(s)<<nl;
    return 0;
}


Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;

ll f(ll x, ll y){
	if (x < y) swap(x, y);
	// x>=y

	if (x%y == 0) return (2 * (x / y) - 1)*y;
	ll m = x%y;
	return 2 * (x / y)*y + f(y, m);
}

int main(){
	ll n, x; scanf("%lld%lld", &n, &x);
	printf("%lld", n + f(n - x, x));
}

Measured memory_bytes: 128
line = input().split()
#print(line)

x1 = int(line[0])
y1 = int(line[1])
x2 = int(line[2])
y2 = int(line[3])
#print(x1,y1,x2,y2)

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include <stdio.h>
#define max(a,b) ((a>b)?a:b)

int main()
{
    int N;
    scanf("%d", &N);
    int masu[3][N+1];
    int i,j;
    for(i=1;i<=N;i++) scanf("%d", &masu[1][i]);
    for(i=1;i<=N;i++) scanf("%d", &masu[2][i]);
    int pattern[N+1];
    for(i=1;i<=N;i++) pattern[i] = 0;
    for(i=1;i<=N;i++){
        for(j=1;j<=N;j++){
            if(j<=i) pattern[i] += masu[1][j];
            if(j>=i) pattern[i] += masu[2][j];
        }
    }
    int max = 0;
    for(i=1;i<=N;i++){
        max = max(max, pattern[i]);
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 1e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    ll n,i,j,k,l,p,q,r,s,x,y;
    cin >> n;
    p = 0;q = INF;r = 0;s = INF;
    set<pair<ll,ll>> mp;
    for(i=1;i<=n;i++)
    {
        
        cin >> x >> y;
        if(mp.find({x,y})==mp.end())
            mp.insert({x,y});
        else
            continue;
        p = max(x+y,p);
        q = min(x+y,q);
        r = max(x-y,r);
        s = min(x-y,s);
    }
    if(mp.size()==1)
    {
        cout << 0;
        return 0;
    }
    cout << max(p-q,r-s);
}


Measured memory_bytes: 16084
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
p = 0

for index, i in enumerate(A):
  if index > len(B) - 1:
    if p > A[index]:
      ans += A[index]
    else:
      ans += p
      
    break

  if A[index] - (B[index] + p) < 0:
    ans += A[index]
    if p > A[index]:
      p = B[index]
    else:
      p = abs(A[index] - B[index] - p)
      
    continue

  ans += B[index] + p
  p = 0

print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,q;
ll a[100005],b[100005],aa[100005],bb[100005];
int bin(int l,int r,ll x,ll f[100005])
{
    int ans=0;
    while(l<=r)
    {
        int mid=l+r>>1;
        if(f[mid]<=x) ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans;
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=m;i++) scanf("%lld",&b[i]);
    for(int i=1;i<=n;i++)
    {
        int t=bin(1,m,a[i],b);
        if(t==0) aa[i]=abs(a[i]-b[1]);
        else if(t==m) aa[i]=abs(a[i]-b[t]);
        else aa[i]=min(abs(a[i]-b[t]),abs(a[i]-b[t+1]));
    }
    for(int i=1;i<=m;i++)
    {
        int t=bin(1,n,b[i],a);
        if(t==0) bb[i]=abs(b[i]-a[1]);
        else if(t==n) bb[i]=abs(b[i]-a[t]);
        else bb[i]=min(abs(b[i]-a[t]),abs(b[i]-a[t+1]));
    }
    while(q--)
    {
        ll x;
        scanf("%lld",&x);
        ll ans;
        int t=bin(1,n,x,a);
        if(t==0) ans=abs(a[1]-x)+aa[1];
        else if(t==n) ans=abs(a[n]-x)+aa[n];
        else ans=min(abs(a[t]-x)+aa[t],abs(a[t+1]-x)+aa[t+1]);
        t=bin(1,m,x,b);
        if(t==0) ans=min(abs(b[1]-x)+bb[1],ans);
        else if(t==m) ans=min(ans,abs(b[m]-x)+bb[m]);
        else ans=min(min(abs(b[t]-x)+bb[t],abs(b[t+1]-x)+bb[t+1]),ans);
        printf("%lld\n",ans);
    }
}


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

int main() {

    int A, B;
    string S, T, U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S==U){
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<string> S(N);
    map<char, ll> m;

    REP(i, N) {
        cin >> S.at(i);
        m[S[i][0]]++;
    }

  
    cout << (m['M'] * m['A'] * (m['R'] + m['C'] + m['H'])) + (m['M'] * m['R'] * (m['C'] + m['H']))
                + (m['M'] * m['C'] * m['H']) + (m['A'] * m['R'] * (m['C'] + m['H'])) + (m['A'] * m['C'] * m['H'])
                + (m['R'] * m['C'] * m['H'])
         << endl;

    return 0;
}


Measured memory_bytes: 6144
ABCD=input()
a=list(ABCD)

for p in range(1<<3):
    t = int(a[0])
    ans = a[0]
    for i in range(1,4):
        if p&(1<<(i-1)):
            t+=int(a[i])
            ans += '+' + a[i]
        else:
            t-=int(a[i])
            ans += '-' + a[i]
    if t==7:
        print(ans+'=7')
        break

Measured memory_bytes: 3064
line = input().split(" ")
n = int(line[0])
yy = int(line[1])

for x in range(0, n+1, 1):
    if((10000 * x) <= yy):
        for y in range(0, (n-x+1), 1):
            if(((5000 * y) + (10000 * x)) <= yy):
                z = n - x - y
                if(((1000 * z) + (5000 * y) + (10000 * x)) == yy and (n == (x + y + z))):
                    print(x,y,z)
                    exit()
x = -1
y = -1
z = -1
print(x,y,z)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++)
    cout<<a[n-i-1]<<((i==n-1)?'\n':' ');
}

Measured memory_bytes: 3084
/*  
    And solitare's the only game in town
    And every road that takes him
    Takes him down
    And by himself it's easy to pretend
    He'll never love again
    _________________________
    _________________________
    984 Hours of Solitude
    Quarantine_Day : 41
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 200005

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

    ll x;
    cin >> x;
    ll best = 1;
    for (ll a = 2; a*a <= x; ++a) {
        for (ll b = a*a; b <= x; b *= a) {
            best = max(best, b);
        }
    }
    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int i,j,num,count[26];
  char a[1200],ch;

  i = 0;
  while(scanf("%c",&ch)!=EOF){
      a[i]=ch;
      i++;
  }

  for(j=0;j<26;j++)
    count[j]=0;
  

  for(j=0;j<i;j++){

    if(a[j]>=65 && a[j]<=90){
      a[j]+=32;
    }
    if('a'<=a[j] && a[j]<='z'){
    num= a[j]-'a';
    count[num]++;
    }
  }

  for(j=0;j<26;j++){
    printf("%c : %d\n",j+97,count[j]);
  }

  return 0;
}

Measured memory_bytes: 540
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if(ans > 10**18):
            print(-1)
            break
        elif(i == N-1):
            print(ans)

Measured memory_bytes: 21560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
const int N=100010;
lint a[N];
namespace T{
	const int E=N<<1;
	int to[E],bro[E],head[N],e=2;
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	lint dfs(int x,int fa){
		if(bro[head[x]]==0){
			return a[x];
		}
		lint sum=0,mx=0;
		for(int i=head[x],v;i;i=bro[i]){
			if((v=to[i])!=fa){
				lint f=dfs(v,x);
				sum+=f;
				if(f>mx){
					mx=f;
				}
			}
		}
		lint vac=sum-mx>mx?(sum&1):mx-(sum-mx),mat=((sum-vac)>>1);
		if(vac+mat>a[x]||mat<(a[x]-(mat+vac))){
			throw false;
		}
		return ((a[x]-(mat+vac))<<1)+vac;
	}
}
int main(){
	int n=ni;
	for(int i=1;i<=n;i++){
		a[i]=ni;
	}
	for(int i=1;i<n;T::add(ni,ni),i++);
	try{
		using namespace T;
		if(bro[head[1]]?dfs(1,0):dfs(to[head[1]],1)!=a[1]){
			throw false;
		}
		puts("YES");
	}catch(bool err){
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 8320
#include <stdio.h>
int main(){
  int i,j,n;
  int a[100];
  int ans=0,min=10000000;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  for(i=-100;i<=100;i++){
    ans=0;
    for(j=0;j<n;j++){
      ans+=(a[j]-i)*(a[j]-i);
    }
    if(ans<min)min=ans;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

class Node {
public:
	long key;
	Node* next;
	Node* prev;
	Node(long k, Node* p, Node* n) {
		key = k;
		next = n;
		prev = p;
	}
};

int main() {
	int q;
	std::cin >> q;
	Node* start = new Node(0, nullptr, nullptr);
	Node* end = new Node(0, start, nullptr);
	start->next = end;
	Node* cur = end;
	int size = 0;
	while (q--) {
		int com;
		std::cin >> com;
		if (com == 0) {
			long x;
			std::cin >> x;
			Node* n = new Node(x, cur->prev, cur);
			cur->prev->next = n;
			cur->prev = n;
			cur = n;
			size++;
		}
		if (com == 1) {
			int d;
			std::cin >> d;
			if (d > 0) {
				for (int i = 0; i < d; i++) {
					cur = cur->next;
				}
			}
			else {
				for (int i = 0; i < std::abs(d); i++) {
					cur = cur->prev;
				}
			}
		}
		if (com == 2) {
			Node* tmp = cur;
			cur->prev->next = cur->next;
			cur->next->prev = cur->prev;
			cur = cur->next;
			delete[] tmp;
			size--;
		}
	}
	cur = start;
	for (int i = 0; i < size; i++) {
		cur = cur->next;
		std::cout << cur->key << std::endl;
	}
}


Measured memory_bytes: 18596
function main()
  n, m, k = parse.(Int, split(readline()))

  A_ = parse.(Int, split(readline()))
  B_ = parse.(Int, split(readline()))
  
  A = zeros(Int, n+1)
  B = zeros(Int, m+1)
  
  
  for i in 2:n+1
    A[i] = A[i-1] + A_[i-1]
  end
  
  for i in 2:m+1
    B[i] = B[i-1] + B_[i-1]
  end

  ans = 0
    
  i = n+1
  j = 1
  
  while i >= 1
    while j <= m
      if A[i] + B[j+1] <= k
        j += 1
      else
        break
      end
    end
    
    if A[i] + B[j] <= k
      ans = max(ans, i + j - 2)
    end
    
    i -= 1
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 208448
#include<bits/stdc++.h>  
using namespace std;
int main(){
  int N;
  while(cin >> N, N){
    int ret = 0;
    bool flag = 0;
    while(N--){
      int k;cin >> k;
      if(k > 0) ret++;
      if(k > 1) flag = 1;
    }
    if(flag) cout << ret + 1 << endl;
    else puts("NA");
  }
}


Measured memory_bytes: 3100
#include <stdio.h>

int main(void) {
	int n, m, i, j, c, num;
	int a[1000][1000], b[1000];
	
	scanf("%d%d", &n, &m);
	
	//aの配列に値を入力する
	for(i = 0; i < n; i++) {
	    for(j = 0; j < m; j++) {
	        scanf("%d", &num);
	        a[i][j] = num;
	    }
	}
	
	//bの配列に値を入力する
	for(i = 0; i < m; i++) {
	    scanf("%d", &num);
	    b[i] = num;
	}
	
	//計算して出力する
	for(i = 0; i < n; i++) {
	    c = 0;
		for(j = 0; j < m; j++) {
			c += a[i][j] * b[j];
		}
		printf("%d\n", c);
	}
	return 0;
}



Measured memory_bytes: 2164
#include<stdio.h>
int main(void)
{
	int i,j,h,w;

	for(;;){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}else{
			for(i=0;i<h;i++){
				for(j=0;j<w;j++){
					printf("#");
				}printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;

struct BIT{
    int N;
    vector<int> dat;
    BIT() {}
    BIT(int n) {
        N = n;
        dat.resize(N + 1);
    }
    void add(int k, int x){
        k++;
        while(k <= N){
            dat[k] += x;
            k += k&-k;
        }
    }
    int sum(int k){
        int s = 0;
        while(k > 0){
            s += dat[k];
            k -= k&-k;
        }
        return s;
    }
};

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    vector<int> cs(n + 1);
    for(int i = 0; i < n; i++) cs[i + 1] = cs[i] + d[i] - k;
    vector<int> a = cs;
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    for(int i = 0; i < n + 1; i++) cs[i] = lower_bound(a.begin(), a.end(), cs[i]) - a.begin();
    int ans = 0;
    BIT b(n + 1);
    for(int i = 0; i < n + 1; i++){
        ans += b.sum(cs[i] + 1);
        b.add(cs[i], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    int x,y;
   while(true){
    cin>>x;
    cin>>y;
    if(x==0 && y==0){
        break;
    }
    if(x<y){
        cout<<x<<" "<<y<<endl;
    }
    else{
        cout<<y<<" "<<x<<endl;
        
    }
    }
   
   

}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vector<pll> P(N);
    REP(i,0,N) {
        cin >> P[i].first;
        P[i].second = i;
    }

    DESC(P);
    REP(i,0,N) {
        if(P[0].second == i) PR(P[1].first);
        else PR(P[0].first);
    }

    return 0;
}

/*



*/

Measured memory_bytes: 6348
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr>void dump(Itr begin, Itr end) {
  for(;begin != end; ++begin) clog << ' ' << *begin;
  clog << LF;
}

signed main()
{
  int n ,h , w;
  cin >> n >> h >> w;

  cout << (n-h + 1) * (n-w + 1) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    
    int a,b;
    cin >>a>>b;
    
    if( a == -b){
        cout<<"0"<<endl;
    }else if(a > -b){
        cout<<"1"<<endl;
    }else{
        cout <<"-1"<<endl;
    }
    
    
}



Measured memory_bytes: 3100
#include<stdio.h>

int gcd(int a, int b){
    int tmp;
    if(a > b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    while(b%a){
        b = b%a;
        tmp = a;
        a = b;
        b = tmp;
    }
    return a;
}

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

int main(void){
    int n, i;
    int array[11];
    int ans = 1;
    scanf("%d", &n);
    
    array[0] = 1;
    for(i = 1;i<=n;i++){
        scanf("%d", &(array[i]));
    }
    
    for(i =0; i<=n;i++){
        ans = lcm(array[i], ans);
    }
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n; cin >> n;
    vector<int> pf(n + 1);
    for (int i = 1; i <= n; i++) 
        for (int j = i; j <= n; j += i) 
            pf[j]++;
    int64_t ans = 0;
    for (int64_t i = 1; i <= n; i++) ans += i * pf[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 42268
#include <bits/stdc++.h>
#include <cstring>
#include <map>
#include <set>
#define int long long int
using namespace std;
const int MAX = 1000000007;

bool dp[400000];

signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    
    int n, k, i, j;
    cin>>n>>k;
    int a[n+1];
    for(i=1;i<=n;i++)
        cin>>a[i];
    dp[0]=false;
    for(i=1;i<=k;i++){
        bool x = true;
        for(j=1;j<=n;j++){
            if(i>=a[j])
                x = x&&dp[i-a[j]];
        }
        dp[i]=!x;
    }

    if(dp[k])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    
}


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

const int TOP = 0,FRONT = 1,LEFT = 3, RIGHT = 2,BACK = 4,BOTTOM = 5;
class Dice{
public:
  vector<int> val;
  Dice():val(6){for(int i=0;i<6;i++) val[i] = i;}
  Dice(int val[6]){for(int i=0;i<6;i++) this->val[i] = val[i];}
  Dice(vector<int> val):val(val){assert(val.size() == 6);}
  
  void rot(string s){
    if(s == "N" || s == "B") rotN();
    else if(s == "S" || s == "F") rotS();
    else if(s == "E" || s == "R") rotE();
    else if(s == "W" || s == "L") rotW();
    else if(s == "CW") rotCW();
    else if(s == "CCW") rotCCW();
    else assert(!"rot error"); /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
  }

  void rot(char ch){rot(string(1,ch));}
  
  //奥に転がす
  void rotN(){
    swap(val[TOP],val[FRONT]);
    swap(val[FRONT],val[BOTTOM]);
    swap(val[BOTTOM],val[BACK]);
  }

  //手前に転がす
  void rotS(){
    //rotN(),rotN(),rotN();
    swap(val[TOP],val[BACK]);
    swap(val[BACK],val[BOTTOM]);
    swap(val[BOTTOM],val[FRONT]);
  }
  
  //右に転がす
  void rotE(){
    swap(val[TOP],val[LEFT]);
    swap(val[LEFT],val[BOTTOM]);
    swap(val[BOTTOM],val[RIGHT]);
  }

  //左に転がす
  void rotW(){
    //rotE(),rotE(),rotE();
    swap(val[TOP],val[RIGHT]);
    swap(val[RIGHT],val[BOTTOM]);
    swap(val[BOTTOM],val[LEFT]);
  }

  //上から見て時計回りに回す
  void rotCW(){
    swap(val[FRONT],val[RIGHT]);
    swap(val[RIGHT],val[BACK]);
    swap(val[BACK],val[LEFT]);
  }

  //上からみて反時計回りに回す。
  void rotCCW(){
    //rotCW(),rotCW(),rotCW();
    swap(val[FRONT],val[LEFT]);
    swap(val[LEFT],val[BACK]);
    swap(val[BACK],val[RIGHT]);
  }
};

int main(){
  vector<int> v(6);
  for(int i=0;i<6;i++) cin>>v[i];
  
  Dice D(v);
  string str;
  cin>>str;
  for(char ch:str) D.rot(ch);
  cout<<D.val[TOP]<<endl;
  return 0;
}



Measured memory_bytes: 3224
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  cout << (N + 1) / 2 << endl;


  return 0;
}

Measured memory_bytes: 256
///God is great

#include <bits/stdc++.h>
using namespace std;

/************************** definations *******************************/
#define pi              2*acos(0.0)
#define ll              long long int
#define llu             unsigned long long int
#define sc(a)           scanf("%d",&a)
#define scc(a,b)        scanf("%d %d",&a,&b)
#define sccc(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sc1(a)          scanf("%lld",&a)
#define sc2(a,b)        scanf("%lld %lld",&a,&b)
#define sc3(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define pf1(a)          printf("%lld\n",a)
#define pf2(a,b)        printf("%lld %lld\n",a,b)
#define Case(a)         printf("Case %d: ",a)
#define Casel(a)        printf("Case %lld: ",a)
#define mem(a,x)        memset(a,x,sizeof(a))
#define INF             1<<29
#define Inf             10000
#define inf             INT_MAX
#define INFL            1e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair
#define NL              cout << endl;
#define DONE            cerr << "Done" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("input.txt", "r", stdin)
#define WRITE           freopen("output.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pii             pair<int,int>
#define ii              pair<ll,int>
#define M               10000007
#define mod             100000007
#define Mod             1000000007
#define MAX             1001
#define qk              5000000
#define REP(i,x,m)      for(i=x;i<m;i++)
#define vi              vector<int>
/************************** definations *******************************/
int main()
{
    /*#ifndef ONLINE_JUDGE
    READ;
    WRITE;
    #endif*/
    ll n,k;
    sc2(n,k);
    if(n%k==0) puts("0");
    else cout << min(n%k,abs(n%k-k));
}

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

int main() {
  int min(int x, int y);
  int A, B, C, D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  int ans = min(A, B) + min(C, D);
  cout << ans << endl;
}

int min(int x, int y) {
  if (x > y) {
    return y;
  } else {
    return x;
  }
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int fx = 0;
	char n[100000000];
	scanf("%s", n);
	rep(i, strlen(n)) {
		fx += n[i] - '0';
	}
	printyn(!(stoi(n) % fx));

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll INF = 5e15;
vector<ll> dp(1e5 + 10);
int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for(ll &h : H) cin >> h;
    dp[0] = 0;
    for(ll i = 1; i < N; i++){
        ll tmp = INF;
        for(ll j = 1; i - j >= 0 && j <= K; j++) tmp = min(tmp, dp[i - j] + abs(H[i] - H[i - j]));
        dp[i] = tmp;
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;


class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);


        int n = Integer.parseInt(br.readLine());

        int arr[][] = new int [n][3];
        for(int i = 0 ; i < n ; i++)
        {
            StringTokenizer st1 = new StringTokenizer(br.readLine());

            arr[i][0] = Integer.parseInt(st1.nextToken());
            arr[i][1] = Integer.parseInt(st1.nextToken());
            arr[i][2] = Integer.parseInt(st1.nextToken());

        }

        int dp[][] = new int[n][3];

        dp[0][0] = arr[0][0];
        dp[0][1] = arr[0][1];
        dp[0][2] = arr[0][2];

        for(int i = 1 ; i < n ; i++)
        {
            for(int j = 0 ; j < 3 ; j++)
            {
                for(int k = 0 ; k < 3 ; k++)
                {
                    if(j != k)
                        dp[i][j] = Math.max(dp[i][j] , dp[i-1][k] + arr[i][j]);
                }
            }
        }

        int res = 0;

        for(int i = 0 ; i < 3 ; i++)
        {
            res = Math.max(res , dp[n-1][i]);
        }

        out.println(res);


        out.flush();
        out.close();
    }

}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n, k, s; std::cin >> n >> k >> s;
  rep(i, k) {
    std::cout << s << " ";
  }
  int val = (s == 1'000'000'000 ? 1 : s+1);
  rep(i, n-k) {
    std::cout << val << (i+1 < n-k ? " " : "\n");
  }
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>

typedef long long ll;

using namespace std;

int main() {
    

    
    string s;
    cin >> s;
    
    vector<int> ret(s.size());
    
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == 'R')
        {
            int c;
            c = 0;
            while (s[i] == 'R')
            {
                ret[i] = 0;
                i++;
                c++;
            }
            ret[i - 1] += c - (c / 2);
            ret[i] += c / 2;
            c = 0;
            int f = i;
            while (s[i] == 'L')
            {
                i++;
                c++;
            }
            ret[f] += c - (c / 2);
            ret[f - 1] += c / 2;
            i--;
        }
    }
    
    for (int i = 0; i < ret.size(); ++i)
    {
        if (i == ret.size() - 1)
        {
            cout << ret[i] << endl;
            break;
        }
        cout << ret[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 1024
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,t,y=100000000000,m;
	 	cin>>k>>l>>n;
	 	r=(l/n)-(k-1)/n;
	 	cout<<r<<endl;
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), fact;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (ll i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			fact.push_back(i);
			fact.push_back(sum / i);
		}
	}
	sort(fact.begin(), fact.end());
	ll ans = 0;
	int m  = fact.size();
	for (int i = 0; i < m; i++) {
		ll t = fact[i];
		vector<ll> tmp(n);
		ll cnt = 0;
		for (int j = 0; j < n; j++) {
			tmp[j] = a[j] % t;
		}
		sort(tmp.begin(), tmp.end());
		int use = 0;
		for (int j = n - 1; j >= 0; j--) {
			if (j < use || tmp[j] == 0) {
				break;
			}
			while (tmp[j] < t) {
				ll add = min(t - tmp[j], tmp[use]);
				tmp[j] += add;
				cnt += add;
				tmp[use] -= add;
				if (tmp[use] == 0) {
					use++;
				}
			}
		}
		if (cnt <= k) {
			ans = t;
		}
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int sum=0;
	int i;
	for(i=0;i<5;i++) {
		int now;
		scanf("%d",&now);
		if(now<40)now=40;
		sum+=now;
	}
	printf("%d\n",sum/5);
	return 0;
}

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

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

  int l, r;
  int maxL = 0;
  int minR = 10000000;
  for(int i = 0; i < m; i++){
    cin >> l >> r;
    if(maxL < l) maxL = l;
    if(minR > r) minR = r;

  }

  if(minR - maxL < 0) cout << '0' << endl;

  else{
    cout << minR - maxL + 1  << endl;
  }

  return 0;

}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {
            var inputList = System.Console.ReadLine().Split(' ').Select((x) => decimal.Parse(x)).ToList();

            for (int i = 0; i < inputList.Count(); i++)
            {
                if (inputList[i] == 0)
                {
                    Output((i + 1).ToString());
                    return;
                }
            }
        }
        private static void Output(string str)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            Console.WriteLine(str);

            Console.Out.Flush();
        }
    }

Measured memory_bytes: 28292
n=int(input())
a=list(map(int,input().split()))
amari=[0]*4

for i in range(n):
    amari[a[i]%4]+=1

if amari[2]>0:
    if amari[1]+amari[3]<=amari[0]:
        print("Yes")
    else:
        print("No")
else:
    if amari[1]+amari[3]-1<=amari[0]:
        print("Yes")
    else:
        print("No")

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

int main(void) {
	int r, g, b;

	cin >> r >> g >> b;
	int n = 100 * r + 10 * g + b;
	if (n % 4 == 0)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}


Measured memory_bytes: 256