akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/
template<class T> class Graph {
public:
    struct edge{int to; T cost; int id;};
    int N;
    vector<vector<edge>> G;
    vector<vector<T>> d;//distance matrix
    Graph(int _N): N(_N){
        G = vector<vector<edge>>(_N, vector<edge>(0));
        //d = vector<vector<long long>>(N, vector<long long>(N));
        d.resize(_N,vector<T>(_N));
    }
    void add_Directed_edge(int from, int to, T cost = 1, int id = 0){
        G[from].push_back(edge({to, cost, id}));
    }

    void add_Undirected_edge(int v1, int v2, T cost = 1, int id = 0){
        add_Directed_edge(v1, v2, cost, id);
        add_Directed_edge(v2, v1, cost, id);
    }
    void WarshallFloyd(){
        //initialize the distance matrix
        for(int i = 0; i < N; ++i){
            for(int j = 0; j < N; j++){
                d[i][j] = ((i == j) ? 0: INFLL);
            }
        }
        for(int i = 0; i < N; ++i){
            for(auto e: G[i]){
                d[i][e.to] = e.cost;
            }
        }
        //WarshallFloyd
        for(int k = 0; k < N; ++k){
            for(int i = 0; i < N; ++i){
                for(int j = 0; j < N; ++j){
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }
    void debug(){
        for(int i = 0; i < N; ++i){
            cerr<<i+1<<": ";
            for(edge e:G[i]){
                cerr<<"{"<<e.to+1<<", "<<e.cost<<"}, ";
            }
            cerr<<endl<<endl;
        }
        cerr<<"distance_matrix"<<endl;
        for(int i = 0; i < N; ++i){
            for(int j = 0; j < N; ++j){
                if(d[i][j] == INFLL){
                    cerr<<-1<<" ";
                }else cerr<<d[i][j]<<" ";
            }
            cerr<<endl;
        }
    }
};
/*------------------------------------*/
int c[100][100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int H,W;
    cin>>H>>W;
    Graph<ll> G(10);
    rep(i,10)rep(j,10){
        cin>>c[i][j];
        G.add_Directed_edge(i,j,c[i][j]);
    }
    G.WarshallFloyd();
    ll ans = 0;
    rep(i,H)rep(j,W){
        int a;
        cin>>a;
        if(a>=0){
            ans += G.d[a][1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7;
int a[M],n,b[M];
vector<int>good;
bool mark[M];
void dfs(int v,int hlp)
{
	mark[v]=1;
	for(int i=0;i<good.size();i++)
	{
		int u=good[i];
		if(!mark[v%u])dfs(v%u,hlp);
	}
	for(int i=1;i<=hlp;i++)
	{
		if(!mark[v%i])dfs(v%i,hlp);
	}
}
bool check(int tmp)
{
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=50;j++)mark[j]=0;
		dfs(a[i],tmp);
		if(!mark[b[i]])return 0;
	}
	return 1;
}
main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(b[i]>a[i])return cout<<-1,0;
	}
	int last=51;
	int ans=0;
	for(int i=1;i<=50;i++)
	{
		for(int j=0;j<last;j++)
		{
			if(check(j))	
			{
				if(j==0)return cout<<ans,0;
				ans+=(1LL<<j);
				good.pb(j);
				last=j;
			}
		}
		if(last==51)return cout<<-1,0;
	}
	cout<<ans;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    for (i=0; i<input.length; i++) {
        tmp = input[i].split(" ")
        var n = parseInt(tmp[0])
        var x = parseInt(tmp[1])
        var num = 0
        if (n === 0 && x === 0) {
            break;
        }
        for (j=1; j <= n-2; j++) {
            for (k=j+1; k<=n-1; k++) {
                for (l=k+1; l<= n; l++) {
                    if (j + k + l === x) {
                        num += 1
                    }
                }
            }
        }
        console.log(num)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 16332
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
  string s;
  cin>>s;
  int k;cin>>k;
  int n=s.size();
  vector<string> v;
  rep(i,n){
    string t="";
    t+=s[i];
    rep(j,5){
      v.push_back(t);
      if(i+j+1<n)t+=s[i+j+1];
      }
    }
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  cout<<v[k-1]<<endl;
  return 0;
  }

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

const int MAX_V = 1010;
const int INF = 1 << 29;

struct edge{int to,cap,rev;};
 
int n[2];
vector<int> v[2];

vector<edge> G[MAX_V];
bool used[MAX_V];
 
void add_edge(int from, int to, int cap){
  G[from].push_back((edge){to, cap, G[to].size()});
  G[to].push_back((edge){from, 0, G[from].size()-1});
}
 
int dfs(int v, int t, int f){
  if(v == t)return f;
  used[v] = true;
  for(int i = 0 ; i < G[v].size() ; i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s,int t){
  int flow = 0;
  while(1){
    fill(used,used+MAX_V,false);
    int f = dfs(s,t,INF);
    if(f == 0)return flow;
    flow += f;
  }
}

void solve(){
  for(int i=0;i<n[0]+n[1]+2;i++) G[i].clear();

  for(int i=0;i<n[0];i++) add_edge(n[0]+n[1], i, 1);
  for(int j=0;j<n[1];j++) add_edge(n[0]+j, n[0]+n[1]+1, 1);

  for(int i=0;i<n[0];i++){
    for(int j=0;j<n[1];j++){
      if(__gcd(v[0][i], v[1][j]) != 1){
        add_edge(i, n[0]+j, 1);
      }
    }
  }

  cout << max_flow(n[0]+n[1], n[0]+n[1]+1) << endl;

}

int main(){
  while(cin >> n[0] >> n[1] && (n[0]|n[1])){
    for(int i=0;i<2;i++){
      v[i].clear();
      for(int j=0;j<n[i];j++){
        int x;
        cin >> x;
        v[i].push_back(x);
      }
    }
    solve();
  }
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}

int main(){

    int n;
    cin >> n;
    vector<ll> name(5);
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        switch(s[0]){
            case 'M':
                name[0]++;
                break;
            case 'A':
                name[1]++;
                break;
            case 'R':
                name[2]++;
                break;
            case 'C':
                name[3]++;
                break;
            case 'H':
                name[4]++;
                break;
            default:
                break;
        }
    }

    ll ans = 0;
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                ans += name[i] * name[j] * name[k];
            }
        }
    }
    cout << ans << endl;


    return 0;
}

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

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

int main() {
  long long a,b;
  cin >> a >> b;
  // aとbの最小公倍数を求めれば良い
  cout << a*b/gcd(a,b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

signed  main(){
    int A, B, C;
    cin >> A >> C >> B;
    if(A < B && B < C || A > B && B > C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
  int N, A, p = 1000000000, pi;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A;
    while (A % 2 == 0) {
      pi++;
      A /= 2;
    }
    if (pi < p) {
      p = pi;
    }
    pi = 0;
  }
  cout << p;
}
      

Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))


memo = [1] * (n)
ans = 0


for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] == H[b]:
        memo[a] = 0
        memo[b] = 0
    elif H[a] > H[b]:
        memo[b] = 0
    elif H[b] > H[a]:
        memo[a] = 0

