akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

const int N = 60;
const int M = N * N;
ll dp[N][M][N];

int main(void){
    int n, A; cin >> n >> A;
    vi x(n);
    for(auto & e : x) cin >> e;

    dp[0][0][0] = 1;
    rep(i, n){
        rep(j, M){
            rep(k, n){
                ll cur = dp[i][j][k];
                if(cur == 0) continue;
                dp[i + 1][j][k] += cur;
                dp[i + 1][j + x[i]][k + 1] += cur;
            }
        }
    }

    ll res = 0;
    rep(j, M){
        rep(k, 1, n + 1){
            if(j == k * A){
                res += dp[n][j][k];
            }
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 15616
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int A, B, list[3];
  
  cin >> A >> B;
  
  list[0] = A + B;
  list[1] = A - B;
  list[2] = A*B;
  
  sort(list, list + 3, greater<int>());
  
  cout << list[0] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;

typedef long long ll;

int main() {
  ll w, h, x, y;
  while (cin >> w >> h >> x >> y) {
    printf("%.10f ", w * h / 2.0);

    if (w % 2 == 0 && h % 2 == 0 && w / 2 == x && h / 2 == y) {
      cout << "1" << endl;
    } else {
      cout << "0" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void PDF(int n,int k,vector < int >A)
{
    sort(A.begin(),A.end());
    int j,s = 0;
    for(j=0;j<k;j++)
    {
        s = s+A[j];
    }
    cout << s <<endl;
}
int main()
{
    int n,i,j,l,k;
    cin >> n >> k;
    vector < int >A(n);
    for (i=0;i<n;i++)
    {
        cin >> A[i];
    }
    PDF(n,k,A);
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void) {
  int A, B;
  long ans;
  
  cin >> A >> B;
  
  int ma = max(A, B);
  ans = ma;
  while(true) {
    if (ans % A == 0 && ans % B == 0) {
      break;
    }
    ans += ma;
  }
    
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int p[n];
  for(int i=0;i<n;i++){
	scanf("%d",&p[i]);
}
int min=p[0],count=1;
for(int i=1;i<n;i++){
if(p[i]<min){count++;
             min=p[i];
            }
}
printf("%d",count);
return 0;
}

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

using namespace std;

#define sd(x) scanf("%d", &x)
#define boost ios_base::sync_with_stdio(false);
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define f first
#define s second

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

const int mod = 1000000007;
const int inf = 5000;
const int maxn = 2010;

int n, k;
vector<int> adj[maxn];
int sub[maxn], par[maxn], dp[maxn][maxn];

void dfs(int cur, int parent)
{
	sub[cur] = 1;
	par[cur] = parent;
	for(int it : adj[cur]){
		if(it != parent){
			dfs(it, cur);
			sub[cur] += sub[it];
		}
	}
}

int solve(int cur, int ht, int parent)
{
	if(ht==0)
		return sub[cur];
	if(dp[cur][ht] != -1)
		return dp[cur][ht];
	int ret = solve(cur, ht-1, parent), sum = 0, nht;
	if(adj[cur].size() == 1){
		for(int it : adj[cur]){
			if(it != parent)
				sum += solve(it, ht-1, cur);
		}
		return dp[cur][ht] = sum;
	}
	nht = min(ht-1, k-ht+1);
	for(int it : adj[cur]){	
		if(it != parent)
			sum += solve(it, nht, cur);
	}
	for(int it : adj[cur]){
		if(it != parent)
			ret = min(ret, sum - solve(it, nht, cur) + solve(it, ht-1, cur));
	}
	return dp[cur][ht] = ret;
}

int main() 
{
	// freopen("i.txt", "r", stdin);
	// freopen("o.txt", "w", stdout);
	memset(dp, -1, sizeof(dp));
	int u, v, i, j;
	scanf("%d%d", &n, &k);
	for(i=1; i<n; i++){
		scanf("%d%d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1, 0);
	int ans = inf;
	for(i=1; i<=n; i++){
		// cout << i << " " << solve(i, k+1, par[i]) << "\n";
		ans = min(ans, solve(i, k+1, par[i]) + n - sub[i]);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 16384
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

struct UnionFind{
    int size;
    std::vector<int> par;
    std::vector<int> rank;
    UnionFind(int x){
        size=x;
        par=std::vector<int> (x);
        rank=std::vector<int> (x,1);
        for (int i=0;i<x;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        else return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y) return;
        if(rank[x]<rank[y]) par[x]=y;
        else par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
    bool check(int x,int y){
        return root(x)==root(y);
    }
    void initialize(){
        for (int i=0;i<size;i++){
            par[i]=i;rank[i]=1;
        }
    }
};

using namespace std;

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rip(i,m,0) {
        int a, b; cin >>a >> b;
        --a;--b;
        uf.unite(a, b);
    }
    set<int> st;
    rip(i,n,0) st.insert(uf.root(i));
    cout << st.size()-1 << endl;
}

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

cnt = 0
b = []
c = []
for i in range(n):
  if i == 0:
    b.append(a[i])
  elif i % 2 == 0:
    b.append(a[i])
  elif i % 2 == 1:
    c.append(a[i])

if n % 2:
  ans = b[::-1] + c
else:
  ans = c[::-1] + b
print(*ans)


Measured memory_bytes: 116152
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		String strN = String.valueOf(n);
		for (int i = 0; i < strN.length(); i++) {
			if (strN.charAt(i) == '7') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 27044
//https://atcoder.jp/contests/dp/tasks/dp_f

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;
const ll INF = 1e18L + 5;

string solveLCS() 
{
	string s, t;  cin >> s >> t;

	swap(s, t);

	vector<vector<int>> dp(s.size() + 1, vector<int> (t.size() + 1, 0));

	for(auto i = 0; i <= (int)s.size(); ++i) {
		dp[i][0] = i;
	}

	for(auto i = 0; i <= (int)t.size(); ++i) {
		dp[0][i] = i;
	}


	for(auto r = 1; r <= (int)s.size(); ++r) {
		for(auto c = 1; c <= (int)t.size(); ++c) {
			if(s[r - 1] == t[c - 1]) {
				dp[r][c] = dp[r - 1][c - 1];
			} else {
				dp[r][c] = min(dp[r - 1][c], dp[r][c - 1]) + 1;
			}
		}
	}

 
	int r = s.size(), c = t.size();

	string ret = "";
	while(r > 0 and c > 0) {
		if(s[r - 1] == t[c - 1]){
			ret += s[r - 1];
			r--;
			c--;
		} else {
			if(dp[r - 1][c] < dp[r][c - 1]) {
				r = r - 1;
			} else {
				c = c - 1;
			}
		}
	}

	reverse(ret.begin(), ret.end());
	return ret;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	auto ret = solveLCS();
	cout << ret;
	return 0;
}




Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int n;
int a[110000];
vector<int> b;
//kより小さい要素のうち最小のもののインデックスを求める
int upper_bound(int k){
  int left=-1,right=b.size();
  while(right-left>1){
    int mid=(right+left)/2;
    if(b[mid]<k) right=mid;
    else left=mid;
  }
  return right;
}

void solve(){
  rep(i,n){
    int ub = upper_bound(a[i]);
    if(ub==b.size()){
      b.push_back(a[i]);
    }
    else{
      b[ub] = a[i];
    }
  }
  cout << (int)b.size() << "\n";
}

int main()
{
  cin >> n;
  rep(i,n) cin >> a[i];
  solve();
  return 0;
}


Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define pii pair<int,int>

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

using namespace std;

int main(){

  llong h, w;
  scanf("%lld %lld", &h, &w);

  llong res = INF;
  FOR(i,1,h){
    llong s1, s2, s3, max_s, min_s;
    s1 = i * w; s2 = (h - i) * (w / 2); s3 = (h - i) * (w - (w / 2));
    max_s = max(s1, max(s2, s3)); min_s = min(s1, min(s2, s3));
    if(res > max_s - min_s){
      res = max_s - min_s;
    }
    s2 = w * ((h - i) / 2); s3 = w * ((h - i) - ((h - i) /2));
    max_s = max(s1, max(s2, s3)); min_s = min(s1, min(s2, s3));
    if(res > max_s - min_s){
      res = max_s - min_s;
    }

  }

  FOR(i,1,w){
    llong s1, s2, s3, max_s, min_s;
    s1 = h * i; s2 = (h / 2) * (w - i); s3 = (h - (h / 2)) * (w - i);
    max_s = max(s1, max(s2, s3)); min_s = min(s1, min(s2, s3));
    if(res > max_s - min_s){
      res = max_s - min_s;
    }


    s2 = h * ((w - i) / 2); s3 = h * ((w - i) - ((w - i) / 2));
    max_s = max(s1, max(s2, s3)); min_s = min(s1, min(s2, s3));
    if(res > max_s - min_s){
      res = max_s - min_s;
    }

  }

  printf("%lld\n", res);
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	long long n;
	scanf("%lld",&n);
	long long w=0,sum=0;
	for (;n>9;n/=10) {w++; sum+=n%10;}
	w*=9;
	if (sum==w) printf("%lld",sum+n);
		else
		if (n==1) printf("%lld",w);
			else printf("%lld",w+n-1);
     return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N){
    int i;
    for(i=0;i<N;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int i, v;
    for(i=1;i<N;i++){
        v = A[i];
        int j = i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int i, N;
    int num[1000];

    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%d", &num[i]);
    }
    trace(num, N);
    insertionSort(num, N);

    return 0;
}


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

int main(){
	int A, B, C;
	cin>>A>>B>>C;
	if(A + B + C == 17){
		if(A == 7 or B == 7 or C == 7){
			if(A == 5 or B == 5 or C == 5){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 5000;
const int INF = 1 << 30;
const double DINF = 1e60;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<int> pt;

/* global variables */

pt pts[MAX_N + 1];
bool used[MAX_N + 1];
double ed2s[MAX_N + 1];

/* subroutines */

double ed2(int a, int b, int c) {
  pt vab(pts[b] - pts[a]), vac(pts[c] - pts[a]), vbc(pts[c] - pts[b]);
  if (vab.dot(vac) <= 0) return (double)vac.d2();
  if (vab.dot(vbc) >= 0) return (double)vbc.d2();
  
  int cr = vab.cross(vac);
  return (double)cr * cr / vab.d2();
}

int pd2(int i, int j) { return (pts[j] - pts[i]).d2(); }

/* main */

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

  for (int i = 0; i <= n; i++) cin >> pts[i].x >> pts[i].y;

  ed2s[0] = DINF;
  used[0] = true;
  double mind2 = INF;
  int nxti = -1;
  for (int i = 1; i <= n; i++) {
    ed2s[i] = (double)pd2(0, i);
    if (mind2 > ed2s[i]) mind2 = ed2s[i], nxti = i;
  }

  double sum = 0.0;

  while (m--) {
    int minpd2 = INF, minpi = -1;
    for (int i = 0; i <= n; i++)
      if (used[i]) {
	int pd2i = pd2(nxti, i);
	if (minpd2 > pd2i) minpd2 = pd2i, minpi = i;
      }
    //printf("nxti=%d, minpi=%d, minpd2=%d\n", nxti, minpi, minpd2);
    
    sum += sqrt((double)minpd2);
    ed2s[nxti] = DINF;
    used[nxti] = true;

    double mined2 = DINF;
    int minei = -1;
    for (int i = 1; i <= n; i++)
      if (! used[i]) {
	double ed2i = ed2(nxti, minpi, i);
	if (ed2s[i] > ed2i) ed2s[i] = ed2i;
	if (mined2 > ed2s[i]) mined2 = ed2s[i], minei = i;
      }

    nxti = minei;
  }

  printf("%.10lf\n", sum);
  return 0;
}

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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/

ll tree[4*mx];
ll arr[mx];
void build(ll at,ll L,ll R)
{
    if(L==R)
    {
        tree[at]=arr[L];
        return;
    }
    ll mid=(L+R)/2;
    build(2*at,L,mid);
    build(2*at+1,mid+1,R);
    tree[at]=__gcd(tree[2*at],tree[2*at+1]);
}
void update(ll at,ll L,ll R,ll id,ll val)
{
    if(R<id||L>id)return;
    if(L==R&&id==R)
    {
        tree[at]=val;
        return;
    }
    ll mid=(L+R)/2;
    update(2*at,L,mid,id,val);
    update(2*at+1,mid+1,R,id,val);
    tree[at]=__gcd(tree[2*at],tree[2*at+1]);
}
ll query(ll at,ll L,ll R,ll l,ll r)
{
    if(l>R||r<L)return 0;
    if(l<=L&&r>=R)return tree[at];
    ll mid=(L+R)/2;
    ll a=query(2*at,L,mid,l,r);
    ll b=query(2*at+1,mid+1,R,l,r);
    return __gcd(a,b);
}

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    ll tst,a,b,c,k,n,m,res=0,ans=0,t=0;
    sl(n);
    for(ll i=1;i<=n;i++)
    {
        sl(arr[i]);
    }
    build(1,1,n);
    for(ll i=1;i<=n;i++)
    {
        update(1,1,n,i-1,arr[i-1]);
        update(1,1,n,i,0);
        res=max(res,query(1,1,n,1,n));
    }
    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>
int main(void)
{
    int A, B, K, i;

    scanf("%d%d%d", &A,&B,&K);

    for(i=A; i<=B; i++){
       if((i <= A+K-1) || (i >= B-K+1))
         printf("%d\n", i);
    }
    return 0;
}


Measured memory_bytes: 128
from functools import lru_cache

N = int(input())

@lru_cache(maxsize=None)
def c(i, j):
    return len([
        i
        for n in range(1, N + 1)
        if str(n)[0] == i
        if str(n)[-1] == j
    ])

def main():
    tmp = 0
    for i in "0123456789":
        for j in "0123456789":
            tmp += c(i, j) * c(j ,i)

    print(tmp)

main()


Measured memory_bytes: 44764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cassert>
using namespace std;

const int N = 1001;
int V, d;

unsigned F[1002];

int main() {

  while( cin >> V >> d ) {
    
    F[0] = 2;
    F[1] = 3;
    for(int i=2; i<1001; i++) {
      F[i] = (F[i-1]+F[i-2]) % N;
    }
    sort(F, F+V);
    
    int ans = 1;
    
    for(int i=0; i<V; i++) {
      if(i>0 && F[i]-F[i-1] >= d) {
	ans ++;
      }
    }
    
    cout << ans << endl;
 
  }
  

  return 0;
}

Measured memory_bytes: 1180
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;


fn main() {
    let n: usize = input();
    let mut rt = (n as f64).sqrt().ceil() as usize;
    while n % rt != 0 {
        rt -= 1;
    }

    let ans = rt - 1 + (n / rt) - 1;
    println!("{}", ans);
}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


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

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

const int N=2e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;


int main()
{
   ll n,d;
   cin>>n>>d;
   int ans=0;
   for(int i=1;i<=n;i++){
     ll x,y;
     cin>>x>>y;
     if(x*x+y*y<=d*d) ans++;

   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3632
def knapsack_weight(single=True):
    """
    重さが小さい時のナップサックDP
    :param single: True = 重複なし
    """
    """ dp[weight <= W] = 重さ上限を固定した時の最大価値 """
    dp_min = 0  # 総和価値の最小値
    dp = [dp_min] * (W + 1)

    for item in range(N):
        if single:
            S = range(W, weight_list[item] - 1, -1)
        else:
            S = range(weight_list[item], W + 1)
        for weight in S:
            if dp[weight] < dp[weight - weight_list[item]] + price_list[item]:
                dp[weight] = dp[weight - weight_list[item]] + price_list[item]
    return dp[W]

N, W = map(int, input().split())                                # N: 品物の種類 W: 重量制限
 
price_list = []
weight_list = []
for _ in range(N):
    weight, price = map(int, input().split())
    price_list.append(price)
    weight_list.append(weight)
 
print(knapsack_weight(single=True))

Measured memory_bytes: 79756
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main(){
    stdin.readln.chomp.filter!(a => a != ',' && a != '.').array.split.filter!(a => a.length > 2 && a.length < 7).reduce!((a, b) => a ~ " " ~ b).writeln;
}

Measured memory_bytes: 996
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
 
const int MN = 1100;

int n, m;
int a[MN];
vector<int> g[MN];
vector<int> rg[MN];
int out[MN];
int top[MN];
int rtop[MN];
int deg[MN];
int val[MN];

void init() {
    fill_n(top, MN, -1);
    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (out[i] == 0) {
            q.push(i);
        }
    }
    int c = 0;
    while (q.size()) {
        int p = q.front(); q.pop();
        if (top[p] != -1) continue;
        top[p] = c;
        rtop[c] = p; c++;
        for (int d: rg[p]) {
            out[d]--;
            if (out[d] == 0) {
                q.push(d);
            }
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y; x--; y--;
        g[x].push_back(y);
        rg[y].push_back(x);
        out[x]++;
    }
    init();
    for (int i = 0; i < n; i++) {
        set<int> s;
        int p = rtop[i];
        for (int d: g[p]) {
            s.insert(deg[d]);
        }
        int c = 0;
        while (s.count(c)) c++;
        deg[p] = c;
        val[deg[p]] ^= a[p];
    }
    bool f = false;
    for (int i = 0; i < n; i++) {
        if (val[i]) {
            f = true;
            break;
        }
    }

    if (f) {
        cout << 1 << endl;
    } else {
        cout << 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 1460
n = int(input())
l = []
for i in range(n):
    c,d = map(int,input().split())
    l.append([c,d])

l.sort(key = lambda x:x[1])

time = 0
ans = "Yes"
for i in range(n):
    limit = l[i][1]
    time += l[i][0]
    if time > limit:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 38036
#include<stdio.h>
#include<stdlib.h>
using namespace std;
const int maxn=1e5+10;
int n;
int a[maxn];
bool pre(int key)
{
    int left,right;
    left=0;
    right=n-1;
    int mid;
    while(left<=right)
    {
        mid=(left+right)/2;
        if(a[mid]==key)
            return true;
        if(key>a[mid])
            left=mid+1;
        else if(key<a[mid])
            right=mid-1;
    }
    return false;
}
int main()
{
    int sum=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
    int m;
    scanf("%d",&m);
    while(m--)
    {
        int x;
        scanf("%d",&x);
        if(pre(x))
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}



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

int main(){
    long long a, b, x;
    cin >> a >> b >> x;

    long long cou = 0;

    if(a % x == 0 && b % x == 0){
        cou += (b / x) - (a / x) + 1;
    }else if(a % x == 0){
        cou += (b / x) - (a / x) + 1;
    }else{
        cou += (b / x) - (a / x);
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys,heapq

input=sys.stdin.readline

N,M=map(int,input().split())
a=list(map(int,input().split()))
uf=UnionFindVerSize(N)
for i in range(M):
    x,y=map(int,input().split())
    uf.unite(x,y)

dic={}
for i in range(0,N):
    if uf.find_root(i) not in dic:
        dic[uf.find_root(i)]=[]
        heapq.heapify(dic[uf.find_root(i)])
    heapq.heappush(dic[uf.find_root(i)],a[i])

m=len(dic)
if m==1:
    print(0)
    exit()
ans=0
for i in dic:
    ans+=heapq.heappop(dic[i])

data=[]
for i in dic:
    data+=dic[i]
data.sort()
if len(data)<m-2:
    print("Impossible")
else:
    print(ans+sum(data[:m-2]))
    

Measured memory_bytes: 97816
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
const int N=200005;
const long long INF=1e18;
int n;
int x[N],y[N];
int pre[N],nxt[N];
struct Node
{
	int x,y,id;
}pos[N];
vector<int>val;
int id[N];
int dis(int a,int b)
{
	return abs(x[a]-x[b])+abs(y[a]-y[b]);
}
map<int,long long>dp[2][N];
long long solve(int l,int r,int side,int Min,int Max)
{
	if(dp[side][l][r]) return dp[side][l][r];
	long long res=INF;
	if(l>1&&(pos[l-1].y==Min-1||pos[l-1].y==Max+1))
	{
		int L=pre[l-1];
		long long tmp=solve(L,r,0,min(Min,pos[L].y),max(Max,pos[L].y))+dis(pos[L].id,pos[side?r:l].id);
		res=min(res,tmp);
	}
	if(r<n&&(pos[r+1].y==Min-1||pos[r+1].y==Max+1))
	{
		int R=nxt[r+1];
		long long tmp=solve(l,R,1,min(Min,pos[R].y),max(Max,pos[R].y))+dis(pos[R].id,pos[side?r:l].id);
		res=min(res,tmp);
	}
	if(res==INF) res=l-r;
	dp[side][l][r]=res;
	return res;
}
long long ans[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		val.push_back(y[i]);
		pos[i].x=x[i],pos[i].y=y[i],pos[i].id=i; 
	}
	sort(pos+1,pos+n+1,[](const Node &a,const Node &b){return a.x<b.x;}); 
	sort(val.begin(),val.end());
	for(int i=1;i<=n;i++)
		pos[i].y=lower_bound(val.begin(),val.end(),pos[i].y)-val.begin()+1;
	pre[1]=1;
	for(int i=2;i<=n;i++)
		if(abs(pos[i].y-pos[i-1].y)==1) pre[i]=pre[i-1];
		else pre[i]=i;
	nxt[n]=n;
	for(int i=n-1;i>=1;i--)
		if(abs(pos[i].y-pos[i+1].y)==1) nxt[i]=nxt[i+1];
		else nxt[i]=i;
	for(int i=1;i<=n;i++)
		ans[pos[i].id]=solve(i,i,0,pos[i].y,pos[i].y);
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 79148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int N,T,A;
  cin>>N>>T>>A;
  int H[N];
  rep(i,N) cin >> H[i];
  int ans;
  int cnt=INF;
  rep(i,N){
    int h=abs(1000*A-(1000*T-H[i]*6));
    if(h<cnt){
      cnt=h;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main()
{
  int n;
  ll a[200000];

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

  sort(a, a+n);

  ll b = a[n/2];

  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a[i] - b);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
using namespace std;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll X,Y;
	cin>>X>>Y;
	if(abs(X - Y) > 1)cout << "Alice" << endl;
	else cout << "Brown" << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int x;
  cin >> x;

  int gohyaku = x / 500;
  int nokori = x % 500;

  int ans = 0;
  ans = gohyaku * 1000;

  int go = nokori / 5;
  ans += go * 5;
  cout << ans;
}

Measured memory_bytes: 256
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll a, b;
int main(){
	IOS;
	cin >> a >> b;
	cout << (a * 3 + b) / 2;
	
	
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C++ (GCC 9.2.1)
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod int(1e9+7)

// fact(n)
template <typename T>
T fact(T n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n, r)
template <typename T>
T nCr(T n, T r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

// swap(&a, &b);
template <typename T>
void swap(T *a, T *b){
	T tmp;
	tmp = *a;	*a = *b;	*b = tmp;
	return;
}

// gcd(a, b)
template <typename T>
T gcd(T a,T b){
	if(a == 0) return b;
	else if(b == 0) return a;
	else return gcd(b,a % b);
}

// lcm(a, b)
template <typename T>
T lcm(T a,T b){
	return a / gcd(a,b) * b;
}

// divisor(type n)
template <typename T>
vector<T> divisor(T n)
{
  vector<T> ret;
  for(T i = 1; i * i <= n; i++)
	{
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

// eratosthenes(type n)
template <typename T>
vector<T> eratosthenes(T n){
	vector<bool> is_prime(n + 2, true);
	vector<T> primes;

	for (T i = 2; i <= n; i++)
	{
		if(is_prime[i]){
			for (T j = 2 * i; j <= n; j += i)	is_prime[j] = false;
			primes.push_back(i);
		}
	}
	return primes;
}

// vector scanner
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
	for(T& x : vec)	is >> x;
	return is;
}

int main(int argc, char const *argv[])
{
	// DON'T CHANGE
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	// here
	TLong a, b, c, d;
	cin >> a >> b >> c >> d;
	OUT(std::max({a * c, a * d, b * c, b * d})) BR;
	RET;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    vector<int> dp(300005);
    rep(i, 300005) dp[i] = i; // 1円のみ
    
    int val[] = {6, 9};
    rep(i, n) {
        rep(j, 2) {
            rep3(beki, 1, 10) {
                if (pow(val[j], beki) > n) break;
                // cout << i << " " << val[j] << " " << k << endl;
                chmin(dp[i + pow(val[j], beki)], dp[i] + 1);
            
            }
        }
    }
    cout << dp[n] << endl;
    // rep(i, n + 1) cout << dp[i] << " "; cout << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
#define IO ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define ull unsigned long long
#define up(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define down(a,b,c) for(ll (a)=(b)-1;(a)>=(c);(a)--)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define mii map<int,int>
#define mll map<ll,ll>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define debug(x) cout << "\t" << (#x) << " = " << (x) << endl
#define debugl(x,y) cout << "on loop " << (#x) << " : " << (x) << ", " << (#y) << " = " << (y) << endl 
#define N 300050

using namespace std;

int main(){
	IO;
	int n,m;
	cin >> n >> m;
	cout << n*(n-1)/2+m*(m-1)/2 << endl;
	
}

Measured memory_bytes: 256
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

p_li = list(map(int, input().split()))
p_li.sort()

ans = 999
for i in range(-1, 102):
    if not i in p_li:
        tmp = i

        if abs(x - ans) > abs(x - tmp):
            ans = i

print(ans)


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

int main() {
  string s;
  cin>>s;
  int n=s.length();
  int cnt=0;
  for (size_t i = 0; i < n; i+=2) {
    if (s[i]=='0') {
      cnt++;
    }
  }
  for (size_t i = 1; i < n; i+=2) {
    if (s[i]=='1') {
      cnt++;
    }
  }
  cout<<min(cnt,n-cnt);
}

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

int main(void){
	int n, m, max = 0;
	queue<int> que;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<bool> v(n, false);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for(int i = 0; i < n; i++){
		int p = 0;
		if(!v[i]) {
			que.push(i);
			v[i] = true;
			p++;
			//printf("%d pushed\n", i);
		}
		while(!que.empty()){
			int t = que.front();
			que.pop();
			//printf("%d poped\n", t);
			for(int j : graph[t]){
				if(!v[j]){
					que.push(j);
					v[j] = true;
					p++;
					//printf("%d pushed\n", j);
				}
			}
		}
		if(max < p) max = p;
	}
	cout << max << endl;
	return 0;
}


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

int a()
{
    std::string s, t;
    std::cin >> s;
    std::cin >> t;
    
    std::string ans = "Yes";
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] != t[i])
        {
            ans = "No";
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<utility>
#include<vector>
using namespace std;
typedef pair<int, int> P;

int n, m;
int c[49], depth[50], p[50];
long dp[50][1 << 20];
vector<P> v[50];

void init(int x, int d) {
    depth[x] = d;
    for (auto &i : v[x]) {
        if (i.first != p[x]) {
            p[i.first] = x;
            init(i.first, d + 1);
        }
    }
}

void lca(int x, int y, int z) {
    if (depth[x] > depth[y]) swap(x, y);
    while (depth[y] > depth[x]) {
        for (auto &i : v[y]) {
            if (i.first == p[y]) {
                c[i.second] |= 1 << z;
            }
        }
        y = p[y];
    }
    while (y != x) {
        for (auto &i : v[x]) {
            if (i.first == p[x]) {
                c[i.second] |= 1 << z;
            }
        }
        x = p[x];
        for (auto &i : v[y]) {
            if (i.first == p[y]) {
                c[i.second] |= 1 << z;
            }
        }
        y = p[y];
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        v[a - 1].emplace_back(b - 1, i);
        v[b - 1].emplace_back(a - 1, i);
    }
    scanf("%d", &m);
    init(0, 0);
    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        lca(u - 1, v - 1, i);
    }
    
    dp[0][0] = 1;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < 1 << m; j++) {
            dp[i + 1][j | c[i]] += dp[i][j];
            dp[i + 1][j] += dp[i][j];
        }
    }

    printf("%ld\n", dp[n - 1][(1 << m) - 1]);
    return 0;
}


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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            res += d[i] * d[j];
        }
    }
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_right = [i+ai for i,ai in enumerate(a,1)]
a_left  = [i-ai for i,ai in enumerate(a,1)]

a_right_count = Counter(a_right)
a_left_count  = Counter(a_left)

ans = 0
for k,v in a_right_count.items():
    ans += v * a_left_count.get(k,0)

print(ans)

Measured memory_bytes: 63516
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1e9+7;

signed main() {
  int N,M;cin>>N>>M;
  std::vector<int> go[N];
  typedef pair<int,int> P;
  std::vector<int> size(N,0);
  std::vector<int> num(N);
  vector<int> from[N];
  for(int i=0;i<N+M-1;i++){
    int a,b;cin>>a>>b;
    a--;b--;
    go[a].push_back(b);
    from[b].push_back(a);
    size[b]++;
  }
  queue<int> que;
  for(int i=0;i<N;i++)if(size[i]==0)que.push(i);
  int number=0;
  while(que.size()){
    int q=que.front();que.pop();
    num[q]=number++;
    for(int i=0;i<go[q].size();i++){
      size[go[q][i]]--;
      if(size[go[q][i]]==0)que.push(go[q][i]);
    }
  }
  for(int i=0;i<N;i++){
    if(from[i].size()==0)cout<<0<<endl;
    else{
      int m=-1,parent;
      for(int j=0;j<from[i].size();j++){
        if(m<num[from[i][j]]){
          m=num[from[i][j]];
          parent=from[i][j];
        }
      }
      cout<<parent+1<<endl;
    }
  }
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
  int n;
  cin>>n;
  int x=n/200;

  if(x==2) cout<<"8";
  else if(x==3) cout<<"7";
  else if(x==4) cout<<"6";
  else if(x==5) cout<<"5";
  else if(x==6) cout<<"4";
  else if(x==7) cout<<"3";
  else if(x==8) cout<<"2";
  else if(x==9) cout<<"1";

   

return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
  char b[10];
    int  ans[]={0},aiu=0,i=0;
  scanf("%s",b);
for(int j=0;j<10;j++){
 if(b[j]=='A'||b[j]=='C'||b[j]=='G'||b[j]=='T') {
   i++;
 }else {
 
   i=0;
 }
if(i>aiu){
  aiu=i;
  }
}
        
  printf("%d",aiu);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python3
# Dmitry _kun_ Sayutin (2020)

from fractions import *

n = int(input())

mp = dict()
for i in range(n):
    var = Fraction(input().strip())
    nom = var.numerator
    denom = var.denominator

    i, j = 0, 0
    
    while denom % 2 == 0:
        i -= 1
        denom //= 2
    
    while denom % 5 == 0:
        j -= 1
        denom //= 5

    while nom % 2 == 0:
        i += 1
        nom //= 2

    while nom % 5 == 0:
        j += 1
        nom //= 5

    i = min(i, 10)
    j = min(j, 10)

    mp[(i, j)] = mp.get((i, j), 0) + 1

ans = 0
for (a, cnt1) in mp.items():
    for (b, cnt2) in mp.items():
        if a < b and a[0] + b[0] >= 0 and a[1] + b[1] >= 0:
            ans += cnt1 * cnt2

for (a, cnt) in mp.items():
    if a[0] >= 0 and a[1] >= 0:
        ans += cnt * (cnt - 1) // 2
            
print(ans)


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

int main () {
    int N;
    cin >> N;
    vector<int>vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at (i);
    }
    double  sum=0.0;
    
    while (true) {
        for (int i=0; i<N; i++) {
            if (vec.at(i)%2==0) {
                sum+=1.0/(N+0.0);
                vec.at(i)/=2;
            }
            else {
                sum-=(i+0.0)/(N+0.0);
                goto OUT;
            }
        }
    }
OUT:
    cout << sum << endl;
}
    

                
                
                


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <math.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          1000000321

using namespace std;
bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;

    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;

    return true;
}

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

}

bool sortbydesc(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    if(a.S < b.S)
        return true;
    else
        return false;
}



int main()
{
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
 ll n;
 cin>>n;
 vector<ll> h;
 ll a;
 h.pb(0);
 fl(i,0,n)
 {
    cin>>a;
    h.pb(a);
  }
  ll dp[n+1];
  dp[1]=0;
  dp[2]=abs(h[2]-h[1]);
  fl(i,3,n+1)
   dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
 cout << dp[n];
}

Measured memory_bytes: 1908