akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T>
vector<T> make_v(size_t a) {
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
    for(auto& e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> c(m), p(m);
    vector<vector<int>> v(m);
    for(int i = 0; i < m; i++) {
        cin >> c[i];
        v[i].resize(c[i]);
        for(int j = 0; j < c[i]; j++) {
            cin >> v[i][j];
            v[i][j]--;
        }
    }
    for(int i = 0; i < m; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++) {
        bool f = true;
        for(int j = 0; j < m; j++) {
            int co = 0;
            for(int k = 0; k < c[j]; k++) {
                if((i >> v[j][k]) & 1) {
                    co++;
                }
            }
            if(co % 2 != p[j]) {
                f = false;
            }
        }
        if(f) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ans = n * (1 + n) / 2;
  ll three = n / 3;
  ans -= three * (3 + 3 * three) / 2;
  ll five = n / 5;
  ans -= five * (5 + 5 * five) / 2;
  ll ft = n / 15;
  ans += ft * (15 + 15 * ft) / 2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
from functools import lru_cache

def main():
    N = int(input())
    infos = []
    for i in range(1,N):
        infos.append(tuple(map(int, input().split())))

    for i in range(1,N):
        current_time = 0
        for station_number in range(i,N):
            current_time = next_arrival_time(current_time, infos[station_number -1])
        print(current_time)
    print(0)

@lru_cache(maxsize = 2**26)
def next_arrival_time(current_time, info):
    if current_time <= info[1]:
        return info[1] + info[0]

    next_time = current_time
    remainder = next_time % info[2]
    while remainder != 0:
        next_time += 1
        remainder = next_time % info[2]
    while next_time < current_time:
        next_time += info[2]

    return next_time + info[0]

main()

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

int main() {
  int n;
  vector<int> a(100, 0);
  cin >> n;
  bool isApproved = true;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) a[i] = x;
  }

  for (int i = 0; i < n; i++)
  {
    if (a[i] % 3 != 0 && a[i] % 5 !=0) 
    {
      isApproved = false;
      break;
    }
  }
  if (isApproved) cout << "APPROVED";
  else cout << "DENIED";

  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    string str;
    std::cin >> str;
    bool n = false;
    bool s = false; 
    bool w = false;
    bool e = false;
    bool ans = false;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == 'N') n = true;
        else if (str[i] == 'S') s = true;
        else if (str[i] == 'W') w = true; 
        else if (str[i] == 'E') e = true; 
    }
    if (n==s && w==e) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

const int MOD = 1e9 + 7;

struct mint {
  long long x;
  mint(long long x = 0) :x((x%MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  int N; cin >> N;
  vector<int> A(N); rep(i, N) cin >> A[i];

  map<int, int> mp;

  rep(i, N) {
    map<int, int> mpi;
    int n = A[i];
    for (int i = 2; i * i <= n; i++) {
      while (n % i == 0) {
        mpi[i]++;
        n /= i;
      }
    }
    mpi[n]++;

    for (auto p : mpi) {
      int x = p.first;
      mp[x] = max(mp[x], mpi[x]);
    }
  }

  mint lcm = 1;
  for (auto p : mp) {
    int x = p.first;
    rep(i, mp[x]) {
      lcm *= x;
    }
  }

  mint ans = 0;
  rep(i, N) {
    ans += lcm / A[i];
  }

  cout << ans.x << endl;
}

Measured memory_bytes: 768
// 2019/03/27 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int W, H, N;
	cin >> W >> H >> N;

	int MX[100000] = {0};

	for(int i=0; i<N; i++){
		int x, y;
		cin >> x >> y;

		MX[y] = max(MX[y], x);
	}

	int mx_max = 0;
	int ans = W+H;

	for(int i=H-1; i>=0; i--){
//		cout << i+mx_max << endl;
		ans = min(ans, i+mx_max);
		mx_max = max(mx_max, MX[i]);
	}

	cout << ans << endl;

	return 0;
}



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

int main(){//2D+1
    int n,d;
    cin>>n>>d;
    
    int hoge=2*d+1;
    
    int count=0;
    while(1){
        n=n-hoge;
        count++;
        if(n<=0)break;
    }
    cout<<count;
}

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

#define       pb                 push_back
#define       sf                 scanf
#define       pf                 printf
#define       mx                 200005
#define       MOD                1000000007
#define 	  optimize           ios::sync_with_stdio(0);cin.tie(0);
#define 	  inf                0x3f3f3f3f
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);

