akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N = 2e3 + 10;
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    FIO;
    int n;
    ll dp[N][N], sum[N];
    scanf("%d", &n);
    for (int i = 3; i <= n; i++) {
        dp[i][i] = sum[i] = 1;
    }
    for (int i = 6; i <= n; i++) {
        for (int j = 3; j <= i - 3; j++) {
            dp[i][j] += sum[i - j];
            sum[i] += dp[i][j];
            dp[i][j] %= mod;
            sum[i] %= mod;
        }
    }
    printf("%lld\n", sum[n]);
    return 0;
return 0;   
}

Measured memory_bytes: 26320
#coding: utf-8
import itertools

N = int(input())
L = list(map(int, input().split()))

cnt = 0
all_cnt = 0

def has_duplicates(seq):
    return len(seq) != len(set(seq))

for pair in itertools.combinations(L, 3):
    all_cnt += 1
    if has_duplicates(pair):
        pass
    else:
        b0 = max(pair)
        pair = set(pair) - {b0}
        b1 = list(pair)[0]
        b2 = list(pair)[1]

        if b0 - b1 < b2 < b0 + b1:
            cnt += 1

print(cnt)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int>l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    for(int i = 0;i<n;i++) {
        for(int j = i+1;j<n;j++) {
            for(int k = j+1;k<n;k++) {
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                if(l[i]+l[j] > l[k] && l[j]+l[k] > l[i] && l[i]+l[k] > l[j]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

double dist(int x,int y)
{
    return sqrt(1ll*x*x + 1ll*y*y);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    double d;
    cin >> n>>d;
    int ct =0;
    for(int i = 0; i< n; ++i)
    {
        int x,y;
        cin >> x >> y;
        double a = dist(x,y);
        if(dist(x,y) <= d)
        {
            ct++;
        }
    }
    cout << ct;


    return 0;
}

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

struct E{
    int to,co;
    E(int to=0,int co=0):to(to),co(co){}
};

string rev(string s){
    reverse(s.begin(),s.end());
    return s;
}

int main(){
    int m;
    cin>>m;
    vector<string> s(m);
    vector<int> c(m);
    rep(i,m)cin>>s[i]>>c[i];
    rep(i,m){
        s.push_back(rev(s[i]));
        c.push_back(c[i]);
    }
    int n=1;
    vector<vector<int> > id(m*2);
    rep(i,m*2){
        int l=s[i].size();
        id[i].resize(l);
        rep(j,l){
            id[i][j]=n++;
        }
    }
    vector<vector<E> > g(n);
    rep(i,m*2){
        int l=s[i].size();
        rep(j,l){
            int v=id[i][j];
            rep(ni,m*2){
                if(i/m==ni/m)continue;
                int nl=s[ni].size();
                int w=min(nl,l-j);
                if(s[i].substr(j,w)!=s[ni].substr(0,w))continue;
                int u=0;
                if(nl>w){
                    u=id[ni][w];
                }
                else if(l>j+w){
                    u=id[i][j+w];
                }else u=0;
                g[v].emplace_back(u,c[ni]);
            }
        }
    }
    const ll INF=1e18;
    vector<ll> dist(n,INF);
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    auto push=[&](int v,ll x){
        if(dist[v]<=x)return;
        dist[v]=x;
        q.emplace(x,v);
    };
    rep(i,m)push(id[i][0],c[i]);
    while(!q.empty()){
        ll x=q.top().first;
        int v=q.top().second;q.pop();
        if(dist[v]!=x)continue;
        for(E e : g[v]){
            push(e.to,x+e.co);
        }
    }
    ll ans=dist[0];
    rep(i,m*2){
        int l=s[i].size();
        rep(j,l){
            string t=s[i].substr(j);
            if(t==rev(t)){
                ans=min(ans,dist[id[i][j]]);
            }
        }
    }
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;

    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#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 FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int f[3001][3001];
string s, t, res;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
aspodapsdo
popo
    */
    cin >> s >> t;
    int n = s.size(), m = t.size();
    s = " " + s;
    t = " " + t;
    FOR(i, 1, n)
    {

        FOR(j, 1, m)
        {
            f[i][j] = max(f[i - 1][j], f[i][j - 1]);
            if(s[i] == t[j])
            {
                f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
            }
          //  cout << f[i][j] << " ";
        }
       // cout << "\n";
    }
    int i = n, j = m;
    while(i > 0 && j > 0)
    {
        if(f[i][j] == f[i - 1][j])
            i--;
        else
        if(f[i][j] == f[i][j - 1])
            j--;
        else
        if(f[i][j] == f[i - 1][j - 1] + 1)
        {
           // cout << i << endl;
            res = s[i] + res;
            i--;
            j--;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 35456
/*
 * 2365.cc: Memory Leak
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef vector<int> vi;
typedef vector<bool> vb;

/* global variables */

int m, vs[26];
int err = false;
vi hp;

/* subroutines */

int expr(string &s, int &pos);

int do_malloc(string &s, int &pos) {
  pos += 7; // 'malloc('
  int num = 0;
  while (pos < s.size() && s[pos] >= '0' && s[pos] <= '9')
    num = num * 10 + s[pos++] - '0';
  pos++;  // ')'

  if (m < num) return 0;
  m -= num;
  hp.push_back(num);
  return (hp.size() - 1);
}

int do_clone(string &s, int &pos) {
  pos += 6; // 'clone('
  int e = expr(s, pos);
  pos++; // ')'

  if (e == 0) return 0;
  if (e < 0 || hp[e] < 0) {
    err = true;
    return -1;
  }
  if (m < hp[e]) return 0;
  m -= hp[e];
  hp.push_back(hp[e]);
  return (hp.size() - 1);
}

int do_free(string &s, int &pos) {
  pos += 5; // 'free('
  int e = expr(s, pos);
  pos++; // ')'
  
  if (e == 0) return 0;
  if (e < 0 || hp[e] < 0) {
    err = true;
    return -1;
  }
  m += hp[e];
  hp[e] = -1;
  return 0;
}

int expr(string &s, int &pos) {
  if (s[pos] == '(') {
    pos++; // '('
    int e = expr(s, pos);
    pos++; // ')'
    return e;
  }

  if (pos + 4 <= s.size() && s[pos] == 'N' && s[pos + 1] == 'U') {
    pos += 4; // 'NULL'
    return 0;
  }

  if (s[pos] == 'm') return do_malloc(s, pos);
  if (s[pos] == 'c') return do_clone(s, pos);

  int vr = s[pos++] - 'A'; // [A-Z]

  if (pos < s.size() && s[pos] == '=') {
    pos++; // '='
    int e = expr(s, pos);
    vs[vr] = e;
  }

  return vs[vr];
}

int read_line(string &s) {
  int pos = 0;
  if (s[0] == 'f') return do_free(s, pos);
  return expr(s, pos);
}

/* main */

int main() {
  memset(vs, -1, sizeof(vs));
  hp.push_back(0);

  cin >> m;

  for (;;) {
    string s;
    cin >> s;
    if (cin.eof()) break;

    read_line(s);

    if (err) {
      puts("Error");
      return 0;
    }
  }

  vb refs(hp.size(), false);

  for (int i = 0; i < 26; i++)
    if (vs[i] > 0) refs[vs[i]] = true;

  int ans = 0;
  for (int i = 1; i < hp.size(); i++)
    if (hp[i] > 0 && ! refs[i]) ans += hp[i];
  printf("%d\n", ans);
  
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const int B = 40;

long long a[N];
int h[B];
int ind[B];
int n;
long long k;


void solve() {
  scanf("%d %lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a+i);
    for (int j = 0; j < B; ++j) {
      if (a[i] & (1LL << j))
	++h[j];
    }
  }
  long long x = 0;
  for (int i = B-1; i >= 0; --i) {
    if (h[i] > n-h[i]) continue;
    if (x + (1LL << i) > k) continue;
    x += 1LL << i;
  }
  debug(x);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += x ^ a[i];
  }
  printf("%lld", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4428
from fractions import gcd

A, B, C, D = map(int, input().split())
l = C * D // gcd(C, D)
x = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // l
y = B - B // C - B // D + B // l
print(y - x)


Measured memory_bytes: 5048
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		while(a != 0 && b!=0){

			for(int i=1;i<=a;i++){
				if(i==1 || i==a){
					for(int j=1;j<=b;j++){
						System.out.printf("#");
					}
				}else{
					for(int j=1;j<=b;j++){
						if(j==1 || j==b)
							System.out.printf("#");
						else
							System.out.printf(".");
					}
				}
					System.out.printf("\n");
			}
			System.out.printf("\n");

			a = sc.nextInt();
			b = sc.nextInt();

		}
		
	}
}


Measured memory_bytes: 57512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> broken(n+1);
  for(int i=0; i<m; i++){
    int a;
    cin >> a;
    broken[a] = 1;
  }
  vector<int> dp(n+2);
  int mod = 1000000007;
  dp[n] = 1;
  for(int i=n-1; i>=0; i--){
    if(broken[i]){
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i+1]+dp[i+2]) % mod;
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 1024
/*
                       _oo0oo_
                      o8888888o
                      88" . "88
                      (| -_- |)
                      0\  =  /0
                    ___/`---'\___
                  .' \\|     |// '.
                 / \\|||  :  |||// \
                / _||||| -:- |||||- \
               |   | \\\  -  /// |   |
               | \_|  ''\---/''  |_/ |
               \  .-\__  '-'  ___/-. /
             ___'. .'  /--.--\  `. .'___
          ."" '<  `.___\_<|>_/___.' >' "".
         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
         \  \ `_.   \_ __\ /__ _/   .-` /  /
     =====`-.____`.___ \_____/___.-`___.-'=====
                       `=---='
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Akshay Vashishtha 

//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences 
you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/   
#include<bits/stdc++.h>
 
#define ps push_back
#define le length
#define in insert
#define vint vector<int>
#define vlld vector<long long int>
#define pii pair<int,int>
#define mk make_pair
#define vst vector<string>
#define lld long long int 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)
#define sv()                  int t; scanf("%d",&t); while(t--)
using namespace std;
 
int main()
{
	lld n,k,pre = 0,mw;
  cin>>n>>k;
  lld mn = n%k;
  n = n%k;
  mn = min(mn , k-n);
  cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           int ans=0;
           rep(i,0,6)if(s[i]=='1')ans++;
           cout<<ans<<endl;
}

Measured memory_bytes: 3616
N,M = map(int,input().split())

A = [[0,0] for i in range(N)]
B = [0 for j in range(N)]

for i in range(N):
    A[i][0],A[i][1] = map(int,input().split())

A.sort()

money = 0
for i in range(N+1):
    if M > A[i][1]:
        M -= A[i][1]
        money += A[i][0] * A[i][1]
    else:
        for j in range(A[i][1]+1):
            if M <= j:
                money += A[i][0] * j
                print(money)
                exit()

Measured memory_bytes: 20864
import Data.List
import Data.Array.IO
import Control.Monad
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

size = 8000

main = do
  --s <- getLine
  s <- map (length . BC.unpack) . BC.split 'T' <$> BC.getLine
  (x:y:_) <- map (read :: String -> Int) . words <$> getLine
  memoX <- newArray ((0, (-size)), (size, size)) False :: IO (IOUArray (Int, Int) Bool)
  memoY <- newArray ((0, (-size)), (size, size)) False :: IO (IOUArray (Int, Int) Bool)
  let (xI', yI) = split s ([], [])
      xI@(i:is) = if head s /= 0
                    then filter (/=0) xI'
                    else 0:(filter (/=0) $ tail xI')
  writeArray memoX (0, 0) True
  writeArray memoX (1, i) True
  writeArray memoY (0, 0) True
  dp memoX 2 is
  dp memoY 1 yI
  resultX <- readArray memoX (length xI, x)
  resultY <- readArray memoY (length yI, y)
  if resultX && resultY then putStrLn "Yes"
                        else putStrLn "No"

split :: [Int] -> ([Int], [Int]) -> ([Int], [Int])
split []       (x, y) = (reverse x, filter (/=0) $ reverse y)
split (s:[])   (x, y) = (reverse (s:x), reverse y)
split (s:t:ts) (x, y) = split ts ((s:x), (t:y))

dp :: IOUArray (Int, Int) Bool -> Int -> [Int] -> IO (IOUArray (Int, Int) Bool)
dp memo _ []     = return memo
dp memo 1 (d:ds) = do
  writeArray memo (1, d) True
  writeArray memo (1, (-d)) True
  dp memo 2 ds >>= return
dp memo n (d:ds) = do
  memo' <- foldM (memoize n d) memo [(-size)..size]
  dp memo' (n+1) ds >>= return

memoize :: Int -> Int -> IOUArray (Int, Int) Bool -> Int -> IO (IOUArray (Int, Int) Bool)
memoize n d memo x
  | x - d >= (-size) && x + d <= size = do
    a <- readArray memo (n-1, x-d)
    b <- readArray memo (n-1, x+d)
    writeArray memo (n, x) $ a || b
    return memo
  | x - d >= (-size) = do
    a <- readArray memo (n-1, x-d)
    writeArray memo (n, x) a
    return memo
  |  x + d <= size = do
    b <- readArray memo (n-1, x+d)
    writeArray memo (n, x) b
    return memo
  | otherwise = do
    return memo


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

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> pos(n, 0);
    for (ll i = 0; i < n; i++) {
        ll p;
        cin >> p;
        pos.at(i) = p;
    }

    vector<ll> count(m + 1, 0);
    vector<ll> imos(m + 1, 0);
    for (ll i = 1; i < n; i++) {
        const ll from = pos[i - 1];
        const ll to = pos[i];
        count[to] += (to - from + m) % m - 1;

        if (from < to) {
            imos[from + 1]++;
            imos[to]--;
        } else if (from < m) {
            imos[from + 1]++;
            imos[1]++;
            imos[to]--;
        } else {
            imos[1]++;
            imos[to]--;
        }
    }
    vector<ll> cnt(m + 1, 0);
    for (ll i = 1; i <= m; i++) {
        cnt[i] = cnt[i - 1] + imos[i];
    }
    //    show(cnt);

    vector<ll> ans(m + 1, 0);
    for (ll i = 1; i <= m; i++) {
        if (i == 1) {
            ll sum = 0;
            for (ll j = 1; j < n; j++) {
                const ll from = pos[j - 1];
                const ll to = pos[j];
                const ll move = (1 - from + m) % m;
                if (0 < move and move <= (to - from + m) % m) {
                    sum += (to - 1 + m) % m + 1;
                } else {
                    sum += (to - from + m) % m;
                }
            }
            ans[1] = sum;
        } else {
            ans[i] = ans[i - 1] + count[i - 1] - cnt[i - 1];
        }
    }
    ll mini = INF<ll>;
    for (ll i = 1; i <= m; i++) {
        if (mini > ans[i]) {
            mini = ans[i];
        }
    }
    cout << mini << endl;

    return 0;
}


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

int main()
{
    int th, ts, ah, as, i;
    cin >> th >> ts >> ah >> as;

    for(i=1; ;i++)
    {
        ah=ah-ts;
        if(ah<=0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        th=th-as;
        if(th<=0)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << ah << " " << th;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 

using namespace std;

long long rec(vector<long long> a,vector<long long> prefix){
	int n = a.size();
	long long dp[n][n];

	for(int i = 0; i < n; i++){
		dp[i][i] = 0;
	}
	for(int len = 2; len <= n; len++){
		for(int i = 0; i + len -1< n; i++){
			int j = i + len -1;
			//dp[i][j] = 1000000000000;
			for(int k = i; k < j; k++){
				long long curr = 0;
				curr += dp[i][k];
				curr += dp[k+1][j];
				if(i > 0)curr += (prefix[k] - prefix[i-1]) + (prefix[j] - prefix[k]);
				else curr += prefix[j];
				if(k == i){
					dp[i][j] = curr;
				}
				else{
					dp[i][j] = min(dp[i][j], curr);
				}
			}
		}
	}
	return dp[0][n-1];
	// if(i == j){
	// 	return a[i];
	// }
	// int res = INT_MAX;
	// // int prefix[j- i + 1];
	// for(int k = i; k < j; k++){
	// 	int ans = 0;
	// 	ans += rec(a, i, k, prefix);
	// 	//dbg(ans);
	// 	ans += rec(a, k+1, j, prefix);
	// 	//dbg(ans);
	// 	if(i > 0)ans += (prefix[k] - prefix[i-1]) + (prefix[j] - prefix[k]);
	// 	else ans += (prefix[k]) + (prefix[j] - prefix[k]);
	// 	dbg(ans);
	// 	res = min(res, ans);
	// }
	// return res;

}

int main(){
	int n;
	cin >> n;
	vector<long long> a(n);
	vector<long long> prefix(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i > 0)prefix[i] = prefix[i-1] + a[i];
		else prefix[i] = a[i];
		//cout << prefix[i] << " ";
	}
	long long res = rec(a,prefix);
	cout << res << endl;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

template<class T> struct LazySegTree{
    int n = 1;
    vector<T> node, lazy;
    
    LazySegTree(int n_){
        while(n < n_) n *= 2;
        node.resize(n*2-1, 0);
        lazy.resize(n*2-1, 0);
    }
    
    void eval(int i, int l, int r){
        if(lazy[i] == 0) return;
        node[i] += lazy[i];
        if(r-l > 1){
            lazy[i*2+1] += lazy[i] / 2;
            lazy[i*2+2] += lazy[i] / 2;
        }
        lazy[i] = 0;
    }
    
    void update(int a, int b, T v, int i, int l, int r){
        eval(i, l, r);
        if(r<=a || b<=l) return;
        if(a<=l && r<=b){
            lazy[i] += v * (r-l);
            eval(i, l, r);
            return;
        }
        update(a, b, v, i*2+1, l, (l+r)/2);
        update(a, b, v, i*2+2, (l+r)/2, r);
        node[i] = node[i*2+1] + node[i*2+2];
    }
    
    T getsum(int a, int b, int i, int l, int r){
        eval(i, l, r);
        if(r<=a || b<=l) return 0;
        if(a<=l && r<=b) return node[i];
        T vl = getsum(a, b, i*2+1, l, (l+r)/2);
        T vr = getsum(a, b, i*2+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    
    LazySegTree<int> lst(n);
    rep(i, n) lst.update(i, i+1, k, 0, 0, lst.n);
    while(q--){
        int a;
        scanf("%d", &a);
        --a;
        lst.update(0, a, -1, 0, 0, lst.n);
        lst.update(a+1, n, -1, 0, 0, lst.n);
    }
    
    rep(i, n) cout << (lst.getsum(i, i+1, 0, 0, lst.n) > 0 ? "Yes": "No") << "\n";
}

Measured memory_bytes: 2688
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::HashSet;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    mut n: u64
    }

    let mut tmp = 26;
    let mut l = 1;
    while n > tmp {
        n -= tmp;
        tmp *= 26;
        l += 1;
    }
    n -= 1;

    let mut vec = vec![];

    for _ in 0..l {
      let amari = n % 26;
      n = n / 26;
      vec.push((amari as u8 + b'a') as char);
    }

     println!("{}", vec.iter().rev().collect::<String>());
}


Measured memory_bytes: 2164
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	int n;cin>>n;
	n%=10;
	if(n==2||n==4 or n==5 or n==7 or n == 9) cout<<"hon\n";
	if (n == 0 or n == 1 or n == 6 or n == 8) cout << "pon\n";
	if (n == 3) cout << "bon\n";
}




Measured memory_bytes: 3592
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 500000
#define MAX_  2000000000
struct tree
{
	long long int key = MAX_ + 1;
	tree *left = NULL, *right = NULL, *p = NULL;
};
tree *flag = NULL;
void insert(tree &T,tree &z)
{
	tree *y = NULL , *x = &T;
	while (x->key != MAX_ + 1) {
		y = x;
		if (z.key < x->key) { x = x->left; }
		else { x = x->right; }
		if (x == NULL) break;
	}
	z.p = y;
	if (y == NULL) { 
		T = z; 
	}
	else if (z.key < y->key) { 
		y->left = &z; 
	}
	else { 
		y->right = &z; 
	}
}
void print_1(tree *T) {
	if (T != NULL) {
		printf(" %lld", T->key);
		print_1(T->left);
		print_1(T->right);
	}
}
void print_2(tree *T) {
	if (T != NULL) {
		print_2(T->left);
		printf(" %lld", T->key);
		print_2(T->right);
	}
}
int find_(tree *T,long long int n){
	if (T == NULL) { return 0; }
	if (T->key == n) { return 1; }
	if (T->key < n) {
		return (find_(T->right, n));
	}
	else {
		return (find_(T->left, n));
	}
}
void delete_(tree *T, long long int n) {
	if (T != NULL) {
		delete_(T->left, n);
		if (T->key == n || flag != NULL) {

			if (flag != NULL) { 
				flag->key = T->key;
				flag = NULL;
			}
			if (T->left == NULL && T->right == NULL) {
				if (T->p->key > T->key) { T->p->left = NULL; }
				else { T->p->right = NULL; }
				return;
			}
			else if (T->left != NULL && T->right != NULL) {
				flag = T;
			}
			else { 
				if (T->p->left == T) {
					if (T->left != NULL) {
						T->p->left = T->left;
						T->left->p = T->p;
					}
					else {
						T->p->left = T->right;
						T->right->p = T->p;
					}
				}
				else {
					if (T->left != NULL) {
						T->p->right = T->left;
						T->left->p = T->p;
					}
					else {
						T->p->right = T->right;
						T->right->p = T->p;
					}
				}
				return;
			}
		}
		delete_(T->right, n);
	}
}

int main() {
	int m, cou = 0;
	long long int k;
	string s;
	tree t, id[MAX];
	scanf_s("%d", &m);
	for (int i = 0; i < m; ++i) {
		cin >> s;
		if (s == "insert") {
			scanf_s("%lld", &id[cou].key);
			insert(t, id[cou]);
			++cou;
		}
		else if(s == "print"){
			print_2(&t);
			printf("\n");
			print_1(&t);
			printf("\n");
		}
		else if(s == "find"){
			scanf_s("%lld", &k);
			if (find_(&t, k)) printf("yes\n");
			else printf("no\n");
		}
		else{
			scanf_s("%lld", &k);
			flag = NULL;
			delete_(&t, k);
		}
	}
	return 0;
}

Measured memory_bytes: 34564
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;

vector<ll> v;

ll p5(ll x){return x*x*x*x*x;}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll x;
    cin >> x;

    repp(A, -1500, 1500){
        repp(B, -1500, 1500){
            if(p5(A) - p5(B) == x){
                cout << A << " " << B;
                return 0;
            }
        }
    }
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


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

int main(){
  int n,i,ans=0;
  cin>>n;
  int p[n];
  for(i=0;i<n;i++) cin>>p[i];

  for(i=1;i<n-1;i++){
    if((p[i+1]-p[i])*(p[i-1]-p[i])<0) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repeat(i, n) for(int (i) = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	ll a = N / (A+B);
	ll b = N % (A+B);
	
	ll result = 0;
	result += a*A;

	if ( b <= A) {
		result += b;
	} else {
		result += A;
	}
	cout << result << endl;
	return 0;
}


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

int n;
int x,y;

int main()
{
   scanf("%d",&n);
   if(n==1) printf("Hello World\n");
   else
   {
      scanf("%d%d",&x,&y);
      printf("%d\n",x+y);
   }
 	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second



int main() {
	ll n, a[100010], ans = 0;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			ans = max(ans, abs(a[i] - a[j]));
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

  if(S == "BBB" || S == "AAA") cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int N, K;
    cin >> N >> K;

    long ans;
    
    ans = K * pow(K-1, N-1);

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
/**
 * snuke code
**/
fn main() {
    input! {
            h:usize,
            w:usize,
            k:usize,
        s:[Chars;h],
    }
    // dbg!(&s);
    let mut ans = INF;
    // 横に切る方法を全探索
    for div in 0..(1usize << (h - 1)) {
        let mut g: usize = 0;
        let mut id = vec![0usize; h + 1];
        for i in 0..h {
            id[i] = g;
            if (((div >> i) & 1) == 1) {
                g += 1;
            }
        }
        // dbg!(div);
        g += 1;
        let mut c = vec![vec![0usize; w]; g];
        // groupにmapping
        for i in 0..h {
            for j in 0..w {
                c[id[i]][j] += (s[i][j] as u8 - b'0') as usize;
            }
        }

        // dbg!(&c);
        let mut num: usize = g - 1;
        // 各グループで何個のホワイトチョコがあるか
        let mut now = vec![0usize; g];
        for j in 0..w {
            // dbg!(j);
            if !add(&mut now, j, g, k, &c) {
                num += 1;
                now = vec![0usize; g];
                if !add(&mut now, j, g, k, &c) {
                    num = INF;
                    break;
                }
            }
            // dbg!(&now);
            // dbg!(num);
        }
        // dbg!(div, num);
        ans = min(ans, num);
    }
    println!("{}", ans);
}
// j列目をnowに加算
fn add(now: &mut Vec<usize>, j: usize, g: usize, k: usize, c: &Vec<Vec<usize>>) -> bool {
    for i in 0..g {
        now[i] += c[i][j];
    }
    for i in 0..g {
        if now[i] > k {
            return false;
        }
    }
    return true;
}
const INF: usize = 1 << 62;

pub fn charconv(c: char, base: char) -> usize {
    return (c as u8 - base as u8) as usize;
}


Measured memory_bytes: 2224
def solve(a, b):
    v = [0,0,0,0]
    for i in range(3):
        v[a[i]-1] += 1
        v[b[i]-1] += 1
    return "YES" if sorted(v) == [1,1,2,2] else "NO"

a = [0]*3
b = [0]*3
for i in range(3):
    a[i], b[i] = map(int, input().split())
print(solve(a, b))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=min(a,b);i>0;i--){
		if(a%i==0&&b%i==0){
			k--;
		}
		if(k==0){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll c[5] = {};
    cin >> n;
    string a , b = "MARCH";
    for( int i = 0 ; i < n ; i++ ) {
        cin >> a;
        for( int j = 0 ; j < 5 ; j++ ) {
            if( b[j] == a[0] ) {
                c[j]++;
                break;
            }
        }
    }
    ll x = 0;
    // 選出3個 , 5 * 4 * 3
    for( int i = 0 ; i < 5 ; i++ ) {
        for( int j = i + 1 ; j < 5 ; j++ ) {
            for( int k = j + 1 ; k < 5 ; k++ ) {
                x += c[i] * c[j] * c[k];
            }
        }
    }
    cout << x;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

int main(void){
    string N;
    cin >> N;
    if(N[0]=='7' || N[1]=='7' || N[2]=='7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll x[2*Maxn+3],y[2*Maxn+3];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll F[2*Maxn];
ll Find(ll a)
{
    return F[a]==0?a:F[a]=Find(F[a]);
}
int main()
{

ll n;
cin>>n;
for(int i=1;i<=n;i++)
 {
     ll a,b;
     cin>>a>>b;
     ll z,zz;
     z=Find(a);zz=Find(b+Maxn);
     if(z!=zz)
     {
         F[zz]=z;
     }
 }
 for(ll i=1;i<=Maxn;i++)
    x[Find(i)]++;
 for(ll i=Maxn+1;i<=Maxn*2;i++)
    y[Find(i)]++;
    ll sum=0;
    for(ll i=1;i<=Maxn;i++)
      
        sum+=(ll)(x[i])*(y[i]);
    cout<<sum-n;
}



Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    vector<double> l;
    for (int i = 0; i < n; ++i) {
        double tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    sort(l.begin(),l.end(),less<double>());
  	for(int i = 0;i<n-1; ++i) {
    	l.at(i + 1) = (l.at(i)+l.at(i+1))/2;
    }

        cout << l.at(n-1) << endl;
    return 0;
}

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

typedef pair<int, int> P;
typedef long long ll;
const int mod = 1000000007;

bool square(ll a){ll n=(ll)sqrt(a);return a==n*n;}
int digitsum(ll N,int a);//a進数におけるNの各桁の和、計算量はloga(N)
ll mpow(ll x, ll n);
ll inv_mod(ll a){return mpow(a,mod-2);}
int gcd(int x,int y){return y ? gcd(y,x%y) : x;};//xとyの最大公約数
int lcm(int x,int y){return x*y/gcd(x,y);}//xとyの最小公倍数

class Fuctorical{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Fuctorical(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(b==0) return 1;
        if(a<b||a<=0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};

int main(){
    string L;
    cin>>L;
    Fuctorical get(100001);
    ll N=L.length();
    ll ans=0;
    int num=0;
    int count=0;
    vector<int> V(N);
    REP(i,N){
        if(L[i]=='1') count++;
        V[i]=count;
    }
    ll dp[100002][2];
    dp[0][1]=1;//和がLに一致する
    dp[0][0]=0;//和がL未満になる
    REP(i,N){
        if(L[i]=='1'){
            dp[i+1][1]=2*dp[i][1]%mod;
            dp[i+1][0]=dp[i][1]+3*dp[i][0]%mod;
        }
        if(L[i]=='0'){
            dp[i+1][1]=dp[i][1]%mod;
            dp[i+1][0]=3*dp[i][0]%mod;
        }
    }
    cout<<(dp[N][0]+dp[N][1])%mod<<endl;
}

int digitsum(ll N,int a){
    if(N==0) return 0;
    int ret=0;
    ret+=digitsum(N/a,a)+N%a;
    return ret;
}
ll mpow(ll x, ll n){ //x^n(mod division) ←普通にpow(x,n)では溢れてしまうため，随時mod計算 2分累乗法だから早い
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}
/*
class Fuctorical{//階乗とその逆元を求めて計算に利用するクラス
private:
    vector<ll> fac;
public:
    
    Fuctorical(ll N){
        fac.push_back(1);
        for(int i=0;i<N;i++) fac.push_back(fac[i]*(i+1)%mod);
    }

    ll fact(ll a){return fac[a];}
    ll ifact(ll a){return inv_mod(fac[a]);}

    ll cmb(ll a,ll b){
        if(a==0&&b==0) return 1;
        if(a<b||a<0) return 0;
        ll tmp =ifact(a-b)*ifact(b)%mod;
        return tmp*fac[a]%mod;
    }
};
*/

/*
class UnionFind{//UnionFind木
 private:
    vector<int> Parent;
 public:
    UnionFind(int N){
        for(int i=0;i<N;i++) Parent.push_back(-1);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        return Parent[A]=root(Parent[A]);
    }

    int size(int A){
        return -Parent[root(A)];
    }

    bool connect(int A,int B){
        A=root(A);
        B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) swap(A,B);
        Parent[A]-=Parent[B];
        Parent[B]=A;
    }
};
*/


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int l, r, d; cin >> l >> r >> d;

    int ans = 0, a = d;
    while (1) {
        if (d >= l && d <= r) {
            ++ans;
        } else if (d > r) {
            break;
        }
        d += a;
    }
    cout << ans << endl;
}   

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int z = n/1000;
  if(n%1000 == 0){
      cout << 0 <<endl;
  }else{
      int rem = 1000*(z+1) - n;
      cout << rem <<endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, S.length()) {
        if (S[i] == T[i]) {
            ++ans;
        }
    }
    print(ans);
}

int main()
{
    solve();

    return 0;
}


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

int main() {
	ll x;
	cin >> x;
	ll ans = 2 * (x / 11);
    if(x % 11 == 0) ans += 0;
	else if (x % 11 <= 6) ans++;
	else ans += 2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * archeryue
 * 9/19/16
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int h = scanner.nextInt();
        System.out.println((a + b) * h / 2);
    }
}

Measured memory_bytes: 9556
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int d;

    while(cin >> d){
        int area = 0;
        for(int i = 1; i * d < 600; i++){
            int miniarea = (i * d) * (i * d) * d;
            area += miniarea;
        }
        cout << area << endl;
    }
}



Measured memory_bytes: 2992
# ABC 054
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0 for i in range(n)]
def zeros2(n, m): return [[0 for i in range(m)] for j in range(n)]

debug = True
def db(x): 
    if debug: print(x)

debug = False
N,m = getIntList()
org = zeros(m)

for i in range(m):    org[i] = getIntList()

db(('org graph',org))
Count = 0

def find(graph, fromNode, route): # -1: NG, >=OK、評価値
    global Count
    db(('find in',fromNode, route))
    if fromNode in route: return -1
    else:
        route = route + [fromNode]  # +=だとrouteを書き換えてしまう
        if len(route)==N: 
            db(('N',N))
            Count += 1
            return 0
        for edge in graph:
            if edge[0]==fromNode:  # graphのソート、一旦fromが見つかった後の中断
                val = find(graph, edge[1], route)
                #if val==0: 
                #    db(('found', route, edge[1]))
                #    return 0
        #db(('cannot',fromNode))
        return -1
    
graph = zeros(m*2)
for i in range(m):
    graph[i*2] = org[i]
    graph[i*2+1] = [org[i][1], org[i][0]]
graph.sort()
db(('new graph',graph))
route = []
find(graph, 1, route)
print(Count)



Measured memory_bytes: 3064
// AOJ Volume 1 Problem 0163 Ohajiki Game

#include <stdio.h>


int main(void)
{
    int i;
    int j;
    int a[25];
    int ohajiki;
    int jiro_turn;
    
    while (1){
        scanf("%d", &i);
        if (i == 0){
            break;
        }

        for (j = 0; j < i; j++){
            scanf("%d", &a[j]);
        }
        
        jiro_turn = 0;
        ohajiki = 32;
        while (1){
            // êYÌ^[
            ohajiki -= ((ohajiki - 1) % 5);
            
            // ¨Í¶«Ì\¦
            printf("%d\n", ohajiki);

            // ¨Í¶«ªÈ­ÈÁ½çI¹
            if (ohajiki == 0){
                break;
            }
            
            // YÌ^[
            ohajiki -= a[jiro_turn];
            jiro_turn = ((jiro_turn + 1) % i);

            // ¨Í¶«ªÈ­ÈÁ½çI¹
            if (ohajiki <= 0){
                printf("0\n");
                break;
            }

            // ¨Í¶«Ì\¦
            printf("%d\n", ohajiki);
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
/*
....................
....................
*/
#include<bits/stdc++.h>
#define ll long long int
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;


int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	ll n,w;
	cin>>n>>w;
	ll A[n],V[n],i,j,k;
	for(i=0;i<n;i++)
		cin>>A[i]>>V[i];
	ll dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
		dp[i][0]=0;
	}
	for(i=0;i<w+1;i++)
	{
		dp[0][i]=0;
	}
	for(i=1;i<n+1;i++)
	{
		for(j=1;j<w+1;j++)
		{
			if(j>=A[i-1])
			{
				dp[i][j] = max(V[i-1]+dp[i-1][j-A[i-1]],dp[i-1][j]);
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;

	return 0;
}


Measured memory_bytes: 82476