akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

#define EPS 1e-10
bool eq(double a, double b) {return fabs(a - b) < EPS;}

struct Point {
    double x, y;
    Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}
    Point operator + (Point &p);
    Point operator - (Point &p);
    Point operator * (double k);
    Point operator / (double k);
    bool operator == (const Point &p) const;
    double norm();
    double abs();
    void print();
} typedef Vec;


struct Segment {
    Point p1, p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(double x1, double y1, double x2, double y2) : p1(Point(x1, y1)), p2(Point(x2, y2)) {}
} typedef Line;

struct Circle {
    Point o; double r;
    Circle(Point o, double r) : o(o), r(r) {}
    Circle(double x, double y, double r) : o(Point(x, y)), r(r) {}
};

double norm(Vec a);
double abs(Vec a);

double dot(Vec a, Vec b);
double cross(Vec a, Vec b);

bool isOrthogonal(Vec a, Vec b);
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2);
bool isOrthogonal(Segment s1, Segment s2);

bool isParallel(Vec a, Vec b);
bool isParallel(Point a1, Point a2, Point b1, Point b2);
bool isParallel(Segment s1, Segment s2);

Point project(Segment s, Point p);
Point reflect(Segment s, Point p);

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Line l(x1, y1, x2, y2);
    int q; cin >> q;
    while(q--) {
        double x, y;
        cin >> x >> y;
        auto p = reflect(l, Point(x, y));
        p.print();
    }
    return 0;
}

Point Point::operator + (Point &p) {return Point(x + p.x, y + p.y);}
Point Point::operator - (Point &p) {return Point(x - p.x, y - p.y);}
Point Point::operator * (double k) {return Point(x * k, y * k);}
Point Point::operator / (double k) {return Point(x / k, y / k);}
bool Point::operator == (const Point &p) const {return eq(x, p.x) && eq(y, p.y);}
double Point::norm() {return x * x + y * y;}
double Point::abs() {return sqrt(norm());}
void Point::print() {printf("%.10lf %.10lf\n", x, y);}

double norm(Vec a) {return a.x * a.x + a.y * a.y;}
double abs(Vec a) {return sqrt(norm(a));}

double dot(Vec a, Vec b) {return a.x * b.x + a.y * b.y;}
double cross(Vec a, Vec b) {return a.x * b.y - a.y * b.x;}

bool isOrthogonal(Vec a, Vec b) {return eq(dot(a, b), 0.0);}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {return isOrthogonal(a1 - a2, b1 - b2);}
bool isOrthogonal(Segment s1, Segment s2) {return eq(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);}

bool isParallel(Vec a, Vec b) {return eq(cross(a, b), 0.0);}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {return isParallel(a1 - a2, b1 - b2);}
bool isParallel(Segment s1, Segment s2) {return eq(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);}

Point project(Segment s, Point p) {
    Vec base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return base * r + s.p1;
};
Point reflect(Segment s, Point p) {return (project(s, p) - p) * 2.0 + p;}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp1[3001][3001],dp2[3001][3001];
ll a[3001];
ll f(ll i,ll j,ll y){
   if(y == -1){
   if(dp2[i][j] != -1){
     return dp2[i][j];
   }
   if(i == j){
     return dp2[i][j] = y*a[i];
   }
   return dp2[i][j] = min(y*a[i]+ f(i+1,j,-y),y*a[j]+ f(i,j-1,-y));
   }
   if(y == 1){
     if(dp1[i][j] != -1){
     return dp1[i][j];
   }
   if(i == j){
     return dp1[i][j] = y*a[i];
   }
   return dp1[i][j] = max(y*a[i]+ f(i+1,j,-y),y*a[j]+ f(i,j-1,-y));
   }
}
signed main(){
  memset(dp1,-1,sizeof dp1);
  memset(dp2,-1,sizeof dp2);
  ll n;
  cin>>n;
  for(ll i=0;i<n;i++)cin>>a[i];
  if(n == 1){
    cout << a[0] << '\n';
    return 0;
  }
  cout << max(a[0]+f(1,n-1,-1) , a[n-1] + f(0,n-2,-1));
return 0;
}


