akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<int>>;

vector<vector<char>> maze(22, vector<char>(22));
vector<vector<int>> d(22, vector<int>(22, -1));
vector<vector<int>> d2(22, vector<int>(22, -1));
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

int H,W;

//sx,syからスタートして最大距離を返すbfs
int bfs(int sx, int sy) {
	d[sx][sy] = 0;
	queue<P> que;
	que.push(P(sx, sy));
	int res = 0;

	while (que.size()) {
		P p = que.front();
		que.pop();
		
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			if (nx < 0 || nx >= H || ny < 0 || ny >= W
				|| d[nx][ny] != -1 || maze[nx][ny] == '#') continue;
			
			d[nx][ny] = d[p.first][p.second] + 1;
			res = max(res, d[nx][ny]);
			que.push(P(nx, ny));
		}
	}

	return res;
}


int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> maze[i][j];
		}
	}

	vector<int> ans;

	for (int sx = 0; sx < H; sx++) {
		for (int sy = 0; sy < W; sy++) {
			
			if (maze[sx][sy] == '#') continue;
			ans.push_back(bfs(sx, sy));
			d = d2;
		}
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());

	cout << ans[0] << endl;

}


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

int main(void) {
    string S;

    cin >> S;
    sort(S.begin(),S.end());

    char tmp1=S[0];
    char tmp2=S[3];

    if(tmp1==S[1] && tmp2==S[2] && S[0]!=S[3])
      cout << "Yes";
      else
      cout << "No";



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    int days = 0;
    while(days < N) {
        if (K > days) ans += X;
        else ans += Y;
        days++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a==1) a+=13;
    if(b==1) b+=13;
    if(a>b) cout << "Alice" << endl;
    else if(a==b) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <list>
using namespace std;

int main()
{
  char s[4] = "";
  cin >> s;
  int cnt=0;
  for(int i=0; i<3; i++){
    if(s[i] == 'o'){
      cnt++;
    }
  }
  cout << 700+cnt*100 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int main()
{
	int n;
	while(cin>>n,n){
		map<pair<int,int>,int> xy;
		xy[make_pair(0,0)]++;		
		vector<pair<int,int> > vp(n);
		vp[0]=make_pair(0,0);
		
		for(int i=1;i<n;i++){
			int idx,dir;
			cin>>idx>>dir;
			int px,py;
			if(dir==0){ //L
				px=vp[idx].first-1;
				py=vp[idx].second;
			}else if(dir==1){ //D
				px=vp[idx].first;
				py=vp[idx].second+1;
			}else if(dir==2){ //R
				px=vp[idx].first+1;
				py=vp[idx].second;
			}else{ //U
				px=vp[idx].first;
				py=vp[idx].second-1;
			}
			xy[make_pair(px,py)];
			vp[i]=make_pair(px,py);
		}
		
		int w=0;
		int l=1000,r=-1000;
		for(int y=-201;y<=201;y++){
			
			for(int x=-201;x<=201;x++){
				if(xy.find(make_pair(x,y))!=xy.end()){
					l=min(x,l);
					break;
				}
			}
		}
		
		for(int y=-201;y<=201;y++){
			for(int x=201;x>=-201;x--){
				if(xy.find(make_pair(x,y))!=xy.end()){
					r=max(r,x);
					break;
				}
			}
		}
		w=r-l+1;

		int h=0;
		int d=-1000,u=1000;
		
		for(int x=-201;x<=201;x++){
			for(int y=201;y>=-201;y--){
				if(xy.find(make_pair(x,y))!=xy.end()){
					d=max(d,y);
					break;
				}
			}
		}
		for(int x=-201;x<=201;x++){
			for(int y=-201;y<=201;y++){
				if(xy.find(make_pair(x,y))!=xy.end()){
					u=min(u,y);
					break;
				}
			}
		}
		h=d-u+1;
				
		cout<<w<<" "<<h<<endl;
		

	}
	
	
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>

using namespace std;

bool isPrime[300100];
int N;

static const int MAX = 300000;

int next(int i) {
  if (i % 7 == 1) {
    i += 5;
  } else {
    i += 2;
  }
  return i;
}

vector<int> primes;

void initPrime() {
  fill(isPrime, isPrime + 2, false);
  fill(isPrime + 2, isPrime + MAX + 1, true);
  for (int i = 2; i <= MAX; i++) {
    if (i % 7 != 1 && i % 7 != 6) {
      isPrime[i] = false;
    }
  }
  for (int i = 6; i * i <= MAX; i = next(i)) {
    for (int j = i + i; j <= MAX; j += i) {
      isPrime[j] = false;
    }
  }
  for (int i = 0; i < MAX; i++) {
    if (isPrime[i]) {
      primes.push_back(i);
    }
  }
}

int main() {
  initPrime();
  while (true) {
    cin >> N;
    if (N == 1) {
      break;
    }
    set<int> primeSet;
    for (int i = 0; i < primes.size(); i++) {
      if (N % primes[i] == 0) {
        primeSet.insert(primes[i]);
      }
    }
    cout << N << ": ";
    set<int>::iterator it = primeSet.begin();
    cout << *it;
    it++;
    for (;it != primeSet.end(); it++) {
      cout << " " << *it;
    }
    cout << endl;
  }
}

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



int go(int *a,int n){
  vector<int> dp(n+1,0);
  dp[2]=abs(a[1]-a[0]);
  for(int i=3;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i-2]),dp[i-2]+abs(a[i-1]-a[i-3]));
  return dp[n];
}

int main(){
 int n;
 cin>>n;
 int a[n];
 for(int i=0;i<n;i++) cin>>a[i];
 cout<<go(a,n)<<endl;
 return 0; 
}

Measured memory_bytes: 4004
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();

        System.out.println(z + " " + x + " "+ y);

    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), a = in();
	cout << n * n - a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int r,g,b,n; cin >>r >>g >> b >>n;
	ll ans=0;
	for(int i=0;i<=n/r;i++){
		for(int j=0;j<=n/g;j++){
			if((n-r*i-j*g)%b==0 &&(n-r*i-j*g)>=0)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(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 fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

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


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll k;
    cin >> k;

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

    int i = 0;
    vector<int> b(n + 1), c(n, -1);
    for (int j = 0;; j++) {
        if (c[i] >= 0) {
            int j0 = c[i];
            int j1 = j;
            int f = j1 - j0;
            if (k < j) {
                cout << b[k] + 1 << endl;
            } else {
                k -= j0;
                k %= f;
                cout << b[j0 + k] + 1 << endl;
            }
            break;
        }
        b[j] = i;
        c[i] = j;

        i = a[i];
    }

    return 0;
}

Measured memory_bytes: 5576
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
string str;
int DD;
ll dp[10005][105][3]={0};
	
int main(){
	cin>>str;
	cin>>DD;
	dp[0][0][0]=(ll)0;
	dp[0][0][1]=(ll)1;
	for(int i=0;i<str.size();i++){
		for(int j=0;j<DD;j++){
			for(int k=0;k<=9;k++){
				int ne = (j+DD*9-k)%DD;
				dp[i+1][j][0]=(dp[i+1][j][0] + dp[i][ne][0])%MOD;
				if(k==str[i]-'0')dp[i+1][j][1]=(dp[i+1][j][1] + dp[i][ne][1])%MOD;
				else if(k<str[i]-'0'){
						dp[i+1][j][0]=(dp[i+1][j][0] + dp[i][ne][1])%MOD;
				}
			}
		}
	}
	/*rep(i,str.size()+1){
		rep(j,DD){
			cout<<dp[i][j][0]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
	rep(i,str.size()+1){
		rep(j,DD){
			cout<<dp[i][j][1]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;*/
	int m=str.size();
	dp[m][0][0]=(dp[m][0][0]-1+MOD)%MOD;
	cout<<(dp[m][0][0]+dp[m][0][1])%MOD<<endl;
}

Measured memory_bytes: 24960
n = input()

a = [0 for i in range(n)]
b = [0 for i in range(n)]

for i in range(n):
	a[i], b[i] = map(int, raw_input().split(' '))

increases = 0

for i in range(n - 1, -1, -1):
	increases += (b[i] - (a[i] + increases)) % b[i]

print increases

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

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



int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;

  int dist[n][n];
  for(int i = 0; i < n; ++i){
   for(int j = 0; j < n; ++j){
     dist[i][j] = abs(i - j);
   }
  }
  dist[x][y] = 1;
  dist[y][x] = 1;

  for(int i = 0; i < n; ++i){
   for(int j = 0; j < n; ++j){
     dist[i][j] = min(dist[i][j], dist[i][x] + 1 + dist[y][j]);
   }
  }

  vector<int> count(n);
  for(int i = 0; i < n; ++i){
   for(int j = i+1; j < n; ++j){
     count[dist[i][j]]++;
   }
  }

  for(int i = 1; i < n; ++i){
    cout << count[i] << endl;
  }
  return 0;
}


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

#define MOD 1000000007
typedef unsigned long long ull;

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

  if (n <= k) {
    cout << 0;
    return 0;
  }

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

  ull sum = 0;
  sort(h.begin(), h.end(), greater<int>());
  for (int i = k; i < n; i++) {
    sum += h[i];
  };

  cout << sum;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 998244353;
vector<int> v;
vector<vector<int> > dp;
vector<ll> pow2;
ll power(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
void solve() {
	int n, s; cin >> n >> s;
	v.resize(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	dp.resize(n + 1, vector<int> (3333, 0));
	pow2.resize(n + 1);
	for (int i = 0; i <= n; i++)pow2[i] = power(2, i);
	//for (auto i : pow2)cout << i << ' '; cout << endl;
	dp[0][0] = pow2[n];
	ll inv2 = power(2ll, mod - 2);
	for (int i = 1; i <= n; i++)for (int j = 0; j <= s; j++) {
			dp[i][j] += 1ll * dp[i - 1][j];
			dp[i][j] %= mod;
			if (j - v[i - 1] >= 0)dp[i][j] += dp[i - 1][j - v[i - 1]] * 1ll * inv2 % mod;
			dp[i][j] %= mod;
		}
	cout << dp[n][s] % mod;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();



}

Measured memory_bytes: 42544
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,l=map(int,input().split())
    T=[int(input()) for _ in range(n)]
    ans=0
    import math
    import cmath
    pi=math.acos(-1)
    for i in range(n):
        for j in range(i+1,n):
            ans+=cmath.rect(1,(T[i]+T[j])*pi/l)*(n-(j-i+1))
            ans+=-cmath.rect(1,(T[i]+T[j])*pi/l)*(j-i-1)
    ans/=n*(n-1)*(n-2)/6
    print(ans.real,ans.imag)
resolve()

Measured memory_bytes: 42732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int CMax = 100002;

int n, k, sk, ats;

int main ()
{
    scanf("%d", &n);
    scanf("%d", &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &sk);
        ats += min(sk * 2, (k - sk) * 2);
    }

    printf("%d\n", ats);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

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


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include <intrin.h>  //AtCoder (gcc) 上ではこれがあると動かない。__popcnt用のincludeファイル。
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;



//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}



//N_C_a を M で割った余り
ll my_combination(ll N, ll a, ll M) {
	ll answer = 1;

	rep(i, a) {
		answer *= (N - i);
		answer %= M;
	}

	rep(i, a) {
		answer *= my_pow(i + 1, M - 2, M);
		answer %= M;
	}

	return answer;
}



ll my_gcd(ll& a, ll& b) {
	if (b == 0) return a;
	ll temp = a % b;
	return my_gcd(b, temp);
}



// long long型 n を、base 進法での、i 桁目の数が入った vector にする。
void ll_to_vector(ll base, ll n, vector<ll>& v) {
	ll tempo = n;

	ll n_digit = floor(log10(n) / log10(base)) + 1;
	v.assign(n_digit, 0);

	//ll n_digit = v.size();

	for (ll i = 0; i < n_digit; i++) {
		v.at(i) = tempo / pow(base, n_digit - 1 - i);
		tempo -= v.at(i) * pow(base, n_digit - 1 - i);
	}
}



int char_to_int(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}



signed main() {
	string S; cin >> S;
	int N = S.size();

	map<int, int> memo; memo[0]++;
	
	int amari = 0;
	int digit = 1;
	
	rep(i, N) {
		amari = (amari+ digit * char_to_int(S.at(N - 1 - i))) % 2019;
		digit = (digit * 10) % 2019;

		memo[amari]++;
		//cout << amari << endl;
	}

	int res = 0;
	for (auto&& iter = memo.begin(); iter != memo.end(); iter++) {
		res += iter->second * (iter->second - 1)/2;
		//cout << iter->first << " " << iter->second << endl;
	}

	cout << res << endl;
}

Measured memory_bytes: 3856
#include <iostream>

int main() {
  using namespace std;

  string S;
  bool flag = false;

  cin >> S;

  for (int i = 0; i < S.length(); i++) {
    if (i == 0) continue;
    if (S[i] == S[i -1]) {
      flag = true;
    }
  }

  if (flag) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N,X,M = map(int,input().split())
ans = X
N -= 1
divs,loop = [],[]
x = X**2%M
for _ in range(M):
    if x%M != 0:
        if x%M in divs:
            loop = divs[divs.index(x%M):]
            start = divs[:divs.index(x%M)]
            break
        else:
            divs.append(x%M)
            x = x**2
            x %= M
    else:
        start = divs
        break
if N >= len(start):
    ans += sum(start)
    if loop:
        cycle = (N-len(start))//len(loop)
        remain = (N-len(start))%len(loop)
        ans += sum(loop)*cycle + sum(loop[:remain])
else:
    ans += sum(start[:N])
print(ans)

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

int main() {
  string s, t; cin >> s >> t;
  bool possible1 = false;
  
  for (int i = 0; i < s.size(); i++) {
    bool possible2 = true;
    for (int j = 0; j < s.size(); j++) {
      int start;
      if (i + j >= s.size()) start = i + j - s.size();
      else start = i + j;
      if (s[start] != t[j]) {
        possible2 = false;
        break;
      }
    }
    if (possible2) {
      possible1 = true;
      break;
    }
  }
  
  if (possible1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

struct Edge {
  int from, to;
};

vector<vector<Edge>> ReadUndirectedGraph(
    int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge({v1, v2}));
    graph[v2].push_back(Edge({v2, v1}));
  }
  return graph;
}

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n;
  cin >> n;
  vector<vector<Edge>> graph = ReadUndirectedGraph(n, n - 1, true);

  vector<vector<FiniteField>> dp = Make2DVector(n, 2, FiniteField(0));

  function<void(int, int)> dfs = [&](int v, int parent) {
    cerr << "v: " << v << endl;

    dp[v][0] = 1;
    dp[v][1] = 1;
    for (auto e : graph[v]) {
      if (e.to == parent) continue;
      dfs(e.to, v);
      dp[v][0] *= dp[e.to][0] + dp[e.to][1];
      dp[v][1] *= dp[e.to][0];
    }
    // cerr << "v: " << v << " " << dp[v][0].Value() << " " << dp[v][1].Value() << endl;
  };
  dfs(0, -1);
  auto ans = dp[0][0] + dp[0][1];
  cout << ans.Value() << endl;
}


Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define M1 1000000007
#define M2 998244353
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define ifl(i,a,b) for(ll i=b-1;i>=a;i--)
#define V(a) vector<a>
#define bn "\n"

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int t=1;
    //cin>>t;
	while(t--)
	{
	   int n;
	   cin>>n;
	   string s;
	   cin>>s;
	   if(n==1)
	   {cout<<0<<bn;continue;}
	   if(n==2)
	   {
	       //if(s[0]!=s[1])
	       //{cout<<1<<bn;
	       //continue;}
	       //else 
	       {cout<<0<<bn;continue;}
	   }
	   ll a[3]={0};
	   for(int i=0;i<n;i++)
	   {
	       if(s[i]=='R')
	       a[0]++;
	       else if(s[i]=='G')
	       a[1]++;
	       else
	       a[2]++;
	       
	   }
	   
	   ll s1 = a[0]*a[1]*a[2];
	   for(int i=0;i<n;i++)
	   {
	       for(int j=1;j<=min(i,n-i-1);j++)
	       {
	           if(s[i]!=s[i-j] && s[i]!=s[i+j] && s[i-j]!=s[i+j])
	           {
	               s1--;
	           }
	       }
	   }
	   cout<<s1<<bn;
	   
	   
	}
	return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline

n = int(input())
la, lxy = [], []
for i in range(n):
  a = int(input())
  la.append(a)
  xy = []
  for j in range(a):
    xy.append(list(map(int, input().split())))
  lxy.append(xy)

from itertools import product

lb = [''.join(b) for b in product('01', repeat=n)]
lc = [sum(int(j) for j in i) for i in lb]
lc, lb = zip(*sorted(zip(lc, lb), reverse=True))
lb = [[int(j) for j in i] for i in lb]

for l in lb:
  ok = 1
  for i in range(n):
    a = la[i]
    for j in range(a):
      x, y = lxy[i][j]
      if l[i] == 1 and l[x-1] != y:
        ok = 0
        break
  if ok:
    print(sum(int(k) for k in l))
    break
else:
  print(0)

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
int main() {
	ll a ,b , k ;
	cin >> a >> b >> k ;
	if(k <= a) {
		cout << a - k << ' ' << b << endl ;
	}
	else if(k > a && k < a + b) {
		cout << 0 << ' ' << b - (k - a)  << endl ;
	}
	else if(k >= a + b) {
		cout << 0 <<' '<< 0 << endl ;
	}
	return 0 ;
} 

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d.at(i);
  }
  
  int count=0;
  sort(d.begin(), d.end());
  count = d.at(n/2) - d.at(n/2-1);
  cout << count << endl;
}


Measured memory_bytes: 640
class UnionFind:
    def __init__(self,n):
        super().__init__()
        self.par = [-1]*n
        self.rank = [0]*n
        self.tsize = [1]*n

    
    def root(self,x):
        if self.par[x] == -1:
            return x 
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x_r = self.root(x)
        y_r = self.root(y)
        
        if self.rank[x_r]>self.rank[y_r]:
            self.par[y_r] = x_r

        elif self.rank[x_r]<self.rank[y_r]:
            self.par[x_r] = y_r

        elif x_r != y_r:
            self.par[y_r] = x_r
            self.rank[x_r] += 1

        if x_r != y_r:
            size = self.tsize[x_r]+self.tsize[y_r]
            self.tsize[x_r] = size
            self.tsize[y_r] = size

    def isSame(self,x,y):
        return self.root(x) == self.root(y)

    def size(self,x):
        return self.tsize[self.root(x)]

def main():
    n,m = tuple([int(t)for t in input().split()])

    t = [tuple([int(t)-1 for t in input().split()])for _ in [0]*m]

    ans = 0
    for k in range(m):
        uf = UnionFind(n)
        for i in range(m):
            if k!=i:
                uf.unite(t[i][0],t[i][1])
        if uf.size(0) !=n :ans+=1
    
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 41584
S = input()

SSize = len(S)

bws = "".join([str(i%2) for i in range(SSize)])
wbs = "".join([str((i+1)%2) for i in range(SSize)])

#print(bws)
#print(wbs)

diffCountBws = 0
diffCountWbs = 0

for i in range(SSize):
	if S[i] != bws[i]:
		diffCountBws += 1
	
	if S[i] != wbs[i]:
		diffCountWbs += 1
		
print(min(diffCountBws,diffCountWbs))

Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin >> str;
    bool app[26];
    for(int i=0; i<26; i++){
        app[i] = false;
    }
    for (int i = 0; str[i] != '\0'; ++i) {
		app[str[i] - 'a'] = true;
	}
    for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			cout << (char)(i + 'a') << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}




Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var input string
	if sc.Scan() {
		input = sc.Text()
	}

	switch input {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  string s;
  while (getline(cin, s)) {
    rep(i, 26) {
      string t = s;
      map<char, char> ma;
      rep(j, 26) {
        char src = 'a' + j;
        char dst = 'a' + (j + i) % 26;
        ma[src] = dst;
      }
      int n = t.size();
      rep(j, n) {
        if (t[j] >= 'a' && t[j] <= 'z') t[j] = ma[t[j]];
      }
      bool f = false;
      for (int i = 0; i + 3 <= n; i++) {
        if (t.substr(i, 3) == "the") f = true;
      }
      for (int i = 0; i + 4 <= n; i++) {
        if (t.substr(i, 4) == "this") f = true;
      }
      for (int i = 0; i + 4 <= n; i++) {
        if (t.substr(i, 4) == "that") f = true;
      }
      if (f) {
        cout << t << '\n';
        break;
      }
    }
  }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef pair<pii,int> ranval;

int main(){
  int n,x,m;
  cin>>n>>x>>m;
  ranval ra[m];
  REP(i,m){
    int l,r,s;
    cin>>l>>r>>s;
    ra[i] = make_pair(make_pair(l,r),s);
  }
  // brute force
  int mx = 1;
  REP(i,n) mx *= (x+1);
  vi mxrow;
  int mxval = -1;
  REP(msk, mx){
    vi ori(n);
    bool flag = true;
    int tmp = msk;
    REP(i,n){
      ori[i] = tmp%(x+1);
      tmp/=(x+1);
    }
    vi sum(n);
    sum[0] = ori[0];
    REPR(i,n) sum[i] = sum[i-1] + ori[i];
    if(mxval > sum[n-1]) continue;
    REP(i,m){
      int l = ra[i].first.first;
      int r = ra[i].first.second;
      int s = ra[i].second;
      int t = sum[r-1];
      if(l>=2) t -= sum[l-2];
      if(s!=t){
        flag = false;
        break;
      }
    }
    if(flag){
      mxval = sum[n-1];
      mxrow = ori;
    }
  }
  if(mxrow.size()==0){
    cout<<-1<<endl;
  }else{
    cout<<mxrow[0];
    REPR(i,n)cout<<" "<<mxrow[i];
    cout<<endl;
  }
  return 0;
}

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

cnt2 = cnt4 = 0
for i in a:
    if i % 2 == 0:
        if i % 4 != 0:
            cnt2 += 1
        else:
            cnt4 += 1

if cnt2:
    if ((n-cnt2+1)//2) <= cnt4:
        print('Yes')
    else:
        print('No')
else:
    if (n-cnt2)//2 <= cnt4:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 15020
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int INF = 1e9+7;

int main() {
    double T,X;
    cin >> T >> X;
    cout << T/X << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<vector>
#define SIZE 100005
using namespace std;

struct Queue
{
  int list[SIZE];
  int head,tail;
  void init(){ head=tail=0; }
  bool isEmpty(){ return head==tail; }
  bool isFull(){ return head==(tail+1)%SIZE; }
  //int head(){ return list[head]; }
  //int tail(){ return list[tail]; }
  void enqueue(int x)
  {
    if(isFull()){
      cout << "ERROR(Over flow)" << endl;
      exit(1);
    }
    list[tail] = x;
    tail++;
    tail %= SIZE;
  }
  int dequeue()
  {
    if(isEmpty()){
      cout << "ERROR(Under flow)" << endl;
      exit(1);
    }
    int x = list[head];
    head++;
    head%=SIZE;
    return x;
  }
};
struct Process
{
  string n;
  int t;
};
int main()
{
  int n,q,idx,now=0;
  vector<Process> p;
  Queue que;

  //input,initialize
  que.init();
  cin>>n>>q; p.resize(n);
  for(int i=0; i<n; i++){
    cin>>p[i].n>>p[i].t; que.enqueue(i);
  }

  //process
  while(!que.isEmpty()){
    idx=que.dequeue();
    if(p[idx].t-q>0){
      p[idx].t-=q; now+=q;
      que.enqueue(idx);
    }else{
      now+=p[idx].t;
      p[idx].t=now;
      cout<<p[idx].n<<" "<<p[idx].t<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6196
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    for(;;){
        C-=B;
        if(C<=0){
            cout<<"Yes"<<endl;
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No"<<endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3640
import math

a, b, c = map(int, input().split())

a_half = abs(((a//2)*b*c)-(math.ceil(a/2)*b*c))
b_half = abs((a*(b//2)*c)-(a*math.ceil(b/2)*c))
c_half = abs((a*b*(c//2))-(a*b*math.ceil(c/2)))

print(min(a_half, b_half, c_half))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define MAX 300
#define INF (1e9)
#define EPS (1e-10)
int n;
double px[MAX],py[MAX],pz[MAX];
double vx[MAX],vy[MAX],vz[MAX];
double r[MAX],vr[MAX];
bool eq(double a){return (-EPS<a&&a<EPS);}
struct data{
  int a,b;
  double t;
  bool operator < (const data &p)const{return t < p.t;}
};

double func(double a,double b,double c){
  if(fabs(a)<EPS||b*b-4.0*a*c<0)return INF;
  double res = (-b-sqrt(b*b-4.0*a*c))/(2.0*a);
  double res2 = (-b+sqrt(b*b-4.0*a*c))/(2.0*a);
  //cout<<res<<' '<<res2<<endl;
  if(res<=0)res=INF;
  if(res2<=0)res2=INF;
  return min(res,res2);
}

double calc(int a,int b){
  double X=(px[a]-px[b]);
  double Y=(py[a]-py[b]);
  double Z=(pz[a]-pz[b]);
  double vX=(vx[a]-vx[b]);
  double vY=(vy[a]-vy[b]);
  double vZ=(vz[a]-vz[b]);
  double R=r[a]+r[b];
  double vR=(vr[a]+vr[b]);
  return func( vX*vX+vY*vY+vZ*vZ-vR*vR , 2.0*(X*vX+Y*vY+Z*vZ+R*vR), X*X+Y*Y+Z*Z-R*R);
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    vector<data> vec;
    vector<bool> flg;
    vector<double> ans;
    flg.resize(n);ans.resize(n);
    for(int i=0;i<n;i++){
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
      vec.push_back((data){i,i,r[i]/vr[i]});
      for(int j=0;j<i;j++){
	vec.push_back((data){i,j,calc(i,j)});
      }
    }
    sort(vec.begin(),vec.end());
    int cnt=0;
    for(int i=0;cnt<n;i++){
      data d=vec[i];
      if(flg[d.a]||flg[d.b])continue;
      ans[d.a]=ans[d.b]=d.t;
      flg[d.a]=flg[d.b]=true;
      if(d.a==d.b)cnt++;
      else cnt+=2;
    }
    for(int i=0;i<n;i++){
      printf("%.10f\n",ans[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int N = 1e5 + 5;
int a[N], n, m;
vector<pair<int,int>> v;
int BS(int startLow, int k){
    int low = startLow, high = n - 1, mid, ans = -1;
    while(low <= high){
        mid = (low + high)/2;
        if(a[mid] < k){
            ans = mid;
            low = mid + 1;
        }
        else high = mid - 1;
    }
    return ans;
}
int main(){
    Hello
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0, b, c; i < m; i++){
        cin >> b >> c;
        v.push_back({c, b});
    }
    sort(a, a + n);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
//    for(int i = 0; i < n; i++)
//        cout << a[i] << " ";
//    cout << endl;
//    for(int i = 0; i < v.size(); i++)
//        cout << v[i].second << " " << v[i].first << endl;
//    cout << endl;
    int cs[m + 5] = {}, startLow = 0;
    for(int i = 0; i < v.size(); i++){
        int ret = BS(startLow, v[i].first);
       // cout << i << " startlow: " << startLow << " k: " << v[i].first << " size: " << v[i].second << " ret: " << ret << endl;
        if(ret != -1){
            cs[i] = startLow + min(ret - startLow, v[i].second - 1);
            startLow = cs[i] + 1;
     //       cout << "last idx: " << cs[i] << endl;
        }
        else cs[i] = 1e9;
    }
    ll sum = 0, lst = 0;
    for(int i = 0; i < m; i++){
        if(cs[i] != 1e9){
            for(int j = lst; j <= cs[i]; j++)
                a[j] = v[i].first;
            lst = cs[i] + 1;
        }
    }
    for(int i = 0; i < n; i++){
        //cout << a[i] << " ";
        sum += a[i];
    }
    cout << sum;
    return 0;
}


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

#define     MX        (1<<18)
#define     mod       998244353
#define     ll        long long
#define     ld        long double
#define     mem(a,b)  memset(a,b,sizeof(a))
#define     fast()    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     F         first
#define     S         second
#define     mp        make_pair
#define     inf       2e18
#define     PI        acos(-1)

int   dx[]      ={+1,-1,0,0};
int   dy[]      ={0,0,+1,-1};

int n,q;
int V[MX],W[MX];
const int BIG=100005;
ll dp[(1<<9)][BIG];

int h;

ll query(int v,int L){
    int lvl = log2(v);
    if(lvl<=h) return dp[v][L];
    vector<int>up;
    while(lvl>h) {
        up.push_back(v);
        v/=2;
        --lvl;
    }
    ll res=0;
    for(int mask=0;mask<(1<<up.size());mask++){
        ll nW=0,nV=0;
        for(int i=0;i<up.size();i++){
            if(mask&(1<<i)) nV+=V[up[i]],nW+=W[up[i]];
        }
        if(nW<=L) res=max(res,nV+dp[v][L-nW]);
    }
    return res;
}

void makeChild(int now){
    vector<int>up;
    int par=now;
    while(par){
        up.push_back(par);
        par/=2;
    }
    for(int mask=0;mask<(1<<up.size());mask++){
        ll nW=0,nV=0;
        for(int i=0;i<up.size();i++){
            if(mask&(1<<i)) nV+=V[up[i]],nW+=W[up[i]];
        }
        if(nW<BIG) dp[now][nW]=max(dp[now][nW],nV);
    }
    for(int i=1;i<BIG;i++) dp[now][i]=max(dp[now][i],dp[now][i-1]);
}
void make(int now){
    int lvl=log2(now);
    if(lvl>h || now>n) return;
    makeChild(now);
    make(now*2);
    make(now*2+1);
}

int main(){
    fast();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    h=log2(n);
    h=h/2;
    for(int i=1;i<=n;i++) {
        cin>>V[i]>>W[i];
    }
    make(1);
    cin>>q;
    for(int i=1;i<=q;i++){
        int v,L;
        cin>>v>>L;
        cout<<query(v,L)<<endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}
ll solve(ll n) {
    vector<ll> v;
    for (ll i = 2; i*i <= n; ++i) {
        if (n % i == 0) {
            while (n % i == 0) n /= i;
            v.pb(i);
        }
    }
    v.pb(n);
    ll res = 1;
    each(x, v) res *= x;
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll p, q; cin >> p >> q;
    cout << max(2LL, solve(q / gcd(p, q))) << endl;
}

Measured memory_bytes: 3192
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}
fn take(vec: &[i32], i: i32) -> i32 {
    match vec.get(i as usize) {
        Some(x) => *x,
        None => 0
    }
}
fn min_array(mut vec: Vec<i32>) -> i32 {
    vec.sort();
    let a= vec.first().unwrap();
    return *a;
}
fn max_array(mut vec: Vec<i32>) -> i32 {
    vec.sort();
    vec.reverse();
    let a = vec.first().unwrap();
    return *a;
}
fn main() {
    let vec = read_vec::<i32>();
    let num_x = take(&vec, 0);
    let num_y = take(&vec, 1);
    let x = take(&vec, 2);
    let y = take(&vec, 3);
    let xs = max_array(read_vec::<i32>());
    let ys = min_array(read_vec::<i32>());
    let x_p = if x < xs  {xs} else {x};
    let y_p = if y > ys  {ys} else {y};
    if x_p >= y_p {
        println!("War");
    } else {
        println!("No War");
    }
}

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

signed main() {
	int h, w;
	cin >> h >> w;
	int all = 0;
	rep(i, h) {
		rep(j, w) {
			int p;
			cin >> p;
			all += p * (i + 1) * (h - i) * (j + 1) * (w - j);
		}
	}
	cout << all << endl;
}


Measured memory_bytes: 3120
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
	int a;
	cin >> a;
    cout << a*a*a << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 3124
import collections
n = int(input())
s = [input() for i in range(n)]
d = collections.Counter(s)
largest = max(d.values())
ans = []
for key in d.keys():
    if d[key] == largest:
        ans.append(key)
common_values = sorted(ans)
for val in common_values:
    print(val)


Measured memory_bytes: 38724
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    int res = 0;
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    for (int aa = 0; aa <= a; aa++) {
        for (int bb = 0; bb <= b; bb++) {
            for (int cc = 0; cc <= c; cc++) {
                if (aa * 500 + bb * 100 + cc * 50 == x) {
                    res++;
                }
            }
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3556
#include <bits/stdc++.h>
#include <array>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


int main() {
	int a, p; CI a >> p;
	CO(a * 3 + p) / 2 EN;
}

Measured memory_bytes: 256