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

int point[100000];

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

  for (int i = 1; i <= n; i++) {
    point[i] = k - q;
  }

  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;
    point[a]++;
  }

  for (int i = 1; i <= n; i++) {
    if (point[i] > 0)
      cout << "Yes" << endl;
	else
		cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define ipair pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1000001],dp[1000001];

int frog(int pos)
{
  if(dp[pos]!=-1)
  {
    return dp[pos];
  }
  return dp[pos]=min(frog(pos-1)+abs(arr[pos]-arr[pos-1]),frog(pos-2)+abs(arr[pos]-arr[pos-2]));

}

int32_t main()
{
  fast;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  memset(dp,-1,sizeof(dp));
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  frog(n-1);
  // for(int i=0;i<n;i++)
  // {
  //   cout<<dp[i]<<" ";
  // }
  cout<<dp[n-1];
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(a) cout << (a) << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,ans = 0,cnt = 0;
    cin >> n;
    vector<bool> c(n,0);
    vector<vector<pair<ll, bool>> > x(n,vector<pair<ll, bool>>(0));
    rep0(i, n){
        ll a;
        cin >> a;
        rep0(j, a){
            ll X,Y;
            cin >> X >> Y;
            x[i].push_back(make_pair(X - 1, Y));
        }
    }
    
    rep0(i, 1 << n){
        bool f = true;
        cnt = 0;
        rep0(j, n)c[j] = 0;
        rep0(j, n){
            if(i >> j & 1){
                c[j] = true;
                ++cnt;
            }else c[j] = false;
        }
        rep0(j, n){
            if(!c[j])continue;
            rep0(k, x[j].size()){
                if(c[x[j][k].first] != x[j][k].second){
                    f = false;
                    break;
                }
            }
        }
        if(f)ans = max(ans, cnt);
    }
    pf(ans)
    return 0;
}


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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

int n;
vi v(3005, 0);
ll tb[3005][3005][2];
int calc[3005][3005][2];

ll dp(int i, int j, bool player) {
	if(i == j) return player == 1 ? -v[i] : v[i];
	if(calc[i][j][player]) return tb[i][j][player];

	ll ans = 0;
	if(player == 0) ans = max(dp(i+1, j, 1) + v[i], dp(i, j-1, 1) + v[j]);
	else ans = min(dp(i+1, j, 0) - v[i], dp(i, j-1, 0) - v[j]);

	tb[i][j][player] = ans;
	calc[i][j][player] = 1;
	return ans;
}

int main()
{
    cin >> n;

	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &v[i]);
	}
	memset(tb, -1, sizeof tb);
	printf("%lld\n", dp(0, n-1, 0));

	return 0;

}

Measured memory_bytes: 212096
def reppref(s, n)
	(s.chars * ((s.size + n - 1) / s.size))
end

s = gets.chomp
t = gets.chomp

ptn = reppref(t, s.size + t.size)
mp = [-1]
j = -1
ptn.size.times{|i|
	j = mp[j] while j >= 0 && ptn[i] != ptn[j]
	j += 1
	mp.push(j)
}

j = 0
mx = 0
reppref(s, s.size * 2 + t.size).each{|x|
	j = mp[j] while j == ptn.size || (j >= 0 && ptn[j] != x)
	j += 1
	mx = j if mx < j
}
puts (mx >= s.size + t.size ? -1 : mx / t.size)


Measured memory_bytes: 91808
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy";
    else if(s == "Cloudy") cout << "Rainy";
    else cout << "Sunny";
}   

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans, cnt[26];
struct Edge { LL to, cost; };
string str;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> str;
	ans += str.size()*(str.size() - 1) / 2;
	rep(i, str.size())
		cnt[str[i] - 'a']++;
	rep(i, 26)ans -= cnt[i] * (cnt[i] - 1) / 2;
	cout << ans+1 << endl;
	return 0;
}


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

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

#[allow(dead_code)]
struct Eratosthnes {
    n: usize,  // incluesive
    bprime: Vec<bool>,  // self.bprime[5] = true
    primes: Vec<usize>, // self.primes[2] = 5
}
#[allow(dead_code)]
impl Eratosthnes {
    fn new(n: usize) -> Eratosthnes {
        let mut bprime = vec![true; n + 1];
        let mut primes = vec![];
        bprime[0] = false;
        bprime[1] = false;
        for i in 2..n+1 {
            if !bprime[i] { continue; }
            primes.push(i);
            if i * i > n { continue; }
            let mut j = i * i;
            while j <= n {
                bprime[j] = false;
                j += i;
            }
        }
        Eratosthnes {
            n: n,
            bprime: bprime,
            primes: primes,
        }
    }
}