Measured memory_bytes: 141184
#include  <functional>
#include  <algorithm>
#include  <exception>
#include  <stdexcept>
#include  <streambuf>
#include  <iterator>
#include  <string.h>
#include  <stdlib.h>
#include  <typeinfo>
#include  <valarray>
#include  <iostream>
#include  <sstream>
#include  <istream>
#include  <stdio.h>
#include  <climits>
#include  <clocale>
#include  <complex>
#include  <csetjmp>
#include  <csignal>
#include  <cstdarg>
#include  <cstddef>
#include  <ctype.h>
#include  <cassert>
#include  <cstdlib>
#include  <utility>
#include  <cstring>
#include  <numeric>
#include  <ostream>
#include  <cwctype>
#include  <fstream>
#include  <iomanip>
#include  <math.h>
#include  <bitset>
#include  <cctype>
#include  <string>
#include  <vector>
#include  <limits>
#include  <locale>
#include  <memory>
#include  <cerrno>
#include  <iosfwd>
#include  <cfloat>
#include  <cstdio>
#include  <cwchar>
#include  <cmath>
#include  <ctime>
#include  <deque>
#include  <queue>
#include  <stack>
#include  <list>
#include  <ios>
#include  <map>
#include  <set>
#include  <new>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define mp make_pair
using namespace std;
int n,m;
map<pair<int,int>,bool> ma;
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        ma[mp(a,b)]=1;
        ma[mp(b,a)]=1;
    }
    for(int i=2;i<=n-1;i++)
    {
        if(ma[mp(i,1)] && ma[mp(i,n)])
        {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 37760
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;



int main(){
    string S;
    cin >> S;
    vector<int> flag(123);
    string ans = "Yes";
    for(int i = 0;i<S.size();i++){
        flag.at(S.at(i)) = flag.at(S.at(i)) + 1;
    }
    for(int j = 0;j<123;j++){
        if(flag.at(j)%2 != 0){
            ans = "No";
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int n,m;

vector<int> edge[1001];
int searched[1001];
int used[1001];
int blocked[1001];
vector<int> path;

bool dfs(int p)
{
    used[p] = 1;
    path.push_back(p);
    int su = 0;
    for(int i = 0; i < edge[p].size(); i++)
    {
        su += used[edge[p][i]];
    }
    if(su >= 2)
        return false;
    if(su == 1)
    {
        for(int i = 0; i < edge[p].size(); i++)
        {
            if(used[edge[p][i]])
            {
                for(int j = 0; j < path.size(); j++)
                {
                    if(path[j] == edge[p][i])
                    {
                        cout << path.size()-j << endl;
                        for(; j < path.size(); j++)
                        {
                            cout << path[j] << endl;
                        }
                        return true;
                    }
                }
            }
        }
    }
    else
    {
        vector<int> bs(edge[p].size());
        for(int i = 0; i < edge[p].size(); i++)
        {
            if(blocked[edge[p][i]])
                bs[i] = 0;
            else
            {
                blocked[edge[p][i]] = 1;
                bs[i] = 1;
            }
        }
        for(int i = 0; i < edge[p].size(); i++)
        {
            if(bs[i])
            {
                if(dfs(edge[p][i]))
                    return true;
            }
        }
        for(int i = 0; i < edge[p].size(); i++)
        {
            if(bs[i])
                blocked[edge[p][i]] = 0;
        }
    }
    used[p] = 0;
    path.pop_back();
    //searched[p] = 1;
    return false;
}

void solve()
{
    int i,j;
    cin >> n >> m;
    int a,b;
    for(i = 0; i < m; i++)
    {
        cin >> a >> b;
        edge[a].push_back(b);
    }
    for(i = 0; i <= n; i++)
    {
        //if(searched[i] == 0 && dfs(i)) return;
        if(dfs(i))
            return;
    }
    cout << -1 << endl;
}

int main()
{
    solve();
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=55,M=110,mod=1e9+7;
int gcd(int a,int b) { return b?gcd(b,a%b):a; }
int Pow(int x,int y) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
int fac[M<<1],inv[M<<1];
void getfac(int n) {
    fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
    inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int C(int n,int m) { return fac[n]*(ll)inv[m]%mod*inv[n-m]%mod; }
int ans,K,n,m;
int vis[N],st[N],top;
int dfn[N],low[N],id;
int mp[N][N];
vector<int> cur;
void sol() {
    int m=0,n=cur.size();
    for(int i=0;i<n;++i)
        for(int j=i+1;j<n;++j)
            m+=mp[cur[i]][cur[j]];
    if(m!=n) ans=ans*(ll)C(m+K-1,K-1)%mod;
    else {
        int t=0;
        for(int i=1;i<=n;++i)
            t=(t+Pow(K,gcd(i,n)))%mod;
        ans=ans*(ll)t%mod*Pow(n,mod-2)%mod;
    }
    // for(int i=0;i<cur.size();++i) printf("%d ",cur[i]); puts("");
    cur.clear();
}
void tarjan(int u,int last) {
    dfn[u]=low[u]=++id;
    st[++top]=u,vis[u]=1;
    for(int v=1;v<=n;++v) if(mp[u][v]&&v!=last) {
        if(!vis[v]) {
            tarjan(v,u),low[u]=min(low[u],low[v]);
            if(low[v]>=dfn[u]) {
                do cur.PB(st[top]); while(st[top--]!=v);
                cur.PB(u),sol();
            }
        }
        else low[u]=min(low[u],dfn[v]);
    }
}
int main() {
    rd(n),rd(m),rd(K);
    getfac(K+m),ans=1;
    for(int i=1,x,y;i<=m;++i)
        rd(x),rd(y),mp[x][y]=mp[y][x]=1;
    for(int i=1;i<=n;++i) if(!vis[i]) tarjan(i,0);
    printf("%d",ans);
    return 0;
}

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

int main(int argc, char const *argv[]) {
	ll w, h, x, y; cin >> w >> h >> x >> y;
	printf("%f %d\n", double(w * h) / 2, (w == x * 2 && h == y * 2));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll long long
#define maxn 100005
using namespace std;
ll a[maxn],b[maxn];
int q[100005];
int n,s;
int main(){
  	scanf("%d %d",&n,&s);
  	int id=0;
  	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&a[i],&b[i]);
  		if(a[i]<s){
  			id=i;	
  		} 
 	}
  	int cnt=0,l=1,r=n;
  	while((l<=id)^(r<=id)){
  		if (b[l]>=b[r]) {
    		q[++cnt]=a[r];
    		b[l]+=b[r];
    		r--;
		}
		else {
			q[++cnt]=a[l];
			b[r]+=b[l];
			l++;
		}
  	}
  	if(r<=id){
 	 	for(int i=l;i<=r;i++){
 	 		q[++cnt]=a[i];
 	 	} 
 	}
	else{
  		for(int i=r;i>=l;i--){
  			q[++cnt]=a[i];
  		} 
  	}
  	q[cnt+1]=s;
  	ll ans=0;
  	for(int i=1;i<=cnt;i++){
  		ans+=abs(q[i]-q[i+1]);
  	} 
  	printf("%lld\n",ans);
  	return 0;
}

Measured memory_bytes: 2176
Sa = input()
Sb = input()
Sc = input()
a, b, c = 0, 0, 0
p = 'a'
ans = ''
while ans == '':
    if p == 'a':
        if a >= len(Sa):
            ans = 'A'
        else:
            p = Sa[a]
            a += 1
    elif p == 'b':
        if b >= len(Sb):
            ans = 'B'
        else:
            p = Sb[b]
            b += 1
    elif p == 'c':
        if c >= len(Sc):
            ans = 'C'
        else:
            p = Sc[c]
            c += 1
    # print(p, a, b, c, ans)

print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {
    int P = 0;
    int Q = 0;
    int R = 0;

    cin >> P >> Q >> R;

    int PQ = P+Q;
    int QR = Q+R;
    int PR = P+R;
  
    if (PQ <= QR && PQ <= PR) {
        cout << PQ;
        return 0;
    }
    if (QR <= PQ && QR <= PR ) {
        cout << QR;
        return 0;
    }

    cout << PR;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll a = 1, b = 2;
	if(n==0)
		cout<<b;
	else if(n==1) cout<<a;
	else
	{
		--n;
		ll h = 1;
		for(int i = 1; i<= n; i++)
		{
			h = a+b;
			b = a;
			a = h;
		}
		cout<<a<<endl;
	}
	return 0;
}

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

int main() {
  int a,b,c;
  cin >> a ;
b=a%1000;
c=a-a%10;
if(b%111==0||c%111==0)
{
  cout << "Yes"<< endl;
}
else{
cout << "No"<< endl;
}
}

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

bool palindrome(string s){
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(palindrome(s) && palindrome(s.substr(0,(n-1)/2)) && palindrome(s.substr((n+1)/2))) { 
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int N;
    readVars(N);
    auto a = readln.split.to!(long[]);

    auto ps = new long[](N + 1);
    ps[0] = a[0 .. N].sum;

    //auto minhp = heapify!"a > b"(Array!long(a[0 .. N]));
    auto minhp = new BinaryHeap!(Array!long, "a > b")();

    foreach(i ; 0 .. N){
        minhp.insert(a[i]);
    }

    long x;

    foreach(i ; 0 .. N){
        minhp.insert(a[N + i]);
        x = minhp.front; minhp.popFront;
        ps[i + 1] = ps[i] + a[N + i] - x;
    }

    auto ss = new long[](N + 1);
    ss[0] = a[2*N .. $].sum;
    
    //auto maxhp = heapify(Array!long(a[2*N .. $]));
    auto maxhp = new BinaryHeap!(Array!long)();

    foreach(i ; 0 .. N){
        maxhp.insert(a[3*N - 1 - i]);
    }

    foreach(i ; 0 .. N){
        maxhp.insert(a[2*N - 1 - i]);
        x = maxhp.front; maxhp.popFront;
        ss[i + 1] = ss[i] + a[2*N - 1 - i] - x;
    }

    /+
    a.writeln;
    ps.writeln;
    ss.writeln;
    +/

    long ans = -(1L<<60);
    //writeln(ans);

    foreach(i ; 0 .. N + 1){
        ans = max(ans, ps[i] - ss[N - i]);
    }

    writeln(ans);

}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 17740
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,m;
	int a[101010]={};
	cin>>n>>m;
	FOR(i,0,m)cin>>a[i];
	sort(a,a+m);
	if(n>=m){
		cout<<0<<endl;
		return 0;
	}
	priority_queue<pair<int,int>> pq;

	FOR(i,1,m){
		pq.push(MP(-(a[i]-a[i-1]),i));
	}
	LL ans=0;
	FOR(i,0,m-n){
		ans+=-pq.top().ST;
		pq.pop();
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

    ll n,m,a,b;
    vector<vector<ll>> v;
    vector<ll> v2;
    int maxx=0;
    int tmpmax=0;

void monmo(int g){
    if(v2[g]!=0){
        
    }else{
        v2[g]=1;
        maxx++;
        for(int i=0;i<v[g].size();i++){
            monmo(v[g][i]);
        }
    }
}


int main() {
    cin>>n>>m;
    for(int i=0;i<=n;i++){
        v.emplace_back();
        v2.push_back(0);
    }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        monmo(i);
        if(tmpmax<maxx)tmpmax=maxx;
        maxx=0;
    }
    cout<<tmpmax;
}


Measured memory_bytes: 21880
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;
ll a[200005],b[200005],c[200005];
int main(){
	ll m,n,i,j,s1,s2;
	cin>>n;
	double s=0,k=0;
	for(i=1;i<=n;i++){
		scanf("%d",&b[i]);
		a[b[i]]++;
	}
	for(j=1;j<=n;j++){
		k+=1.*(a[b[j]]-1)/2;
	}
	for(i=1;i<=n;i++){
	  	s=k;
	  	s-=a[b[i]]*(a[b[i]]-1)*1.0/2;
	  	a[b[i]]--;
	  	s+=a[b[i]]*(a[b[i]]-1)*1.0/2;
	   	printf("%lld\n",(ll)s);
  		a[b[i]]++;
 	}
   return 0;
} 

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

typedef long long ll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    rep(i, N - 2) {
        for (int j = i + 1; j < N - 1; j++) {
            if (L[i] == L[j]) continue;
            for (int k = j + 1; k < N; k++) {
                if (L[j] == L[k]) continue;
                if (L[i] + L[j] <= L[k]) continue;
                ans++;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3632
N = int(input())
now = 0
ans = 0
for i in range(1,N+1):
    if i%2 == 0:
        continue
    else:
        for j in range(1,i+1):
            if i%j == 0:
                now += 1
        if now == 8:
            ans += 1
        now = 0
print(ans)

Measured memory_bytes: 2940
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ')
using namespace std;
    
template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    
template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n;
LL a[1000005];
LL buk[5];

int main()
{
	read(n);
	for(RI i=1;i<=n;++i)
	{
		read(a[i]);
		if(a[i]%2==0)//a[i]为偶数
		{
			buk[2]++;	
		} 
		else
			buk[1]++;
	}
	if(buk[2]%2==0 && buk[1]%2==0)//如果有偶数个偶数 且有偶数个奇数
	{
		printf("YES");
		return 0;
	} 
	if(buk[2]%2==0 && buk[1]%2==1)//如果有偶数个偶数 且有奇数个奇数
	{
		printf("NO");
		return 0;	
	} 
	if(buk[2]%2==1 && buk[1]%2==0)//如果有奇数个偶数 且有偶数个奇数
	{
		printf("YES");
		return 0;
	} 
	if(buk[2]%2==1 && buk[1]%2==1)//如果有奇数个偶数 且有奇数个奇数
	{
		printf("NO");
		return 0;	
	} 
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    for(int i =0; i <= 100; i++)
    {
       for(int j = 0; j <= 100; j++)
       {
          if(i+j == x && 2*i + 4*j == y)
          {
             cout << "Yes";
             return 0;
          }
       }
    }
    cout << "No";
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<numeric>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

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

	string S;
	cin >> S;

	map<char,int> smap;
	rep(i,S.size()){
		smap[S[i]]++;
	}

	if(smap.size() != 26){
		char ch = 'a';
		while(1){
			if(!smap.count(ch)){
				S.push_back(ch);
				cout << S << endl;
				return 0;
			}
			else{
				ch++;
			}
		}
	}
	else{
		map<char,int> yuni;
		yuni[S[S.size()-1]]++;
		for(int index = S.size() - 2; index >= 0; index-- ){
			for(auto p: yuni ){
				if(p.first > S[index]){
					rep(j,index){
						cout << S[j];
					}
					cout << p.first << endl;
					return 0;
				}
				else{
					yuni[S[index]]++;
				}
			}
		}
	}


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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    public static MyScanner scan;
    public static PrintWriter out;
    public static void main(String[] args) {
        scan=new MyScanner();
        out=new PrintWriter(new BufferedOutputStream(System.out));

        int t=1;
//        int t=scan.nextInt();
        while(t-->0) {

            int n=scan.nextInt(),m=scan.nextInt(),ans=0;
            Djs groups=new Djs(n);
            for(int c=0;c<m;c++) {
                int a=scan.nextInt(),b=scan.nextInt();
                groups.union(a-1,b-1);
            }

            int[] freq=new int[n];
            for(int c=0;c<n;c++) freq[groups.getRoot(c)]++;
            for(int c=0;c<n;c++) ans=Math.max(ans,freq[c]);
            out.println(ans);

        }
        out.close();
    }

    static class Djs {
        int[] upper;
        Djs(int n) {
            upper=new int[n];
            Arrays.fill(upper, -1);
        }

        public int getRoot(int x) {
            return upper[x]<0?x:(getRoot(upper[x]));
        }

        public boolean equals(int x, int y) {
            return getRoot(x)==getRoot(y);
        }

        public boolean union(int x, int y) {
            x=getRoot(x);
            y=getRoot(y);
            if(x!=y) {
                if(upper[y]<upper[x]) {
                    int d=x;
                    x=y;
                    y=d;
                }
                upper[x]+=upper[y];
                upper[y]=x;
            }
            return x==y;
        }
    }



//    int n=scan.nextInt();
//    long sum=0,mod=(long)1000000007;
//    long[] a=new long[n];
//            for(int c=0;c<n;c++) a[c]=scan.nextLong();
//    HashSet<String> check=new HashSet<>();
//            for(int i=0;i<n;i++) {
//        for(int j=0;j<n;j++) {
//            if(!check.contains(i+" "+j)&&!check.contains(j+" "+i)&&i!=j) {
//                sum+=a[i]*a[j];
//                check.add(i+" "+j);
//                check.add(j+" "+i);
////                        out.println(sum);
//            }
//        }
//    } out.println(sum%mod);

    //scanner
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

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

int maxd = 0;
int k, n, a;
set<int, greater<int>> distances;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> k >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        distances.insert(a);
    }

    auto j = distances.begin();
    auto i = j++;

    while (j != distances.end())
    {
        maxd = max(maxd, *i - *j);
        i++;
        j++;
    }

    i = distances.begin();
    j = distances.end();
    j--;

    maxd = max(maxd, k - (*i - *j));

    cout << k - maxd;
    cin >> n;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int v[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d", &v[i]);
	}
	sort(v, v + n);
	reverse(v, v + n);
	int ind;
	for(ind = 0; v[ind] > ind; ind++);
	ind--;
	int dy = v[ind] - ind;
	int dx = 0;
	for(; v[ind + dx] >= ind + 1; dx++);
	//printf("%d %d\n", dx, dy);
	if (dy % 2 == 1 && dx % 2 == 1){
		printf("Second\n");
	} else {
		printf("First\n");
	}
	
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

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

int main() {
	// your code goes here
	ll n;
	cin >> n;
	string s="";
	while(n){
	    int temp = n%26;
	    if(temp==0){
	        temp=26;
	        n--;
	    }
	    s += ('a'+temp-1);
	    n=n/26;
	}
	reverse(s.begin(),s.end());
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3624
package main

import "fmt"

func main(){
	var n,x,y,dis int
	fmt.Scan(&n,&x,&y)
	fmt.Println(n)
	ans := make([]int,n)
	for i:=1 ; i<=n-1 ; i++ {
		for j := i+1 ; j<=n ; j++ {
			// measure dis(i,j)
			if j <= x || y <= i {
				// out of loop
				dis = j-i
			}
			if i <= x && y <= j {
				// out of loop
				dis = j-(y-x)-i+1
			}
			if x <= i && j <= y {
				// both in loop
				temp := i-x + 1 + y-j
				if temp < j-i {
					dis = temp
				} else {
					dis = j-i
				}
			}
			if i < x && x < j && j < y{
				// either in loop
				temp := y-j+1+x-i
				if temp < j-i {
					dis = temp
				} else {
					dis = j-i
				}
			}
			if x < i && i < y && y < j {
				temp := i-x + 1 + j-y
				if temp < j-i {
					dis = temp
				} else {
					dis = j-i
				}
			}
			//////////////////fmt.Println(i,j,dis)
			ans[dis]++
		}
	}
	for i:=2 ; i<n ; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 512
N, W = map(int, input().split())
w, v = [0]*N, [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())

memo = {}

def knapsack(i, j):
    key = '{}-{}'.format(i, j)
    if key in memo:
        return memo[key]
    if i == N:
        r = 0
    elif j < w[i]:
        r = knapsack(i + 1, j)
    else:
        r = max([knapsack(i + 1, j), knapsack(i + 1, j - w[i]) + v[i]])
    memo[key] = r
    return r

print(knapsack(0, W))


Measured memory_bytes: 19012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

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

int main(){
    string s1,s2,s3;

    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[0] << s3[0] << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n,m;
    cin>>n>>m;
    vector<int> g(n);
    REP(i,m) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a]++;
        g[b]++;
    }
    REP(i,n) {
        cout<<g[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int w,h,h2,l;
  scanf("%d %d",&w,&h);
  h2=2*h;
  if(h2>=w)
  {
    printf("%d",0);
  }
  else
  {
    l=w-h2;
    printf("%d",l);
  }
}
    

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vector<string> v(n);
    set<string> st;
    rep(i, n) {
        cin >> v[i];
        st.insert(v[i]); 
    }

    if(st.size() != n) {
        out("No");
        re0;
    }

    rep(i, n-1) {
        ll m = v[i].size();
        if(v[i][m-1] != v[i+1][0]) {
            out("No");
            re0;
        }
    }
    
    out("Yes");
    re0;
}

Measured memory_bytes: 256
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
	long long N,B,A;
	vector<long long> h;

	cin>>N>>A>>B;

	FOR(i,0,N){
		long long tmp;
		cin>>tmp;
		h.push_back(tmp);
	}

	long long upper=1000000000LL;
	long long lower=1;

	while(lower<upper){
		long long mid=(upper+lower)/2;
		long long need=0;

		FOR(i,0,N){
			long long tmp=h[i]-B*mid;
			if(tmp<0) tmp=0;
			need+=(tmp+(A-B)-1)/(A-B);
		}

		if(need>mid){
			lower=mid+1;
		}else{
			upper=mid;
		}
	}

	cout<<lower<<endl;
}


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=0;
		for(int n=1;n<=W;n++){
			x++;
			soto.append("#");}
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}}

Measured memory_bytes: 21136
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

bool primeCheck(int candidate){
	for (int i = 3; i <= sqrt(candidate); i += 2){
		if (candidate%i == 0)
			return false;
	}
	return true;
}

void kakunou(VPII &primeList){
	for (int i = 3; i < 10000; i += 2){
		if (primeCheck(i))
			if (primeCheck(i + 2))
				primeList.push_back(MP(i, i + 2));
	}
}

int main(){
	fastIO;
	VPII primeList;
	int n = 0;

	kakunou(primeList);

	while (cin >> n, n){
		for (int i = n; i >= 5; i--){
			if (count(primeList.begin(), primeList.end(), MP(i - 2, i)) == 1){
				cout << (i - 2) << " " << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1208
A, B, K = map(int, input().split())
for i in range(K):
  if i % 2 == 0:
    if A % 2 == 1:
      A -= 1
    A = A // 2
    B += A
  else:
    if  B % 2 == 1:
      B -= 1
    B = B // 2
    A += B
    
print(A, B)

Measured memory_bytes: 3060
N = 8


def putQueen(i):
    if i == N:
        printBoard()
        return

    if i in default:
        putQueen(i+1)

    else:
        for j in range(N):
            if col [j]   or \
               dpos[i+j] or \
               dneg[i-j+N-1]:
                continue

            tmp = row[i]
            row[i] = j
            col[j] = dpos[i+j] = dneg[i-j+N-1] = True

            putQueen(i+1)

            row[i] = tmp
            col[j] = dpos[i+j] = dneg[i-j+N-1] = False


def printBoard():
    for i in range(N):

        line = ''
        for j in range(N):
            if row[i] == j: line += 'Q'
            else          : line += '.'

        print(line)


if(__name__ == '__main__'):
    row  = [None] * N
    col  = [False] * N
    dpos = [False] * (2*N - 1)
    dneg = [False] * (2*N - 1)

    default = []

    n = int(input())

    for _ in range(n):
        r, c = [int(i) for i in input().split()]

        row[r] = c
        col[c] = dpos[r+c] = dneg[r-c+N-1] = True

        default.append(r)

    putQueen(0)



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (ll)4e18;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll mx = *max_element(all(a));
	ll sa = 1e9;
	ll m2;
	rep(i, n) {
		if (mx == a[i]) continue;
		ll t;
		t = min(mx - a[i], a[i]);
		if (sa >= mx / 2 - t) {
			sa = mx / 2 - t;
			m2 = a[i];
		}
	}
	printf("%lld %lld\n", mx, m2);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807
int main()
{
ll h , w ;
cin >> h >> w ;
vector<string> s(h);
rep(i, h){
  cin >> s[i];
}
rep(i,w-1){
vector<vector<ll>> v(h, vector<ll>(h,0) );
vector<vector<ll>> vv(h, vector<ll>(h,INF) );
vv[0][0]=0;
ll c=0;
rep(j,h){
  if(s[j][i]==s[j][i+1])c++;
  v[h-1-j][h-1-j]=c;
}
rep(l,h-1){
  c=0;
  rep(j,h-l-1){
    if(s[j][i]==s[j+l+1][i+1])c++;
    v[h-1-j][h-1-j-l-1]=c;
  }
  c=0;
  rep(j,h-l-1){
    if(s[j+l+1][i]==s[j][i+1])c++;
    v[h-1-j-l-1][h-1-j]=c;
  }
}
vv[0][0]=v[0][0];
rep(i,h-1){
  rep(j,h-1){
    vv[i][j+1]=min(vv[i][j+1],vv[i][j]+v[i][j+1]);
    vv[i+1][j]=min(vv[i+1][j],vv[i][j]+v[i+1][j]);
  }
}
ll t=INF;
rep(i,h)t=min(t,vv[i][h-1]);
rep(i,h)t=min(t,vv[h-1][i]);
ans+=t;
}

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

Measured memory_bytes: 1896
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
  if (y > x) x = y;
#define amin(x, y) \
  if (y < x) x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
  if (f) yes else no;
#define noo \
  { no return; }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
  vector<T> a = vector<T>(n + oneIndexed);

  for (ll i = 0; i < n; i++) {
    T p;
    cin >> p;
    a[i + oneIndexed] = p;
  }

  return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i] << " ";
  }
  cout << endl;
}

template <typename T, typename A>
void papair(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i].first << " " << a[i].second << endl;
  }
}
ll dp[500][500] = {0};
// ll dp2[1000] = {0};
void solve() {
  ll n;
  cin >> n;
  vector<ll> arr = ga(n);
  vector<ll> arr2;
  ll s = 0;
  arr2.push_back(0);
  for (ll i = 0; i < n; i++) {
    arr2.push_back(arr[i] + s);
    s += arr[i];
  }
  //   arr2.push_back(s);

  for (ll i = 1; i < n; i++) {
    for (ll j = i - 1; j >= 0; j--) {
      dp[j][i] = 1e16;
      for (ll k = j; k < i; k++) {
        amin(dp[j][i], dp[j][k] + dp[k + 1][i] + arr2[i + 1] - arr2[j]);
      }
    }
  }
  cout << dp[0][n - 1];
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // ll t;cin >> t;while(t--)
  solve();
  return 0;
}

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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while (t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n, m; cin >> n >> m;
    cout << ((m >= n) ? "unsafe" : "safe");
}

Measured memory_bytes: 3612
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Long[] H = new Long[N];
        for (int i = 0; i < N; i++){
            H[i] = sc.nextLong();
        }
        Arrays.sort(H, Collections.reverseOrder());
        for (int i = 0; i < K; i++){
            if (i == N) {
                break;
            }
            H[i] = (long)0;
        }
        long result = 0;
        for (int i = 0; i < N; i++){
            result += H[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 95920
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static final int MOD = (int) 1e9 + 7;

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] a = new int[n];
      for (int i = 0; i < n; i++) a[i] = in.nextInt();

      long[] ps = new long[n];
      ps[0] = 0;
      for (int i = 1; i < n; i++) {
         ps[i] = a[i - 1] + ps[i - 1];
         ps[i] %= MOD;
      }
      long ans = 0;
      for (int i = 1; i < n; i++) {
         ans += (a[i] * ps[i]) % MOD;
         ans %= MOD;
      }
      out.println(ans);
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

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

}


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

int main(void) {
	int N, D;
	cin >> N >> D;
	int count = 0;
	int i = D + 1;
	for (; i <= N; i = i + 2 * D + 1) {
		count++;
	}
	if (N > i - D - 1) {
		count++;
	}
	cout << count << endl;
}

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

lint n, x, m;
const lint E = 40;

lint f(lint z) {
    return z * z % m;
}

struct str {
    lint dest;
    lint sum;
    str() {}
    str(lint d, lint s) : dest(d), sum(s) {}
};

vector<vector<str>> doubling;

lint solve(int start, lint num) {
    lint now = start;
    bitset<E> b(num);
    lint res = 0;
    for (int i = 0; i < E; i++) {
        if (b[i]) {
            auto s = doubling[i][now];
            now = s.dest;
            res += s.sum;
        }
    }
    return res;
}

int main() {
    cin >> n >> x >> m;
    doubling.resize(E, vector<str>(m));
    for (int i = 0; i < m; i++) {
        doubling[0][i] = str(f(i), i);
    }
    for (int e = 1; e < E; e++) {
        for (int i = 0; i < m; i++) {
            auto first = doubling[e - 1][i];
            auto second = doubling[e - 1][first.dest];
            doubling[e][i] = str(second.dest, first.sum + second.sum);
        }
    }
    cout << solve(x, n) << endl;
}

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, k, a[105], dp[105][100005], pre[100005], mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	cont (i, n) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	int to = 0;
	cont (i, n) {
		to += a[i];
		to = min(to, k);
		pre[0] = dp[i - 1][0];
		cont (j, to) {
			pre[j] = pre[j - 1] + dp[i - 1][j];
			pre[j] %= mod;
		}
		loop (j, to + 1) {
			dp[i][j] = pre[j] - (j - a[i] - 1 < 0 ? 0 : pre[j - a[i] - 1]);
			dp[i][j] += mod;
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][k] << endl;
}


Measured memory_bytes: 40832
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main()
{

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    long X;
    cin >> X;
    long res = 0;

    res += X / 500 * 1000;
    X %= 500;
    res += X / 5 * 5;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int deg[10];
int main() {
    int a ,b;
    for (int i = 0; i < 3; ++i) {
        scanf("%d%d", &a, &b);
        ++deg[a];
        ++deg[b];
    }
    sort(deg+1, deg+5);
    if (deg[1] == 1 && deg[2] == 1 && deg[3] == 2 && deg[4] == 2) {
        puts("YES");
    } else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
    map<string,int> mp;
	int n;
	char ch[10];
	while(cin>>n)
	{
		for(int i=0;i<n;++i)
		cin>>ch,mp[ch]++;
		printf("AC x %d\n",mp["AC"]);
		printf("WA x %d\n",mp["WA"]);
		printf("TLE x %d\n",mp["TLE"]);	
		printf("RE x %d\n",mp["RE"]);
	}
	return 0;
}

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

int main(){
	string s;
	cin>>s;
	int count[26]={};
	rep(i,s.size()){
		count[s[i]-'a']++;
	}
	rep(i,26){
		if(count[i]==0){
			cout << (char)('a'+i)<<endl;
			return 0;
		}
	}
	puts("None");
}


Measured memory_bytes: 512