using namespace std;

typedef       long long int      ll;
typedef       vector<int> 	     vi;

int dx[] = {0, 0, +1, -1};
int dy[] = {+1,-1, 0,  0};
/*============GRAPH MOVES==================*/
//const int fx[] = {1, -1, 0, 0};
//const int fy[] = {0, 0, 1, -1};
//const int fx[] = {0, 0, 1, -1, -1, 1, -1, 1};  // Kings move
//const int fy[] = {-1, 1, 0, 0, 1, 1, -1, -1};  // Kings move
//const int fx[] = {-2, -2, -1, -1, 1, 1, 2, 2}; // Knights move
//const int fy[] = {-1, 1, -2, 2, -2, 2, -1, 1}; // Knights move
/*=========================================*/

inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline bool isLeapYear(ll year) { return (year%400==0) || (year%4==0 && year%100!=0); }
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
inline ll mod(ll a, ll m){ if(a<0) return m-(abs(a)%m); else if(a<m) return a; else return (a%m); }
inline string tstring(ll a) {stringstream ss; ss << a; string str = ss.str(); return str; }

double x[10], y[10];
bool vis[10];
int n;
double total, ans, fact = 1, cn;

double dis(int i, int j)
{
    return sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
}

double func(int in)
{
    vis[in] = true;

    for(int i = 1; i <= n; i++)
    {
        if(vis[i]==false)
        {
            vis[i] = true;

            ans += dis(in, i);
            ++cn;

//            cout << i << " ";

            func(i);

//            cout << endl << cn << endl;;

            if(cn==n) total += ans;
            cn--;

            ans -= dis(in, i);

            vis[i] = false;
        }
    }
}

int main()
{
	cin >> n;

	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];

	for(int i = 1; i <= n; i++)
    {
        ans  = 0;
        cn = 1;
        fact *= i;

        memset(vis, false, sizeof(vis));

        func(i);
    }

//    cout << total << " " << fact << endl;

    double x = (total/fact);

    printf("%.10f\n", x);


    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