print(sum(memo))


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

#define ll long long

using namespace std;

int main(){
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(n == i*j){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    int N;
    cin >> N;
    set<int> se;
    int A;
    rep(i,N){
        cin >> A;
        se.insert(A);
    }
    if((N-se.size())%2){
        cout << se.size()-1 << endl;
    }else{
        cout << se.size() << endl;
    }

    return 0;
} 

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

int main() {
 int N,A;
  cin>>N>>A;
  if(A>=499){
  cout<<"Yes"<<endl;
  }
  else if(N%500<=A){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int k=in.nextInt();
            int[] heights=new int[n];
            for(int i=0;i<n;i++){
                heights[i]=in.nextInt();
            }
            int[] dp =new int[n];
            dp[0]=0;
            dp[1]=Math.abs(heights[0]-heights[1]);
            for(int i=2;i<n;i++){
                int min=Integer.MAX_VALUE;
                for(int j=1;j<=k;j++){
                    if((i-j)>=0){
                       min=Math.min(min, Math.abs(heights[i]-heights[i-j])+dp[i-j]); 
                    }
                }
                dp[i]=min;
            }
            out.println(dp[n-1]);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 3e5);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}


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

int main()
{
  int n, flag, count = 0;
  cin >> n;
  int a[100];
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  flag = 1;  
    
  while (flag)
  {
    flag = 0;
      
    for (int j = n - 1; j > 0; j--)
    {
      if(a[j] < a[j-1])
      {
        int c = a[j];
        a[j] = a[j-1];
        a[j-1] = c;

        flag = 1;
        count++;
      }
    }
  }

  //out
  for(int i = 0; i < n - 1; i++)
  {
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
    
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define iton for(int i=0;i<n;i++)
#define itok for(int i=0;i<k;i++)
#define jton for(int j=0;j<n;j++)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long n;
    cin>>n;
    vector<ll> v(n,0);
    iton
    cin>>v[i];
    vector<ll> dp(n,0);
    dp[0]=0;
    dp[1]= abs(v[1]- v[0]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-2]+abs(v[i]-v[i-2]), dp[i-1]+abs(v[i]-v[i-1]));
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        D = list(map(int, input().split()))

        if D[0] != 0:
            print(0)
            exit()
        D = D[1:]
        D.sort()

        if D[0] == 0:
            print(0)
            exit()

        cnt = []
        before = 0
        for d in D:
            if d > before + 1:
                print(0)
                exit()
            else:
                if len(cnt) == d - 1:
                    cnt.append(1)
                else:
                    cnt[-1] += 1
                before = d

        ans = 1
        for i, v in enumerate(cnt):
            if i > 0:
                ans *= (cnt[i - 1]) ** v
        print(ans % 998244353)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 56860
n, x = map(int, input().split())
xlist = list(map(int, input().split()))

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

mx = abs(xlist[0] - x)
for _x in xlist[1:]:
  mx = gcd(max(abs(_x-x), mx), min(abs(_x-x), mx))
print(mx)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int D,N; cin>>D>>N;
    int ans = 1;
    REP(i,D){
        ans *= 100;
    }
    if(N==100) Out(101*ans);
    else Out(ans*N);
}




Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]

    tmp = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                tmp += 1

    if tmp == H + W - 1:
        print('Possible')
    else:
        print('Impossible')


