akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n; cin >> n;
	VI a(n); rep(i, n)cin >> a[i];
	int q; cin >> q;
	VI k(q); rep(i, q)cin >> k[i];

	rep(i, q) {
		decltype(a)::iterator it = lower_bound(all(a), k[i]);
		size_t pos = distance(a.begin(), it);
		cout << pos << endl;
	}
}


Measured memory_bytes: 3884
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int total = (int) Math.ceil(((double)n / 1000));
		total *= 1000;
		System.out.println(total - n);
	}
}

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

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

  int x = a + b, y = a - b, z = a * b;
  int max = x;
  if (max < y) max = y;
  if (max < z) max = z;

  cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b,c;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26264
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    string s1, s2, s3; cin >> s1 >> s2 >> s3;
    char s[26]; REP(i,26) s[i] = 'A'+i;
    cout << s[s1[0]-'a'] << s[s2[0]-'a'] << s[s3[0]-'a'] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));
    cout << a[n/2] - a[n/2-1];
    return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main() {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r<0 || y-r<0 || x+r>W || y+r>H) printf("No\n");
    else printf("Yes\n");
    return 0;
}

Measured memory_bytes: 584
#include<stdio.h>
typedef long long ll;
const int mod=1e9+7,i2=(mod+1)/2;
int mul(int a,int b){return(ll)a*b%mod;}
int ad(int a,int b){return(a+=b)>=mod?a-mod:a;}
int pow(int a,int b){
	int s=1;
	while(b){
		if(b&1)s=mul(s,a);
		a=mul(a,a);
		b>>=1;
	}
	return s;
}
int fac[200010],rfac[200010],pw[200010];
void pre(int n){
	int i;
	fac[0]=1;
	for(i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	rfac[n]=pow(fac[n],mod-2);
	for(i=n;i>0;i--)rfac[i-1]=mul(rfac[i],i);
	pw[0]=1;
	for(i=1;i<=n;i++)pw[i]=mul(pw[i-1],i2);
}
int C(int n,int k){return mul(fac[n],mul(rfac[k],rfac[n-k]));}
int go(int n,int m){
	return mul(C(n+m,n),pw[n+m]);
}
int f[200010],g[200010];
int main(){
	int n,m,i;
	scanf("%d%d",&n,&m);
	pre(n+m);
	for(i=n;i<=n+m;i++)f[i]=ad(f[i-1],mul(go(n-1,i-n),i2));
	for(i=m;i<=n+m;i++)g[i]=ad(g[i-1],mul(go(i-m,m-1),i2));
	for(i=0;i<n+m;i++)printf("%d\n",mul(mod+1-f[i]+g[i],i2));
}

Measured memory_bytes: 5248
S = input()

a = len(S)

while a != 0:
    if a - 5 < 0:
        print("NO")
        exit()
    elif S[a - 1] == "m" and S[a - 5:a] == "dream":
        a -= 5
    elif S[a - 1] == "e" and S[a - 5:a] == "erase":
        a -= 5
    elif S[a - 3:a] == "mer" and a - 7 >= 0 and S[a - 7:a] == "dreamer":
        a -= 7
    elif S[a - 3:a] == "ser" and a - 6 >= 0 and S[a - 6:a] == "eraser":
        a -= 6
    else:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    rep1(i, N){
        string S = to_s(i);
        ll ct = 0;
        for(auto s : S) ct += s - '0';
        if(ct >= A and ct <= B) ans += i;
    }

    print(ans);

    return 0;
}

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

using namespace std;

int main(){
	int map[6];
	for(int i=0;i<6;i++){
		map[i]=0;
	}
	int n;
	double length;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>length;
		if(length<165.0){
			map[0]++;
		}else if(length<170.0){
			map[1]++;
		}else if(length<175.0){
			map[2]++;
		}else if(length<180.0){
			map[3]++;
		}else if(length<185.0){
			map[4]++;
		}else{
			map[5]++;
		}
	}
	
	
	for(int i=0;i<6;i++){
		cout<<i+1<<":";
		for(int j=0;j<map[i];j++){
			cout<<"*";
		}
		cout<<endl;
	}
	
}

