akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 limit = 100005;
using edge = struct {int to; long long cost;};

int n;
vector<edge> tree[limit];
vector<long long> dist;

void dfs(int v, long long d = 0, int p = -1){
    dist[v] = d;
    for(auto &e : tree[v]) {
        if(e.to == p) continue;
        dfs(e.to, d + e.cost, v);
    }
}

vector<long long> calcDist(int s){
    dist = vector<long long>(n);
    dfs(s);
    return dist;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
		ll c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
	int q, k;
	cin >> q >> k;
	k--;
	vector<ll> distK = calcDist(k);
	rep(i,q){
		int x, y;
		cin >> x >> y;
		x--; y--;
		ll ans = dist[x] + dist[y];
		cout << ans << endl;
	}
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
const int MOD = 1e9+7;
ll cache[123456];
ll calc(int cnt[], int n) {
	if(n==0) {
		return 0;
	}
	if(n==1) {
		return cnt[n];
	}
	
	if(cache[n]!=-1) {
		return cache[n];
	}
	// if we select nth element, then we cant get previous(n-1) result, 
	// we need to get it from prevoious of the previous(n-2) result
	// because previous(n-1) was removed according to game rules
	ll point = 1ll*n*cnt[n];
	cache[n] = max(calc(cnt, n-1), calc(cnt, n-2) + point);
	return cache[n];
}
int main() {
	int n;
	cin>>n;
	ll sum = 0;
	for (int i=1;i<=n; i++) {
		if(i%3==0 && i%5==0) {
			continue;
		} else if(i%3==0) {
			continue;
		} else if(i%5==0) {
			continue;
		}
		sum+=i;
	}
	
	cout << sum;
	return 0;
}

Measured memory_bytes: 3632
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;
static const size_t MAX_N = 200050;

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll& r) { return (x + r.x) % MOD; }
	modll operator+=(const modll & r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll & r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll & r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll & r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll & r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	modll dp[2] = { 0,1 };
	for (char c : s) {
		dp[0] *= 3;
		if (c != '0') {
			dp[0] += dp[1];
			dp[1] *= 2;
		}
	}
	modll ans = dp[0] + dp[1];
	cout << ans << endl;
	return 0;
}


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

vector <vector<int> > vert,hori;
vector <vector<bool> >grid;
char c;
int h,w,cur,ans;

int main(){
    scanf ("%d %d",&h,&w);
    vert.resize(h);
    hori.resize(h);
    grid.resize(h);
    for (int i = 0; h > i; i++){
        vert[i].resize(w);
        hori[i].resize(w);
        grid[i].resize(w);
    }

    for (int i = 0; h > i; i++){
        for (int j = 0; w > j; j++){
            vert[i][j]  = 0;
            hori[i][j] = 0;
        }
    }

    for (int i = 0; h > i; i++){
        scanf ("\n");
        for (int j = 0; w > j; j++){
            scanf("%c",&c);
            if (c == '.') grid[i][j] = true;
            else grid[i][j] = false;
        }
    }

    cur = 0;

    for (int i = 0; h > i; i++){
        for (int j = 0; w >= j; j++){
            //printf ("%d %d\n",i,j);
            if (w == j){
                //hori[i][j] = 0;
                for (int k = j-1; k >= j-cur && k >= 0; k--){
                    hori[i][k] = cur;
                }
                cur = 0;
            }
            else if (!grid[i][j]){
                hori[i][j] = 0;
                for (int k = j-1; k >= j-cur && k >= 0; k--){
                    hori[i][k] = cur;
                }
                cur = 0;
            }else{
                cur++;
            }
        }
    }
    cur = 0;
    for (int j = 0; w > j; j++){
        for (int i = 0; h >= i; i++){
            if (h == i){
                //vert[i][j] = 0;
                for (int k = i-1; k >= i-cur && k >= 0; k--){
                    vert[k][j] = cur;
                }
                cur = 0;
            }
            else if (!grid[i][j]){
                vert[i][j] = 0;
                for (int k = i-1; k >= i-cur && k >= 0; k--){
                    vert[k][j] = cur;
                }
                cur = 0;
            }else{
                cur++;
            }
        }
    }

    ans = 0;
    //printf  ("hello\n");
    /*for (int i = 0; h >  i; i++){
        for (int j = 0; w > j; j++){
            printf ("%d",hori[i][j]);
        }printf ("\n");
    }printf ("\n");
    for (int i = 0; h >  i; i++){
        for (int j = 0; w > j; j++){
            printf ("%d",vert[i][j]);
        }printf ("\n");
    }printf ("\n");
*/
    for (int i = 0; h >  i; i++){
        for (int j = 0; w > j; j++){
            ans = max(ans,vert[i][j]+hori[i][j]);
        }
    }
    printf ("%d",ans-1);
}


