akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void DynamicProgramming(int x,vector<vector<int> > & dp)
{


  for (int i = 0; i < 10; i++)
  {
    for (int j = 0; j < 10; j++)
    {
      int t = i*100 + j*10 + x;
      int tt = i*10 + j;
      dp[2][t] |= dp[1][tt];
    }
  }

  for (int i = 0; i < 10; i++)
  {
    int t =i*10 + x;
    dp[1][t] |= dp[0][i];
  }

  dp[0][x] = 1;
  
  return ;
}

void solve(void)
{
  int n;cin>>n;
  vector<int> vec (n,0);
  for (int i = 0; i < n; i++)
  {
    char x;cin>>x;
    vec[i] = x - '0';
  }
  vector<vector<int> > dp (3,vector<int>(1000,0));
  for (int i = 0; i < n; i++)
  {
    int x = vec[i];
    DynamicProgramming(x,dp);
  }
  int res = 0;
  for (int i = 0; i < 1000; i++)
  {
    res += dp[2][i];
  }
  // DEBUG(dp);
  cout<<res<<endl;
  
  


  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main() { 
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && b == c) || (a != b && b!= c && a != c)) {
        cout << "No" << '\n';
    } else {
        cout << "Yes" << '\n';
    }

    return 0;
}


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

using namespace std;
#define f first
#define s second
//#define int long long
#define st string
#define int long long
#define dear_crush int32_t main()
#define bari_ja return 0
#define forn(i, n) for (int i = 0; i < n; i++)
#define INF 1e9+5

dear_crush
{

string str;

cin >> str;

	bool flag = true;
	int c=0;

for(int i=0; i<str.size(); i++){

	if (str[i]=='A') {
		c++;
	}
}

if (c!=0 && c<3) {

	std::cout << "Yes" << '\n';
}

else
std::cout << "No" << '\n';





bari_ja;
}


Measured memory_bytes: 256
#include<stdio.h>
#define NUM 10

int main(void)
{
	int top1=0, top2=0, top3=0;
	int i, input;
	
	for(i=0; i<NUM; i++){
		scanf("%d",&input);
		if(top1<input){
			top3 = top2;
			top2 = top1;
			top1 = input;
		}
		else if(top2 < input){
			top3 = top2;
			top2 = input;
		}
		else if(top3 < input){
			top3 = input;
		}
	}
	printf("%d\n",top1);
	printf("%d\n",top2);
	printf("%d\n",top3);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i++)
  {
    string si = to_string(i);
    if (si.size() % 2 != 0) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3760
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
		int N, F; 
		cin >> N >> F;
		map<pair<string, string>, int> m;
		for (int i = 0; i < N; i++) {
			int M; cin >> M;
			vector<string> s(M);
			for (int j = 0; j < M; j++) cin >> s[j];
			sort(s.begin(), s.end());
			for (int j = 0; j < M; ++j) {
				for (int k = j + 1; k < M; k++) {
					m[make_pair(s[j], s[k])] += 1;
				}
			}
		}
		int ans = 0;
		map<pair<string, string>, int>::iterator it;
		for (it = m.begin(); it != m.end(); it++) {
			if (it->second >= F) ans++;
		}
		cout << ans << endl;
		for (it = m.begin(); it != m.end(); it++) {
			if (it->second >= F) 
				cout << it->first.first << " " << it->first.second << endl;
		}	
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;

class Puzzle
{
public:
    vector<int> pos;
    int g,e;

    ull P=1e8+7;

    Puzzle()
    {
        pos.resize(16);
    }

    bool operator < (const Puzzle & b) const
    {
        return e<b.e;
    }

    bool operator > (const Puzzle & b) const
    {
        return e>b.e;
    }


    bool finished()
    {
        bool flag=true;
        for(int i=0;i<15;i++)
        {
            if(pos[i]!=i+1)
            {
                flag=false;
            }
        }
        if(pos[15]!=0)
        {
            flag=false;
        }
        return flag;
    }

    int mhd(int a,int b)
    {
        return abs(a/4-b/4)+abs(a%4-b%4);
    }

    int getPos(int a)
    {
        int p;
        if(a==0)
        {
            p=15;
        }else
        {
            p=a-1;
        }
        return p;
    }

    int estimate()
    {
        int sum=0;
        for(int i=0;i<16;i++)
        {
            sum+=mhd(i,getPos(pos[i]));
        }
        sum-=mhd(getZero(),15);
        return sum;
    }

    ull getHash()
    {
        ull Hash=0;
        for(int i=0;i<16;i++)
        {
            Hash=Hash*P+pos[i];
        }
        return Hash;
    }

    int getZero()
    {
        for(int i=0;i<16;i++)
        {
            if(pos[i]==0) return i;
        }
        return 0;
    }

    void _swap(int i,int j)
    {
        swap(pos[i],pos[j]);
    }
};


int dr[4]={1,0,-1,0},dc[4]={0,1,0,-1};

int aStar(Puzzle puzzle)
{
    priority_queue<Puzzle,vector<Puzzle>,greater<Puzzle> > st;

    map<ull,bool> used;

    puzzle.g=0;
    puzzle.e=puzzle.estimate();
    st.push(puzzle);
    used[puzzle.getHash()]=true;

    while(!st.empty())
    {
        Puzzle tmp=st.top();st.pop();
        if(tmp.g>45) continue;
        if(tmp.finished())
        {
            return tmp.g;
        }
        int idx=tmp.getZero();
        int r=idx/4,c=idx%4;
        for(int i=0;i<4;i++)
        {
            int rr=r+dr[i],cc=c+dc[i];
            if(rr<4&&rr>=0&&cc<4&&cc>=0)
            {
                Puzzle newP=tmp;
                newP._swap(idx,rr*4+cc);
                if(!used[newP.getHash()])
                {
                    used[newP.getHash()]=true;
                    newP.g=tmp.g+1;
                    newP.e=newP.g+newP.estimate();
                    st.push(newP);
                }
            }
        }
    }

    return -1;
}

int main()
{
    Puzzle puzzle;
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<4;j++)
        {
            cin>>puzzle.pos[i*4+j];
        }
    }

    cout<<aStar(puzzle)<<endl;

    return 0;
}



