akhauriyash/Code-Regression huggingface dataset:
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int h,w,K;
   cin >> h >> w >> K;
   vector<vector<char>> A(h,vector<char>(w));
   f(i,0,h){
      f(j,0,w){
         cin >> A[i][j];
      }
   }
   int ans = 0;
   f(i,0,(1<<h)){
      f(j,0,(1<<w)){
         vector<vector<char>> B = A;
         f(k,0,h){
            if((1<<k) & i){
               f(l,0,w){
                  B[k][l] = '?';
               }
            }
         }
         f(k,0,w){
            if((1<<k) & j){
               f(l,0,h){
                  B[l][k] = '?';
               }
            }
         }
         int c = 0;
         f(i,0,h){
            f(j,0,w){
               c += (B[i][j] == '#');
            }
         }
         ans += (c == K);
      }
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 3648
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) {
        int n = 0;
        int[] arr = null;
        try (Scanner scanner = new Scanner(System.in)) {
            n = scanner.nextInt();
            arr = new int[n];
            for(int i = 0; i < n ;i++) {
                arr[i] = scanner.nextInt();
            }
        }
        
        long[][] dp = new long[n+1][n+1];
        for(int l = n - 1; l >= 0; l--) {
            for(int r = l; r < n; r++) {
                if(l == r)
                    dp[l][r] = arr[l];
                else
                    dp[l][r] = Math.max(arr[l] - dp[l+1][r]
                                    , arr[r] - dp[l][r-1]);
            }
        }
        
        
        // for(int[]d :dp) 
        //     System.out.println(Arrays.toString(d));
        
        System.out.println(dp[0][n- 1]);
        
    }
    
}

Measured memory_bytes: 129784
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int LIM = (int)1e3;

int A, B;
ll AB;

ll f(ll k, ll x) {
  return x * (k - x);
}

bool check(ll l1, ll r1, ll l2, ll r2) {
  if (l1 > r1 || l2 > r2) {
    return 1;
  }

  assert(r1 - l1 == r2 - l2);
  
  // 0 <= i <= X
  // i * (Y - i) -> max
  ll L = 0, R = r1 - l1, k = r2 - l1;
  ll lim = AB - l1 * r2;
  ll mx = f(k, L);
  mx = max(mx, f(k, R));
  
  for (ll off = -3; off <= 3; ++off) {
    ll pt = k / 2 + off;
    
    if (L <= pt && pt <= R) {
      mx = max(mx, f(k, pt));
    }
  }
  
  return mx < lim;
}

bool check(ll x) {
  if (x < A) {
    return check(1, x, 1, x);
  }
  
  if (x < B) {
    return check(A + 1, x + 1, 1, x - A + 1) && check(1, A - 1, x - A + 2, x);
  }
  
  // x > A && x > B
  // [1, 2, ..., A - 1, A + 1, ..., x + 1]
  // [1, 2, ..., B - 1, B + 1, ..., x + 1]
  
  ll lenA1 = A - 1, lenA2 = x - A + 1;
  ll lenB1 = B - 1, lenB2 = x - B + 1;
  bool ret = 1;
  
  if (lenA2 <= lenB1) {
    ret &= check(A + 1, x + 1, 1, lenA2);
    ret &= check(1, lenB2, B + 1, x + 1);
    ret &= check(lenB2 + 1, A - 1, lenA2 + 1, B - 1);
  }
  else {
    ret &= check(1, B - 1, x + 2 - lenB1, x + 1);
    ret &= check(1, A - 1, x + 2 - lenA1, x + 1);
    ret &= check(A + 1, x + 1 - lenB1, B + 1, x + 1 - lenA1);
  }
  
  return ret;
}

void solve() {
  scanf("%d %d", &A, &B);
  
  if (A > B) {
    swap(A, B);
  }
  
  AB = A * 1ll * B;
  ll l = 1, r = (ll)2e9, ans = 0;
  
  while (l <= r) {
    ll mid = (l + r) >> 1;
    
    if (check(mid)) {
      l = mid + 1;
      ans = mid;
    }
    else {
      r = mid - 1;
    }
  }
  
  printf("%lld\n", ans);
}

int main() {
  int tt;
  scanf("%d", &tt);
  
  while (tt--) {
    solve();
  }

  return 0;
}



Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<string>
using namespace std;
using ll = long long int;