Measured memory_bytes: 32256
def main():
    n, k = [int(x) for x in input().split()]
    all_ = set(x for x in range(n))
    snack_holders = set()
    for i in range(k):
        int(input())
        for x in input().split():
            snack_holders.add(int(x) - 1)

    return len(all_ - snack_holders)


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


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

bool c[51][51];
bool checked[51][51];
int w, h;

void dfs(int y, int x) {
    if (checked[y][x] || !c[y][x]) return;
    checked[y][x] = true;
    repd(i, -1, 2) {
        repd(j, -1, 2) {
            if (i == 0 && j == 0) continue;
            int yy = y + i, xx = x + j;
            if (yy < 0 || yy >= h || xx < 0 || xx >= w) continue;
            dfs(yy, xx);
        }
    }
}

int main()
{
    while (1) {
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep(i, h) {
            rep(j, w) {
                int k;
                cin >> k;
                c[i][j] = k;
                checked[i][j] = false;
            }
        }

        int cnt = 0;
        rep(i, h) {
            rep(j, w) {
                if (!checked[i][j] && c[i][j]) {
                    dfs(i, j);
                    cnt++;
                }
            }
        }

        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int N, X;
  cin >> N >> X;
  vi L(N+1);
  rep(i, 0, N) cin >> L[i];
  L[N] = 0;
  ++N;

  int ans = 0;
  for (int i=0, D=0; i<N && D<=X; ++i, ++ans) {
    D += L[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}



const int N = 200005;
int n, ans[N], len[N], suff_ans[N], pos[30], goto_[N];
char str[N];


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

    cin>>(str+1);
    n = strlen(str+1);

    memset(pos, -1, sizeof(pos));
    ans[n+1] = 0;
    len[n+1] = 1;
    suff_ans[n+1] = n+1;
    for(int i=n;i>=1;i--){

    	len[i] = ans[i] = MOD;
    	pos[str[i]-'a'] = i;
    	for(int j=0;j<26;j++)
    		if(pos[j] == -1){
    			int newlen = 1;
    			if((newlen < len[i]) || (newlen == len[i] && j < ans[i])){
    				ans[i] = j;
    				len[i] = newlen;
    				goto_[i] = n+1;
    			}
    		}
    		else{
    			int p = pos[j];
    			int nxt = p+1;
    			int newlen = 1 + len[nxt];
    			if((newlen < len[i]) || (newlen == len[i] && j < ans[i])){
    				ans[i] = j;
    				len[i] = newlen;
    				goto_[i] = p+1;
    			}
    		}
    }

    int i = 1;
    while(i <= n){
    	cout<<((char)('a'+ans[i]));
    	i = goto_[i];
    }

    return 0;
}







 




Measured memory_bytes: 2816
#include <iostream>
#include <string>

using namespace std;

string erase(string s, int n)
{
	for(int i=0; i<n; i++)
	{
		string erase;
		erase = s[i];
		size_t c;
		while((c = s.find_first_of(erase, i+1)) != string::npos){
			s.erase(c,1);
			n--;
		}
	}

	return s;
}


int main()
{
	int max=0, sum;
	int n;
	string s, r, l;

	cin >> n >> s;

	for(int i=1; i<n; i++)	//どこで切るか
	{
		l = s.substr(0, i);
		r = s.substr(i, n-1);

		l = erase(l, i);
		r = erase(r, n-i-1);

		sum = 0;
		for(int j=0; j<l.size(); j++)
		{
			for(int k=0; k<r.size(); k++)
			{
				if(l[j] == r[k]) sum++;

			}

		}
		if(max < sum) max = sum;
	}

	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
N = input()
A = [0]*N
B = [0]*N
for i in range(N):
  A[i],B[i] = map(int, raw_input().split())

T = []
for i in range(N):
  T += [(-A[i]-B[i], i)]
T.sort()

ans = 0
for i in range(N):
  if i%2==0:
    ans += A[T[i][1]]
  else:
    ans -= B[T[i][1]]
print ans


Measured memory_bytes: 24824
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c; cin >> a >> b >> c; int tmp = a;
    bool ok = 0;
    REP(i,LCM(a,b)/a+1){tmp+=a;if(tmp%b==c) ok = 1;}
    YN(ok);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <stack>
#include <map>
#define INF 100000000
using namespace std;

typedef long long ll;
int main() {
	int n;
	cin >> n;

	int minl = INF;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		int cnt = 0;
		while (x % 2 == 0) {
			cnt++;
			x = x / 2;
		}
		if (cnt < minl) minl = cnt;
	}
	cout << minl << endl;

	return 0;
}

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

long long a, b;

int main(){
  cin >> a >> b;
  long long res = (a * b) / __gcd(a, b);
  cout << res << endl;
  return 0;
}

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

using namespace std;


int main() {
	string s;
	cin >> s;
	int k = 3;
	int n = (int)s.length();

	vector<int> counter(26, 0);

	for (int i = 0; i < n; i++) {
		counter[s[i] - 'a']++;
		if (i - k + 1 >= 0) {
			int total = 0;
			for (int i = 0; i < 26; i++) {
				if (counter[i] != 0) total++;
			}
			if (total <= 2) {
				cout << i - k + 2 << " " << i + 1;
				return 0;
			}
			counter[s[i - k + 1] - 'a']--;
		}
	}

	int total = 0;

	for (int i = 0; i < 26; i++) {
		if (counter[i] != 0) total++;
	}

	if (total <= 1) {
		cout << 1 << " " << 2;
		return 0;
	}

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


Measured memory_bytes: 512
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| x1; y1; x2; y2 |] ->
    let x = x2 - x1
    let y = y2 - y1
    let x3 = x2 - y
    let y3 = y2 + x
    let x4 = x1 - y
    let y4 = y1 + x
    printfn "%d %d %d %d" x3 y3 x4 y4


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

int main() {

  long N;
  std::vector<long> v;
  long temp;
  long ans;
  long total;

  for(;;) {
    v.clear();
    std::cin >> N;
    if( N == 0 ) break;

    for(int i = 0; i < N; ++i) {
      std::cin >> temp;
      v.push_back(temp);
    }

    std::sort(std::begin(v), std::end(v));

    total = 0;
    for(int i = 1; i < N-1; ++i) total += v[i];
    ans = total / (N-2);

    std::cout << ans << std::endl;
  }
  
  return 0;
}

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

int main() {
  int N, B=0;
  double Sum=0, M;
  cin >> N >> M;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
    Sum+=A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  rep(i, M){
    if(A.at(i)<Sum/(4*M)){
      B=1;
      break;
    }
  }
  if(B==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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;
  ll int c;
  cin >> n >> c;
  vector<pair<ll int, ll int> > right, left;

  REP(i, n){
    ll int x;
    ll int v;
    cin >> x >> v;
    right.pb(mp(x, v));
    left.pb(mp(c-x, v));
  }
  sort(All(right));
  sort(All(left));

  ll int rmax[100000], lmax[100000];
  ll int oldpos = 0;
  ll int tmp = 0;
  REP(i, right.size()){
    tmp += right[i].second - (right[i].first - oldpos);
    if(i != 0) rmax[i] = max(rmax[i-1], tmp);
    else rmax[i] = tmp;
    oldpos = right[i].first;
  }
  oldpos = 0;
  tmp = 0;
  REP(i, left.size()){
    tmp += left[i].second - (left[i].first - oldpos);
    if(i != 0) lmax[i] = max(lmax[i-1], tmp);
    else lmax[i] = tmp;
    oldpos = left[i].first;
  }
  ll int r2max[100000], l2max[100000];
  oldpos = 0;
  tmp = 0;
  REP(i, right.size()){
    tmp += right[i].second - (right[i].first - oldpos) * 2;
    if(i != 0) r2max[i] = max(r2max[i-1], tmp);
    else r2max[i] = tmp;
    oldpos = right[i].first;
  }
  oldpos = 0;
  tmp = 0;
  REP(i, left.size()){
    tmp += left[i].second - (left[i].first - oldpos) * 2;
    if(i != 0) l2max[i] = max(l2max[i-1], tmp);
    else l2max[i] = tmp;
    oldpos = left[i].first;
  }

  // REP(i, n) cout << rmax[i] << " ";
  // cout << endl;
  // REP(i, n) cout << lmax[i] << " ";
  // cout << endl;
  // REP(i, n) cout << r2max[i] << " ";
  // cout << endl;
  // REP(i, n) cout << l2max[i] << " ";
  // cout << endl;

  ll int ans = 0;
  REP(i, n){
    ll int tmp = rmax[i];
    if(n-i-2 >= 0 && n-i-2 <= n-1){
      tmp += l2max[n-i-2];
    }
    ans = max(tmp, ans);
  }
  REP(i, n){
    ll int tmp = lmax[i];
    if(n-i-2 >= 0 && n-i-2 <= n-1){
      tmp += r2max[n-i-2];
    }
    ans = max(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
int main(){
  ll h,w;
  cin >> h >> w;
  ll ans=0;
  if(h==1 || w==1){
    cout << 1;
    return 0;
  }
  if(w%2==0){
    rep(i,h){
      ans+=w/2;
    }
  }else{
    rep(i,h){
      if(i%2==0){
        ans+=(w+1)/2;
      }else{
        ans+=w/2;
      }
    }
  }
  cout << ans;
}
    

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int i,v[n],c,sum=0;
	for(i=0;i<n;i++)	cin >> v[i];
	int d;
	for(i=0;i<n;i++){
		cin >> c;
		d = v[i]-c;
		if(d > 0)	sum+=d;
	}
	cout << sum << endl;
	return 0;
}

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

uint32_t binary_pow(uint32_t base, uint32_t n, uint32_t mod) {
  if (n == 1) return base % mod;

  uint64_t value = binary_pow(base, n / 2, mod);
  return (n % 2 == 0) ? (value * value) % mod
                      : (((value * value) % mod) * base) % mod;
}

int main() {
  const uint32_t mod = 1'000'000'007;
  uint32_t m = 0, n = 0;
  std::cin >> m >> n;

  std::cout << binary_pow(m, n, mod) << std::endl;

  return 0;
}


Measured memory_bytes: 3096
n=int(input())
a=[list(map(int,input().split()))]
a.append(list(map(int,input().split())))
m=[[0]*n,[0]*n]
#m1=[[0]*n]*2これだとおかしな挙動
m[0][0]=a[0][0]
m[1][0]=m[0][0]+a[1][0]

for i in range(1,n):
    m[0][i]=m[0][i-1]+a[0][i]

for i in range(1,n):
    m[1][i]=max(m[0][i]+a[1][i],m[1][i-1]+a[1][i])

print(m[1][n-1])

Measured memory_bytes: 3064
import numpy as np
import bisect

n = int(input())
l = np.array(list(map(int, input().split())))

# l.sort()

# ans = 0
# for a in range(n - 2):
#     for b in range(a + 1, n - 1):
#         ans += bisect.bisect_left(l, l[a] + l[b]) - (a + 1)
# print(ans)

res = 0
l = sorted(l)
for i in range(1, n - 1):
    b = l[i]
    for j in range(0, i):
        a = l[j]
        res += bisect.bisect_left(l, a + b) - (i + 1)
print(res)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  int n;
  cin >> n;
  if (n%1000 == 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << (n/1000+1) * 1000 - n  << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll mod = 5e18;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    ll N; cin >> N;
    ll ans = 0;
    if(N % 2){
        cout << ans << endl;
        return 0;
    } 
    ll jyuubai = 10;
    ll now = N;
    if(N == 1e18){
        while(jyuubai <= N){
            ans += N / jyuubai;
            if(jyuubai == 1e18) break;
            jyuubai *= 5;
        }
    }
    else{
        while(jyuubai <= N){
            ans += N / jyuubai;
            jyuubai *= 5;
        }
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3652
#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);
  }
  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());
  cout << d.size() << endl;
}


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

int main() {
  int N; cin >> N;
  vector<int> factors;
  cout << N << ":";

  for (int i = 2; i <= sqrt(N); i++) {
    while (N % i == 0) {
      factors.push_back(i);
      N /= i;
    }
    if (N == 1) break;
  }
  if (N != 1) factors.push_back(N);

  for (int i = 0; i < factors.size(); i++)
    cout << " " << factors[i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3140
h, w = gets.split.map(&:to_i)
field = h.times.map {gets.chomp.chars}

remove_rows = ->{
  compared = ["."] * field.first.size
  field.delete(compared)
}
remove_rows.()

field = field.transpose
remove_rows.()
field = field.transpose

puts field.map(&:join)


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool flag = (S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3]);
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
dp0 = [0] * (n+11)
dp1 = [0] * (n+11)
dp2 = [0] * (n+11)
for i,ai in enumerate(A):
  dp2[i+11] = (max(dp0[i+7] + ai, dp1[i+8] + ai, dp2[i+9] + ai) if i >= 2 else 0)
  dp1[i+11] = (max(dp0[i+8] + ai, dp1[i+9] + ai) if i >= 1 else 0)
  dp0[i+11] = dp0[i+9] + ai 
if n % 2 == 0:
  print(max(dp0[n + 9], dp1[n + 10]))
else:
  print(max(dp0[n + 8], dp1[n + 9], dp2[n + 10]))

# debug
# print(dp0,dp1,dp2,sep="\n")




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

int n, a[200], ans = 0;

int main() {
  cin >> n;
  rep(i,n) cin >> a[i];
  
  bool ok = true;
  while (ok) {
    rep(i,n) if (a[i] % 2 == 1) ok = false;
    if (ok) {
      ans++;
      rep(i,n) a[i] /= 2;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import os
import sys

import numpy as np


def solve(inp):
    def dfs(links, s, checked, postorder):
        stack = [0, s]
        while stack:
            i, v = stack[-2:]
            if i == 0 and checked[v]:
                stack.pop()
                stack.pop()
                continue
            checked[v] = 1
            l = len(links[v])
            while i < l and checked[links[v][i]] == 1:
                i += 1
            if i == l:
                postorder.append(v)
                stack.pop()
                stack.pop()
                continue
            stack[-2] = i + 1
            stack.append(0)
            stack.append(links[v][i])

    def dfs2(rev_links, s, checked):
        q = [s]
        checked[s] = 1
        scc = [s]
        while q:
            v = q.pop()
            for u in rev_links[v]:
                if checked[u] == 0:
                    q.append(u)
                    checked[u] = 1
                    scc.append(u)
        return scc

    n = inp[0]
    m = inp[1]
    aaa = inp[2::2]
    bbb = inp[3::2]

    int_list = [0]
    int_list.clear()
    links = [int_list.copy() for _ in range(n)]
    rev_links = [int_list.copy() for _ in range(n)]

    for i in range(m):
        a = aaa[i]
        b = bbb[i]
        if a != b:
            links[a].append(b)
            rev_links[b].append(a)

    checked = np.zeros(n, np.int8)
    postorder = []

    for v in range(n):
        if checked[v]:
            continue
        dfs(links, v, checked, postorder)

    postorder.reverse()
    checked = np.zeros(n, np.int8)
    sccs = []

    for v in postorder:
        if checked[v]:
            continue
        sccs.append(dfs2(rev_links, v, checked))

    return sccs


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8[:],)', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(len(ans))
for scc in ans:
    print(len(scc), *scc)


Measured memory_bytes: 245624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

class dice {
    int num_up;
    int num_s;
    int num_w;
    int num_n;
    int num_e;
    int num_bot;
    
public:
    dice()
    {
        num_up = num_s = num_w = num_n = num_e = num_bot = 0;
    }
    
    dice(int num1, int num2, int num3, int num4, int num5, int num6)
    : num_up( num1 )
    , num_s( num2 )
    , num_e( num3 )
    , num_w( num4 )
    , num_n( num5)
    , num_bot( num6 )
    {
    }
    
    dice(string str)
    {
        stringstream ss(str);
        ss >> num_up >> num_s >> num_e >> num_w >> num_n >> num_bot;
    }
    
    int getUpperNumber(void) {
        return num_up;
    }
    
    void printAllNumber(void) {
            cout << num_up << " " << num_s << " " << num_e << " " << num_w << " " << num_n << " " << num_bot << endl;
    }
    
    void printDevelopment(void) {
        cout << "     ---\n";
        cout << "    |" << setw(3) << num_up << "|\n";
        cout << " --- --- --- ---\n";
        cout << "|" << setw(3) << num_w << "|" << setw(3) << num_s << "|" << setw(3) << num_e << "|" << setw(3) << num_n << "|\n";
        cout << " --- --- --- ---\n";
        cout << "    |" << setw(3) << num_bot << "|\n";
        cout << "     ---\n";
        //     ---
        //    |100|
        // --- --- --- ---
        //|xx3|  x|xxx|xxx|
        // --- --- --- ---
        //    |xxx|
        //     ---
    }
    
    void rollToN() {
        int tmp;
        tmp = num_bot;
        num_bot = num_n;
        num_n = num_up;
        num_up = num_s;
        num_s = tmp;
    }
    
    void rollToS() {
        int tmp;
        tmp = num_bot;
        num_bot = num_s;
        num_s = num_up;
        num_up = num_n;
        num_n = tmp;
    }
    
    void rollToE() {
        int tmp;
        tmp = num_bot;
        num_bot = num_e;
        num_e = num_up;
        num_up = num_w;
        num_w = tmp;
    }
    
    void rollToW() {
        int tmp;
        tmp = num_bot;
        num_bot = num_w;
        num_w = num_up;
        num_up = num_e;
        num_e = tmp;
    }
    
    void rollCommandWithChar(char c) {
        switch (c) {
            case 'E':
                rollToE();
                break;
                
            case 'N':
                rollToN();
                break;
                
            case 'S':
                rollToS();
                break;
                
            case 'W':
                rollToW();
                break;
                
            default:
                break;
        }
    }
};

int main(void) {
    string str;
    getline(cin, str);
    dice x(str);
//    dice x("1 2 4 8 16 32");

    getline(cin, str);
    for(char c : str) {
        x.rollCommandWithChar(c);
//        x.printDevelopment();
//        x.printAllNumber();
    }

    cout << x.getUpperNumber() << endl;


    return 0;
    
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>

using namespace std;

int main(){
    string s;
    cin >> s;
    int count = 0;
    char now = s[0];
    for (int i = 1; i < 4; i++){
        //printf("now : %d, s : %d", now, s[i]);
        if (now == s[i]){
            count++;
        }else{
            count = 0;
            now = s[i];
        }
        if (count >= 2){
        	puts("Yes");
            return 0;
    	}
    }
    puts("No");

    return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll>v(10000005);
	v[0]=0;
	for(ll i=1;i<n+5;i++) v[i]=1000000;
	for(ll i=0;i<n+5;i++){
		for(ll j=0;j<8;j++){
			v[i+pow(9,j)]=min(v[i]+1,v[i+pow(9,j)]);
			v[i+pow(6,j)]=min(v[i]+1,v[i+pow(6,j)]);
		}
		v[i+1]=min(v[i]+1,v[i+1]);
	}
	cout<<v[n]<<endl;
	return 0;
}


Measured memory_bytes: 78336
void main() {
	bool n, w, s, e;
	auto S = rs;
	foreach(c; S) {
		switch(c) {
			case 'N': n = true; break;
			case 'W': w = true; break;
			case 'S': s = true; break;
			case 'E': e = true; break;
			default: assert(0);
		}
	}
	if(n && !s || !n && s || w && !e || !w && e) writeln("No");
	else writeln("Yes");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define ll long long
#define INF 0x7fffffff
#define re register

using namespace std;

int read()
{
	register int x = 0,f = 1;register char ch;
	ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -f;ch = getchar();}
	while(ch <= '9' && ch >= '0'){x = x * 10 + ch - 48;ch = getchar();}
	return x * f;
}

char s[1000005];

long long  k = 100000000000000;

int main()
{
	cin >> s;
	ll l = strlen(s);
	for(ll i = 1; i < l; i++)
	{
		if(s[i] != s[i - 1])
		{
			if(i > l - i)
			{
				k = min(k,i);
//				if(s[i] == '1') s[i] = '0';
//				else s[i] = '1';
			}
			else
			{
				k = min(k,l - i);
//				if(s[i] == '1') s[i] = '0';
//				else s[i] = '1';
			}
//			cout << k << endl;
		}
	}
	cout << min(k,l) << endl;
    return 0;
}


Measured memory_bytes: 384
import Control.Arrow
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Bits

main :: IO ()
main = readLn >>= main'
    where
        main' n = breads >>= print . solve n 

solve :: Int -> [Int] -> Int 
solve n as = count bs bs newVec 
    where
        bs = zip [1..] as

        newVec = 0

        count (x@(ix, vx) : xs) (y@(iy, vy) : ys) vs
            | isSatisfy vy vs = count (x : xs) ys ws
            | otherwise = calc ix iy + count xs (y : ys) us
            where
                us = sub vx vs 
                ws = add vy vs 
        count ((ix, _) : _) _ _ = calc2 ix n

        isSatisfy v vs = v .&. vs == 0 

        calc x y = y - x
        calc2 x y = (v * (v + 1)) `div` 2
            where
                v = y - x + 1

        add = (.|.)
        sub = xor

breads :: IO [Int]
breads = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

Measured memory_bytes: 29052
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main() {
	vector<int> vec(3);
	  cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
	  sort(vec.begin(), vec.end());
	  cout <<(vec.at(2) - vec.at(0)) << endl;
	
}


Measured memory_bytes: 256
import sys
from collections import Counter
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    B = Counter(A)
    cc = 0
    for i in B.keys():
        cc += B[i] * (B[i]-1) // 2
    for a in A:
        print(cc + 1 - B[a])
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 26044
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<LL> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int MO=924844033;
const int g=5;
LL fac[1000010],inv[1000010],ans[1000010];
int n,m,LOG2[1000010],siz[500010],R[1000010],tmp[500010],x,y,hed[500010],too[500010],nxt[500010],nedge;
vec A,B;
LL pw(LL x,LL y){
	LL t=1;
	for (;y;y>>=1){
		if (y&1) t=t*x%MO;
		x=x*x%MO;
	}
	return t;
}
LL C(int x,int y){
	return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void dfs(int x,int l){
	siz[x]=1;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (y==l) continue;
		dfs(y,x);
		siz[x]+=siz[y];
	}
	if (x>1) ++tmp[siz[x]],++tmp[n-siz[x]];
}
void fft(vec &a,int tp){
	int n=SZ(a);
	int L=LOG2[n];
	FOR(i,1,n-1) R[i]=(R[i>>1]>>1)|((i&1)<<(L-1));
	FOR(i,1,n-1) if (i<R[i]) swap(a[i],a[R[i]]);
	for (int i=1;i<n;i<<=1){
		LL wn=pw(g,(tp==1)?((MO-1)/i/2):(MO-1-((MO-1)/i/2)));
		for (int p=i<<1,j=0;j<n;j+=p){
			LL w=1;
			for (int k=0;k<i;++k,w=w*wn%MO){
				LL x=a[j+k],y=a[j+k+i];
				a[j+k]=(x+y*w)%MO,a[j+k+i]=(x-y*w)%MO;
			}
		}
	}
	if (tp==-1){
		LL t=pw(n,MO-2);
		FOR(i,0,n-1) a[i]=a[i]*t%MO;
	}
}
int main(){
	cin>>n;
	fac[0]=1;
	FOR(i,1,1000000) fac[i]=fac[i-1]*i%MO;
	inv[1000000]=pw(fac[1000000],MO-2);
	FORD(i,999999,0) inv[i]=inv[i+1]*(i+1)%MO;
	FOR(i,1,1000000) LOG2[i]=log2(i);
	FOR(i,2,n){
		getint(x),getint(y);
		ae(x,y),ae(y,x);
	}
	dfs(1,0);
	m=1;
	while (m<=n+n) m<<=1;
	A.resize(m);
	B.resize(m);
	FOR(i,0,n) (A[n-i]+=fac[i]*tmp[i])%=MO;
	FOR(i,0,n) B[i]=inv[i];
	fft(A,1);
	fft(B,1);
	FOR(i,0,m-1) A[i]=A[i]*B[i]%MO;
	fft(A,-1);
	FOR(i,1,n) ans[i]=((C(n,i)*n-A[n-i]*inv[i])%MO+MO)%MO;
	FOR(i,1,n) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 54912
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void solve() {
    int n , m;
    cin>>n>>m;
    memset(dp , -1 , sizeof(dp));
    dp[0] = 1;
    for(int i = 0 ; i < m ; i++){
        int ith ;
        cin>>ith;
        dp[ith] = 0;
    }
    if(dp[1] != 0){
        dp[1] = 1;
    }
    if(dp[2] != 0){
        dp[2] = 1;
        if(dp[1] != 0) dp[2] += 1;
    }
    for(int i = 3 ; i<= n ; i++){
        if(dp[i] == -1){
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;
        }
    }
    cout<<dp[n]<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;

int N,M;
priority_queue<int, vector<int>, greater<int> > A;
vector< pair<int,int> > O;

int main() {
    cin>>N>>M;
    for(int i=0;i<N;i++) {
        int a;
        cin>>a;
        A.push(a);
    }

    for(int i=0;i<M;i++) {
        int b,c;
        cin>>b>>c;
        O.push_back(make_pair(c,b));
    }

    sort(O.begin(), O.end());

    long long res = 0;
    for(int i=M-1;i>=0&&!A.empty();i--) {
        int b = O[i].second;
        int c = O[i].first;
        while(!A.empty() && A.top() < c  && b>0) {
            res+=c;
            A.pop();
            b--;
        }
    }

    while(!A.empty()) {
        res+=A.top();
        A.pop();
    }
    cout<<res;
}

Measured memory_bytes: 1784
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,H,W; cin >> N >> H >> W;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    bitset<10000> window;
    rep(i,N) {
        if (i&1) {
            int L = i*W-A[i];
            rep(j,W) {
                window[j+L] = 1;
            }
        } else {
            int L = i*W+A[i];
            rep(j,W) {
                window[j+L] = 1;
            }
        }
    }
    int cnt = 0;
    rep(i,N*W) {
        if (!window[i]) cnt++;
    }
    cout << H*cnt << ln;
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef pair<int, int> P;

const int MAX = 1000010;

int prime[MAX];
bool is_prime[MAX];
int sieve(int n) {
	int p = 0;
	for(int i = 0; i <= n; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++) {
		if(is_prime[i]) {
			prime[p++] = i;
			for(int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

const int CENTER = 1000;
int b[CENTER * 2][CENTER * 2];
bool v[CENTER * 2][CENTER * 2];
int pi[MAX], pj[MAX];
P dp[CENTER * 2][CENTER * 2];

bool comp(P p1, P p2) {
	if(p1.first != p2.first) return p1.first < p2.first;
	return p1.second < p2.second;
}

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

	sieve(1000000);
	int nx = CENTER, ny = CENTER, dirx = 0, diry = 1;
	for(int i = 1; i <= 1000000; i++) {
		b[ny][nx] = i;
		int dlx = diry, dly = -dirx;
		if(b[ny + dly][nx + dlx] == 0) {
			dirx = dlx;
			diry = dly;
		}
		nx += dirx;
		ny += diry;
	}

	int n, m;
	while(cin >> m >> n, n | m) {
		for(int y = 0; y < CENTER * 2; y++) {
			for(int x = 0; x < CENTER * 2; x++) {
				dp[y][x] = make_pair(0, 0);
				v[y][x] = false;
				if(b[y][x] == n) v[y][x] = true;
			}
		}

		P ans = make_pair(0, 0);
		for(int y = 0; y < CENTER * 2; y++) {
			for(int x = 0; x < CENTER * 2; x++) if(v[y][x]) {
				if(is_prime[b[y][x]]) {
					dp[y][x] = make_pair(dp[y][x].first + 1, b[y][x]);
				}

				for(int dx = -1; dx <= 1; dx++) {
					if(b[y + 1][x + dx] != 0 && b[y + 1][x + dx] <= m) {
						v[y + 1][x + dx] = true;
						dp[y + 1][x + dx] = max(dp[y + 1][x + dx], dp[y][x]);
					}
				}
				ans = max(ans, dp[y][x]);
			}
		}
		if(ans.first) {
			cout << ans.first << " " << ans.second << endl;
		}
		else {
			cout << "0 0" << endl;
		}
	}
}

Measured memory_bytes: 56488
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def is_even(s):
    slen = len(s)
    halflen = slen//2
    for i in range(halflen):
        if s[i] != s[i+halflen]:
            return False
    
    return True

def solve():
    s = input()
    slen = len(s)
    for i in range(slen-2, 0, -2):
        if is_even(s[0:i]):
            print(i)
            break




solve()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    string s;
    int d[100000];
    int n,q,a,b;
    cin>>n>>q;
    cin>>s;
    for(int i=0;i<=n+1;i++){
        d[i]=0;
    }

    for(int i = 1; i <= n; i++){
        if(s[i-1]=='A'&&s[i]=='C'){
             
             d[i]=1;
             
        }
    }
    for(int i = 1 ;i <= n; i++){
        d[i]+=d[i-1];
    }
    
    for(int i=1 ;i <= q; i++){
        cin>>a>>b;
        cout<<d[b-1]-d[a-1]<<endl; 
    }
   
    
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    vector<int> w;
    w.reserve(20010);
    int size = s.size();
    bool pickable = false;
    ll k=0;
    for(int i=0;i<size;i++){
        if(s[i]=='B')pickable=true;
        if(pickable){
            if(s[i]=='W')w.push_back(i);
        }else{
            if(s[i]=='W')k++;
        }
    }
    int wsize = w.size();
    ll ans=0;
    for(int i=0;i<wsize;i++){
        ans+=w[i]-k;
        k++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1252
// 長方形の中に円が含まれるかを判定するプログラムを作成してください。
// 次のように、長方形は左下の頂点を原点とし、右上の頂点の座標 (W,H)が与えられます。
// また、円はその中心の座標 (x,y)と半径 rで与えられます。
// 【入力】
// ５つの整数 W、H、x、y、rが空白区切りで１行に与えられます。
// 【出力】
// 円が長方形の内部に含まれるなら Yes と、
// 一部でもはみ出るならば No と１行に出力してください。
// 【制約】
// −100≤x,y≤100
// 0<W,H,r≤100
// 【例】
// 入力：5 4 2 2 1、出力：Yes
// 入力：5 4 2 4 1、出力：No
#include<iostream>
using namespace std;

int main( void) {
  int W, H;
  int x, y, r;

  cin >> W >> H >> x >> y >> r;

  if ( y - r < 0 || y + r > H) cout << "No" << endl;
  else if ( x - r < 0 || x + r > W) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc092/tasks/abc092_b

int main() {
    int N; cin >> N;
    int D, X; cin >> D >> X;

    int A;
    int sum=0;
    REP(i, N) {
        cin >> A;
        FOR(j, 1, D+1) {
            if ((j - 1) % A == 0) sum++;
        }
    }

    cout << sum + X << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    ll n,m;
    cin >> n >> m;
    cout << (1900*m+100*(n-m))*pow(2,m) << endl;
    return 0;
}


Measured memory_bytes: 256