Measured memory_bytes: 222688
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
vector<vi> g;
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	if(n%2==0){
		repA(i,1,n/2) g.pb(vi{i,n+1-i});
	}
	else{
		g.pb(vi(1,n));
		repA(i,1,n/2) g.pb(vi{i,n-i});
	}
	int gg = sz(g);
	vector<pii> ans;
	rep(i,gg){
		rep(j,i){
			trav(a,g[i]) trav(b,g[j]) ans.pb(mp(a,b));
		}
	}
	cout<<sz(ans)<<'\n';
	trav(i,ans) cout<<i.fst<<' '<<i.snd<<'\n';
	
	
	
	return 0;
}



Measured memory_bytes: 384
def main():
    a, b, c, d = [int(x) for x in input().split()]
    while 1:
        c -= b
        if not (a > 0 and c > 0):
            break

        a -= d
        if not (a > 0 and c > 0):
            break

    if a > 0:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9172
#include <stdio.h>
int main() {
	int i;

	int N;
	int A[20], B[20], C[20];
	int ans = 0;

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

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

	for (i = 0; i < N; i++) {
		ans += B[A[i]];
		if (i != 0 && A[i] - A[i - 1] == 1) {
			ans += C[A[i - 1]];
		}
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n, m;

//inputします
void input() {
    cin >> n >> m;
}

//ライブラリ置き場

//main
int main() {
    input();
    i64 ans,ans1,ans2;
    ans = 1;
    ans1 = 0;
    ans2 = 0;
    set<int> dat;
    ff(i, 0, m) {
        int a;
        cin >> a;
        dat.insert(a);
    }
    ff(i, 1, n+1) {
        ans2 = ans1;
        ans1 = ans;
        if (dat.count(i))ans = 0;
        else {
            ans = ans1 + ans2;
        }
        if (ans >= inf)ans %= inf;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#define ll long long



int main()
{
  char ch[3];
  scanf("%s",ch);

  for (int i = 0; i<3;i++)
  {
  if (ch[i]=='7'){printf("Yes");
  return 0;}

  }
  printf("No");
    return 0;

}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin >> n;
    int tb[101][101];
    mset(tb, 0);
    inc(i, 0, n){
        int h;cin >> h;
        inc(j, 0, h){
            tb[j][i] = 1;
        }
    }
    int ans = 0;
    inc(i, 0, 101){
        int b = tb[i][0];
        inc(j, 1, 101){
            if(tb[i][j] == 0 && b == 1) ans++;
            b = tb[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int a,b;
char tree[100][100];

int main(){
    cin >> a >> b;
    cout << 100 << ' ' << 100 << endl;
    
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 100; j++)    tree[i][j] = '.';
    }
    for(int i = 50; i< 100; i++){
        for(int j = 0; j < 100; j++)    tree[i][j] = '#';
    }
    --a;
    --b;
    for(int i = 0; i < 50; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(b == 0)  break;
            tree[i][j] = '#';
            --b;
        }
    }

    for(int i = 51; i < 100; i += 2){
        for(int j = 0; j < 100; j += 2){
            if(a == 0)  break;
            tree[i][j] = '.';
            --a;
        }
    }

    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            printf("%c", tree[i][j]);
        }
        cout << '\n';
    }
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {

	long a;
	string s; cin >> a >> s;

	if (a >= 3200) cout << s << endl; else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int K,d,e,n,ki,kisu,gusu;
	
	scanf("%d",&K);
	
	d=K%2;
	
	ki=0;
	
	if(d==1){
		ki=1;
		
	}
	
	if(ki==0){
		
		kisu=K/2;
		gusu=K/2;
		
		
	}else{
		
		kisu=(K/2)+1;
		gusu=K/2;
		
	}
	
	n=kisu*gusu;
	
	printf("%d\n",n);
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case() {

    
    

    ll n;
    cin>>n;

    ll a, b ;
    cin>>a>>b;

    ll ans = 0;

    ans = ( n / (a + b)) * a;

    n = n % (a + b);

    if( n >  0) {
        ans+= min(a,n);
    }

    cout<<ans<<endl;



    




  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

ll n,fa[N],bb,ans;
struct Node
{
	ll x,y,id;
} node[N];
struct Bn
{
	ll a,b,c;
	bool operator < (const Bn u) const
	{
		return c<u.c;
	}
} bn[N<<1];

ll ff(ll u)
{
	return u==fa[u]?u:fa[u]=ff(fa[u]);
}
inline bool cmp1(Node u,Node v)
{
	return u.x<v.x;
}
inline bool cmp2(Node u,Node v)
{
	return u.y<v.y;
}

int main()
{
	ll i,j,p;
	cin>>n;
//fafafa
	for(i=1; i<=n; i++)
	{
		scanf("%lld%lld",&node[i].x,&node[i].y);
		node[i].id=i;
		fa[i]=i;
	}
	sort(node+1,node+n+1,cmp1);
	for(i=1; i<n; i++) bn[++bb].a=node[i].id,bn[bb].b=node[i+1].id,bn[bb].c=node[i+1].x-node[i].x;
	sort(node+1,node+n+1,cmp2);
	for(i=1; i<n; i++) bn[++bb].a=node[i].id,bn[bb].b=node[i+1].id,bn[bb].c=node[i+1].y-node[i].y;
	sort(bn+1,bn+bb+1);
	for(i=1; i<=bb; i++)
	{
		if(ff(bn[i].a)==ff(bn[i].b)) continue;
		fa[ff(bn[i].a)]=ff(bn[i].b);
		ans+=bn[i].c;
	}
	cout<<ans;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int m[1010];

int main(void) {
	int N, X;
	int sum = 0;
	int min = 1000000;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m[i];
		sum += m[i];
		min = min > m[i] ? m[i] : min;
	}
	cout << N + (X - sum) / min << endl;
	//system("pause");
}

Measured memory_bytes: 256
n = int(input())
b = [int(x) for x in input().split()]
a = [0 for x in range(n)]

a[0] = b[0]
for i in range(1, n-1):
    a[i] = b[i]
    if b[i] > b[i-1]:
        a[i] = b[i-1]

a[n-1] = max(b[n-2:n-1]) 

print(sum(a))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
    int n,m,l,i,j,k;
    cin >> n >> m >> l;
    long long a[n][m], b[m][l], c[n][l] = {};
    for (i=0;i<n;i++) for (j=0;j<m;j++) cin >> a[i][j];
    for (i=0;i<m;i++) for (j=0;j<l;j++) cin >> b[i][j];
    for (i=0;i<n;i++) {
        for (j=0;j<l;j++) {
            for (k=0;k<m;k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
            cout << c[i][j] << (j==l-1?"\n":" ");
        }
    }
    return 0;
}

Measured memory_bytes: 3344
// AtCoder Grand Contest 015
// C - Nuske vs Phantom Thnook

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;


const int MAX_N = 2000;
const int MAX_M = 2000;

int N, M, Q;
int nodes[MAX_N + 1][MAX_M + 1];
int edges[2][MAX_N + 1][MAX_M + 1];

int main() {

    char c;
    int x1, y1, x2, y2;
    int q_nodes, q_edges;

    cin >> N >> M >> Q;
    memset(nodes, 0, sizeof(0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> c;
            nodes[i + 1][j + 1] = (c == '0' ? 0 : 1);
        }
    }

    memset(edges, 0, sizeof(edges));
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            if (nodes[i][j] == 1 && nodes[i - 1][j] == 1) {
                edges[0][i][j] = 1;
            }
            if (nodes[i][j] == 1 && nodes[i][j - 1] == 1) {
                edges[1][i][j] = 1;
            }
        }
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= M; j++) {
            nodes[i][j] += nodes[i][j - 1];
            edges[0][i][j] += edges[0][i][j - 1];
            edges[1][i][j] += edges[1][i][j - 1];
        }
    }
    for (int j = 1; j <= M; j++) {
        for (int i = 1; i <= N; i++) {
            nodes[i][j] += nodes[i - 1][j];
            edges[0][i][j] += edges[0][i - 1][j];
            edges[1][i][j] += edges[1][i - 1][j];
        }
    }

    for (int q = 0; q < Q; q++) {
        cin >> x1 >> y1 >> x2 >> y2;
        q_nodes = nodes[x2][y2] - nodes[x2][y1 - 1] - nodes[x1 - 1][y2] + nodes[x1 - 1][y1 - 1];
        q_edges = edges[0][x2][y2] - edges[0][x2][y1 - 1] - edges[0][x1][y2] + edges[0][x1][y1 - 1];
        q_edges += edges[1][x2][y2] - edges[1][x2][y1] - edges[1][x1 - 1][y2] + edges[1][x1 - 1][y1];
        cout << q_nodes - q_edges << endl;
    }

    return 0;

}





Measured memory_bytes: 48768
//lec04
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>

using namespace std;

#define n 4
#define n1 16
#define LIMIT 100


static const int x[4]={0,-1,0,1};
static const int y[4]={1,0,-1,0};
static const char c[4]={'r','u','l','d'};
int MDT[n1][n1];

struct Puzzle{
	int m[n1];
	int space;
	int MD;
};

Puzzle state;
int lim;
int path[LIMIT];

bool DFS(int depth, int s){
	if(state.MD==0){
		return true;

	}
	if(depth+state.MD>lim){
		return false;
	}
	int stx=state.space/n;
	int sty=state.space%n;
	Puzzle temp;

	for(int i=0;i<n;i++){
		int tx=stx+x[i];
		int ty=sty+y[i];
		if(tx<0||ty<0||tx>=n||ty>=n){
			continue;
		}
		int mmax=max(s,i);
		int mmin=min(s,i);
		if(mmax-mmin==2){
			continue;
		}
		temp=state;
		state.MD-=MDT[ty+tx*n][state.m[ty+tx*n]-1];
		state.MD+=MDT[sty+stx*n][state.m[ty+tx*n]-1];
		swap(state.m[ty+tx*n],state.m[sty+stx*n]);
		state.space=ty+tx*n;
		if(DFS(depth+1,i)){
			path[depth]=i;
			return true;
		}
		state=temp;

	}
	return false;
}


int get(Puzzle p){
	int sum=0;
	for(int i=0;i<n1;i++){
		if(p.m[i]==n1){
			continue;
		}
		int pp=p.m[i]-1;
		sum+=MDT[i][pp];
	}
	return sum;
}

string hanpu_depth(Puzzle in){
	in.MD=get(in);
	for(lim=in.MD;lim<=LIMIT;lim++){
		state=in;
		if(DFS(0,-100)){
			string a="";
			for(int i=0;i<lim;i++){
				a+=c[path[i]];
			}
			return a;
		}
	}
	return "unsolve";

}

int main(){
  for(int i=0;i<n1;i++){
  	for(int j=0;j<n1;j++){
  		MDT[i][j]=abs(i/n-j/n)+abs(i%n-j%n);
  	}
  }
  Puzzle input;
  for(int i=0;i<n1;i++){
  	cin>>input.m[i];
  	if(input.m[i]==0){
      input.m[i]=n1;
      input.space=i;
    }
  }
  string ans =hanpu_depth(input);
  cout<<ans.size()<<endl;
  return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool func(int a){
	int s=0;
	while(a!=0){
		s+=a%10;
		a/=10;
	}
	if(s==10)
	return true;
	return false;
}
void merge(int arr[], int brr[],int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    /* create temp arrays */
    int L[n1], R[n2]; 
    int L1[n1], R1[n2];
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++) 
        {L[i] = arr[l + i]; L1[i] = brr[l+i];} 
    for (j = 0; j < n2; j++) 
        {R[j] = arr[m + 1+ j]; R1[j] = brr[m + 1 + j];}
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            brr[k] = L1[i];
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            brr[k] =R1[j];
            j++; 
        } 
        k++; 
    } 
  
    /* Copy the remaining elements of L[], if there 
       are any */
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        brr[k] = L1[i];
        i++; 
        k++; 
    } 
  
    /* Copy the remaining elements of R[], if there 
       are any */
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        brr[k] = R1[j];
        j++; 
        k++; 
    } 
} 
  