if __name__ == "__main__":
    main()


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


int main() {
  string s,t;
  cin>>s>>t;
  string a=s;
  for(char i='a';i<='z';i++) {
    s=a+i;
    if(s==t) {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3624
import queue
n,m = map(int,input().split())

adj = [[] for i in range(n)]
dist = [-1]*n
for i in range(m):
    a,b = map(int,input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
    
q = queue.Queue()
dist[0] = 0
q.put(0)

while not q.empty():
    x = q.get()
    
    for f in adj[x]:
        if dist[f] != -1:
            continue
        
        dist[f] = dist[x] + 1
        q.put(f)
     
if dist[n-1] == 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 93768
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, H;
lli M=0;
lli ans = 0;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> H;
		if(H >= M){
			M = H;
			ans++;
		}
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21732
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<string> week={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  for(int i=0;i<7;i++){
    if (s == week[i]){
      int ans = i;
      cout << 7-ans << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define M 100000
#define  S 2000000000

struct node{
    char pair;
    int number;
};

struct node L[M/2+2],R[M/2+2];

    void merge(struct node A[],int n,int left,int mid,int right){
        int i,j,k,n1,n2;
    n1=mid-left;
    n2=right-mid;

    for(i=0;i<n1;i++){
        L[i]=A[left+i];
    }
    for(i=0;i<n2;i++){
        R[i]=A[mid+i];
    }
    L[n1].number = R[n2].number=S;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i].number <= R[j].number){
            A[k]=L[i++];
        }else{
            A[k]=R[j++];
        }
    }

    }

    void mergesort(struct node A[],int n,int l,int r){
        int mid;
        if(l+1<r){
            mid=(l+r)/2;
            mergesort(A,n,l,mid);
            mergesort(A,n,mid,r);
            merge(A,n,l,mid,r);
        }
    }

    int partition(struct node A[],int n,int p,int r){
        int i,j;
        struct node cng,x;
        x=A[r];
        i=p-1;
        for(j=p;j<r;j++){
            if(A[j].number<=x.number){
                i++;
                cng=A[i];
                A[i]=A[j];
                A[j]=cng;
            }
        }
        cng=A[i+1];
        A[i+1]=A[r];
        A[r]=cng;
        return i+1;
    }

    void qsort(struct node A[],int i,int j,int k){
        int q;
        if(j<k){
            q=partition(A,i,j,k);
            qsort(A,i,j,q-1);
            qsort(A,i,q+1,k);
        }
    }

    int main(){
        int n,i,t;
        struct node A[M],B[M];
        char c[10];
        int stb=1;

        scanf("%d",&n);

        for(i=0;i<n;i++){
            scanf("%s %d",c,&t);
            A[i].pair=B[i].pair=c[0];
            A[i].number=B[i].number=t;
        }
        mergesort(A,n,0,n);
        qsort(B,n,0,n-1);

        for(i=0;i<n;i++){
            if(A[i].pair!=B[i].pair)
            stb=0;
        }

        if(stb == 1)printf("Stable\n");
        else printf("Not stable\n");
        for(i=0;i<n;i++){
            printf("%c %d\n",B[i].pair,B[i].number);
        }
        return 0;
    }


Measured memory_bytes: 4052
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
signed main() {
	ll a, b;
	cin >> a >> b;
	cout << max(a, b) + max(min(a, b), max(a, b) - 1) << endl;
	ggr
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int X,N,p[101]={0},Xcheck=0;
  scanf("%d %d",&X,&N);
  for(int i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  
  int x,flag,flag2=0;
  
  for(int i=0;i<100;i++){
    
    flag = 1;
    x = X-i;
    for(int j=0;j<N;j++){
      if(p[j]==x){
        flag = 0;
        break;
      }
    }
    if(flag==1){
      printf("%d",x);
      break;
    }
    
    flag = 1;
    x = X+i;
    for(int j=0;j<N;j++){
      if(p[j]==x){
        flag = 0;
        break;
      }
    }
    if(flag==1){
      printf("%d",x);
      return 0;
      break;
    }
  }
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define pb push_back
#define cmax(a,b) (a<(b)?a=(b):a)
#define cmin(a,b) (a>(b)?a=(b):a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=2e5+50,MOD=1e9+7;
int sub(int a,int b){ a-=b; return (a<0)?a+MOD:a; }
int add(int a,int b){ a+=b; return (a>=MOD)?a-MOD:a; }

struct Pair { int x,v; } a[N];
bool cmpv(const Pair &a,const Pair &b){ return a.v<b.v; }
bool cmpx(const Pair &a,const Pair &b){ return a.x<b.x; }

int n,l[N],r[N],f[N],sum[N];
vector<int> g[N];

int main(){
#ifdef CURIOUSCAT 
	freopen("dat.in","r",stdin);
	freopen("my.out","w",stdout);
#endif	
	scanf("%d",&n); 
	rep(i,1,n){
		scanf("%d%d",&a[i].x,&a[i].v);
	}
	sort(a+1,a+n+1,cmpv);
	rep(i,1,n)a[i].v=i;
	sort(a+1,a+n+1,cmpx);
	for(int t=a[1].v,i=1;i<=n;++i){
		r[a[i].v]=t;
		if(i+1<=n)cmax(t,a[i+1].v);
	}
	for(int t=a[n].v,i=n;i>=1;--i){
		l[a[i].v]=t;
		if(i-1>=1)cmin(t,a[i-1].v);	
	}
	rep(i,1,n)g[r[i]].pb(l[i]);
	sum[0]=f[0]=1;
	rep(i,1,n){
		sum[i]=sum[i-1];
		sort(all(g[i]));
		for(int j:g[i]){
			Pr("(%d,%d)\n",j,i);
			int w=sub(sum[i],j-2>=0?sum[j-2]:0);
			f[i]=add(f[i],w);
			sum[i]=add(sum[i],w);
		}
		Pr("f[%d]=%d\n",i,f[i]);
	}
	printf("%d\n",f[n]);
	return 0;
}


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

void zero(string &a){
  while(a.length() != 6){
    a = "0" + a;
  }
}

int main() {

  int N, M;
  cin >> N >> M; //N個の県，M個の市

  vector<tuple<int, int, int>> city;
  for(int i=0; i<M; i++){
    int P, Y; //所属県P，誕生Y年
    cin >> P >> Y;
    city.push_back(make_tuple(P, Y, i));
  }

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

  vector<tuple<int, string, string>> code;

  int j = get<2>(city.at(0)); //市番号
  string ue = to_string(get<0>(city.at(0)));
  int shita = 1; //P県で何番目
  code.push_back(make_tuple(j, ue, to_string(shita)));

  int i=1;
  while(i<M){
    j = get<2>(city.at(i));
    string thisue = to_string(get<0>(city.at(i)));
    if(thisue != ue){
      ue = thisue;
      shita = 0;
    }
    shita++;
    code.push_back(make_tuple(j, ue, to_string(shita)));

    i++;
  }

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

  for(int i=0; i<M; i++){
    string a = get<1>(code.at(i));
    string b = get<2>(code.at(i));
    zero(a);
    zero(b);
    cout << a << b << endl;
  }
  

}


Measured memory_bytes: 14320
N,A,B=map(int ,raw_input().split())
s=raw_input()
ls=list(s)
cou=0
fnum=1
for i in ls:

    if i=="a" and cou<A+B:
        print "Yes"
        cou+=1
    elif i=="b" and cou<A+B and  fnum<=B:
        print "Yes"
        cou+=1
        fnum+=1
    else:
        print "No"

Measured memory_bytes: 33256
k = int(input())
ans=0
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
 
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(a,gcd(b,c))
print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    double a, b, x;
    cin >> a >> b >> x;

    if (x / a >= a * b / 2)
    {
        cout << 180.0 * atan2(2 * (a * b - x / a) / a, a) / acos(-1.0) << endl;
    }
    else
    {
        cout << 180.0 * atan2(b, 2 * x / (a * b)) / acos(-1.0) << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(int i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()

int main() {
    while(1) {
        int n; cin >> n;
        if(n == 0) return 0;
        int count = 0;
        Rep(i, 1, n) {
            Rep(j, i, n) {
                if((i+j) * (j-i+1) == n*2) count++;
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3060
//
// Created by Akifumi Ohata on 2017/10/03.
//


#include<iostream>
#include <vector>
#include <numeric>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll =  long long int;

int main() {
    ios::sync_with_stdio(false);

    int N;
    cin >> N;


    std::vector<int> Arrays;
    for(int i=0;i<N ;i++){

        int tmp=0;
        cin >> tmp;
        int time=0;

        if(tmp%2==0){

            time=1;
        }


        if(tmp%4==0){

            time=2;
        }

        Arrays.push_back(time);

    }


    int num_zero= static_cast<int>(std::count(Arrays.begin(), Arrays.end(), 0));
    int num_one= static_cast<int>(std::count(Arrays.begin(), Arrays.end(), 1));
    int num_tow= static_cast<int>(std::count(Arrays.begin(), Arrays.end(), 2));


    if(num_zero <= num_tow){

        cout << "Yes" << endl;

    }


    if(num_zero > num_tow){

        if (num_zero-num_tow >= 2){
            cout << "No" << endl;
        }

        if (num_zero-num_tow == 1){

            if(num_one==0){
            cout << "Yes" << endl;
            }else{
                cout << "No" << endl;

            }
        }

    }



    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define int long long
int f(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return (t==s);
}
signed  main(){
 	string s;
	 cin>>s;
	 int n=s.size();
	 string t1=s.substr(0,(n-1)/2);
	 
	 string t2=s.substr((n+3)/2-1);
	 //cout<<t1<<" "<<t2;
	 if(f(t1)&&f(t2)&&f(s)) cout<<"Yes";
	 else cout<<"No"; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++)
		cout << s[i];
	cout << " ";
	for (int i = 4; i < s.length(); i++)
		cout << s[i];
	cout << endl;
	return 0;
}

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

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();

	std::string line;
	std::getline(std::cin, line);

	if(line[0] == line[2])
		std::cout << "Yes";
	else
		std::cout << "No";
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
int main(void) {
  int max, i, imax ,scan1, scan2;
  while(scanf("%d%d",&scan1,&scan2), scan1+scan2 ) {
    max = scan1 + scan2;
    imax = 1;
    for(i = 2; i < 6; i++ ) {
      scanf("%d%d",&scan1,&scan2);
      if(max < scan1+scan2 ) {
	max = scan1+scan2;
	imax = i;
      }
    }
    switch(imax) {
    case 1 : printf("A %d\n",max); break;
    case 2 : printf("B %d\n",max); break;
    case 3 : printf("C %d\n",max); break;
    case 4 : printf("D %d\n",max); break;
    case 5 : printf("E %d\n",max); break;
    }
  }
  return(0);
}

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

int main() {
    string s;
    cin >> s;
    int ans = 700;
    if (s[0] == 'o') ans += 100;
    if (s[1] == 'o') ans += 100;
    if (s[2] == 'o') ans += 100;

    cout << ans << endl;
}

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

def main():
    A, B, C, K = map(int, input().split())
    if A >= K:
        print(K)
    elif (A + B) >= K:
        print(A)
    else:
        print(A*2 - K + B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

ll po(ll i,ll p){
    if(p<0)return 0;
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return po(mod(mod(i)*mod(i)),p/2);
    else  return mod(mod(i)*po(i,p-1));
}

int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    ll dp[n+1][3];
    rep(j,0,2)dp[0][j]=0;
    rep(i,0,n-1){
        rep(j,0,2)dp[i+1][j]=dp[i][j];
        if(s[i]=='A')dp[i+1][0]++;
        else if(s[i]=='C')dp[i+1][1]++;
        else if(s[i]=='?')dp[i+1][2]++;
    }
    /*rep(i,0,n){
        rep(j,0,2){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=0;
    rep(i,1,n-2){
        if(s[i]=='A'||s[i]=='C')continue;
        ll a=dp[i][0];
        ll b=dp[i][2];
        ll c=dp[n][1]-dp[i+1][1];
        ll d=dp[n][2]-dp[i+1][2];
        //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
        ll add=a*c*po(3,b+d);
        //cout<<add<<" ";
        Add(add,a*d*po(3,b+d-1));
        //cout<<add<<" ";
        Add(add,b*c*po(3,b+d-1));
        //cout<<add<<" ";
        Add(add,b*d*po(3,b+d-2));
        //cout<<add<<endl;
        
        Add(ans,add);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2768
#include <iostream>
//#include <string>
//#include <cmath>
//#include <cstdlib>
#include <algorithm>
//#include <functional>
//#include <array>
#include <vector>

using ssl = signed long long;

int N, M;
ssl v[1000][3] = {0};

std::vector<ssl> ppp;
std::vector<ssl> ppm;
std::vector<ssl> pmp;
std::vector<ssl> pmm;
//std::vector<ssl> mpp;
//std::vector<ssl> mpm;
//std::vector<ssl> mmp;
//std::vector<ssl> mmm;

int main(void) {
  std::cin >> N;
  std::cin >> M;

  ssl tmp;
  ppp.reserve(N);
  ppm.reserve(N);
  pmp.reserve(N);
  pmm.reserve(N);
  //mpp.reserve(N);
  //mpm.reserve(N);
  //mmp.reserve(N);
  //mmm.reserve(N);
  for (size_t i = 0; i < N; i++) {
    std::cin >> v[i][0];
    std::cin >> v[i][1];
    std::cin >> v[i][2];

    ppp.push_back(+v[i][0] +v[i][1] +v[i][2] +30000000000);
    ppm.push_back(+v[i][0] +v[i][1] -v[i][2] +30000000000);
    pmp.push_back(+v[i][0] -v[i][1] +v[i][2] +30000000000);
    pmm.push_back(+v[i][0] -v[i][1] -v[i][2] +30000000000);
    //mpp.push_back(-v[i][0] +v[i][1] +v[i][2] +30000000000);
    //mpm.push_back(-v[i][0] +v[i][1] -v[i][2] +30000000000);
    //mmp.push_back(-v[i][0] -v[i][1] +v[i][2] +30000000000);
    //mmm.push_back(-v[i][0] -v[i][1] -v[i][2] +30000000000);
  }

  std::sort(ppp.begin(), ppp.end(), std::greater<ssl>());
  std::sort(ppm.begin(), ppm.end(), std::greater<ssl>());
  std::sort(pmp.begin(), pmp.end(), std::greater<ssl>());
  std::sort(pmm.begin(), pmm.end(), std::greater<ssl>());
  //std::sort(mpp.begin(), mpp.end(), std::greater<ssl>());
  //std::sort(mpm.begin(), mpm.end(), std::greater<ssl>());
  //std::sort(mmp.begin(), mmp.end(), std::greater<ssl>());
  //std::sort(mmm.begin(), mmm.end(), std::greater<ssl>());

  for (size_t i = 0; i < N; ++i) {
    ppp[i] -= 30000000000;
    ppm[i] -= 30000000000;
    pmp[i] -= 30000000000;
    pmm[i] -= 30000000000;
    //mpp[i] -= 30000000000;
    //mpm[i] -= 30000000000;
    //mmp[i] -= 30000000000;
    //mmm[i] -= 30000000000;
  }

  ssl max = 0;
  //std::vector<ssl>* vecs[] = {&ppp, &ppm, &pmp, &pmm, &mpp, &mpm, &mmp, &mmm};
  std::vector<ssl>* vecs[] = {&ppp, &ppm, &pmp, &pmm};
  const size_t siz = sizeof(vecs)/sizeof(std::vector<ssl>*);
  for (size_t i = 0; i < siz; ++i) {
    ssl value = 0;
    for (size_t j = 0; j < M; ++j) {
      value += (*vecs[i])[j];
    }
    if (max < value) {
      max = value;
    }

    value = 0;
    for (size_t j = 0; j < M; ++j) {
      value += -(*vecs[i])[N-1-j];
    }
    if (max < value) {
      max = value;
    }
  }

#if 0
  std::sort(v.begin(), v.end(), std::greater<int>());

  std::for_each(v.begin(), v.end(), [](int x) {
      std::cout << x << std::endl;
  });
#endif

  std::cout << max << std::endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n;
    cin>>n;
    rrepi(i,1,sqrt(n)+1){
        if(n%i==0){
            cout<<(lint)log10(n/i)+1;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,M;
    cin >> N >> M;
    priority_queue<int> A;
    rep(i,N){
        int a;
        cin >> a;
        A.push(a);
    }
    rep(i,M){
        int a = A.top() / 2;
        A.pop();
        A.push(a);
    }
    ll ans = 0;
    rep(i,N){
        ans += A.top();A.pop();
    }
    cout << ans << endl;
    
    return 0;
}

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string O = Console.ReadLine();

            string E = Console.ReadLine();

            int len_o = O.Length;
            int len_e = E.Length;

            StringBuilder ans = new StringBuilder("");

            for (int i = 0; i < (len_o + len_e); i++) {
                if (i % 2 == 0) {
                    ans.Append(O[i / 2]);
                } else {
                    ans.Append(E[i / 2]);
                }


            }

            Console.WriteLine(ans);

        }
    }
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, D, d[500050], Q, q[500010], pos[500010], ok[500010];

int main() {
    //cout.precision(10)
    cin >> N >> D;
    pos[0] = D;
    for(int i = 1; i <= N; i++) {
        cin >> d[i];
        pos[i] = min(pos[i - 1], abs(pos[i - 1] - d[i]));
    }
    ok[N] = 0;
    for(int i = N - 1; i >= 0; i--) {
        ll val = d[i + 1];
        if(val >= 2 * (ok[i + 1] + 1)) {
            ok[i] = ok[i + 1];
            continue;
        }
        ok[i] = ok[i + 1] + d[i + 1];
    }
    for(int i = 0; i <= N; i++) {
        //cout << i << " " << ok[i] << endl;
    }
    for(int i = 0; i <= N; i++) {
        //cout << i << " " << pos[i] << endl;
    }
    cin >> Q;
    while(Q--) {
        int q;
        cin >> q;
        if(ok[q] < pos[q - 1]) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 15488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    vector<ll> z(m);
    vector<ll> t(100001);
    for (int i = 0; i < n; i++) {
        ll k;
        cin >> k;
        z[k % m]++;
        t[k]++;
    }
    ans += z[0] / 2;
    z[0] -= ans*2;
    if (m % 2 == 0) {
        ans += z[m / 2]/2;
        z[m / 2] -= z[m / 2] / 2 * 2;
    }
    for (int i = 1; i <= (m-1)/2; i++) {
        ans += min(z[i], z[m - i]);
        ll jj = min(z[i], z[m - i]);
        z[i] -= jj;
        z[m - i] -= jj;
    }
    for (int i = 0; i < m; i++) {
        ll h = 0;
        for (int j = i; j < 100001; j+=m) {
            h += t[j] / 2;
        }
        ans += min(h, z[i]/2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4728