Measured memory_bytes: 1232
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    long n,m,x,i,j,k,flag,flag1,i1;
    cin>>n>>m>>x;
    long a[n][m+1],sum[m+1],b[n];
    flag=0;
    for ( i = 0; i < m+1; i++) sum[i]=0;
    for ( i = 0; i < n; i++) for ( j = 0; j < m+1; j++) cin>>a[i][j];
    for ( i = 0; i < n; i++) for ( j = 0; j < m+1; j++) sum[j]+=a[i][j];
    for (i = 1; i < m+1; i++)
    {
        if (sum[i]<x)
        {
            flag=-1;
            break;
        }
    }
    if (flag==0)
    {
        flag=sum[0];
        for ( i = 0; i < n; i++) b[i]=0;
        k=(int)(pow(2,n));
        for ( j = 1; j < k; j++)
        {
            for ( i = 0; i < n; i++)
            {
                if (b[i]==0) 
                {
                    b[i]=1;
                    break;
                }
                else
                {
                    b[i]=0;
                }
            }
            for ( i = 0; i < m+1; i++) sum[i]=0;
            for ( i = 0; i < n; i++) for ( i1 = 0; i1 < m+1; i1++) sum[i1]+=a[i][i1]*b[i];
            flag1=0;
            for (i = 1; i < m+1; i++)
            {
                if (sum[i]<x)
                {
                    flag1=-1;
                    break;
                }
            }
            if (flag1==0) if (sum[0]<flag) flag=sum[0];
        }
    }
    cout<<flag<<endl;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=100010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans;

    return (0);
}


Measured memory_bytes: 3664
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2005;
int c[N],a[N],n,k,res,sum;
inline void chg(R int x){for(;x<=2000;x+=x&-x)++c[x];}
inline int query(R int x){R int res=0;for(;x;x-=x&-x)res+=c[x];return res;}
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&a[i]),upd(res,i-1-query(a[i])),chg(a[i]);
	res=mul(res,k);
	fp(i,1,n)upd(sum,query(a[i]-1));
	upd(res,mul(sum,(1ll*k*(k-1)>>1)%P));
	printf("%d\n",res);
	return 0;
}

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

using lint = long long;