fn main() {
    let n = 1e+5 as usize + 10;
    let era = Eratosthnes::new(n as usize);
    let mut sums = vec![0; n];
    for i in 1..n {
        if era.bprime[i] && era.bprime[(i + 1) / 2] { sums[i] += 1; }
        sums[i] += sums[i - 1];
    }
    let q: usize = read();
    for _ in 0..q {
        let l: usize = read();
        let r: usize = read();
        println!("{}", sums[r] - sums[l - 1]);
    }
}

Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

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

ll nlcm(vector<ll> numbers) {
    int res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> A(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> A[i];
    }
    ll All = nlcm(A);
    ll res = 0;
    for(size_t i=0;i<N; i++)
    {
        res += All/A[i];
    }
    cout << fixed << setprecision(10) << 1.0 * All/res << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000009
using namespace std;

void funk_min(string s, int n){
    vector<int> v(n, 0);
    int m = n - 1;
    int j = n;
    int i = 0;
    while(i < m){
        int k = i;
        while(i < m && s[i] == '>'){
            i++;
        }
        int l = i;
        while(i < m && s[i] == '<'){
            i++;
        }
        for(int p = i; p > l; p--){
            v[p] = j--;
        }
        for(int p = k; p <= l; p++){
            v[p] = j--;
        }
        i++;
    }
    for(auto it : v){
        if(it == 0){
            cout << j-- << " ";
        }else{
            cout << it << " ";
        }
    }
    cout << endl;
}

void funk_max(string s, int n){
    int m = n - 1;
    vector<int> v(n, 0);
    int i = n - 1;
    int cnt = count(s.begin(), s.end(), '<');
    int j = n;
    while(i > 0){
        if(s[i - 1] == '<'){
            v[i] = j--;
        }
        i--;
    }
    for(int i = 0; i < n; i++){
        if(v[i] == 0){
            v[i] = j--;
        }
    }
    for(auto it : v){
        cout << it << " ";
    }
    cout << endl;
}

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

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if((a[0] == a[1] && a[1] != a[2]) || (a[0] != a[1] && a[1] == a[2])){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int count=1;
		int x;
		while(true){
			x = scan.nextInt();
			if(x == 0){break;}

			System.out.println("Case " + count + ": " + x);
			count++;
		}
		scan.close();

	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<vector<int>> cnt(10, vector<int>(10, 0));
  
  for (int i = 1; i <= N; i++) {
    string x = to_string(i);
    int a = x[0] - '0'; // 先頭
    int b = i % 10; // 末尾
    
    if (a == 0 || b == 0) continue;
    cnt.at(a).at(b)++;
  }
  
  int ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += cnt.at(i).at(j) * cnt.at(j).at(i);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(){
char ch;
while(1){
scanf("%c",&ch);
if(ch=='\n') break; else if('A'<=ch && 'Z'>=ch) printf("%c",tolower(ch)); else if('a'<=ch && 'z'>=ch) printf("%c",toupper(ch));else printf("%c",ch);
}
printf("\n");
return 0;
}

Measured memory_bytes: 524
k, n = map(int, input().split())
a = list(map(int, input().split()))

bef = a[0]
max_diff = 0
for i in range(1,n):
    diff = abs(bef - a[i])
    max_diff = max(diff, max_diff)
    bef = a[i]

print(k - max(max_diff, k - abs(a[n-1] - a[0])))

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug cout<<"Reached\n";

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li k;

    cin>>k;

    string s;

    cin>>s;

    li n=s.length();

    if(n<=k)
    {
        cout<<s;
    } 
    else
    {
        cout<<s.substr(0,k);
        cout<<"...";
    }

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>

int main()
{
    int W = 0;
    int H = 0;
    int x = 0;
    int y = 0;
    int r = 0;

    // input
    std::cin >> W;
    std::cin >> H;
    std::cin >> x;
    std::cin >> y;
    std::cin >> r;

    // judge
    if (W <= 0 || W > 100 || H <= 0 || H > 100 || r <= 0 || r > 100 || x < -100 || x > 100 || y < -100 || y > 100)
    {
        std::cout << "Error : out of range!" << std::endl;
        return -1;
    }

    // judge
    if (W <= 0 || W > 100 || H <= 0 || H > 100 || r <= 0 || r > 100 || x < -100 || x > 100 || y < -100 || y > 100)
    {
        std::cout << "Error : out of range!" << std::endl;
        return -1;
    }

    // output
    if (x - r < 0 || x + r > W || y - r < 0 || y + r > H)
    {
        std::cout << "No" << std::endl;
    }
    else
    {
        std::cout << "Yes" << std::endl;
    }
        return 0;
}


Measured memory_bytes: 3100
a = int(input())
b = list(map(int, input().split()))
c = {}
for i in b:
    if i not in c:
        c[i] = 1
    else:
        c[i] += 1
c = sorted(c.items(), key=lambda x: x[0], reverse=True)
d = 0
for k, v in c:
    if v // 2 == 1:
        if d != 0:
            print(d * k)
            exit()
        else:
            d = k
    elif v // 2 >= 2:
        if d != 0:
            print(d * k)
            exit()
        else:
            print(k ** 2)
            exit()
print(0)


Measured memory_bytes: 21896
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
class UnionFind{
private:
	vector<int> Parent;
public:
	UnionFind(int N){rep(i,N) Parent.push_back(-1);}
	int root(int A){
		if(Parent[A]<0) return A;
		else return root(Parent[A]);
	}
	int size(int A){return -Parent[root(A)];}
	bool connect(int A,int B);
};

signed main(){
    string s;
    cin>>s;
    int ans;
    ans =s.size()%2;
    if(s[0]!=s.back()) ans=1-ans;
    if(ans==0) cout<<"First"<<endl;
    if(ans==1) cout<<"Second"<<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S;
    cin >> S;
    bool flg = false;
    for (int i = 0; i <= 7; i++) {
        string f = S.substr(0,i);
        string e = S.substr(S.length()-(7-i),(7-i));
        string k = f + e;
        if(k == "keyence"){
            flg = true;
        }
    }
    YES(flg);
}

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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  int x[N+10];
  for(int i=0; i<N; i++){
    cin >> x[i];
    if(abs(x[i]-K) < x[i]){
      sum+=abs(x[i]-K);
    }else{
      sum+=x[i];
    }
  }
  cout << sum*2 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
const ll mod=1e9+7;


int main(void){
    string S;
    bool truth=false;
    cin>>S;
    if(S.at(0)==S.at(1) && S.at(2)==S.at(3) && S.at(0)!=S.at(2)) truth=true;
    if(S.at(0)==S.at(2) && S.at(1)==S.at(3) && S.at(0)!=S.at(1)) truth=true;
    if(S.at(0)==S.at(3) && S.at(2)==S.at(1) && S.at(0)!=S.at(2)) truth=true;
    if(truth) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	ll a,b,c,d,N;
	cin>>a>>b>>c>>d>>N;
	chmin(b,a*2);
	chmin(c,b*2);
	chmin(d,c*2);
	cout<<(N/2)*d + (N%2)*c<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var mod = 1000000007

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)

	ans := "No"
LOOP:
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if i*j == n {
				ans = "Yes"
				break LOOP
			}
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int dp[100000][3];
int main(){
	int n;
	scanf("%d",&n);
	for(int i = 0; i < n; i++)
		scanf("%d %d %d",&dp[i][0],&dp[i][1],&dp[i][2]);
	for(int i = 1; i < n; i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + dp[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + dp[i][1];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + dp[i][2];	
	}
	printf("%d\n", max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2])));
	return 0;
}