/* l is for left index and r is right index of the 
   sub-array of arr to be sorted */
void mergeSort(int arr[],int brr[], int l, int r) 
{ 
    if (l < r) 
    { 
        // Same as (l+r)/2, but avoids overflow for 
        // large l and h 
        int m = l+(r-l)/2; 
  
        // Sort first and second halves 
        mergeSort(arr,brr, l, m); 
        mergeSort(arr,brr, m+1, r); 
  
        merge(arr,brr, l, m, r); 
    } 
} 
int32_t main()
{
   int com=1e9;
   int n,k,s; 	cin>>n>>k>>s;
   for(int i=0;i<n;++i){
	   if(i<k)
	   cout<<s<<" ";
	   else if(s!=com)
	   cout<<s+1<<" ";
	   else
	   cout<<s-1<<" ";
   }
   return 0;
}


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

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

    int A, B;
    cin >> A >> B;

    if (A <= 5) {
        cout << 0 << endl;
    } else if (A <= 12) {
        cout << B/2 << endl;
    } else {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

  int N,Y;

  scanf("%d %d",&N,&Y);

  for(int i=0; i<=N; i++){
    for(int j=0; i+j<=N; j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y && N-i-j>=0){
        cout << i << ' ' << j << ' ' <<  N-i-j << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long K){
  ll x = 0;
  for (int i = 1; i < 2000000; i++) {
    x = (x*10 + 7)%K;
    if(x == 0){
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main(){
    long long K;
  scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3688
#include <atcoder/scc>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    printf("%d\n", int(scc.size()));
    for (auto v : scc) {
        printf("%d", int(v.size()));
        for (int x : v) {
            printf(" %d", x);
        }
        printf("\n");
    }

    return 0;
}

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

int main(){
	int c = 0, h = 0;
	int s1, s2, t;
	char a, b;
	while(cin >> s1 >> a >> s2 >> b >> t){
		if(((s1 * s1) + (s2 * s2)) == t * t) c++;
		if(s1 == s2) h++;
	}
	cout << c << endl;
	cout << h << endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

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

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

unsigned int comb(unsigned int n, unsigned int r) {
    if ( r * 2 > n ) r = n - r;
    unsigned int dividend = 1;
    unsigned int divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int recursive_comb(int *indexes, int s, int rest, vector<vector<int>> *comb_list, int idx, int k) {
    if (rest == 0) {
        REP(i, k) {
            (*comb_list)[idx][i] = indexes[i];
        }
        idx++;
    } else {
        if (s < 0) return idx;
        idx = recursive_comb(indexes, s - 1, rest, comb_list, idx, k);
        indexes[rest - 1] = s;
        idx = recursive_comb(indexes, s - 1, rest - 1, comb_list, idx, k);
    }
    return idx;
}

// nCkの組み合わせに対して処理を実行する
ll foreach_comb(int n, int k, vector<vector<int>> *comb_list) {
    int indexes[k];
    ll len = comb(n,k);
    (*comb_list).resize(len);
    REP(i, len){
        (*comb_list)[i].resize(k);
    }
    ll idx = 0;
    recursive_comb(indexes, n - 1, k, comb_list, idx, k);
    return len;
}

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

    int n,k; cin >> n >> k;
    ll a[n];
    REP(i, n) {
        cin >> a[i];
    }
    int idx = 0;
    k--;
    while (k > 0 && a[idx] < a[idx+1]) {
        idx++;
        k--;
    }
    ll smallest[n];
    smallest[0] = 0;
    FOR(i, 1, n) {
        smallest[i] = max(smallest[i-1], a[i-1]);
    }

    vector<vector<int>> comb_list;
    // nCk を全列挙
    ll len = foreach_comb(n-idx-1, k, &comb_list);
    ll mm = -1;
    REP(i, len) {
        ll s = smallest[idx];
        ll cost = 0;
        REP(j, k) {
            int ii = comb_list[i][j]+idx+1;
            s = max(s, smallest[ii])+1;
            if (a[ii] < s) cost += s-a[ii];
        }
        if (cost < mm || mm < 0) mm = cost;
    }
    cout << mm << "\n";
}

Measured memory_bytes: 3684
#include<stdio.h>

int main() {
  int A, B, sum = 0;
  scanf("%d %d", &A, &B);
  for(int i = 0; i < 2; i++) {
    if(A > B) {
      sum += A;
      A = A-1;
  	} else  {
      sum += B;
      B = B-1;
    } 
  }
  printf("%d\n", sum);
}
      

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
	int a, b, c, k;
	scanf("%d%d%d%d", &a, &b, &c, &k);
	if(k <= a) printf("%d\n", k);
	else if(k - a < b) printf("%d\n", k);
	else if(k - a - b < c) printf("%d\n", a - (k - a - b));
	else printf("%d\n", a - c);
}


Measured memory_bytes: 3820
#include <iostream>

using namespace std;
 
int main(){
    long long int a, b, c, d;

    cin >> a >> b >> c >> d;

    long long int multi[4];

    multi[0] = a * c; 
    multi[1] = a * d; 
    multi[2] = b * c; 
    multi[3] = b * d; 

    long long int max = multi[0];
    for (int i= 1; i < 4; i++){
        if (max < multi[i]){
            max = multi[i];
        }
    }

    cout << max << endl;

return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(v) (v).begin(),(v).end()
#define mp make_pair



int main(){
  int k, x;
  
  cin >> k >> x ;
  
  if(500 * k >= x)
  	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
#define chmin(x, v)                                                            \
  do {                                                                         \
    x = min(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N, K, ans=0;
  cin >> N >> K;
  while(N>0) {
    ans++;
    N/=K;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
    int A, B;

    cin >> A >> B;

    if ((A + B) >= 10) {
        cout << "error" << endl;
    } else {
        cout << A + B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int maxi = 0;
  int ans = 0;

  for (int i = 0; i < N; i++) {
    int za, zb;
    cin >> za >> zb;

    if (maxi < za) {
      maxi = za;
      ans = za + zb;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    M, D = [int(i) for i in input().split()]
    cnt = 0
    for m in range(2, M + 1):
        for d in range(22, D + 1):
            d_one = d % 10
            d_ten = d // 10
            if d_one < 2 or d_ten < 2:
                continue
            if m == d_one * d_ten:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
from collections import defaultdict, deque
n,m = list(map(int, input().split()))

d = defaultdict(set)

for _ in range(m):
    
    a,b = list(map(int, input().split()))
    d[a].add(b)
    d[b].add(a)
    
visited = set()

def dfs(node):
    
    c = 0
    stack = deque([node])
    visited.add(node)
    while stack:
        n = stack.popleft()
        c+=1
        for i in d[n]:
            if  i not in visited:
                visited.add(i)
                stack.append(i)
                
    return c
    

ans = 1

for key in list(d.keys()):
    if key not in visited:

        c = dfs(key)
        ans = max(ans, c)
        


print(ans)
        

Measured memory_bytes: 96572
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
void solve()
{
    double d;
    cin>>d;
    std::cout<<setprecision(15)<<(d/3.0)*(d/3.0)*(d/3.0);
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define fr(i,n) for(i=1;i<=n;i++)

typedef pair<int, int> II;
typedef vector< II > VII;
typedef vector<int> VI;

string s,s1,s2,s3,s4,s5,s6;
map<pair<string, string>, ll> mp1,mp2;
map<pair<string, string>, ll>::iterator it;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,cnt=0,j;
    cin>>n>>s;
    for(i=0;i<n;i++) s1.PB(s[i]);
    for(i=2*n-1;i>=n;i--) s2.PB(s[i]);
    for(i=0;i<(1<<n);i++)
    {
        s3.clear(), s4.clear(), s5.clear(), s6.clear();
        for(j=0;j<n;j++)
        {
            if((i&(1<<j)))
                s3.PB(s1[j]), s5.PB(s2[j]);
            else
                s4.PB(s1[j]), s6.PB(s2[j]);
        }
        mp1[MP(min(s3, s4), max(s3, s4))]++;
        mp2[MP(min(s5, s6), max(s5, s6))]++;
    }
    while(!mp1.empty())
    {
        it=mp1.begin();
        if(mp2.find(it->first)!=mp2.end())
        {
            cnt+=(it->second)*((mp2.find(it->first)->second)/2);
            if((it->first).F==(it->first).S)
                cnt+=(it->second)*((mp2.find(it->first)->second)/2);
        }
        mp1.erase(mp1.begin());
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 46080
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        long[] XY = r.ll();

        long n = (long)(Math.log((long)XY[1]/XY[0])/Math.log(2));
        long a = XY[0]*(long)Math.pow(2, n);
        for( ; a <= XY[1]; n++)
            a *= 2;
        println(n);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 20692
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,a1,a2,ans;
char s[200005];
int a[200005],d,v;
int fa[200005];
int di[200005],fac;

int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    n*=2;
    d=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='W'){if(d==1) a[i]=1;else a[i]=0;}
        else{if(d==0) a[i]=1;else a[i]=0;}
        d^=a[i];
    }
    if(a[1]==0){
        printf("0\n");
        return 0;
    }
    fa[1]=1;
    for(int i=2;i<=n;i++){
        if(a[i]==0){
            if(fa[i-1]==2) fa[i]=1;
            else fa[i]=2;
        }
        else fa[i]=fa[i-1];
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(fa[i]==1) a1++,di[++cnt]=n/2-a2;
        else a2++;
    }
    if(a1!=n/2){
        printf("0\n");
        return 0;
    }
    ans=1;
    sort(di+1,di+n/2+1);
    for(int i=1;i<=n/2;i++){
        if(di[i]<i){
            printf("0\n");
            return 0;
        }
        ans=1ll*ans*(di[i]-(i-1))%mod;
    }
    fac=1;
    for(int i=1;i<=n/2;i++) fac=1ll*fac*i%mod;
    printf("%d\n",1ll*ans*fac%mod);

    return 0;
}

Measured memory_bytes: 2816
import sys
import numpy as np
import math
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))
n,k = Mi()
a = np.array(sys.stdin.readline().split(), np.int64)
mina = np.sum(a//(n+k))
maxa = np.max(a)
while maxa > mina+1:
  mid = (mina+maxa)//2
  div = np.sum(np.ceil(a/mid))-n
  if div > k:
    mina = mid
  else:
    maxa = mid
  
print(maxa)

Measured memory_bytes: 52736
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;


public class Main  {

    private static long[] sumA;
    private static long[] sumB;


    private static int max = 0;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] temp = br.readLine().split(" ");
        int a = Integer.parseInt(temp[0]);
        int b = Integer.parseInt(temp[1]);
        int time = Integer.parseInt(temp[2]);

        sumA = new long[a+1];
        sumB = new long[b+1];



        temp = br.readLine().split(" ");
        for(int i=1;i<=a;i++){
            sumA[i] = sumA[i-1] + Long.parseLong(temp[i-1]);

        }

        temp = br.readLine().split(" ");
        for(int i=1; i<=b;i++){
            sumB[i] = sumB[i-1] + Long.parseLong(temp[i-1]);
        }


        int j = b;
        for(int i=0;i<=a;i++){


            if(sumA[i] > time)break;

            while(sumB[j] > time - sumA[i])j--;

            max = Math.max(max, i+j);

        }
        System.out.println(max);

    }


}



Measured memory_bytes: 72692
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        x: i64,
        y: i64,
    }
    let mut prices = vec![];
    prices.push(a * x + b * y);
    prices.push(std::cmp::max(x, y) * c * 2);
    prices.push(x * c * 2 + if y - x > 0 { (y - x) * b } else { 0 });
    prices.push(y * c * 2 + if x - y > 0 { (x - y) * a } else { 0 });
    let ans = prices.iter().min().unwrap();
    println!("{}", ans);
}


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

#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define all(a) s.begin(), s.size()
#define file(s, w) freopen(s".in", "r", stdin); freopen(w".out", "w", stdout);

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 500;
const int mod = 1e9 + 7;
const int eps = 1e9 - 11;
const int inf = 2e9;
long long a, b, c, d;
int main()
{
        cin >> a >> b >> c >> d;
        cout << max(a * b, c * d);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;
int main(){
	
	ll n;
	cin>>n;
	ll A[n];
	int k;
	cin>>k;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	ll dp[n+5];
//	memset(dp,INT_M)
	dp[0]=0;
	dp[1]=abs(A[1]-A[0]);
	
	for(int i=2;i<n;i++){
		dp[i]=INT_MAX;
		for(int j=1;j<=k&&i-j>=0;j++){
			
			dp[i]=min(dp[i],dp[i-j]+abs(A[i]-A[i-j]));
		}
	}
	cout<<dp[n-1];
	return 0;
	
	
	
}


Measured memory_bytes: 5140
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
using namespace std;
int n;
/*int a[100020];
int b[100020];*/
pair<long long, int> d[100200];
map<long long, int> mp;
vector<int> ed[100200];
int sz[100200];
long long f[100200];
int par[100200];
void bad() {
    cout << "-1\n";
    exit(0);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> d[i].first;
        d[i].second = i;
    }
    vector<pair<int, int> > ans;
    sort(d + 1, d + n + 1);
    for (int i = 1; i <= n; i++) mp[d[i].first] = i;

    for (int i = n; i > 1; i--) {
        sz[i]++;
        long long x = d[i].first - (n - 2 * sz[i]);
        if (mp[x] == 0) bad();
        else {
            sz[mp[x]] += sz[i];
            ans.push_back(make_pair(d[i].second, d[mp[x]].second));
            f[mp[x]] += f[i] + sz[i];
        }
        if (sz[i] > n) bad();
    }
    sz[1]++;
    if (sz[1] != n) bad();
    if (f[1] != d[1].first) bad();
    //check(ans);
    for (auto it: ans) cout << it.first << " " << it.second << "\n";
    return 0;
}

Measured memory_bytes: 13816
#include<bits/stdc++.h>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  string str; cin>>str;
  int N = str.size();
  map<char,int> mp;
  for (auto &&s : str)
  {
    mp[s]++;
  }
  int res = N*(N-1)/2;
  for (auto &&x : mp)
  {
    int P = x.second;
    res -= P*(P-1)/2;
  }
  cout<<res + 1<<endl;
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,q=0,w=1;
  char d[10000000]={};
  cin>>a;
  cin>>d;
  for(int i=0;i<a;i++){
    if(d[i+1]==0){
      w=0;
    }
    if(d[i]!=d[i+1]&&w==1){
       i++;
       q++;
    }
  }
  cout<<q<<"\n";
}



Measured memory_bytes: 12876
(let ((A (read))
      (B (read))
      (C (read))
      (X (read)))
  (format t "~A~%"
          (loop for k upto A with totalA
             do
               (setf totalA (* k 500))
             sum (loop for m upto B with totalB
                    do
                      (setf totalB (+ totalA (* 100 m)))
                    sum (loop for n upto C
                           count (= (+ totalB (* 50 n))
                                    X))))))


Measured memory_bytes: 14692
#include<bits/stdc++.h>
using namespace std;
long long bit[1000000], _size, n, cnt, __X1[200000], __Y1[200000], __X2[200000], __Y2[200000];
vector<long long>XX, YY, _XX, _YY; vector<tuple<long long, long long, long long>>vec;
void add(long long p, long long x) { while (p <= _size) { bit[p] += x; p += p&-p; } }
long long sum(long long p) { int _sum = 0; while (p >= 1) { _sum += bit[p]; p -= p&-p; }return _sum; }
long long __sum(long long l, long long r) { return sum(r) - sum(l - 1); }
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> __X1[i] >> __Y1[i] >> __X2[i] >> __Y2[i];
	for (int i = 0; i < n; i++) { XX.push_back(__X1[i]); XX.push_back(__X2[i]); YY.push_back(__Y1[i]); YY.push_back(__Y2[i]); }
	sort(XX.begin(), XX.end()); sort(YY.begin(), YY.end());
	for (int i = 0; i < XX.size(); i++) { if (i == 0 || XX[i - 1] != XX[i])_XX.push_back(XX[i]); if (i == 0 || YY[i - 1] != YY[i])_YY.push_back(YY[i]); }
	for (int i = 0; i < n; i++) {
		int pos1 = lower_bound(_XX.begin(), _XX.end(), __X1[i]) - _XX.begin(), pos2 = lower_bound(_YY.begin(), _YY.end(), __Y1[i]) - _YY.begin();
		int pos3 = lower_bound(_XX.begin(), _XX.end(), __X2[i]) - _XX.begin(), pos4 = lower_bound(_YY.begin(), _YY.end(), __Y2[i]) - _YY.begin();
		pos1++; pos2++; pos3++; pos4++; __X1[i] = pos1; __Y1[i] = pos2; __X2[i] = pos3; __Y2[i] = pos4; if (__X1[i] > __X2[i])swap(__X1[i], __X2[i]); if (__Y1[i] > __Y2[i])swap(__Y1[i], __Y2[i]);
		if (__X1[i] == __X2[i]) { vec.push_back(make_tuple(__Y1[i], -1LL << 60, __X1[i])); vec.push_back(make_tuple(__Y2[i], 1LL << 60, __X1[i])); }
		else { vec.push_back(make_tuple(__Y1[i], __X1[i], __X2[i])); }
	}sort(vec.begin(), vec.end()); _size = XX.size() + 10;
	for (int i = 0; i < vec.size(); i++) { if (abs(get<1>(vec[i])) >= 1LL << 50)add(get<2>(vec[i]), get<1>(vec[i]) / (-1LL << 60)); else { cnt += __sum(get<1>(vec[i]), get<2>(vec[i])); } }
	cout << cnt << endl;
}

Measured memory_bytes: 17120