bool second_less(pair<int, lint> a, pair<int, lint> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

struct Edge {
    int from, to;
    lint cost;
};

struct UnionFind {
    vector<int> par;
    UnionFind(int N): par(N) {
        for (int i = 0; i < N; i++) {
            par[i] = i;
        }
    }

    int root(int a) {
        if (par[a] == a) {
            return a;
        } else {
            par[a] = root(par[a]);
            return par[a];
        }
    }
    void unite(int a, int b) {
        if (root(a) != root(b)) {
            par[root(b)] = root(a);
        }
    }
    bool same(int a, int b) {
        return root(a) == root(b);
    }
};

int main() {
    int N;
    cin >> N;
    vector<pair<int, lint>> x(N), y(N);
    for (int i = 0; i < N; i++) {
        x[i].first = y[i].first = i;
        cin >> x[i].second >> y[i].second;
    }

    sort(x.begin(), x.end(), second_less);
    sort(y.begin(), y.end(), second_less);

    vector<Edge> edge;
    for (int i = 1; i < N; i++) {
        edge.push_back({x[i - 1].first, x[i].first, abs(x[i].second - x[i - 1].second)});
        edge.push_back({y[i - 1].first, y[i].first, abs(y[i].second - y[i - 1].second)});
    }

    sort(edge.begin(), edge.end(), [](Edge a, Edge b) {return a.cost < b.cost;});

    lint ans = 0;
    UnionFind uf(N);
    for (int i = 0; i < edge.size(); i++) {
        if (uf.same(edge[i].from, edge[i].to) == false) {
            uf.unite(edge[i].from, edge[i].to);
            ans += edge[i].cost;
        }
    }

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

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

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int area[2][2];
    area[0][0] = 0;
    area[0][1] = 0;
    area[1][0] = W;
    area[1][1] = H;

    for(int i = 0; i < N; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
        switch(a) {
            case 1:
                area[0][0] = max(area[0][0], x);
                break;
            case 2:
                area[1][0] = min(area[1][0], x);
                break;
            case 3:
                area[0][1] = max(area[0][1], y);
                break;
            case 4:
                area[1][1] = min(area[1][1], y);
                break;
        }
    }
    int xx = area[1][0] - area[0][0];
    int yy = area[1][1] - area[0][1];
    int s;
    if(xx < 0 || yy < 0) s = 0;
    else s = xx * yy;
    cout << s << endl;
}

Measured memory_bytes: 256
s = input()
p = input()
r = 'No'
for i in range(len(s)):
	r_tmp = 'Yes'
	for j in range(len(p)):
		if s[(i+j)%(len(s))] != p[j]:
			r_tmp = 'No'
			break
	if r_tmp == 'Yes':
		r = r_tmp
		break
print(r)


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int n,a[200001];
int ans=1;
int main()
{
	int ans=1;
    cin >> n;
    for (int i=1;i<=n;i++)cin >> a[i];
    for (int i=1,d=0;i<=n;i++)
    {
        d=max(d,i-1-(a[i-1]+1)/2);
        ans=1ll*ans*(i-d)%MOD;
    }
    cout << ans;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;


class dice{
    public:
        dice():pip{0}{
        };
        void setpips();
        int getupnum();
        void direction(char dir);
        int cir(int up,int flont);
        bool operator==(const dice &d2) const{return !memcmp(pip, d2.pip,sizeof(int)*6);}
        friend std::ostream &operator<<(std::ostream &out, const dice &d); //この二つはセットfrindはまだ完全にわかっていない           
    private:
        int pip[6];
};

void dice::direction(char order){
    int tem;
    switch (order){
        case 'N':{
            tem=pip[0];
            pip[0]=pip[1];
            pip[1]=pip[5];
            pip[5]=pip[4];
            pip[4]=tem;
            break;
        }
        case 'E':{
            tem=pip[0];
            pip[0]=pip[3];
            pip[3]=pip[5];
            pip[5]=pip[2];
            pip[2]=tem;
            break;
        } 
        case 'S':{
            tem=pip[0];
            pip[0]=pip[4];
            pip[4]=pip[5];
            pip[5]=pip[1];
            pip[1]=tem;
            break;
        }
        case 'W':{
            tem=pip[0];
            pip[0]=pip[2];
            pip[2]=pip[5];
            pip[5]=pip[3];
            pip[3]=tem;
            break;
        }
        case 'R':{
            tem=pip[1];
            pip[1]=pip[2];
            pip[2]=pip[4];
            pip[4]=pip[3];
            pip[3]=tem;
            break;
        }
    }
}

void dice::setpips(){
    for(int i=0;i<6;i++){
        std::cin>>pip[i];
    }
}

int dice::getupnum(){
    return pip[0];
}

int main(){

    dice d1;
    dice d2;

    d1.setpips();
    d2.setpips();

    std::string dirs="RRRRNRRRWRRRWRRRERRRNRRR";
    for(int i= 0; i<dirs.size();i++){
        d1.direction(dirs[i]);
        if(d1==d2){
            std::cout<<"Yes"<<std::endl;
            return 0;
        }
    }
    std::cout<<"No"<<std::endl;
    return 0;
}


Measured memory_bytes: 3172
h, w = map(int, input().split())
f = [0 for _ in range(h)]
for i in range(h):
    f[i] = input()
cw = [f[i].count("W") for i in range(h)]
cb = [f[i].count("B") for i in range(h)]
cr = [f[i].count("R") for i in range(h)]
count = h * w
for i in range(1, h - 1):
    for j in range(i, h):
        count = min(count,h * w - sum(cw[:i]) - sum(cb[i:j]) - sum(cr[j:]))
print(count)


Measured memory_bytes: 5608
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  long n;
  cin >> n;
  ll x_i, y_i;
  vector<ll> z;
  vector<ll> w;
  REP(i, n) {
    cin >> x_i >> y_i;
    z.push_back(x_i + y_i);
    w.push_back(x_i - y_i);
  }
  size_t zmax = distance(z.begin(), max_element(z.begin(), z.end()));
  size_t zmin = distance(z.begin(), min_element(z.begin(), z.end()));
  size_t wmax = distance(w.begin(), max_element(w.begin(), w.end()));
  size_t wmin = distance(w.begin(), min_element(w.begin(), w.end()));
  cout << max({z[zmax] - z[zmin], w[wmax] - w[wmin]}) << endl;
}


Measured memory_bytes: 6580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();

ll ans=0,c=0;
rep(i,0,n-1)if(s[i]=='W')c++;

rep(i,0,n-1)
{
	if(s[i]=='W')c--;
	else ans+=c;
}
ol(ans);
return 0;
}