bool ok(vector<int> v)
{
    REP(i,v.size())if(v[i]!=i+1)return false;
    return true;
}
int main()
{
    int n;
    cin>>n;
    vector<int>v(n);
    string ans="NO";
    REP(i,n)cin>>v[i];
    if(ok(v))ans="YES";
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            swap(v[i],v[j]);
            if(ok(v))ans="YES";
            swap(v[i],v[j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int dp[50000];
signed main() {
	int a, b; cin >> a >> b;
	dp[0] = 1;
	for (int c = 0; c < a; c++) {
		int d; cin >> d;
		for (int e = 10000; e >= d; e--) {
			dp[e] += dp[e - d];
		}
	}
	int ans = 0;
	for (int i = 0; i <= 10000; i++) {
		if (i % 2 == b)ans += dp[i];
	}
	cout << ans << endl;
}

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

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

int n, m;
int p[100010];
string s[100010];
int pena[100010];
int corr[100010];


int main() {

    cin >> n >> m;

    rep(i, m) cin >> p[i] >> s[i];

    rep(i, n) {
        corr[i] = 0;
        pena[i] = 0;
    }

    rep(i, m) {
        int pos = p[i] - 1;
        if (s[i] == "AC") corr[pos] = 1;
        if (s[i] == "WA" && corr[pos] != 1) pena[pos]++;
    }

    int pena_res = 0;
    int corr_res = 0;
    rep(i, n) {
        if (corr[i] == 1) {
            pena_res += pena[i];
            corr_res++;
        }
    }

    cout << corr_res << ' ' << pena_res << endl;

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 1000;
int n, ans;
int a[N], b[N], c[N];

int main() {
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) cin >> b[i];
    rep(i, 1, n - 1) cin >> c[i];
    rep(i, 1, n) {
        ans += b[a[i]];
        if (i > 1 && a[i - 1] + 1 == a[i]) ans += c[a[i - 1]];
    }
    printf("%d\n", ans);
    return 0;
}


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


int main(void){

	int i,n;
	char *p;
	char a[1002];
	//char word[]="hoshino";
	scanf("%d\n",&n);
	for(i = 0;i < n;i++){
        fgets(a,sizeof(a),stdin);
        while((p = strstr(a,"Hoshino"))!=NULL){
            p[6] = 'a';
        }
                printf("%s",a);

    }


return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
ll inf = -1;
ll mod = pow(10, 9) + 7;

int main() {
	int n,m;cin>>n>>m;
	vector<int>a(n);
	vector<P>cb(m);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>cb[i].second>>cb[i].first;
	}
	sort(a.begin(),a.end());
	sort(cb.begin(),cb.end(),greater<P>());
	vector<int>c;
	int cnt=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<cb[i].second;j++){
			if(cnt>=n){
				break;
			}
			c.push_back(cb[i].first);
			cnt++;
		}
	}
	ll ans=0;
	if(c.size()<n){
		for(int i=0;i<n-c.size();i++){
			c.push_back(0);
		}
	}
	for(int i=0;i<n;i++){
		ans+=max(a[i],c[i]);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    long long h;
    cin >> h;
    long long c = 0;
    long long i = 1;
    while(h > 0)
    {
        if (h == 1)
        {
            c++;
            break;
        }
        h = h / 2;
        c += pow(2, i);
        i++;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];
  sort(all(d));
  reverse(all(d));
  int ans=1;
  rep(i,n-1){
    if(d[i]!=d[i+1]) ans++;
  }
  cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
N = int(input())
s = [int(input()) for i in range(N)]
ss = sum(s)
m = 101
for i in range(N):
    if s[i] % 10 != 0 and s[i] < m:
        m = s[i]
if m == 101:
    print(0)
elif ss % 10 == 0:
    print(ss-m)
else:
    print(ss)


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

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; 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 printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	printyn(s.find("7") != string::npos);

	Please AC;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, d, a; cin >> n >> d >> a;
    vector<pll> v(n);
    rep(i,n) cin >> v[i].first >> v[i].second;
    sort(ALL(v));

    ll ans = 0;
    ll sum = 0;
    queue<pll> q;
    rep(i,n) {
        while(!q.empty()) {
            if(q.front().first < v[i].first) {
                sum -= q.front().second;
                q.pop();
            }
            else break;
        }
        v[i].second -= sum;
        if(v[i].second<=0) continue;
        ll atk = (v[i].second-1)/a + 1;
        ll dam = atk * a;
        sum += dam;
        ans += atk;
        q.push({v[i].first+2*d,dam});
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
import java.util.*;
//080D
public class Main {
	public static void main(String[] args) {
		//同じチャンネルは連続でとれる。
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), C = sc.nextInt();
		int sec = (int)1e5;
		Integer overlap[] = new Integer[sec];
		Arrays.fill(overlap,0);
		int chan[][] = new int[C][sec];
		for(int i=0;i<N;i++) {
			int s = sc.nextInt(), t = sc.nextInt(), c = sc.nextInt()-1;
			for(int j=s;j<=t-1;j++) {
				chan[c][j]++;
			}
		}	
		for(int i=0;i<C;i++) {
			for(int j=1;j<sec;j++) {
				if(chan[i][j-1]==0&&chan[i][j]==1) overlap[j-1]++;
				if(chan[i][j]==1) overlap[j]++;
			}
			
		}
		
		Arrays.sort(overlap,Comparator.reverseOrder());
		int ans = overlap[0];
		System.out.println(ans);
	}
}


Measured memory_bytes: 113544
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n, k):
    m = 10**9+7
    res = 0
    for i in range(k, n+2):
        res += n*i - i*i + i + 1
    return res % m


if __name__ == "__main__":
    n, k = inums()
    print(solve(n, k))


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int H,W; cin >> H >> W;
    int fi[H+2][W+2];
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> fi[i][j];
    vector<int> a, b, c, d;

    for(int i=1; i<=H; i++){
        if(i%2 == 1){ // ----->
            for(int j=1; j<=W; j++){
                if(fi[i][j]%2 == 1){
                    if(i == H && j == W) continue;

                    int ni = (j == W)? i+1:i;
                    int nj = (j == W)? j:j+1;
                    fi[ni][nj] += 1;
                    a.push_back(i);
                    b.push_back(j);
                    c.push_back(ni);
                    d.push_back(nj);
                }
            }
        }
        else{ // <-----
            for(int j=W; j>=1; j--){
                if(fi[i][j]%2 == 1){
                    if(i == H && j ==1) continue;

                    int ni = (j == 1)? i+1:i;
                    int nj = (j == 1)? j:j-1;
                    fi[ni][nj] += 1;
                    a.push_back(i);
                    b.push_back(j);
                    c.push_back(ni);
                    d.push_back(nj);
                }
            }
        }
    }

    cout << a.size() << endl;
    for(int i=0; i<a.size(); i++) printf("%d %d %d %d\n", a[i], b[i], c[i], d[i]);
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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...));
}