Measured memory_bytes: 4952
/*
- Featured Article -
Reimu Hakurei is one of the main characters of the Touhou Project
series, having appeared in almost every game in the series.
As the sole maiden of the Hakurei Shrine, she is commonly called
upon (or calls it upon herself) to investigate strange occurrences
throughout Gensokyo. In earlier games, Reimu's spiritual abilities
were highly limited. (In Highly Responsive to Prayers, she was
unable to directly harm enemies at all.) As time passed, however,
she developed her abilities, becoming able to manipulate the
Hakurei Yin-Yang Orb, special amulets, and her own spiritual power
to fight more effectively. Sometime between Mystic Square and
Embodiment of Scarlet Devil, she realized...
*/
#include <bits/stdc++.h>
using namespace std;
#define N 1000000

int main(){
    bool cmp[N]={true};
    int npr[N];
    for(int i=2;i<N;i++){
        if(!cmp[i]){
            for(int j=2;i*j<N;j++)cmp[i*j]=true;
        }
        npr[i]=npr[i-1]+!cmp[i];
    }
    int data[30],i;
    for(i=0;cin>>data[i];i++);
    for(int j=0;j<i;j++){
        cout<<npr[data[j]]<<endl;
    }
}

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

#define int long long

using namespace std;

const int mod = 1e9 + 7;
const int TREE_SZ = 524288;