const ll ALP = 26;
int main(){
    ll n;
    cin >> n;
    vector<char> Name;
    ll num = 26;
    ll bef = 0;
    ll tot = 26;
    ll e = 1;
    while(num < n){
        bef = num;
        num = bef + tot * ALP;
        tot *= ALP;
        e++;
    }
    n -= bef+1;
    ll d = 1;
    for(int i = 0; i < e; i++){
        ll k = n / d;
        k %= ALP;
        char s = 'a' + k;
        Name.push_back(s);
        d *= ALP;
    }
    for(int i = e-1; i >= 0; i--){
        cout << Name[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3048
#!/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

k = int(input())
a ,b = map(int,input().split())
for i in range(a,b+1):
  if i % k == 0:
    print("OK")
    exit()
print("NG")

Measured memory_bytes: 9536
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,m,n;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	m=p-c;
	n=d*m;
	if(p<=c){
		y=b;
	}
	else if(c<=p){
		y=b+n;
	}
	if(x<=y){
		printf("%d\n",x);
	}
	else if(y<=x){
		printf("%d\n",y);
	}
	return 0;
}


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

int a,b,k,n,j,aa,bb;
int ans[210],f_ans[210];

int main() {
	cin >> a >> b >> k;
	aa = a;
	bb = b;
	for(int i = 0; i < k; i++){
		ans[i] = a;
		a++;
	}
	
	for(int i = 0; i < k; i++){
		ans[k+i] = b;
		b--;
	}
	n = 2*k;
	sort(ans,ans+n);
	
	int d = bb-aa;
	if(d >= 2*k){
		for(int i = 0; i < n; i++) cout << ans[i] << endl;
	}
	if(d < 2*k)
	{
		while(aa-1 != bb)
		{
		cout << aa << endl;
		aa++;
		}
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int INF=1e9;
int n;
int t[301][301];
int u[301][301];

int sum(int ai,int aj,int bi,int bj){
  ai--,aj--;
  return u[bi][bj]-u[ai][bj]-u[bi][aj]+u[ai][aj];
}

int calc(int l,int r){

  int A[301]={};
  int B[301]={};
  for(int i=1;i<=n;i++){
    A[i]=t[l][i];
    if(l<r)A[i]+=t[r][i];
    if(l+1<r)B[i]=sum(l+1,i,r-1,i);
  }
  int res=-INF;
  int dp[301]={};
  for(int i=1;i<=n;i++){
    dp[i]=A[i]+B[i];
    if(i>1)dp[i]=max(dp[i],dp[i-1]+A[i]);
    res=max(res,dp[i-1]+A[i]+B[i]);
  }
  return res;
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cin>>t[i][j];
      u[i][j]=t[i][j]+u[i-1][j]+u[i][j-1]-u[i-1][j-1];
    }
  }
  int ans=-INF;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      ans=max(ans,calc(i,j));
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1872
#include <iostream>

using namespace std;

int n, q, tmp, answer = 0;
int s[100100];
int c = 0;

bool binarySearch(int key){
    int left = 0, right = n, mid;
    while(left < right){
        mid = (left + right) / 2;
        if(s[mid] == key){
            return true;
        }else if(key > s[mid]) left = mid + 1;
        else right = mid;
    }
    return false;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i]; 
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> tmp;
        if(binarySearch(tmp)) answer++;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

typedef long long ll;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

string s;
void solve(){
  for(string::iterator it=s.begin();it!=s.end();it++){
    cout<<(char)(((*it)-'A'-3+26)%26+'A');
  }
  cout<<endl;
}
int main(){
  cin >> s;
  solve();
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        int odd = 0;
        int two = 0;
        int four = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] % 2 == 1) {
                odd += 1;
            }
            if (a[i] % 4 == 0) {
                four += 1;
            } else if (a[i] % 2 == 0) {
                two += 1;
            }
        }
        if (odd == 0) {
            System.out.println("Yes");
            return;
        }
        if (two == 0) {
            if (odd == four + 1) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            if (odd <= four) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 50328
function Main(input) {
	input = input.split("\n");
	tmp = input[1].split(" ");
	var a = parseInt(input[0], 10);
  	var p = 0;
  	for(var i = 1;i<a+1;i++)
    {
		var tmp = input[i].split(" ");
		p += tmp[0] * (tmp[1]=="JPY"?1:380000);
    }
	console.log(p);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1e18+7;
ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(long long i = a;i < b;i++)
#define rf(i,a,b) for(long long i=a;i>=b;i--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define w(t) while(t--)
#define c(n); cin>>n;
#define p(n) cout<<n;
#define pl(n) cout<<n<<endl;
#define ps(n); cout<<n<<" ";
#define F first
#define S second
#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()
#define ull unsigned long long
#define vll vector<ll>
#define vii vector<ii>
#define mkp make_pair
#define ld long double
#define arrin(a,n) f(i,0,n){cin>>a[i];}
#define arrout(a,n) f(i,0,n){cout<<a[i]<<" ";}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define PI (2*acos(0))
const long long N = 1e6+5;
vll visit,dist,taken;
vector<vll> adj;
vector<vii> adj2;
priority_queue<ii,vector<ii>, greater<ii> > pq;
ll bit[N]={0};
ll siz;
ll res = 0;
ll lcm(ll a,ll b){return (a * b) / __gcd(a,b);}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll power(ll a,ll b){if(b == 0)return 1;if(b == 1)return a;ll ans = power(a,b/2) % MOD;ans *= ans;ans %= MOD;if(b % 2 == 1)ans *= a;return ans%MOD;}
ll inverse(ll x){x%=MOD;return power(x,MOD-2);}
void BITup(ll k, ll x){while(k <= siz){bit[k]+=x;k += k & -k;}}
ll BITq(ll k){ll s=0;while(k>=1){s+=bit[k];k -= k &-k;}return s;}
struct node{ll lazy,val;}seg[4000000];
struct point{ll x,y;};
void dfs(ll v){visit[v] = 1;for(auto x:adj[v]){if(!visit[x])dfs(x);}}
void bfs(ll s){visit[s] = 1;queue<ll>q;q.push(s);while(!q.empty()){ll u = q.front();ps(u);q.pop();for(auto x:adj[u]){if(!visit[x]){visit[x] = 1;q.push(x);}}}}
void dijkstra(ll s){pq.push(ii(0,s));dist[s] = 0;while(!pq.empty()){ii f = pq.top();pq.pop();ll w = f.F;ll u = f.S;for(auto v:adj2[u]){if(dist[v.F] == INF){dist[v.F] = dist[u] + v.S;pq.push(ii(dist[v.F],v.F));}else if(dist[v.F] != dist[u] + v.S){cout<<"No";exit(0);}}}}
void prim(ll edge) {taken[edge] = 1;for(auto v:adj2[edge]) {if (taken[v.first]==0)pq.push(ii(v.second, v.first));}}
ll mst(ll s){taken.assign(N, 0);prim(s);ll cost = 0;while(!pq.empty()){ii front = pq.top();pq.pop();ll w = front.first;ll u = front.second;if(taken[u]==0)cost += w;prim(u);}return cost;}
void YESNO(ll a){if(a){pl("Yes");}else{pl("No");}}
void filesin(void){freopen("tracing.in","r",stdin);}
void filesout(void){freopen("tracing.out","w",stdout);}
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///ΑτΚοδερ ;)
int main(void){
    fastio;
    ll n,m;
    cin>>n>>m;
    ll a,b,w;
    adj2.assign(n+5,vii());
    f(i,0,m){
        cin>>a>>b>>w;
        adj2[a].pb(ii(b,w));
        adj2[b].pb(ii(a,-w));
    }
    dist.assign(n+5,INF);
    f(i,1,n+1){
        if(dist[i] == INF){
            dijkstra(i);
        }
    }
    YESNO(1);
}


Measured memory_bytes: 15856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (ll i = ll(a); i < ll(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, x, m;
    cin, n, x, m;
    const int sz = 100000;
    vector<ll> a(sz, 0), b(sz, 0);
    REP(i, 0, sz) {
        a[i] = (i * i) % m;
        b[i] = i;
    }
    ll sum = 0;
    while (n) {
        if (n & 1) {
            sum += b[x];
            x = a[x];
        }
        vector<ll> c(sz, 0), d(sz, 0);
        REP(i, 0, sz) {
            c[i] = a[a[i]];
            d[i] = b[i] + b[a[i]];
        }
        a = c;
        b = d;
        n >>= 1;
    }
    print(sum);
    return 0;
}


Measured memory_bytes: 6344
import numpy as np
bingo=np.array([list(map(int,input().split())) for _ in range(3)])
n=int(input())
call=[int(input()) for _ in range(n)]
#k=[list(map(int,input().split())) for _ in range(n)]
#bingo=[[] for _ in range(100)]
for i in range(3):
    f=True
    yoko=bingo[i]
    for each in yoko:
        if not each in call:
            f=False
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    f=True
    tate=bingo[:,i]
    for each in tate:
        if not each in call:
            f=False
            break

    if f:
        print("Yes")
        exit()
hoge=[]
huga=[]
for i in range(3):
    for j in range(3):
        if i==j:
            hoge.append(bingo[i][j])
        if i==2-j:
            huga.append(bingo[i][j])
f=True
for each in hoge:
    if not each in call:
        f=False
if f:
    print("Yes")
    exit()
for each in huga:
    if not each in call:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 12436
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 


pair<int, int> operator+(const pair<int, int> &lhs, const pair<int, int> &rhs)
{
    pair<int, int> p = { lhs.first + rhs.first, lhs.second + rhs.second };
    return p;
}

bool operator==(const pair<int, int> &lhs, const pair<int, int> &rhs)
{
    return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool is_in_field(int col, int row, const pair<int, int> &point)
{
    const int c = point.second;
    const int r = point.first;
    return (0 <= c && c < col) && (0 <= r && r < row); 
}


int solve(int col, int row, vector<string> field, const pair<int, int> &start, const pair<int, int> &goal){

  
    // 各座標の訪問履歴
    vector<vector<int>> memo;
    for(int i=0;i<row;i++){
      vector<int> v(col, 0);
      memo.push_back(v);
    }

    //移動方向
    const pair<int, int> points[] = {
      {-1, 0}, {1, 0}, {0, -1}, {0, 1}
    };

    //スタートのマスをキューに格納
    queue<pair<int, int>> q;
    q.push(start);

    while(!q.empty()){

      //キューの先頭から1マス取得する
      pair<int, int> cur = q.front();
      q.pop();

      //取り出したマスがゴールなら終了
      if(cur == goal){
        return memo[cur.first][cur.second];
      }

      for(const auto &point : points){

        //curの上下左右いずれかに移動
        pair<int, int> next = cur + point;

        //移動先のマスが迷路外でないことを確認
        if(is_in_field(col, row, next)){

          const char c = field[next.first][next.second];
          
          //移動先のマスが道であることを確認
          if(c == '.'){
            
            //移動先のマスが未訪問であることを確認
            if(memo[next.first][next.second] == 0){
              q.push(next);
              memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
            }
          }
        }
      }
    }
    return -1;
}


int main(void){

    int row, col;
    cin>>row>>col;

    vector<string> s(row);
    for(int i=0;i<row;i++){
      string x;
      cin>>x;
      s[i] = x;
    }

    pair<int, int> start, goal;
    int ans, ANS = 0;

    for(int i=0;i<row*col;i++){
      start = make_pair(i/col, i%col);
     // cout<<start.first<<", "<<start.second<<" ";

      if(s[start.first][start.second] == '.'){
        for(int j=0;j<row*col;j++){
          goal = make_pair(j/col, j%col);
         // cout<<goal.first<<", "<<goal.second<<endl;
          if(s[goal.first][goal.second] == '.'){
            ans = solve(col, row, s, start, goal);
            //cout<<ans<<endl;
            ANS = max(ans, ANS);
          }
        }
      }
    }

    // start = make_pair(0, 0);
    // goal = make_pair(2,2);
    // cout<<solve(col, row, s, start, goal)<<endl;
    cout<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    cnt = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cnt += 1
            if cnt == i:
                ans = max(ans, i)
                break
        else:
            ans = max(ans, cnt)
            cnt = 0
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 43000
import bisect
from itertools import chain, combinations
from math import ceil, floor, sqrt

def powerset(iterable):
    s = list(iterable)
    # return chain.from_iterable(combinations(s, r) for r in range(len(s)+1, -1, -1))
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))

N = int(input())
lN = [n for n in range(N)]
lxy = [[] for _ in range(N)]
for i in range(N):
    ai = int(input())
    for _ in range(ai):
        xij, yij = list(map(int, input().split()))
        xij -= 1
        lxy[i].append((xij, yij))

# iter all of powersets inverse
ans = 0
for s in powerset(lN):
    # print(s) # assumed polite
    flag = True
    tmp = len(s)
    for elem in s:
        # print(lxy[elem])
        for xi, yi in lxy[elem]:
            if xi in s and yi == 0 or xi not in s and yi == 1:
                # if xi in s != (yi == 0):
                # print(elem, xi, yi)
                flag = False
    if flag:
        ans = max(ans, tmp)

print(ans)

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

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

using namespace std;

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

  ll fill=1000000000;
  if(s==fill)fill--;
  rep(i,n){
    if(i<k) cout<<s;
    else cout<<fixed<<setprecision(10)<<fill;
    if(i<n-1)cout<<' ';
  }

  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

void prime_factorize(uint64_t x, uint64_t *n, uint64_t **p, uint64_t **q)
{
    uint64_t s;
    for(s=0; s*s<x; s++);
    *p = malloc(sizeof(uint64_t) * s);
    *q = malloc(sizeof(uint64_t) * s);

    int cps = 0;

    for(int i=2; i<=s; i++){
        int qi;
        for(qi=0; x%i==0; x/=i, qi++);
        if(qi!=0){
            (*p)[cps] = i;
            (*q)[cps] = qi;
            cps++;
        }
    }
    if(x!=1){
        (*p)[cps] = x;
        (*q)[cps] = 1;
        cps++;
    } 
    *n = cps;
}

uint64_t gcd(uint64_t x, uint64_t y)
{
    uint64_t z;
    while(y != 0){
        z = x % y;
        x = y;
        y = z;
    }
    return x;
}

uint64_t np(uint64_t x)
{
    uint64_t n, *p, *q;
    prime_factorize(x, &n, &p, &q);
    return n;
}

int main()
{
    uint64_t A, B;
    scanf("%"PRIu64"%"PRIu64, &A, &B);

    uint64_t c = gcd(A, B);

    printf("%"PRIu64"\n", np(c)+1);
    return 0;
}




Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>

char c[500000];
int a[500000],b[500000];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
		scanf("%c",&c[i]);
	a[0]=0;b[0]=0;
	for(int i=1;i<=n;i++){
		a[i]=a[i-1];
		if(c[i-1]=='E')a[i]++;
	}
	for(int i=n;i>=1;i--){
		b[i]=b[i+1];
		if(c[i+1]=='W')b[i]++;
	}
	int max=a[1]+b[1]+1;
	for(int i=2;i<=n;i++)
		if(max<a[i]+b[i]+1)max=a[i]+b[i]+1;
	printf("%d",n-max);
}

Measured memory_bytes: 3712
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 081 B "Shift only"
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int[] A = in.nextIntArray(N);

		int ans = Integer.MAX_VALUE;
		for (int Ai : A) {
			int count = 0;
			while (Ai > 1) {
				if (Ai % 2 == 0) {
					Ai /= 2;
					count++;
				} else {
					break;
				}
			}
			ans = Math.min(ans, count);
		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)

const ll N = 123456;
const ll mod = 1e9 + 7;
const ld eps = 1e-5;

ll a[N];

ll dp[123][N];

ll pre[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cout << fixed;

    int n , k;

    cin >> n >> k;

    rep(i , 1 , n) cin >> a[i];

    rep(i , 1 , n) {
        dp[i][0] = 1;
    }

    rep(j , 0 , k) {
        if(j <= a[1]) {
            dp[1][j] = 1;
            pre[j] = 1;
        }
    }

    rep(i , 1 , k) {
        pre[i] += pre[i - 1];
        pre[i] %= mod;
    }

    
    rep(i , 2 , n) {
        rep(j , 1 , k) {
            int end = max(0 , (int) j - (int)a[i]);
            
            if(end == 0) {
                dp[i][j] = pre[j];
                dp[i][j] %= mod;
            }
            else {
                dp[i][j] = pre[j] - pre[end - 1];
                dp[i][j] %= mod;
                if(dp[i][j] < 0) dp[i][j] += mod;
            }
        }

        // copy the value to prefix array

        rep(j , 0 , k) {
            pre[j] = dp[i][j];
            pre[j] %= mod;
        }

        rep(j , 1 , k) {
            pre[j] += pre[j - 1];
            pre[j] %= mod;
        }
    }

    cout << dp[n][k] << endl;
    return 0;
}


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

vector<int> pos(4,-1);
string s;
string ans;
int n;

template <class T>
void chmin(T &x, T y)
{
    x=min(x,y);
}

string parse()
{
    string ret;
    vector<string> tmp;
    int add=0;
    for(char ch: s)
    {
        if(ch=='[')
        {
            tmp.emplace_back("");
        }
        else if(ch==']')
        {
            string t=tmp.back();
            reverse(begin(t),end(t));
            tmp.pop_back();
            if(tmp.empty())
            {
                ret+=t;
            }
            else
            {
                tmp.back()+=t;
            }
        }
        else if(ch=='+')
        {
            add++;
        }
        else if(ch=='-')
        {
            add--;
        }
        else
        {
            int dif=(ch-'A'+add)%26;
            if(dif<0) dif+=26;
            ch='A'+dif;
            add=0;
            if(tmp.empty()) ret+=ch;
            else tmp.back()+=ch;
        }
    }
    return ret;
}

void dfs(int step)
{
    if(pos[step]<0) chmin(ans,parse());
    else
    {
        s[pos[step]]='A';
        for(char &ch=s[pos[step]]; ch<='Z'; ch++)
        {
            dfs(step+1);
        }
    }
}

main()
{
    for(;;)
    {
        cin>>s;
        if(s==".") break;
        ans=string(1,'Z'+1);
        n=s.size();

        for(int i=0,j=0; i<n; ++i)
        {
            if(s[i]=='?')
            {
                pos[j++]=i;
            }
        }

        dfs(0);
        cout << ans << "\n";

        pos=vector<int>(4,-1);
    }
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

vector<pair<int, int>> g[maxn];
int dist[maxn], parent[maxn], n, m, src;


void dijkstra(int src) {
    memset(dist, 63, sizeof dist);
    int inf = dist[0];
    dist[src] = 0;
    set<pair<int, int>> q;

//    dist , node
    q.insert({0, src});
    while (!q.empty()) {
        int len = q.begin()->first;
        int node = q.begin()->second;

        q.erase({len, node});
        for (auto x: g[node]) {
            if (dist[x.first] > dist[node] + x.second) {
                q.erase({dist[x.first], x.first});
                parent[x.first] = node;
                dist[x.first] = x.second + dist[node];
                q.insert({dist[x.first], x.first});
            }
        }
    }
    for (int i = 0; i < n; i++)
        if (dist[i] == inf)
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
}

void solve() {
    cin >> n >> m >> src;

    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;

        g[a].push_back({b, c});
    }
    dijkstra(src);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


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

int main()
{
	int a;
	cin >> a;
	if (a % 10 == 9) {
		cout << "Yes" << endl;
	}
	else if (a / 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}


Measured memory_bytes: 256
import itertools
n,m,q=map(int,input().split())
Se=[]
for i in range(q):
    Se.append(tuple(map(int,input().split())))
#print(Se)
integerset={i for i in range(1,m+1)}
#print(integerset)
everyset=itertools.combinations_with_replacement(integerset,n)
max=0
for v in everyset:
  #  print(v)
 #   print(len(v))
    sum=0
    for i in range(len(Se)):
        if v[Se[i][1]-1]-v[Se[i][0]-1]==Se[i][2]:
            sum+=Se[i][3]
   # print(sum)
    if sum>max:
        max=sum
print(max)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }
int mod(int a) { return (a % MOD + MOD) % MOD; }

/////////////////////////////////////////////////////////////////////

const int N = 1e4 + 1;

bool marked[N];

int f(int x) { 
    return (x % 2 ? 3 * x + 1 : x / 2);
}

int32_t main() {

    sync;

    int s; cin >> s;

    marked[s] = true;
    for(int i = 2; i <= 1e6; i++) {
        s = f(s);
        if (marked[s]) die(i);
        else marked[s] = true;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define Int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
int mod = (int)1e9 + 7 ;
/************************************************************/
#define popcount __builtin_popcount
bool isSet( int x, int n ){
	return x & ( 1 << n ) ;
}

signed main(){
	int N ; cin >> N ;
	let pos = matrix<int>( N, N, false ) ;
	for( int i = 0 ; i < N ; i++ ){
		for( int j = 0 ; j < N ; j++ ){
			cin >> pos[i][j] ;
		}
	}
	vector<int> dp( 1 << N, 0 ) ;
	dp[0] = 1 ;
	for( int i = 0 ; i < ( 1 << N ) - 1 ; i++ ){
		int a = popcount( i ) ;
		for( int j = 0 ; j < N ; j++ ){
			if( pos[a][j] & !isSet( i, j ) ){
				int m2 = i | ( 1 << j ) ;
				( dp[m2] += dp[i] ) %= mod ;
			}
		}
	}
	cout << dp[ ( 1 << N ) - 1 ] ;
	return 0 ;
}

Measured memory_bytes: 11420
n, k = gets.chomp.split.map(&:to_i)
buildings = gets.chomp.split.map(&:to_i)

def main(n, k, buildings)
  min = Float::INFINITY
  (0..2**n-1).each do |n_ten|
    n_two = n_ten.to_s(2).rjust(n, '0')
    extending = n_two.chars.map(&:to_i)
    next if extending.count { |flag| flag == 1 } < k

    amount = 0

    dupped_buildings = buildings.dup
    current_max = 0
    dupped_buildings.each.with_index do |building, index| 
      if index == 0
        current_max = [building, current_max].max
        next building 
      end

      if extending[index] == 0
        current_max = [building, current_max].max
        next building 
      end

      if current_max < dupped_buildings[index]
        current_max = [dupped_buildings[index], current_max].max
        next dupped_buildings[index]
      else
        diff = (current_max - dupped_buildings[index]) + 1
        dupped_buildings[index] += diff
        amount += diff
        current_max = [dupped_buildings[index], current_max].max
        next dupped_buildings[index]
      end
    end

    
    amount = amount

    if amount < min
      min = amount 
    end
  end
  min 
end

puts main(n, k, buildings)

Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
#define maxn 200100
#define lc (o<<1)
#define rc ((o<<1)|1)
#define mid ((l+r)>>1)
#define ll long long
int n,q,a,b;
int x[maxn];
ll mn[maxn<<2],add[maxn<<2];
struct Seg
{
    ll mn[maxn<<2],add[maxn<<2];
    void up(int o)
    {
        mn[o]=min(mn[lc],mn[rc]);
    }
    void build(int o,int l,int r,int sgn)
    {
        add[o]=0;
        if(l==r)
        {
            mn[o]=min(abs(a-l)+abs(b-x[1]),abs(a-x[1])+abs(b-l))+sgn*l;
            return;
        }
        build(lc,l,mid,sgn);
        build(rc,mid+1,r,sgn);
        up(o);
    }
    void down(int o)
    {
        if(add[o]!=0)
        {
            add[lc]+=add[o];
            mn[lc]+=add[o];
            add[rc]+=add[o];
            mn[rc]+=add[o];
            add[o]=0;
        }
    }
    void update(int o,int l,int r,int y1,int y2,ll val)
    {
        if(y1<=l&&y2>=r)
        {
            add[o]+=val;
            mn[o]+=val;
            return;
        }
        down(o);
        if(y1<=mid) update(lc,l,mid,y1,y2,val);
        if(y2>mid) update(rc,mid+1,r,y1,y2,val);
        up(o);
    }
    void Set(int o,int l,int r,int y1,ll val)
    {
        if(l==r)
        {
            mn[o]=min(mn[o],val);
            return;
        }
        down(o);
        if(y1<=mid) Set(lc,l,mid,y1,val);
        else Set(rc,mid+1,r,y1,val);
        up(o);
    }
    ll query(int o,int l,int r,int y1,int y2)
    {
        if(y1<=l&&y2>=r) return mn[o];
        down(o);
        if(y1<=mid&&y2>mid) return min(query(lc,l,mid,y1,y2),query(rc,mid+1,r,y1,y2));
        else if(y1<=mid) return query(lc,l,mid,y1,y2);
        else return query(rc,mid+1,r,y1,y2);
    }
}seg[3];
int main()
{
    while(~scanf("%d%d%d%d",&n,&q,&a,&b))
    {
        for(int i=1;i<=q;++i) scanf("%d",&x[i]);
        seg[0].build(1,1,n,0);
        seg[1].build(1,1,n,-1);
        seg[2].build(1,1,n,1);
        ll lx1,lx2,lx3;
        //puts("yes");
        for(int i=2;i<=q;++i)
        {
            //puts("check1");
            seg[0].update(1,1,n,1,n,abs(x[i]-x[i-1]));
            //puts("check2");
            lx1=seg[1].query(1,1,n,1,x[i])+x[i];
            //puts("check3");
            lx2=seg[2].query(1,1,n,x[i],n)-x[i];
            //puts("check4");
            seg[0].Set(1,1,n,x[i-1],min(lx1,lx2));
            //puts("check5");
            seg[1].update(1,1,n,1,n,abs(x[i]-x[i-1]));
            //puts("check6");
            seg[2].update(1,1,n,1,n,abs(x[i]-x[i-1]));
            //puts("check7");
            lx3=seg[0].query(1,1,n,x[i-1],x[i-1]);
            //puts("check8");
            seg[1].Set(1,1,n,x[i-1],lx3-x[i-1]);
            //puts("check9");
            seg[2].Set(1,1,n,x[i-1],lx3+x[i-1]);
            //puts("check10");
        }
        cout<<seg[0].mn[1]<<"\n";
    }
    return 0;
}


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

using namespace std;

pair <int, int> a[10];

double dist(pair<int, int> x, pair<int, int> y) {
	int dx = x.first - y.first;
	int dy = x.second - y.second;
	return sqrt(dx * dx + dy * dy);
}

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
	
	int fact = 1;
	
	for (int i = 1; i <= n; i++) fact *= i;
	
	int mul = fact;
	mul *= n - 1;
	mul /= n * (n - 1) / 2;
	
	double res = 0;
	
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			res += dist(a[i], a[j]);
		}
	}
	
	res *= mul;
	res /= fact;
	
	printf("%.12lf\n", res);
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String slims = in.next();
        Deque<Character> stack = new ArrayDeque<>();
        for (char c: slims.toCharArray()) {
            if (stack.isEmpty() || stack.peek() != c) {
                stack.push(c);
            }
        }
        System.out.println(stack.size());
        in.close();
    }
}

Measured memory_bytes: 26816
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n,m;
  cin >> n >> m;
  priority_queue<I> q;
  REP(i,n){
    I j;
    cin >> j;
    q.push(j);
  }
  REP(i,m){
    I j = q.top();q.pop();
    q.push(j/2);
  }
  I t=0;
  REP(i,n){
    I j = q.top();q.pop();
    t += j;
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 1400
//     自己选择的路，跪着也要走完。朋友们，虽然这个世界日益浮躁起来，只
// 要能够为了当时纯粹的梦想和感动坚持努力下去，不管其它人怎么样，我们也
// 能够保持自己的本色走下去。                               ——陈立杰

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

typedef signed char          int8;
typedef unsigned char       uint8;
typedef short                int16;
typedef unsigned short      uint16;
typedef int                  int32;
typedef unsigned            uint32;
typedef long long            int64;
typedef unsigned long long  uint64;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
       return init * flag;
}

template <typename Int>
inline Int read(char &c)       
{
    Int flag = 1;
    c = getchar();
    while ((!isdigit(c)) && c != '-' && c != EOF) c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
       return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}

#define int int64

int n;
int a[100007];
int ans = 0;
int l[100007], r[100007];

signed main() {
    n = read<int>() + 1;
    for (int i = 1; i <= n; i++) a[i] = read<int>();
    for (int i = n; i >= 1; i--) {
        l[i] = ((l[i + 1] + 1) >> 1) + a[i];
        r[i] = r[i + 1] + a[i];
    }
    if (l[1] > 1) {
        puts("-1");
        return 0;
    }
    for (int i = 1, cnt = 1; i <= n; i++) {
        if (i != 1) cnt = min(cnt << 1, r[i]);
        ans += cnt;
        cnt -= a[i];
        // printf("cnt = %lld\n", cnt);
    }
    write(ans, 10);
    return 0;
}
/*
r   = {4, 4, 3, 2}
cnt = {1, 2, 3, 2}
*/
// Create File Date : 2020-05-30

Measured memory_bytes: 5972
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int MOD = 1000000007;
template<typename T,T uku>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
};

//INSERT ABOVE HERE
const int MAX = 3030;
using M = Mint<int, 0>;
M po[MAX*MAX];
M pp[MAX];
M dp[MAX][MAX];

M fact[MAX],finv[MAX];
M C(int n,int k){
  if(n<k||k<0) return M(0);
  return fact[n]*finv[n-k]*finv[k];
}
M P(int n,int k){
  if(n<k||k<0) return M(0);
  return fact[n]*finv[n-k];
}
signed main(){
  int n;
  cin>>n>>MOD;

  po[0]=1;
  for(int i=1;i<MAX*MAX;i++) po[i]=po[i-1]+po[i-1];
  
  pp[0]=2;
  for(int i=1;i<MAX;i++) pp[i]=pp[i-1]*pp[i-1];

  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      dp[i][j]=0;

  fact[0]=1;
  for(int i=1;i<=n;i++) fact[i]=fact[i-1]*M(i);
  finv[n]=M(1)/fact[n];
  for(int i=n;i>=1;i--) finv[i-1]=finv[i]*M(i);
  
  dp[0][0]=1;
  for(int i=0;i+1<MAX;i++){
    for(int j=0;j+1<MAX;j++){
      dp[i+1][j+1]+=dp[i][j];
      dp[i][j+1]+=dp[i][j]*M(i+1);
    }
  }
  
  M ans(0);
  for(int x=0;x<=n;x++){
    int y=n-x;
    for(int i=0;i<=n;i++){
      M res(1);
      res*=C(n,x);
      res*=dp[i][x];
      res*=po[i*y];
      res*=pp[y];
      
      if(~x&1) ans+=res;
      else ans-=res;
    }
  }
  cout<<ans.v<<endl;
  return 0;
}


Measured memory_bytes: 72064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll B[110];
    rep(i,0,N-1) cin >> B[i];
    ll A[110] = {};
    rep(i,0,N){
        if(i == 0){
            A[i] = B[i];
        }else if(i == N-1){
            A[i] = B[N-2];
        }else{
            A[i] = min(B[i-1], B[i]);
        }
    }
    ll sum = 0;
    rep(i,0,N) sum += A[i];
    print(sum);


    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

int h,w;
char c[1010][1010];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dist[1010][1010];

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    queue<P> que;
    rep(i,h)rep(j,w){
        dist[i][j]=INF;
        cin>>c[i][j];
        if(c[i][j]=='#'){
            dist[i][j]=0;
            que.push(P(i,j));
        }
    }
    while(que.size()){
        int x=que.front().F,y=que.front().S;
        que.pop();
        rep(i,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=0 and nx<h and ny>=0 and ny<w and dist[nx][ny]>dist[x][y]+1){
                que.push(P(nx,ny));
                dist[nx][ny]=dist[x][y]+1;
            }
        }
    }
    int ans=0;
    rep(i,h)rep(j,w)chmax(ans,dist[i][j]);
    cout<<ans<<endl;
}

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

int main()
{
  int n;
  cin >> n;
  int tmp;
  priority_queue<int>a;
  rep(i,n) {
    cin >> tmp;
    a.push(tmp);
  }
  int alice=0,bob=0;int i=1;
  while(!a.empty()){
    if(i%2==1){
      alice+=a.top();
    }else{
      bob+=a.top();
    }
    a.pop();
    i++;
  }
  cout << alice-bob << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    cout << max({A1, A2, A3}) - min({A1, A2, A3}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
map<string,int> mp;
int main(){
	mp["SUN"]=7;
	mp["MON"]=6;
	mp["TUE"]=5;
	mp["WED"]=4;
	mp["THU"]=3;
	mp["FRI"]=2;
	mp["SAT"]=1;
	string s;
	cin>>s;
	cout<<mp[s];
	re 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,M=get_i
diff=N-M
puts (diff*100+M*1900)*2**M

Measured memory_bytes: 1788