struct edge{
    int to;
    ll cost;
};
vector<vector<edge>> g;
vector<ll> d;

void dijkstra(int s) {
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> que;
    for(ll &x : d) x = LINF;
    d[s] = 0;
    que.push(make_pair(0LL, s));
    
    while(!que.empty()) {
        pair<ll,int> p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        
        rep(i,g[v].size()) {
            edge e = g[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}


int main() {
    int n,m;
    cin>>n>>m;
    g.resize(n);
    rep(i,n-1) {
        g[i+1].push_back({i,0});
    }
    rep(i,m) {
        int l,r;
        ll c;
        cin>>l>>r>>c;
        l--;r--;
        g[l].push_back({r,c});
        g[r].push_back({l,c});
    }
    
    d.resize(n);
    dijkstra(0);
    cout<<(d[n-1]==LINF ? -1 : d[n-1])<<endl;
}



Measured memory_bytes: 13048
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    div = [0 for i in range(max(A)+1)]

    for a in A:
        if div[a] == 0:
            div[a] += 1
            idx = 2*a

            for i in range(10**6):
                if idx >= len(div):
                    break
                else:
                    div[idx] += 1
                    idx += a
                    
        else:
            div[a] += 1

    ans = 0
    for a in A:
        if div[a] == 1:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32132
#include<stdio.h>
#include <stdlib.h>
int main(){
  int N;
  int A[100010];
  int result[100010];
  int distance;

  scanf("%d",&N);
  A[0]=0;
  A[N+1]=0;
  for(int i=1;i<=N;i++){
    scanf("%d", &A[i]);
  }

  for(int i=1;i<=N+1;i++){
    distance+=abs(A[i]-A[i-1]);
  }


  for(int i=1;i<=N;i++){
    result[i]=distance-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]);
  }

  for(int i=1;i<=N;i++){
    printf("%d\n",result[i]);
  }
  return 0;
}


Measured memory_bytes: 1920
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//


int main() {

    int n; cin >> n;

    ll dp[45];
    dp[0] = dp[1] = 1;
    for (int i = 2; i <= 44; ++i) dp[i] = dp[i-1] + dp[i-2];
    out(dp[n]);

    return 0;
}











Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}
signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> t;
	vector<int> last(num);
	// srand(time(NULL));
	
	cin>>D;
	
	// D = 365;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
		// c[i] = rand()%100;
	}
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			// s[i][j] = rand()%20000;
			
			if(s[i][t[i]] + last[t[i]] * last[t[i]] * c[t[i]] < s[i][j] + last[j] * last[j] * c[j]) {
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
	}
	
	// srand(time(NULL));
	
	
	int p = point(t);
	
	// cout<<point(t)<<endl;
	for(int i = 0; i < 10000; i++){
		int d = rand()%D, x = rand()%num, np;
		int tx;
		
		tx = t[d];
		
		t[d] = x;
		
		np = point(t);
		
		if(p < np) {
			np = p;
		} else {
			t[d] = tx;
		}
		
	}
	// cout<<point(t)<<endl;
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	// cout<<point(t)<<endl;
	
	return 0;
}

Measured memory_bytes: 3756
#include<stdio.h>