Measured memory_bytes: 720
import sys

input=sys.stdin.readline
sys.setrecursionlimit(10**7)

N,M=map(int,input().split())
edge=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

odd=0
f=0
s=0
v=[]
for i in range(N):
    if len(edge[i])%2==1:
        odd+=1
    elif len(edge[i])==4:
        f+=1
        v.append(i)
    elif len(edge[i])>=6:
        s+=1

if odd>0:
    print("No")
else:
    if s>0:
        print("Yes")
    elif f>2:
        print("Yes")
    elif f!=2:
        print("No")
    else:
        start=v[0]
        ban=v[1]
        check=False
        def dfs(V,pv):
            global check
            if V==start and pv==-1:
                for i in edge[start]:
                    if i!=ban:
                        dfs(i,start)
            elif V==start:
                check=True
            else:
                for i in edge[V]:
                    if i!=ban and i!=pv:
                        dfs(i,V)
        dfs(start,-1)
        if check:
            print("Yes")
        else:
            print("No")


Measured memory_bytes: 43184
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    N = input()

    print("Yes") if N == N[::-1] else print("No")


main()


Measured memory_bytes: 4884
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		ArrayList<Integer> p = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}

		int count = 0;
		for (int i = 1; i < n - 1; i++) {
			List<Integer> subList = new ArrayList<Integer>(p.subList(i - 1, i + 2));
			Collections.sort(subList);
			int subi = subList.get(1);
			int pi = p.get(i);
			if (subi == pi) {
				count++;
			}
		}

		PrintWriter out = new PrintWriter(System.out);
		out.println(count);

		out.flush();
	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 22356
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W, K;
  cin>>H>>W>>K;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  int num;
  int ans = inf;
  int tmpans;
  bool yaba;
  bool dame;
  bool ok;
  for(int bit=0;bit<(1<<H);++bit) {
    dame = false;
    map<int, int> amap;
    tmpans = 0;
    for(int i=0;i<H;++i) {
      if((bit&(1<<i))!=0) tmpans++;
    }
    for(int j=0;j<W;++j) {
      num = 0;
      ok = true;
      for(int i=0;i<H;++i) {
        if(S[i][j]=='1') {
          amap[num]++;
        }
        if(amap[num]>K) {
          ok = false;
          if(yaba) {
            dame = true;
            break;
          }
          else yaba = true;
          tmpans++;
          for(int i=0;i<H;++i) amap[i] = 0;
          j--;
          break;
        }
        if((bit&(1<<i))!=0) num++;
      }
      if(dame) break;
      if(ok) {
        yaba = false;
        dame = false;
      }
    }
    if(dame) continue;
    ans = min(ans, tmpans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3632
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
t = na()
m = ni()
p = [na() for _ in range(m)]

for i in range(m):
    a = []
    a = t.copy()
    a[p[i][0]-1] = p[i][1]
    print(sum(a))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n == 7 || n == 5 || n == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int a[100010], b[100010];
ll c[100010], n, m;

template <typename T>
struct UnionFind
{
    vector<T> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool connected(T x, T y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return true;
        else
            return false;
    }

    bool unite(T x, T y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return false;
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    int find(T k)
    {
        if (data[k] < 0)
            return k;
        return (data[k] = find(data[k]));
    }

    T size(T k)
    {
        return (-data[find(k)]);
    }
};

int main()
{
    cin >> n >> m;
    UnionFind<ll> uf(n);
    for (int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
    c[m - 1] = n * (n - 1) / 2;
    for (int i = m - 1; i >= 0; i--)
    {
        if (uf.connected(a[i], b[i]))
        {
            c[i - 1] = c[i];
        }
        else
        {
            c[i - 1] = c[i] - uf.size(a[i]) * uf.size(b[i]);
            uf.unite(a[i], b[i]);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cout << c[i] << endl;
    }
}


Measured memory_bytes: 3712
#include<functional>
#include<vector>
template<typename T> class SparseTable {
 public:
  explicit SparseTable(const std::vector<T>& v, const std::function<bool(T, T)>& F = std::less<T>()) : V(v), F(F), table_(v.size()) {
    for(auto i = 0; i < v.size(); ++i) table_[0].emplace_back(i);
    for(auto i = 1; pow2(i) <= v.size(); ++i) {
      for(auto j = 0; j + pow2(i) - 1 < v.size(); ++j) {
        auto a = table_[i - 1][j + pow2(i - 1)];
        auto b = table_[i - 1][j];
        table_[i].emplace_back(F(v[a], v[b]) ? a : b);
      }
    }
  }
  T index(int l, int r) const {
    auto d = leftmost(r - l + 1);
    auto a = table_[d][r - pow2(d) + 1];
    auto b = table_[d][l];
    return F(V[a], V[b]) ? a : b;
  }
  T find(int l, int r) const {
    return V[index(l, r)];
  }
 private:
  inline int pow2(int n) const {return 1 << n;}
  inline int leftmost(int n) const {return std::__lg(n);}
  const std::vector<T> V;
  const std::function<bool(T, T)> F;
  std::vector<std::vector<int>> table_;
};

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

using LL = long long;

const LL INF = 1e18;

int N, M;
LL K;
vector<LL> A;

LL score(int l, int r) {
  static SparseTable<LL> minimum(A);
  static SparseTable<LL> maximum(A, greater<LL>());
  return K + (r - l) * (maximum.find(l, r-1) - minimum.find(l, r-1));
}

LL dfs(int i) {
  static vector<LL> memo(N, -1);
  if(i == N) return 0;
  if(~memo[i]) return memo[i];
  LL res = INF;
  for(auto w = 1; w <= M; ++w) if(i+w <= N) res = min(res, score(i,i+w)+dfs(i+w));
  return memo[i] = res;
}

int main() {
  cin >> N >> M >> K;
  A.resize(N);
  for(auto& i: A) cin >> i;
  cout << dfs(0) << endl;
}

Measured memory_bytes: 7988
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
struct node{
	double x,y;
}p[105];
bool cmp(node a,node b){
	RE atan2(a.x,a.y)<atan2(b.x,b.y);
}
int n;
int main(){
	scanf("%d",&n);
	FOR(i,1,n)scanf("%lf%lf",&p[i].x,&p[i].y);
	sort(p+1,p+n+1,cmp);
	int l;
	double tx,ty,ans=0;
	FOR(i,1,n){
		tx=p[i].x;ty=p[i].y;l=i;
		ans=max(ans,tx*tx+ty*ty);
		rep(j,1,n){
			l++;
			if(l>n)l=1;
			tx+=p[l].x;ty+=p[l].y;
			ans=max(ans,tx*tx+ty*ty);
		}
	}
	printf("%.12f",sqrt(ans));
	RE 0;
}



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

int main(){
  int A, B;
  cin >> A >> B;
  string s;
  int count = 0;
  
  for(int i=A; i<=B; i++){
    s = to_string(i);
    if(s.at(0)==s.at(4) && s.at(1)==s.at(3)){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep (i, n) {
        cin >> a[i];
        a[i] *= 2;
    }

    rep (i, n) {
        a.pb(a[i]);
    }

    ll nowAns = 0;
    rep (i, n) {
        if (i % 2 == 0) nowAns += a[i];
        else nowAns -= a[i];
    }

    rep (i, n) {
        if (!i) cout << nowAns / 2<< endl;
        else {
            nowAns *= -1;
            nowAns += a[i - 1] *= 2;
            cout << nowAns / 2 << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int H;
void input() {
  cin >> N >> M;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
  ;
}
void solve() {
  sort(all(va));
  reverse(all(va));
  int ans = 0;
  rep(i, 0, N - 1) {
    if (i >= M) {
      ans += va[i];
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vp ab(N);
  rep(i,N) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(rng(ab));
  int ans = ab.back().first + ab.back().second;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4032
N,M = gets.chomp.split(" ").map(&:to_i)
I = []
for i in 1..M
  a,b = gets.chomp.split(" ").map(&:to_i)
  I.push(a,b)
end

P = []
for i in 1..N
  num = I.count(i)
  P.push(num)
end

P.each do |n|
  print("#{n}\n")
end

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

using Lint=long long;
const Lint INF=1e18;

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

   vector<Lint> sum(N+1);
   for(int i=0;i<N;i++) sum[i+1]=sum[i]+a[i];

   vector<vector<Lint>> dp(N+1,vector<Lint>(N+1,INF));
   for(int i=0;i<N;i++) dp[i][i+1]=0;
   for(int len=2;len<=N;len++){
      for(int i=0;i+len<=N;i++){
         int j=i+len;
         for(int k=i+1;k<j;k++) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]+(sum[j]-sum[i]));
      }
   }
   cout<<dp[0][N]<<endl;
   return 0;
}


Measured memory_bytes: 1536
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
           
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
           
//#define int long long
  
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template<typename T>
using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
  
void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifndef _offline
    //freopen("mincost.in", "r", stdin);
    //freopen("mincost.out", "w", stdout);
    #endif
}

const int INF = 1e9 + 7;
const int MAXN = 105;
char c[MAXN][MAXN];
int dp[MAXN][MAXN];

signed main() {
    FAST_IO();
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            dp[i][j] = INF;
            if (i == 0 && j == 0) {
                dp[i][j] = (c[i][j] == '#' ? 1 : 0);
                continue;
            }
            if (i != 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1][j] == '.' && c[i][j] == '#'));
            }
            if (j != 0) {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (c[i][j - 1] == '.' && c[i][j] == '#'));
            }
        }
    }
    cout << dp[n - 1][m - 1] << '\n';
}  

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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  //srand(time(NULL));

  vecll human(26);
  vecll last(26);

  ll manzoku=0;
  rep(i,d){
    int id = 0;
    ll mx = s[i][0];
    rep(j,26){
      if(mx < s[i][j]){
        id = j;
        chmax(mx, s[i][j]);
      }
    }
    prt(id+1);

    manzoku += s[i][id];
    rep(j,26){
      if(j!=id) last[j]++;
      else last[j]=0;
    }
    rep(j,26){
      manzoku -= last[j]*c[j];
    }
    //prt(manzoku);
  }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n;
    ll ans = 0;
    for (i = 1; i <= n;i++){
        ans += (i * (n - i + 1));
    }
    for (i = 1; i < n;i++){
        ll u, v;
        cin >> u >> v;
        ans -= (min(u, v) * (n - max(u, v) + 1));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long int a[n];
	long long int ans=0;
	long long int maxx[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans = max(ans,a[i]);
		maxx[i] = ans;
	}
	long long int cnt=0;
	for(int i=1;i<n;i++){
		if(a[i]!=maxx[i]){
			cnt+=(maxx[i]-a[i]);
		}
	}
	cout<<cnt<<endl;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

template<typename T>
T arg_min(V<T> v){
    auto itr = min_element(ALL(v));
    return distance(v.be(),itr);
}

int main(){
    int N,M;
    cin>>N>>M;
    V<Pii> PY(M);
    V<Vi> Y(N);
    REP(i,M){
        cin>>PY[i].fi>>PY[i].se;
        Y[PY[i].fi-1].pb(PY[i].se);
    }

    REP(i,N) sort(ALL(Y[i]));

    V<Mii> YY(N);
    REP(i,N){
        REP(j,Y[i].size()){
            YY[i][Y[i][j]] = j+1;
        }
    }

    REP(i,M){
        cout<<setw(6)<<setfill('0')<<PY[i].fi;
        cout<<setw(6)<<setfill('0')<<YY[PY[i].fi-1][PY[i].se]<<endl;
    }
    return 0;
}

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

int main() {
	long long  Q, H, S, D; // 0.25, 0.5, 1, 2L
	cin >> Q >> H >> S >> D;
	int N;
	cin >> N;
	int divide = N / 2;
	long long ans = 0;
	ans += min({Q * 8, H * 4, S * 2, D}) * divide;
	ans += min({Q * 4, H * 2, S}) * (N % 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		new Main().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long x = sc.nextLong();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long[][] min_cost = new long[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(min_cost[i], 1L << 60);
		}

		long[] total_cost = new long[n];
		for (int i = 0; i < n; i++) {
			total_cost[i] += x * i;
		}
		// min_cost[i][j]:i番目のスライムの作るのに必要なコストの最小値
		// （但し魔法はj回使うものとして、魔法のコストは含まない)
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				int pos = (j + n - k) % n;
				if (k > 0)
					min_cost[j][k] = min_cost[j][k - 1];
				min_cost[j][k] = Math.min(min_cost[j][k], a[pos]);
				total_cost[k] += min_cost[j][k];
			}
		}

		long ans = 1L << 60;
		for (int i = 0; i < n; i++) {
			ans = Math.min(ans, total_cost[i]);
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 43288
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n, d;
    cin >> n >> d;
    int ans = n/(2*d+1);
    if (n % (2*d+1) != 0) ans++;
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    vector<ll> sa(n);
    iota(ALL(sa), 0);
    sort(ALL(sa), [&](int x, int y){
        return a[x] > a[y];
    });
    bool used[n];
    rep(i, n)used[i] = false;
    ll pos = 0;
    vector<ll> value;
    rep(i, n-1){
        used[i] = true;
        while(used[sa[pos]])pos++;
        value.push_back(a[sa[pos]]-a[i]);
    }
    sort(ALL(value), greater<ll>());
    
    ll ans =1;
    while(value[ans] == value.front())++ans;
    cout << ans << endl;
}

Measured memory_bytes: 3064
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=II()
	A=[II() for _ in range(n)]
	s=set()
	for i,v in enumerate(A):
		if i%2:
			s.add(v)
	A.sort()
	ss=set()
	for i,v in enumerate(A):
		if i%2:
			ss.add(v)
	ans=len(s)

	sss=s&ss

	print(ans-len(sss))
















if __name__ == "__main__":
	main()


Measured memory_bytes: 19600
import sys

sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
n, q = map(int, input().split())

edges = [[] for _ in range(n)]
for _ in range(n - 1):
    frm, to = map(int, input().split())
    # 0-index
    edges[frm - 1].append(to - 1)
    edges[to - 1].append(frm - 1)

scores = [0] * n
for _ in range(q):
    v, s = map(int, input().split())
    scores[v - 1] += s


def dfs(frm, cur):
    if cur > 0:
        scores[cur] += scores[frm]
    for to in edges[cur]:
        if frm != to:
            dfs(cur, to)


dfs(-1, 0)
print(" ".join([str(w) for w in scores]))

Measured memory_bytes: 232340
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const ll INF = 1001001001;

int main() {
  int k;
  cin >> k;
  int cur = 0;
  set<int> st;
  int ans = 0;

  while (1) {
    ans++; 
    cur = (cur * 10 + 7) % k;
    if (cur == 0) break;;
    auto it = st.find(cur);
    if (it != st.end()) {
      cout << -1 << endl;
      return 0;
    }

    st.insert(cur);
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 50504
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

import bisect
ans=0
for i in b:
    q=bisect.bisect_left(a,i)
    s=bisect.bisect_right(c,i)
    ans=ans+q*(n-s)
print(ans)
    


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

int main(){

    int N;
    cin >> N;

    string s;
    cin >> s;

    bool result = true;
    if (N&1) {
        result = false;
    } else {
        int mid = N/2;
        for (int i = 0; i < mid; i++) {
            if (s[i] != s[i+mid]) {
                result = false;
                break;
            }
        }
    }

    if (result)
        cout << "Yes";
    else
        cout << "No";
    cout << "\n";


    return 0;
}


Measured memory_bytes: 256
<?php
$s = trim(fgets(STDIN));
$l = strlen($s);
$half = floor($l/2);

$s1 = substr($s,0,$half);
$s2 = substr($s,-$half);

echo isP($s) && isP($s1) && isP($s2) ? "Yes" : "No";

function isP($s){
  $l = strlen($s);
  $flag = true;
  for($i = 0; $i < $l; $i++){
    if($s[$i] != $s[$l-$i-1]){
      $flag = false;
    }
  }
  return $flag;
}

Measured memory_bytes: 4604