vector<int> mx(TREE_SZ, -2e18);

int get_max(int v, int l, int r, int L, int R) {
    if (R <= l || r <= L) {
        return -2e18;
    }
    if (L <= l && r <= R) {
        return mx[v];
    }
    int m = (l + r) / 2;
    return max(
                get_max(2 * v + 1, l, m, L, R),
                get_max(2 * v + 2, m, r, L, R)
              );
}

void set_elem(int v, int l, int r, int i, int x) {
    mx[v] = max(mx[v], x);
    if (l == r - 1) {
        return;
    }
    int m = (l + r) / 2;
    if (i < m) {
        set_elem(2 * v + 1, l, m, i, x);
    } else {
        set_elem(2 * v + 2, m, r, i, x);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), p(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    vector<int> b = a;
    sort(b.begin(), b.end());
    map<int, int> M;
    for (int i = 0; i < b.size(); i++) {
        M[b[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        a[i] = M[a[i]];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int cur = max(0ll, get_max(0, 0, n, 0, a[i])) + p[i];
        ans = max(ans, cur);
        set_elem(0, 0, n, a[i], cur);
    }
    cout << ans << endl;
}


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

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
         int a,b;
         cin>>a>>b;
         if(a>=13) cout<<b;
         else if(a<6) cout<<0;
         else cout<<b/2;
     }
    signed main()
    {   
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

#define INPUT freopen("input.txt", "r", stdin);

#define ll long long
#define ld long double

#define len(s) s.size()

#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)
#define fll fl(0, n, 1)
#define ifl(st, en, in) for (int j = st; j < en; j += in)

#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl;
#define ci(s) cin >> s
#define co(s) cout << s << endl

#define vl vector<ll>
#define pb(x) push_back(x)

#define ms(arr, x) memset(arr, x, sizeof(arr))

#define inf INT_MAX

#define mod (ll)1000000007

void solve()
{
    ll n;
    ci(n);
    ll ar[n];
    fll
    {
        ci(ar[i]);
    }
    ll pre[n];
    ms(pre, 0);
    fll
    {
        if (i == 0)
            pre[i] = ar[i];
        else
        {
            pre[i] = pre[i - 1] + ar[i];
        }
        //pre[i] %= mod;
    }
    ll ans = 0;
    fll
    {
        ans += ((ar[i] % mod) * ((pre[n - 1] - pre[i]) % mod));
        ans = ans % mod;
    }
    co(ans);
}

int main()
{
    //INPUT;
    // int t;
    // ci(t);
    // while (t--)
    solve();
}

Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)=='B'&&s.at(1)=='B'&&s.at(2)=='B'){
    cout<<"No"<<endl;
    return 0;
  }
  else if(s.at(0)=='A'&&s.at(1)=='A'&&s.at(2)=='A'){
    cout<<"No"<<endl;
    return 0;
  }
  else{
    cout<<"Yes"<<endl;
    return 0;
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;
const int H_MAX = 510;
const int W_MAX = 510;
int H,W;
vector<vector<int>> a(H_MAX,vector<int>(W_MAX,0));

int main(){
    string S,T;
    cin >> S >> T;
    vector<int> cnt_s(26),cnt_t(26);
    rep(i,S.size()){
        cnt_s[S[i]-'a']++;
        cnt_t[T[i]-'a']++;
    }
    sort(cnt_s.begin(),cnt_s.end());
    sort(cnt_t.begin(),cnt_t.end());
    rep(i,26){
        if(cnt_s[i]!=cnt_t[i]){
            cout << "No" << endl;  
            return 0;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 1800
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 55 
pair<string,int> a[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	int ans=0;
	for(int i=1;i<=n;i++) cin>>a[i].fir>>a[i].sec;
	for(int i=1;i<=n;i++) ans+=a[i].sec;
	string op;
	cin>>op;
	for(int i=1;i<=n;i++)
	{
		ans-=a[i].sec;
		if(a[i].fir==op) break;
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	string s;
	cin>>n>>s;

	map<lli,lli> d;

	REP(i,0,n){
		d[s.at(i)-'a']++;
	}

	lli sum=1;
	REP(i,0,26){
		if(d[i]==0)continue;
		sum *= (d[i]+1);
		sum %= MOD;
	}

	cout<<(sum+MOD-1)%MOD<<endl;


	return 0;
}

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

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

  int a[N];
  for (int i = 0; i < N; i++) {
	cin >> a[i];
  }
  
  int maxDistance = 0;
  for (int i = 1; i < N; i++) {
    if (a[i] - a[i-1] > maxDistance) {
      maxDistance = a[i] - a[i-1];
    }
  }
  if (K - a[N-1] + a[0] > maxDistance) {
    maxDistance = K - a[N-1] + a[0];
  }
  
  cout << K - maxDistance;
      
  
  
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n;
    string s,t;
    cin>>n>>s>>t;
    rep(i,n) cout<<s[i]<<t[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
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()
{
    ll N;
    cin>>N;
    vll A(N);
    ll ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
    }
    sort(all(A),greater<ll>());
    multiset<ll> player;
    for (size_t i = 0; i < N; i++)
    {
        if(!player.empty())
        {
            ans += *(----player.end());
            player.erase(--player.end());
//            player.erase(player.begin()++);
        }
        player.insert(A[i]);
        player.insert(A[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 14324
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,M,count=0;
  scanf("%d %d",&N,&M);
  int num[M],sa[M-1];
  for(int i=0;i<M;i++) scanf("%d ",&num[i]);
  qsort(num,M,sizeof(int),compare_up_int);
  if(M>N){
    for(int i=0;i<M-1;i++) sa[i] = num[i+1] - num[i];
    qsort(sa,M-1,sizeof(int),compare_down_int);
    for(int i=0;i<N-1;i++) count += sa[i];
    printf("%d",num[M-1]-num[0]-count);
  }
  else printf("%d",0);
  //printf("%d %d %d\n",num[M-1],num[0],count);
  return 0;
}


Measured memory_bytes: 1268
def f(a):
    for x in ['o','x']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'd'

while 1:
    try:a=list(input())
    except:break
    print(f(a))

Measured memory_bytes: 7420
n = int(input())
a = list(map(int, input().split())) + [0]
b = [abs(a[0])]
c = [abs(a[1])]

for i in range(n):
    b.append(abs(a[i] - a[i + 1]))
    if i < n - 1:
        c.append(abs(a[i] - a[i + 2]))

sum_b = sum(b)
for i in range(n):
    print(sum_b + c[i] - b[i] - b[i + 1])

Measured memory_bytes: 17152
points = []
while true
  line = STDIN.gets.chomp
  if line == "0 0" then break end
  point = Array.new(2) { |i|  i = line.split(" ")[i].to_i}
  points << point
end

# print points

points.each do |point|
  output = 0
  for i in 1..point[0] - 1 do
    for j in i+1..point[1] do
      # print "i = #{i}, j = #{j}\n"
      num = point[1] - i - j;
      if num > 0 && num <= point[0] && num > j then
        # puts "success! i = #{i}, j = #{j}, num = #{num}"
        output += 1
      end
    end
  end
  puts output
end

Measured memory_bytes: 6104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int takahashi = (C+B-1) / B;
    int aoki = (A+D-1) / D;

    if(takahashi <= aoki) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

int main() {
int A, P,ans;
cin >> A >> P;
ans =(P+3*A)/2;
    



cout << ans << endl;

}






Measured memory_bytes: 256
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
b =[]
ans = []
for i in range(m):
    t = tuple(map(int,input().split()))
    b.append(t)
b = sorted(b,key = lambda x:x[1],reverse=True)
for i in b:
    for j in range(i[0]):
        if a:
            x =a.pop()
            if x > i[1]:
                print(sum(a) + x + sum(ans))
                exit()
            else:
                ans.append(i[1])
        else:
            print(sum(ans))
            exit()
print(sum(ans)+sum(a))


Measured memory_bytes: 85612
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define ll long long int
using namespace std;
int find(vector<int>a,vector<bool>f,vector<int>&path)
{
    f[1]=true; path.push_back(1); int next=a[1];
    while(true)
    {
       if(f[next])
        { path.push_back(next); return next;}
       else
       {
        f[next]=true;
        path.push_back(next);
        next=a[next];
       }
    }
}
void print(vector<int>v)
{   int l=v.size();
    rep(i,0,l-1)
    cout<<v[i]<<" ";
    cout<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n; ll k; cin>>n>>k;
    vector<int>a(n+1); a[0]=-1;
    rep(i,1,n) cin>>a[i];
    vector<bool>f(n+1);
    rep(i,0,n) f[i]=false;
    vector<int>path;
    int p=find(a,f,path);
    int i1,i2;
    rep(i,0,path.size()-1)
    {
        if(path[i]==p)
            { i1=i; break;}
    }
    rep(i,i1+1,path.size()-1)
    {
        if(path[i]==p)
            { i2=i; break;}
    }
    int l=i2-i1; 
    if(a[1]==1)
        cout<<1<<"\n";
    else if(k<=i1)
    {
      cout<<path[k]<<"\n";
    }
    else
    {
        k-=i1;
        int f=k%l;
        cout<<path[i1+f]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5896
a=input()
k=len(a)
an=int(a[len(a)-1])
if an==2 or an==4 or an==5 or an==7 or an==9:
	print("hon")
elif an==0 or an==1 or an==6 or an==8:
	print("pon")
else:
	print("bon")

Measured memory_bytes: 9204
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    F = [list(map(int, input().split())) for _ in range(N)]
    P = [list(map(int, input().split())) for _ in range(N)]

    result = -10**10
    for i in range(1, 1 << 10):
        count = [0 for _ in range(N)]
        for j in range(10):
            for k in range(N):
                if (i >> j) & 1 == 1 and F[k][10 - j - 1] == 1:
                    count[k] += 1
        total = 0
        for k in range(N):
            total += P[k][count[k]]
        result = max(result, total)
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define sl(mark) scanf("%lld",&mark)
#define debug(mark) printf("check%d\n",mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
ll ans=0;
void go(ll a,ll b)
{
	ans+=(2*b*(a/b));
	if(a%b==0)
	{
		ans-=b;
		return;
	}
	go(b,a%b);
}
int main()
{
	ll n,x;
	sl(n);sl(x);
	ans+=n;
	go(x,n-x);
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
H = IL()

tmp = H[0]
cnt = 1
for i in range(1,N):
    if tmp <= H[i]:
        cnt += 1
        tmp = H[i]
print(cnt)

Measured memory_bytes: 21728
#include <bits/stdc++.h> // Replace needed headers for speed up

// -------------8<------- start of library -------8<------------------------
template<typename T>
struct RangeMinimumQuery {
    const T INF;
    int n;
    std::vector<T> val;

    RangeMinimumQuery(int size, T inf = std::numeric_limits<T>::max()) : INF(inf) {
        for (n = 1; n < size; ) n <<= 1;
        val.assign(2 * n + 1, INF);
    }

    // 最小値を返す
    inline T op(T v1, T v2) const { return v1 <= v2 ? v1 : v2; }

    void update(int idx, T v) {
        idx += n - 1;
        val[idx] = v;
        while (0 < idx) {
            idx = (idx - 1) >> 1;
            val[idx] = op(val[2 * idx + 1], val[2 * idx + 2]);
        }
    }
    T find(int l, int r) {
        T res = INF;
        l += n - 1; r += n - 1;
        while (l < r) {
            if (!(l & 1)) res = op(res, val[l]);
            if (!(r & 1)) res = op(res, val[r - 1]);
            l >>= 1;
            r = (r - 1) >> 1;
        }
        return res;
    }
};

// -------------8<------- end of library ---------8-------------------------
int main() {
    int n, q;
    std::cin >> n >> q;

    RangeMinimumQuery<int> rmq(n);
    for (int i = 0, com, x, y; i < q; ++i) {
        std::cin >> com >> x >> y;
        if (com == 0) rmq.update(x, y);
        else std::cout << rmq.find(x, y + 1) << '\n';
    }

    return 0;
}



Measured memory_bytes: 3800
S = readline.chomp

count_0 = 0
S.each_char.with_index do |c,idx|
  if idx % 2 == 0
    count_0 += 1 if c != '0'
  else
    count_0 += 1 if c != '1'
  end
end

count_1 = 0
S.each_char.with_index do |c,idx|
  if idx % 2 == 0
    count_1 += 1 if c != '1'
  else
    count_1 += 1 if c != '0'
  end
end

puts [count_0,count_1].min


Measured memory_bytes: 1916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long N;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  long long cur = 1;
  string o = "";
  for (int i=0; i<=40; i++) {
    if (N%(cur*2)!=0) {
      N -= cur;
      o += '1';
    }
    else {
      o += '0';
    }
    cur *= -2;
  }
  while (o.size() > 1 && o.back() == '0') o.pop_back();
  reverse(all(o));
  cout << o << "\n";
  return 0;
}


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

int main()
{
	int N;
	while (cin >> N, N) {
		vector<int> xs, ys;
		vector<int> x(N), y(N);
		vector<int> a(4), b(4);
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i];
			xs.push_back(x[i]);
			xs.push_back(x[i] - 1);
			xs.push_back(x[i] + 1);
			ys.push_back(y[i]);
			ys.push_back(y[i] - 1);
			ys.push_back(y[i] + 1);
		}
		int xma = -20000, xmi = 20000, yma = -20000, ymi = 20000;
		for (int i = 0; i < 4; i++) {
			cin >> a[i] >> b[i];
			xs.push_back(a[i]);
			xs.push_back(a[i] - 1);
			xs.push_back(a[i] + 1);
			ys.push_back(b[i]);
			ys.push_back(b[i] - 1);
			ys.push_back(b[i] + 1);
			xma = max(xma, a[i]);
			xmi = min(xmi, a[i]);
			yma = max(yma, b[i]);
			ymi = min(ymi, b[i]);
		}
		sort(xs.begin(), xs.end());
		xs.erase(unique(xs.begin(), xs.end()), xs.end());
		sort(ys.begin(), ys.end());
		ys.erase(unique(ys.begin(), ys.end()), ys.end());

		int nx = xs.size(), ny = ys.size();
		vector<vector<int>> sta(nx, vector<int>(ny));
		for (int i = 0; i < N; i++) {
			int y1 = y[(i + 1) % N], y2 = y[i];
			if (y1 != y2) {
				if (y1 > y2) swap(y1, y2);
				int sy = lower_bound(ys.begin(), ys.end(), y1) - ys.begin();
				int ey = lower_bound(ys.begin(), ys.end(), y2) - ys.begin();
				int X = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
				for (int j = sy; j < ey; j++) {
					sta[X][j]++;
				}
			}
		}
		ll res = 0;
		for (int i = 0; i < ny; i++) {
			for (int j = 1; j < nx; j++) {
				sta[j][i] = (sta[j][i] + sta[j - 1][i]) & 1;
				if (i + 1 < ny && j + 1 < nx && sta[j][i]) {
					res += (ll)(xs[j + 1] - xs[j]) * (ys[i + 1] - ys[i]);
				}
			}
		}
		int cxs = lower_bound(xs.begin(), xs.end(), xmi) - xs.begin();
		int cxt = lower_bound(xs.begin(), xs.end(), xma) - xs.begin();
		int cys = lower_bound(ys.begin(), ys.end(), ymi) - ys.begin();
		int cyt = lower_bound(ys.begin(), ys.end(), yma) - ys.begin();
		for (int i = cxs; i < cxt; i++) {
			for (int j = cys; j < cyt; j++) {
				if (sta[i][j]) {
					res -= (ll)(xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
string a,b;
bool flag;
char word[220]={};
int main()
{
	cin>>a;
	cin>>b;
	int now=a.length();
	for(int i=0;i<a.length();i++)
		word[i]=word[i+a.length()]=a[i];
	for(int i=0;i<a.length();i++)
	{
		flag=1;
		for(int j=i;j<i+a.length();j++)
		{
			if(b[j-i]!=word[j])
			{
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().split())

bt = (1 + (b - a)) / 2 * (b - a)

print(int(bt - b))


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, c; cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	else if (a == c)cout << b << endl;
	else cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

struct Point {
  int dist;
  int x, y;
};

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
const int INF = 1 << 30;

int main() {
  int a, b;
  cin >> a >> b;
  cout << ((a > 8 || b > 8) ? ":(" : "Yay!") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    if(s.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, s.size()-1) {
        if(s[i] != 'h' || s[i+1] != 'i') {
            cout << "No" << endl;
        return 0;
        }
        i++;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<utility>
using namespace std;
#define INF 1000000000
struct Edge{
	int to;
	int weight;
};
void dijkstra(vector<vector<Edge>> &G,vector<int> &distance,int start)
{
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	pq.push({0,start});
	while(!pq.empty())
	{
		pair<int,int> p = pq.top();
		pq.pop();
		if(p.first > distance[p.second])
		{continue;}
		distance[p.second] = p.first;
		for(auto e : G[p.second])
		{
			if(distance[e.to] <= distance[p.second] + e.weight)
			{continue;}
			pq.push({distance[p.second] + e.weight,e.to});
		}
	}
}
int main()
{
	int Vnum,Enum,start;
	cin >> Vnum >> Enum >> start;
	int i;
	vector<vector<Edge>> G;
	G.resize(Vnum);
	for(i = 0;i < Enum;i++)
	{
		Edge tmpedge;
		int tmps;
		cin >> tmps >> tmpedge.to >> tmpedge.weight;
		G[tmps].push_back(tmpedge);
	}
	vector<int> distance;
	distance.assign(Vnum,INF);
	dijkstra(G,distance,start);
	for(i = 0;i < Vnum;i++)
	{
		if(distance[i] != INF)
		cout << distance[i] << endl;
		else
		cout << "INF" << endl;
	}
	return 0;
}
		
		
		
	
	


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

namespace AtCoderRegular
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            Console.WriteLine(Math.Abs(long.Parse(input[0])-long.Parse(input[1])) > 1 ? "Alice" : "Brown");
        }
                
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <vector> 
#include <algorithm>
#include <numeric>


int main()
{
  std::size_t n = 0;
  std::cin >> n;

  auto top = std::vector<std::size_t>(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> top[i];
  std::sort(top.begin(), top.end());

  auto mid = std::vector<std::size_t>(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> mid[i];
  std::sort(mid.begin(), mid.end());

  auto bot = std::vector<std::size_t>(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> bot[i];
  std::sort(bot.begin(), bot.end());

  auto count = std::size_t(0);

  for (auto it_m = mid.begin(); it_m != mid.end(); ++it_m)
  {
    auto t_lower = std::lower_bound(top.begin(), top.end(), *it_m);
    auto top_num = std::size_t(0);
    if (*t_lower >= *it_m && t_lower != top.end())
    {
      t_lower--;
      top_num = t_lower - top.begin() + 1;
    }
    else if ( *t_lower >= *it_m && t_lower == top.begin())
      top_num = 0;
    else
      top_num = t_lower - top.begin();

    auto b_upper = std::upper_bound(bot.begin(), bot.end(), *it_m);
    auto bot_num = std::size_t(0);
    if ((*b_upper == *it_m) && b_upper != bot.end())
    {
      b_upper++;
      bot_num = bot.end() - b_upper;
    }
    else if ( *b_upper <= *it_m && b_upper == bot.end() )
      bot_num = 0;
    else
      bot_num = bot.end() - b_upper;

    count += top_num * bot_num;
  }

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 2560
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21

ll min(ll a, ll b) { return b < a ? b : a; }
ll max(ll a, ll b) { return b < a ? a : b; }

int main() {
  ll N;
  cin >> N;

  ll A[N + 1];
  ll B[N];
  for (ll i = 0; i < N + 1; i++) {
    cin >> A[i];
  }
  for (ll i = 0; i < N; i++) {
    cin >> B[i];
  }

  ll cnt = 0;
  // i番目の勇者が、i+1番目のモンスターを
  //　狩り尽くしたらi番目を狩るというループ
  for (ll i = 0; i < N; i++) {
    // i+1番目の街とi番目の街から削ったモンスターの数
    cnt += min((A[i + 1] + A[i]), B[i]);
    /*  i+1番目の街の後ででi番目の勇者が生きてたら
        i番目の街のモンスターを
        (B[i]-A[i])削る、死ぬならそのまま  */
    A[i + 1] -= max(0, B[i] - A[i]);
    if (A[i + 1] < 0) A[i + 1] = 0;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1792