int main(void){

  int a=0, b=0, c=0;
  int x=0, k=0;
  int m=0, n=0, buffer=0;
  int num[3]={0};
  int max=0, num_sum=0;

  for(m=0; m<3; m++){
    scanf("%d", num+m);
    num_sum=num_sum+num[m];
  }

  for(m=0; m<2; m++){
    for(n=m+1; n<3; n++){
      if(num[m]<num[n]){
	buffer=num[m];
	num[m]=num[n];
	num[n]=buffer;
      }
    }
  }
  m=0;
  max=num[0];

  while((num_sum+2*m) % 3 != 0 || ((num_sum+2*m) / 3 ) < max){
    m++;
  }

  x=(num_sum+2*m) / 3;

  k=( 3*x-num_sum ) / 2;

  printf("%d\n", k);

  return 0;
}


Measured memory_bytes: 128
#for内でその都度sumをとるのはまずいらしい
n,k = map(int,input().split())
p = list(map(int,input().split()))
ave = []
ans = 0
tmp = 0

for i in range(n):
  ave.append((p[i]+1)/2)

for j in range(n):
  tmp += ave[j]
  if j >= k:
    tmp -= ave[j-k]
    
  ans = max(ans,tmp)


print(ans)

Measured memory_bytes: 24804
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
 
string line;
 
inline bool isOp(char c) {
  return c == '+' || c == '-' || c == '*' || c == '/';
}
 
set<int> rec(int l, int r) {
  vector<int> v;
  for(int i = l, j = 0; i < r; ++i) {
    if(line[i] == '(') ++j;
    if(line[i] == ')') --j;
    if(j == 0 && isOp(line[i])) v.push_back(i);
  }
 
  if(v.size() == 0) {
    if(line[l] == '(') return rec(l+1, r-1);
    set<int> res;
    res.insert(atoi(line.substr(l,r-l).c_str()));
    return res;
  }
 
  set<int> res;
  for(int i = 0; i < v.size(); ++i) {
    set<int> a, b;
    a = rec(l, v[i]);
    b = rec(v[i]+1, r);
    for(set<int>::iterator p = a.begin();
        p != a.end(); ++p) {
      for(set<int>::iterator q = b.begin();
          q != b.end(); ++q) {
        if(line[v[i]] == '+') {
          res.insert(*p + *q);
        } else if(line[v[i]] == '-') {
          res.insert(*p - *q);
        } else if(line[v[i]] == '*') {
          res.insert(*p * *q);
        } else if(line[v[i]] == '/') {
          if(*q != 0) res.insert(*p / *q);
        }
      }
    }
  }
  return res;
}
 
int main() {
  while(getline(cin, line) && line != "#") {
    cout << rec(0, line.size()).size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1296
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#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 all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

ll h,w,n;
map<P, bool> wb;

vi dx={-1,0,1};
vi dy={-1,0,1};

int main()
{
    cin >> h >> w >> n;
    vp cand;
    rep(i,n){
        int in1,in2;
        cin >> in1 >> in2;
        wb[mp(in1,in2)] = 1;
        rep(k,3){
            rep(l,3){
                int x = in2+dx[k];
                int y = in1+dy[l];
                if(2<=x && x<=w-1 && 2<=y && y<=h-1) cand.pb(mp(y,x));
            }
        }
    }
    sort(all(cand));
    vp cand2;
    if(!cand.empty()) cand2.pb(cand[0]);
    for(int i = 1; i < cand.size(); i++){
        if(cand[i] != cand[i-1]) cand2.pb(cand[i]);
    }
    ll ans[10] = {};
    rep(i, cand2.size()){
        int kuro = 0;
        rep(k,3){
            rep(l,3){
                int x = cand2[i].se + dx[k];
                int y = cand2[i].fi + dy[l];
                if(wb[mp(y,x)] == 1) kuro++;
            }
        }
        ans[kuro]++;
    }
    ll sum = 0;
    rep(i,10) sum+=ans[i];
    ans[0] = (ll)(w-2)*(h-2)-sum;
    rep(i,10) cout << ans[i] << endl;
}


Measured memory_bytes: 172136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class14
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int count = 0;

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

                int a = S.IndexOf(i.ToString());
                if (a != -1)
                    for (int j = 0; j <= 9; j++)
                    {
                        int b = S.IndexOf(j.ToString(), a + 1);
                        if(b!=-1)
                            for(int k = 0; k <= 9; k++)
                            {
                                int c = S.IndexOf(k.ToString(), b + 1);
                                if (c != -1)
                                    count++;
                            }

                    }
                
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13536
#include<stdio.h>

int main(){
  float n,x,t;
  scanf("%f %f %f",&n,&x,&t);
  float times = n/x;
  int temp = (int)times;
  if(times - (float)temp != 0){
    temp++;
  }
  temp = temp*t;
  printf("%d",(int)temp);
}

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

template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}

int a[5] = {5, 12, 17, 24, 31};
void solve(int n){
	vector<string> v;
	readVector(n, v);
	for(int i=0; i<n; ++i){
		int cnt = 0;
		int flag = 0;
		for(int j=i; j<n; ++j){
			cnt += v[j].size();
			for(int k=0; k<5; ++k)
				if(cnt == a[k])
					flag += (1 << k);
		}
		if(flag == 31){
			cout << i+1 << "\n";
			return;
		}
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}


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

int main(){
	int a,b,c;
	
    cin>>a>>b>>c;
    int res=0;
    if(b/a>=c) { res=c;
    }else res=b/a;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll x;
    cin >> x;
    ll y=x/11;
    ll z=x%11;
    y*=2;
    if (z>0 && z<=6) ++y;
    else if (z>6) y+=2;
    cout << y << endl; 
   
    return 0;   
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int sum = a + b + c;
    if (sum <= 21) {
      System.out.println("win");
    } else {
      System.out.println("bust");
    }
  }
}


Measured memory_bytes: 21844
# include <iostream>
# include <string>
# include <set>
using namespace std;

int main() {
  string s; cin >> s;
  set<char> char_set;
  
  for (int i = 0; i < s.size(); ++i) char_set.insert(s[i]);
  
  if (s.size() == char_set.size()) cout << "yes" << endl;
  else cout << "no" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, x;
  cin >> a >> b >> x;

  if(x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

int main(){
  int a, b, c;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    int s=i%10, t=i/10000, u=i/10%10, v=i/1000%10;
    if(s==t&&u==v) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    
    scanf("%d", &n);
    
    printf("%d", n/3);
    
    return 0;
}



Measured memory_bytes: 1728
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int a, b;
        try(Scanner cin = new Scanner(System.in)) {
            a = cin.nextInt();
            b = cin.nextInt();
        }
        if (a <= 8 && b <= 8)
            System.out.println("Yay!");
        else
            System.out.println(":(");
    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
class dice{
    public:
    int d[6];
    void input(){
        rep(i, 6) cin >> d[i];
    }
    void roll(char s){
        if (s == 'N'){
            int sub = d[0];
            d[0] = d[1];
            d[1] = d[5];
            d[5] = d[4];
            d[4] = sub;
        }
        if (s == 'S'){
            int sub = d[0];
            d[0] = d[4];
            d[4] = d[5];
            d[5] = d[1];
            d[1] = sub;
        }
        if (s == 'E'){
            int sub = d[2];
            d[2] = d[0];
            d[0] = d[3];
            d[3] = d[5];
            d[5] = sub;
        }
        if (s == 'W'){
            int sub = d[2];
            d[2] = d[5];
            d[5] = d[3];
            d[3] = d[0];
            d[0] = sub;
        }
      	if (s == 'R'){
          	int sub = d[1];
          	d[1] = d[2];
          	d[2] = d[4];
          	d[4] = d[3];
          	d[3] = sub;
        }
    }
    int print(){
        return d[2];
    }
    void roll_and_return(int top, int front){
      	while (d[0] != top){
          	roll('S');
          	if (d[0] != top){
            	roll('E');
            }
        }
      	rep(i, 4){
            if (d[1] == front) break;
            roll('R');
        }
    }
};
int main(){
    dice d;
    d.input();
    int n;
    cin >> n;
    rep(i, n){
        int a, b;
      	cin >> a >> b;
        d.roll_and_return(a, b);
        cout << d.print() << endl;
    }
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    cout<<(A!=C?1:0)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, sum;
    char ch;
    while(1){
        sum = 0;

        while(1){
        ch = getchar();
        if(ch == '\n')break;

        sum += ch - 48;
        }
        if(sum == 0)break;
        printf("%d\n", sum);
    }
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int m,n;
bool f;
char a[10][10],c[10];
int movex[5]={1,0};
int movey[5]={0,1};
bool pb(){
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			//cout<<a[i][j];
			if(a[i][j]=='#'){
				//cout<<i<<" "<<j;
				return false;
			}
		}
		//cout<<endl;
	}
    return true;
}
void dfs(int x,int y){
	if(x==m&&y==n){
		//cout<<1;
		if(pb()==true){
		    cout<<"Possible";
		    f=true;
			exit(0);	
		}
		else return ;
	}
	for(int i=0;i<=1;i++){
		int xx=x+movex[i];
		int yy=y+movey[i];
		
		if(a[xx][yy]=='#'&&xx<=m&&yy<=n){
			//cout<<xx<<yy<<endl;
			a[xx][yy]='.';
			dfs(xx,yy);
			a[xx][yy]='#';
		}
	}
}
int main()
{
	cin>>m>>n;
	for(int i=1;i<=m;i++){
		scanf("%s",c+1);
		for(int j=1;j<=n;j++){
			a[i][j]=c[j];
		}
	}
	a[1][1]='.';
	dfs(1,1);
	if(f==true)return 0;
	cout<<"Impossible";
	return 0;
 } 

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main () {
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    int s = S.size();
    int t = T.size();

    rep(i, s-t+1) {
        int count = 0;
        rep(j, t) {
            if(S[i+j] != T[j]) {
                count++;
            }
        }

        ans = min(count, ans);
    }
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  vector<int> m(n);
  m.at(0) = p.at(0);
  for (int i = 1; i < n; i++) {
    if (m.at(i-1) > p.at(i))
      m.at(i) = p.at(i);
    else
      m.at(i) = m.at(i-1);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (p.at(i) == m.at(i))
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string.h>
using namespace std;
char a[5];
int main(){
	cin>>a;
	int len=strlen(a);
	bool ff=false,f=false;
	for(int i=0;i<len;i++){
		if(a[i]=='A'){
			f=true;
		}
		if(a[i]=='B'){
			ff=true;
		}
	}
	if(ff && f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
#define memset(x) memset(x, 0, sizeof(x))
using namespace std;
int n, a[N], f[N][35], l, q;
int main()
{
	//freopen("trav.in", "r", stdin);
	//freopen("trav.out", "w", stdout);
	sc(n);
	for (int i = 1; i <= n; i++)
	sc(a[i]);
	sc(l);
	for (int i = 1; i <= n; i++)
	{
		int id = (int)(upper_bound(a + 1, a + n + 1, a[i] + l) - a - 1);
		f[i][0] = id;
	}
	for (int j = 1; j <= 30; ++j)
	for (int i = 1; i <= n; ++i)
	f[i][j] = f[f[i][j - 1]][j - 1];
	sc(q);
	while (q--)
	{
		int x, y;
		sc(x);
		sc(y);
		if (x > y) swap(x, y);
		int sum = 1;
		for (int i = 30; i >= 0; i--)
		if (f[x][i] < y)
		{
			sum += 1 << i;
			x = f[x][i];
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;cin >> n;
  vector<ll> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }
  ll sum = accumulate(hoge.begin(), hoge.end(), 0LL);
  ll x = 0;
  ll m = 100000000000;
  rep_i(i, n - 1){
    x += hoge[i];
    if(abs(sum - x*2) < m){
      m = abs(sum - x*2);
    }
  }
  say(m);
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  ll ans=inf;
  for(int i=1;i<=100;i++){
    ll sum=0;
    rep(j,n){
      sum+=(i-x[j])*(i-x[j]);
    }
    chmin(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
    if i - a[i] in d:
        count+=d[i - a[i]]
    if i + a[i] in d:
        d[i+a[i]] += 1
    else:
        d[i+a[i]] = 1

print(count)

Measured memory_bytes: 40464
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(s: chars);
    match s[1] {
        'B' => println!("ARC",),
        'R' => println!("ABC",),
        _ => (),
    }
}


Measured memory_bytes: 2112