akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>

using namespace std;

int main() {
  string s;
  cin>>s;
  if(s[2] == s[3] && s[4] == s[5])
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#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>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(A);
	READV(B);
	READV(C);
	ll R=A-B;
	if (R>=C)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<C-R<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int sx,sy,len,n,m;
char S[N],T[N];
int tot1,tot2;
struct data{
	int x,y;
	data(int _x=0,int _y=0):x(_x),y(_y){};
}A[N<<1],B[N<<1];
void add(char x,int y){
	if(x=='L')A[++tot1]=data(-1,y);
	else if(x=='R')A[++tot1]=data(1,y);
	else if(x=='U')B[++tot2]=data(-1,y);
	else if(x=='D')B[++tot2]=data(1,y);
}
int main(){
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	scanf("%d%d%d%d%d%s%s",&n,&m,&len,&sx,&sy,S+1,T+1);
	for(int i=1;i<=len;++i){
		add(S[i],0);
		add(T[i],1);
	}
	int fg=0,a1=0,a2=0,b1=0,b2=0;
	for(int i=1;i<=tot1;++i){
		if(!A[i].y){
			if(A[i].x==-1)a1++;
			else a2++;
			if(a1-b2>=sy||a2-b1>m-sy){fg=1;break;}
		}else {
			if(A[i].x==-1)b1++;
			else b2++;
			if(b1-a2>=sy)b1=sy+a2-1;	
			if(b2-a1>m-sy)b2=m-sy+a1;
		}
	}
	if(fg){puts("NO");return 0;}
	a1=a2=b1=b2=0;
	for(int i=1;i<=tot2;++i){
		if(!B[i].y){
			if(B[i].x==-1)a1++;
			else a2++;
			if(a1-b2>=sx||a2-b1>n-sx){fg=1;break;}
		}else{
			if(B[i].x==-1)b1++;
			else b2++;
			if(b1-a2>=sx)b1=a2+sx-1;
			if(b2-a1>n-sx)b2=n-sx+a1;
		}
	}
	puts(fg?"NO":"YES");
	return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>
#include<string.h>
int main (int argc, char * argv[])
{
    char str[1000];//文字列
    char c[1000];
    int d;
    int q;//命令の数
    int a,b;//命令の範囲
    scanf("%s",str);
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%s %d %d",c,&a,&b);
        if(c[2] == 'i'){
//            printf("表示\n");
            for(int j=a;j<=b;j++){
                printf("%c",str[j]);
            }
            printf("\n");
        }else if(c[2] == 'p'){
            int len = b-a+1;
            char p[len];
//            printf("置き換える\n");
            scanf("%s",p);
            for(int j=a;j<=b;j++){
                str[j] = p[j-a];
              }
//            printf("%s",str);
        }else if(c[0]=='r'&&c[1]=='e'&&c[2]=='v'){

                
                while(a<b)
                  {
                      d=str[a];
                      str[a]=str[b];
                      str[b]=d;
                      a++;
                      b--;
                  }
                
            
        }
    }
    return 0;
}



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

int main() {
    vector<string> days = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    long long no = 0;
    for (long long i = 0; i < 7; ++i) {
        if (s == days[i]) {
            no = (days.size() - (i + 1)) + 1;
        }
    }
    cout << no << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

int main(void)
{
    int n, d, a;
    vector<P> monster;
    int x, h;
    int i, j;
    int target, targetx, targeth;
    int mid;
    ll count;
    ll ans = 0;
    vector<int> damage(200010, 0);

    cin >> n >> d >> a;

    monster.emplace_back(0, 0);

    rep(i, 1, n + 1)
    {
        cin >> x >> h;
        monster.emplace_back(x, h);
    }

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

    rep(i, 1, n + 1)
    {
        damage[i] += damage[i - 1];

        if (damage[i] < monster[i].second)
        {
            target = i;
        }
        else
        {
            continue;
        }

        targetx = monster[target].first;
        targeth = monster[target].second - damage[target];

        count = (targeth + a - 1) / a;

        ans += count;

        int ok = 0, ng = n + 1;

        while (ng - ok > 1)
        {
            mid = (ok + ng) / 2;

            if (monster[mid].first <= targetx + d * 2)
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        damage[target] += count * a;
        damage[ok + 1] += -count * a;
    }

    cout << ans << endl;
}

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

int main() {
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i=0; i<N; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int ans = 0;
    int i=0;
    while (x > 0) {
        if (x >= a.at(i) && i != N-1) {
            ans++;
            x -= a.at(i);
        }
        else if (i == N-1) {
            if (x == a.at(N-1)) {
                ans++;
                break;
            } else {
                break;
            } 
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	long long n;
	cin >> n;
	multiset<long double> s;
	for(long long i=0;i<n;i++){
		long double a;
		cin >> a;
		s.insert(a);
	}set <long double> :: iterator it;
	it=s.begin();
	long double ans=*it;
	for (long long i = 1; i < n; i++)
	{
	    	long double x = *next(s.begin(), i);
	    	ans=(ans+x)/2;
	    }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-8;
int main(){
    int x,y,z,n;
    scanf("%d",&n);
    double fg,a,b,c,d;
    a=4.0/n;
    for( x=1;x<=3500;++x){
        b=1.0/x;
        for(y=1;y<=3500;++y){
            c=1.0/y;
            d=a-b-c;
            if(d<0)continue;
            fg=1.0/d;
            if(abs( fg-(int)fg ) <=eps ){
                printf("%d %d %d\n",x,y,(int)fg);
                return 0;
            }
        }
    }
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if ((a+b) > (c+d)) {
    cout << "Left" << endl;
  }else if ((a+b) < (c+d)){
    cout << "Right" << endl;
  }else{
  cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    int ans = INT_MAX;
    for (int i = 1; i <= 100; ++i) {
        int tmp = 0;
        for (int j = 0; j < n; ++j) {
            tmp += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N,T = list(map(int, input().rstrip().split()))
t_list = list(map(int, input().rstrip().split()))
#-----

cnt=0
for i in range(1,len(t_list)):
    diff = t_list[i] - t_list[i-1]
    if diff <= T:
        cnt += diff
    else:
        cnt += T

cnt += T

print(cnt)


Measured memory_bytes: 25200
#include <iostream>
#include <utility>

using namespace std;

#define REP(var, count) for(int var=0; var<count; var++)

int poss[16][16];
bool myoko[16][16];
bool mtate[16][16];

int calc(int x, int y) {
	if ( poss[x][y] >= 0 ) { return poss[x][y]; }
	
	int ret = 0;
	if ( mtate[x][y] == false ) {
		ret += calc(x,y-1);
	}
	if ( myoko[x][y] == false ) {
		ret += calc(x-1,y);
	}
	
	poss[x][y] = ret;
	return ret;
}

void solve(void) {
	int GX, GY;
	cin >> GX >> GY;
	
	REP(i,16) REP(j,16) {
		poss[i][j] = -1;
		myoko[i][j] = false;
		mtate[i][j] = false;
	}
	REP(i, 16) {
		myoko[0][i] = true;
		mtate[i][0] = true;
	}
	
	poss[0][0] = 1;
	
	int P;
	cin >> P;
	
	REP(i, P) {
		int x1, x2, y1, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if ( x1 == x2 ) {
			if ( y1 > y2 ) {
				swap(y1,y2);
			}
			mtate[x1][y2] = true;
		} else {
			if ( x1 > x2 ) {
				swap(x1,x2);
			}
			myoko[x2][y1] = true;
		}
	}
	
	int r = calc(GX,GY);
	if ( r == 0 ) { cout << "Miserable Hokusai!" << endl; }
	else { cout << r << endl; }
}

int main(void) {
	int D;
	cin >> D;
	REP(i,D) solve();
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
 ll n,m; cin>>n>>m;
 ll res;
 if(n==1&&m==1)res=1;
 else if(n==1||m==1)res=n*m-2;
 else res=n*m-(n+m-2)*2;

cout<<res<<endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s=new Scanner(System.in);
        int[]list=new int[3];
        int x;
        for(int i=0;i<10;i++){
            x=s.nextInt();fun(x,list);
        }
        for(int i=0;i<3;i++){
            System.out.println(list[i]);
        }
    }
    
    static int[] fun(int x,int[] z){
        if(z[0]<x){z[2]=z[1];z[1]=z[0];z[0]=x;}
        else if(z[1]<x){z[2]=z[1];z[1]=x;}
        else if(z[2]<x){z[2]=x;}
        return z;
    }
}


Measured memory_bytes: 26252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
bool comp(pair<ll,ll>a,pair<ll,ll>b){
    return a.second<b.second;
}
int main(){
   ll n;
   cin>>n;
   vector<pair<ll,ll>>a(n);
   for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
   sort(a.begin(),a.end(),comp);
   ll sum=0;
   bool flag=true;
   for(int i=0;i<n;i++){
       sum+=a[i].first;
       if(sum>a[i].second)flag=false;
   }
   if(flag)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}

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

using namespace std;

int n,d1,d2,cnt,a[620][620];

void jian(int x){
    int c=0;
	while(x%4==0){
		x/=4;
		c++;
	} 
	if (x & 1){
		for (int i=0;i<2*n;i++)
			for (int j=0;j<2*n;j++)
				if (((i>>c)+(j>>c)) & 1)
					a[i][j]=1;
	}
	else
	{
		for (int i=0;i<2*n;i++)
			for (int j=0;j<2*n;j++)
				if ((i>>c) & 1)
					a[i][j]=1;	
	} 
}

int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	jian(d1);
	jian(d2);
	cnt=0;
	for (int i=0;i<2*n;i++)
		for (int j=0;j<2*n;j++)
			if (cnt<n*n && !a[i][j])
				printf("%d %d\n",i,j),cnt++;
	return 0;
} 

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <deque>

using namespace std;

deque<int> q;

void command(string str, int key){
    if(str == "insert"){
        q.push_front(key);
    }else if(str == "delete"){
        for(deque<int>::iterator itr = q.begin(); itr < q.end(); itr++){
            if(*itr == key){
                q.erase(itr);
                break;
            }
        }  
    }else if(str == "deleteFirst"){
        q.pop_front();
    }else if(str == "deleteLast"){
        q.pop_back();
    }
}

int main(){
    int n, k;
    string cmd;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> cmd;
        if(cmd == "insert" || cmd == "delete"){
            cin >> k;
        }
        command(cmd, k);
    }
    for(deque<int>::iterator itr = q.begin(); itr < q.end(); itr++){
        cout << *itr;
        if(itr < q.end() - 1)
            cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 7092
#include <iostream>
#include <queue>
#include <functional>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

class MyClass {
public:
	int x, y;
	int dir;
	int cost;

	MyClass(int _x, int _y, int _dir, int _cost):x(_x),y(_y),dir(_dir),cost(_cost){}

	bool operator < (const MyClass& obj) const
	{
		return cost < obj.cost;
	}

	bool operator > (const MyClass& obj) const
	{
		return cost > obj.cost;
	}
};

const int INF = 1 << 29;
const int MAX = 30;
const int dx[4][4] = { { 1, 0, -1, 0 },{ 0, -1, 0, 1 },{ -1, 0, 1, 0 },{ 0, 1, 0, -1 } };
const int dy[4][4] = { { 0, 1, 0, -1 },{ 1, 0, -1, 0 },{ 0, -1, 0, 1 },{ -1, 0, 1, 0 } };

int main()
{
	while (true) {
		int w, h;
		
		cin >> w >> h;

		if (w == 0 && h == 0) {
			break;
		}

		int grid[MAX][MAX];
		int cost[MAX][MAX][MAX];

		rep(y, h) {
			rep(x, w) {
				rep(i, 4) {
					cost[y][x][i] = INF;
				}
			}
		}

		int robot[4];
		priority_queue<MyClass, vector<MyClass>, greater<MyClass>> pq;

		rep(y, h) {
			rep(x, w) {
				cin >> grid[y][x];
			}
		}

		rep(i, 4) {
			cin >> robot[i];
		}

		pq.push(MyClass(0, 0, 0, 0));
		cost[0][0][0] = 0;

		while (pq.empty() == false) {
			MyClass temp = pq.top();
			pq.pop();

			int x = temp.x;
			int	y = temp.y;
			int	dir = temp.dir;
			int	c = temp.cost;
			int	g = grid[y][x];

			if (x == w - 1 && y == h - 1) {
				cout << c << endl;
				break;
			}

			int nx = x + dx[dir][g];
			int	ny = y + dy[dir][g];
			int	nd = (dir + g) % 4;

			if (g != 4 && 0 <= nx && nx < w && 0 <= ny && ny < h && c < cost[ny][nx][nd]) {
				pq.push(MyClass(nx, ny, nd, c));
			}

			rep(i, 4) {
				if (i == g) {
					continue;
				}

				int nx = x + dx[dir][i],
					ny = y + dy[dir][i],
					nd = (dir + i) % 4;

				if (0 <= nx && nx < w && 0 <= ny && ny < h && c + robot[i] < cost[ny][nx][nd]) {
					pq.push(MyClass(nx, ny, nd, c + robot[i]));
					cost[ny][nx][nd] = c + robot[i];
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3768
//{{{
#pragma GCC optimize("O3")
#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
//types
typedef long long ll;
typedef pair<int,int> pii;
//input
bool SR(int &_x){return scanf("%d",&_x)==1;}bool SR(ll &_x){return scanf("%lld",&_x)==1;}
bool SR(double &_x){return scanf("%lf",&_x)==1;}bool SR(char *_s){return scanf("%s",_s)==1;}
bool RI(){return true;}
template<typename I,typename... T>bool RI(I &_x,T&... _tail){return SR(_x) && RI(_tail...);}
//output
void SP(const int _x){printf("%d",_x);}void SP(const ll _x){printf("%lld",_x);}
void SP(const double _x){printf("%.16lf",_x);}void SP(const char *s){printf("%s",s);}
void PL(){puts("");}
template<typename I,typename... T>void PL(const I _x,const T... _tail)
{SP(_x);if(sizeof...(_tail)) putchar(' ');PL(_tail...);}
//macro
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<int(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=int(b);i++)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
//}}}
const int MOD=1e9+7;
const int maxn=2e5+5;
const int K=2e3+3;
int C[K][K];
int fac[K<<2],inv[K<<2],ifac[K<<2];
void predo()
{
    REP(i,K) C[i][0]=1;
    REP1(i,1,K-1) REP1(j,1,i)
        C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

    fac[0]=1;
    REP1(i,1,4*K-1) fac[i]=1LL*fac[i-1]*i%MOD;
    inv[1]=1;
    REP1(i,2,4*K-1) inv[i]=1LL*inv[MOD%i]*(MOD-MOD/i)%MOD;
    ifac[0]=1;
    REP1(i,1,4*K-1) ifac[i]=1LL*ifac[i-1]*inv[i]%MOD;
}
int n,a[maxn],b[maxn];
void read()
{
    RI(n);
    vector<pii> v(n);
    REP(i,n) RI(v[i].F,v[i].S);
    sort(ALL(v));
    REP(i,n) a[i]=v[i].F,b[i]=v[i].S;
}
ll _[K*4],*dp=_+K*2;
void build()
{
    REP(i,n) a[i]--;
    for(int k=a[n-1];k>=0;k--)
    {
        int up=lower_bound(a,a+n,k)-a;
        REP1(i,up,n-1) dp[b[i]-k]+=C[a[i]][a[i]-k];
        for(int i=K;i>=-K;i--) dp[i]=(dp[i]+dp[i+1])%MOD;
    }
    REP(i,n) a[i]++;
}
void sol()
{
    ll ans=0,sum=0;
    REP1(i,-K,K)
    {
        sum=(sum+dp[-i])%MOD;
        ans=(ans+sum*dp[i])%MOD;
    }
    
    REP(i,n)
    {
        ll cur=fac[a[i]+b[i]+a[i]+b[i]];
        cur=cur*ifac[a[i]<<1]%MOD;
        cur=cur*ifac[b[i]<<1]%MOD;
        ans=(ans-cur)%MOD;
    }

    ans=ans*inv[2]%MOD;
    if(ans<0) ans+=MOD;
    PL(ans);
}
int main()
{
    predo();
    read();
    build();    
    sol();
    return 0;
}




































/*End Of File*/




Measured memory_bytes: 17280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double L,A,B,C,D;
int main()
{
  cin >>L>>A>>B>>C>>D;
  if(A/C>B/D)
    cout <<L-ceil(A/C)<<endl;
  else
    cout<<L-ceil(B/D)<<endl;
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>  
using namespace std;
long long int dp[3005][3005];
int vis[3005][3005]={0};
long long int solve(int q,int i,int j,long long int a[])
{
    if(vis[i][j])return dp[i][j];
    if(j<i)return 0;
    vis[i][j]=1;
    long long int ans;
    if(q==0)
        ans=max(a[i]+solve(1,i+1,j,a),a[j]+solve(1,i,j-1,a));
    else
        ans=min(solve(0,i+1,j,a)-a[i],solve(0,i,j-1,a)-a[j]);
    return dp[i][j]=ans;
} 
int main()
{
    int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<solve(0,0,n-1,a);
}

Measured memory_bytes: 105216
#include<stdio.h>
int main(void)
{
	int N;
	scanf("%d", &N);
	int H[100];

	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);
	int count = 1;
	int Max = H[0];
	for (int i = 0; i < N-1; i++) {
		
		if (Max - H[i + 1] <= 0) {
			count++;
			Max = H[i + 1];

		}
			
	}

	printf("%d", count);

	return 0;



}

Measured memory_bytes: 760
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int[] counts = new int[n];
		int[] idxes = new int[]{-1, -1, -1};
		for (int i = 0; i < n; i++) {
		    int cnt = 0;
		    for (int j = 0; j < 3; j++) {
		        if (arr[i] - 1 == idxes[j]) {
		            counts[i]++;
		        }
		    }
		    if (counts[i] == 0) {
		        System.out.println(0);
		        return;
		    }
		    for (int j = 0; j < 3; j++) {
		        if (arr[i] - 1 == idxes[j]) {
		            idxes[j] = arr[i];
		            break;
		        }
		    }
		}
		long total = 1;
		for (int i = 0; i < n; i++) {
		    total *= counts[i];
		    total %= MOD;
		}
		System.out.println(total);
	}
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    string s; cin >> s;

    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	long long c = a+b;
	if(c%2)
	{
		cout<<"IMPOSSIBLE\n";
	}
	else
	{
		cout<<c/2<<endl;
	}
	return 0;
	
}

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


const int MaxN = 2e5+10;
int N;
int a[MaxN];
vector<int> adj[MaxN];
int dp[MaxN];
int len[MaxN];


void dfs(int u, int fa, int maxlen)
{
    int k = lower_bound(dp, dp + N, a[u]) - dp;
    len[u] = max(maxlen, k + 1);
    int dpk_old = dp[k];
    for (int v : adj[u]) {
        if (v != fa) {
            dp[k] = a[u];
            dfs(v, u, max(maxlen, k + 1));
            dp[k] = dpk_old;
        }
    }
}


void solve()
{
    memset(dp, 0x7f, sizeof(dp));
    dfs(1, 0, 0);
    for (int i = 1; i <= N; i++) cout << len[i] << endl;
}


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

    cin >> N;
    for (int i = 1; i <= N; i++) cin >> a[i];
    int u, v;
    for (int i = 1; i <= N - 1; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    solve();
    return 0;
}


Measured memory_bytes: 34100
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> M;
	vector<vector<int>>edge(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--, R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>dis(N, MOD);
	Calculate_Depth(edge, dis, 0);
	cout << "Yes\n";
	for (int i = 1; i < N; i++) {
		for (auto j : edge[i]) {
			if (dis[j] == dis[i] - 1) {
				cout << j + 1 << endl;
				break;
			}
		}
	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(200001);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        v[a]++;
    }
    sort(v.begin(), v.end(), greater<int>());

    int res = 0;
    for (int i = K; i <= 200000; i++)
        res += v[i];

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
package main
import (
  "fmt"
  "sort"
)

func main() {
	var n, d, ind int
  	a := make([]int, 0)
  	fmt.Scan(&n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d)
   		a = append(a, d)
  	}
  b := make([]int, 0)
  for _, v := range a {
    b = append(b, v)
  }
  sort.Sort(sort.IntSlice(b))
  size := len(b)
  max := b[size-1]
  big := b[size-2]
  for i, v := range a {
    if ind == 0 {
      switch {
    	case v == max :
      		ind = i
      }
    }
  }
  switch {
    case max == big:
    for i := 0; i < n; i++{
      fmt.Println(max)
    }
    case max != big:
    	a[ind] = big
      for i, v := range a {
        if i == ind {
          fmt.Println(v)
        }else{
          fmt.Println(max)
        }
      }
    }
}

Measured memory_bytes: 11008
#include<iostream>
#include<cmath>

using namespace std;

int main() {
  long long H, W;

  cin >> H >> W;

  long long mins, maxs;
  long long mind = 10000000000000;
  for (int w = 1; w <= W; w++) {
    long long o_mind = mind;
    maxs = w * H;
    mins = w * H;
    long long difw = W - w;
    if (difw >= 2) {
      maxs = fmax(maxs, (difw / 2) * H);
      mins = fmin(mins, (difw / 2) * H);
      maxs = fmax(maxs, (difw - (difw / 2)) * H);
      mins = fmin(mins, (difw - (difw / 2)) * H);
      mind = fmin(mind, maxs - mins);
    }

    maxs = w * H;
    mins = w * H;
    if (difw >= 1 && H >= 2) {
      maxs = fmax(maxs, H / 2 * difw);
      mins = fmin(mins, H / 2 * difw);
      maxs = fmax(maxs, (H - (H / 2)) * difw);
      mins = fmin(mins, (H - (H / 2)) * difw);
      mind = fmin(mind, maxs - mins);
    }

  }

  for (int h = 1; h <= H; h++) {
    maxs = h * W;
    mins = h * W;
    long long difh = H - h;
    if (difh >= 2) {
      maxs = fmax(maxs, difh / 2 * W);
      mins = fmin(mins, difh / 2 * W);
      maxs = fmax(maxs, (difh - (difh / 2)) * W);
      mins = fmin(mins, (difh - (difh / 2)) * W);
      mind = fmin(mind, maxs - mins);
    }

    maxs = h * W;
    mins = h * W;
    if (H - h >= 1 && W >= 2) {
      maxs = fmax(maxs, W / 2 * (H - h));
      mins = fmin(mins, W / 2 * (H - h));
      maxs = fmax(maxs, (W - (W / 2)) * (H - h));
      mins = fmin(mins, (W - (W / 2)) * (H - h));
      mind = fmin(mind, maxs - mins);
    }
  }

  cout << mind << endl;
  return 0;
}


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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    if (b / k != (a - 1) / k) cout << "OK";
    else cout << "NG";
    return 0;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static int total = 0;
    static int list[];

    static Boolean check[];

    public static void main(String[] args) {
        check = new Boolean[2000 + 1];
        Scanner inp = new Scanner(System.in);

        total = inp.nextInt();
        list = new int[total];

        for (int k = 0; k < total; k++) {
            int item = inp.nextInt();
            list[k] = item;
        }

        solve(0, 0);
        int n;

        int num = inp.nextInt();
        StringBuilder s = new StringBuilder();

        for (int i = 0; i < num; i++) {
            n = inp.nextInt();

            if (check[n] != null && check[n]) {
                s.append("yes");
            } else {
                s.append("no");
            }

            if (i != num-1) {
                s.append("\n");
            }
        }

        System.out.println(s);
    }

    public static void solve(int place, int sum) {
        if (place == total) {
            check[sum] = true;
            return;
        }

        int u = list[place];

        solve(place+1, sum);

        if (sum+u <= 2000) {
            solve(place+1, sum+u);
        }
    }
}



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

using namespace std;

int n;
int ch[200010];

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

    for(int i = 2; i <= n; i++){
        int p; cin >> p;

        ch[p]++;
    }

    for(int i = 1; i <= n; i++) cout << ch[i] << "\n";

    return 0;
}

Measured memory_bytes: 4372
a,b,k = map(int,input().split())
num = []

if b-a <= k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        num.append(i)
    for i in range(b-k+1,b+1):
        num.append(i)
        
    num = list(set(num))
    num.sort()
    
    for i in num:
        print(i)



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

int main() {
  int N;
  cin >> N;
  int M = 0;
  int sum = 0;
  for(int i=0; i<N; ++i) {
    int L;
    cin >> L;
    sum += L;
    M = max(M, L);
  }
  if(sum - M > M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  int a[3] = {};

  for(int i=0; i<3; i++){
    cin >> a[i];
  }
  swap(a[0],a[1]);
  swap(a[0],a[2]);

  for(int i=0; i<3; i++){
    cout << a[i] << " ";
  }
}


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

int main(){
  int n;
  string a,b;
  cin >> n >> a >> b;
  int count=0;
  for(int i=1;i<=n;i++){
    bool check=true;
    for(int j=0;j<i;j++){
      if(a.at(n-i+j)!=b.at(j)){
      check=false;
      }
    }
    if(check) count=i;
  }
  cout << 2*n-count << endl;
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    int x[5],ans,i;
    for(i=0;i<5;i++)
    {
        scanf("%d",&x[i]);
        if(x[i]==0) ans=i+1;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		String number = null;
		
		Scanner sn = new Scanner(System.in);
		String n = sn.next();
		if(1000 <= Integer.parseInt(n) && Integer.parseInt(n) <= 9999){
			number = n;
		}
		sn.close();
		
		int i = 0;
		if(number.charAt(i) == number.charAt(i+1) && number.charAt(i) == number.charAt(i+2)
				|| number.charAt(i+1) == number.charAt(i+2) && number.charAt(i+1) == number.charAt(i+3)){
				System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21332
fun str() = readLine()!!
fun int() = str().toInt()

fun main() {
	val n = int()
	val t = Array(n) {str()}

	fun f(v:String) = println("$v x ${t.count {it==v}}")

	f("AC")
	f("WA")
	f("TLE")
	f("RE")
}


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

isOK=True
for i in range(n-1,0,-1):
    diff=H[i-1]-H[i]
    if diff<1:
        pass
    elif diff==1:
        H[i-1]-=1
    else:
        isOK=False
        break

if isOK:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20708
import numpy as np

n = int(input())
T, A = map(int, input().split())
h = [int(i) for i in input().split()]

b = 600
num = 0
for j in range(n):
  temp = T - h[j]*0.006 - A
  t = np.abs(temp)
  if t < b:
    b = t
    num = j + 1

print(num)

Measured memory_bytes: 12472
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int[][] red = new int[N][2];
    for (int i = 0; i < N; i++) {
      red[i][0] = sc.nextInt();
      red[i][1] = sc.nextInt();
    }
    Arrays.sort(red, (a, b)->b[1]-a[1]);

    int[][] blue = new int[N][2];
    for (int i = 0; i < N; i++) {
      blue[i][0] = sc.nextInt();
      blue[i][1] = sc.nextInt();
    }
    Arrays.sort(blue, (a, b)->a[0]-b[0]);

    int ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (red[j][0] != -1 && red[j][1] != -1
            && red[j][0] < blue[i][0]
            && red[j][1] < blue[i][1]) {
          ans++;
          red[j][0] = -1;
          red[j][1] = -1;
          break;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26836
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],b[N]; 
int main(){
	int n,k,c;
	string s;
	cin>>n>>k>>c>>s;
	for(int i=0,id=0;i<n;i++) if(s[i]=='o') a[id++]=i,i+=c;
	for(int i=n-1,id=k-1;i>=0&&id>=0;i--) if(s[i]=='o') b[id--]=i,i-=c;
	for(int i=0;i<k;i++) if(a[i]==b[i]) cout<<a[i]+1<<endl;
	return 0; 
}


Measured memory_bytes: 3332
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;
int main(){

        string strs[] = {"dream","dreamer","erase","eraser"};
        string S; cin >> S;
        rep(i,4) reverse(strs[i].begin(),strs[i].end());
        reverse(S.begin(),S.end());
        string ans = "YES";
        for (int i = 0; i < S.size(); ) {
                bool flag = false;
                rep(j,4){
                        if(strs[j] == S.substr(i,strs[j].size())) {
                                i += strs[j].size();
                                flag = true;
                        }
                }
                if(flag == false) {
                        ans = "NO";
                        break;
                }
        }

        cout << ans << endl;

        return 0;
}


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

using namespace std;

int main(){

 int k;
 
 cin >> k;
      
 if(k == 1){
        cout << "ACL" << endl;;
 }if(k == 2){
        cout << "ACLACL" << endl;
 }if(k == 3){
        cout << "ACLACLACL" << endl;
 }if(k == 4){
        cout << "ACLACLACLACL" << endl;
 }if(k == 5){
        cout << "ACLACLACLACLACL" << endl;
    }
 return 0;
}

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	char data[1000];
	int num[1000];
	int sum = 0;
	int i, j;
	
	while(1){
		sum = 0;
		gets(data);
		for(i=0 ; i < strlen(data) ; i++){
			num[i] = data[i] - '0';
			sum += num[i];
		}
		if(num[0]==0){
			return 0;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 H, W, A, B;
  std::cin >> H >> W >> A >> B;

  for (i64 y = 0; y < B; ++y) {
    std::cout << std::string(A, '0') << std::string(W - A, '1') << std::endl;
  }
  for (i64 y = B; y < H; ++y) {
    std::cout << std::string(A, '1') << std::string(W - A, '0') << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1280
from bisect import bisect_right
s = input()
t = input()
alpha = [[] for _ in range(26)]
def f(c): return ord(c)-ord("a")


for i,c in enumerate(s): alpha[f(c)].append(i)
# print(alpha)
idx = -1
roop = 0
for c in t:
    lst = alpha[f(c)]
    if not lst:
        ans = -1
        break
    i = bisect_right(lst,idx)
    if i == len(lst):
        roop += 1
        idx = lst[0]
    else:
        idx = lst[i]
else:
    ans = len(s)*roop+idx+1
print(ans)

Measured memory_bytes: 7540
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))



int main() {
	ll N, D, A;
	cin >> N >> D >> A;
	vector<pair<ll, ll>> V(N);
	vector<ll> C(N);
	REP(i, 0, N) {
		cin >> V[i].first >> V[i].second;
		C[i] = 0;
	}
	auto cmp = [](const pair<ll,ll>& a,const pair<ll, ll>& b) {return a.first < b.first; };
	sort(V.begin(), V.end(), cmp);
	ll ans = 0, cur = 0;
	REP(i, 0, N) {
		ll n = (V[i].second + cur + A - 1) / A;
		MAXS(n, 0);
		ans += n;
		C[i] += -n * A;
		int j = distance(V.begin(), upper_bound(V.begin(), V.end(), pair<ll,ll>{ V[i].first + 2 * D, 0 }, cmp)) - 1;
		C[j] += n * A;
		cur += C[i];
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 8000
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int n, a;
ll dp[55][5050] = {0};

int main () {
  cin >> n >> a;
  vi x(n);
  rep(i,n) cin >> x[i];

  int X = max(*max_element(ALL(x)),a);

  vi y(n);
  rep(i,n) {
    y[i] = x[i] - a;
  } 

  dp[0][n*X] = 1;
  rep(j,n+1) {
    rep(t,2*n*X+1) {
      if (j >= 1 && (t-y[j-1]<0 || t-y[j-1]>2*n*X)) {
        dp[j][t] = dp[j-1][t];
      }
      if (j >= 1 && (0<=t-y[j-1] && t-y[j-1]<=2*n*X)) {
        dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]];
      }
    }
  }

  cout << dp[n][n*X]-1 << endl;
}

Measured memory_bytes: 2176
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;
static const ll LLINF = 1001001001001001001;

#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i)
#define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i)
#define POSITIVE(x) (x)=((x) < 0) ? 0 : (x)

ll pow(ll x, ll y) {
    ll ret = 1;
    while(y-- > 1) ret *= x;
    return ret;
}

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    ll r = x / y;
    return gcd(y, x-y*r);
}

int run(istream& in, ostream& out) {
    ll N,R ;
    in >> N >> R;
    ll ans = 0;
    ans = R;
    if (N < 10) {
        ans = R + 1000 - 100 * N;
    }
    out << ans << endl;
    return 0;
}

int main() {
    return run(cin, cout);
}


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

int main()
{
    int n;
    cin >> n;
    int p[n];
    for (int i=0;i<n;++i){
        cin >> p[i];
    }
    int count = 0;
    for (int i=0;i<n;++i){
        if (!(p[i] == i+1)) {
            ++count;
        }
    }
    if (count <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string n;
  cin >> n;
  int i =0;
  while (i < n.size()){
      if (n.at(i)=='1'){
          n.at(i) = '9';
      } else {
          n.at(i) = '1';
      }
      i++;
  }
  cout << n << endl;
}

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

#define ran 1011

int n, m;
int a[ran];

int main() {
	scanf("%d%d", &n, &m);
	
	int s = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		s+=a[i];
	}
	
	int cnt = 0;
	for(int i=0;i<n;i++)
		if(a[i]*4*m>=s) cnt++;
	puts(cnt>=m?"Yes":"No");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int x = in();
    int ans = (x + 10) / 11 * 2;
    if(x % 11 != 0 and x % 11 <= 6) ans--;
    cout << ans << endl;
}

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

int main(){
    int N, X, Y;
    std::cin >> N >> X >> Y;
    X--;
    Y--;
    std::vector< int > dist_list(N-1, 0);
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            int dist;
            if(i <= X && j <= X){
                dist = j - i;
            }else if(i <= X && j <= Y){
                int dist1 = j - i;
                int dist2 = (X - i) + 1 + (Y - j);
                dist = dist1 > dist2 ? dist2 : dist1;
            }else if(i <= X){
                dist = (X - i) + 1 + (j - Y);
            }else if(i <= Y && j <= Y){
                int dist1 = j - i;
                int dist2 = (i- X) + 1 + (Y - j);
                dist = dist1 > dist2 ? dist2 : dist1;
            }else if(i <= Y){
                int dist1 = j - i;
                int dist2 = (i- X) + 1 + (j - Y);
                dist = dist1 > dist2 ? dist2 : dist1;
            }else{
                dist = j - i;
            }
            dist_list[dist-1]++;
        }
    }
    for(int i=0; i<N-1; i++){
        std::cout << dist_list[i] << std::endl;
    }
    
    return 0;
}



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

int L;
vector<int> B;
int K;

int main() {
  cin >> L;
  for(int b = 19; b >= 0; --b) {
    if(L & (1 << b)) B.push_back(b);
  }
  K = B.front();
  cout << K + 1 << ' '
    << B.size() - 1 + 2 * K << endl;
  for(int b = K - 1; b >= 0; --b) {
    cout << K - b << ' ' << K - b + 1 << ' '
      << (1 << b) << endl;
    cout << K - b << ' ' << K - b + 1 << ' '
      << 0 << endl;
  }
  int s = 0;
  for(int b : B) {
    if(s != 0) {
      cout << 1 << ' ' << K - b + 1 << ' '
        << s << endl;
    }
    s += (1 << b);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  
  if(a>=b)
    cout<<"delicious"<<endl;
  else if((a+x)>=b)
    cout<<"safe"<<endl;
  else 
    cout<<"dangerous"<<endl;

  return 0;
}


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

using namespace std;

int main()
{
    int N, K;

    cin >> N >> K;

    double all_pro = 0.0;

    for(int i=1; i<=N; i++){
        int score = i;
        double pro = 1.0 / (double)N;
        int num = 0;

        while(score < K){
            score *= 2;
            pro *= 0.5;
        }

        all_pro += pro;
    }

    cout << setprecision(12) << all_pro << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int A, B, X;

int main()
{
	in >> A >> B >> X;
	out << (A + B < X || A > X ? "NO" : "YES") << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    int H, W;
    cin >> H >> W;
    vector<vector<char>> G(H, vector<char>(W));
    vector<vector<ll>> dp(H + 1, vector<ll>(W + 1, INF));

    rep(i, H) {
        rep(j, W) { cin >> G[i][j]; }
    }

    if (G[0][0] == '#')
        dp[0][0] = 1;
    else
        dp[0][0] = 0;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i - 1 >= 0 && G[i - 1][j] == '.' && G[i][j] == '#')
                chmin(dp[i][j], dp[i - 1][j] + 1);
            if (j - 1 >= 0 && G[i][j - 1] == '.' && G[i][j] == '#')
                chmin(dp[i][j], dp[i][j - 1] + 1);
            if (i - 1 >= 0 && G[i - 1][j] == '.' && G[i][j] == '.')
                chmin(dp[i][j], dp[i - 1][j]);
            if (j - 1 >= 0 && G[i][j - 1] == '.' && G[i][j] == '.')
                chmin(dp[i][j], dp[i][j - 1]);
            if (i - 1 >= 0 && G[i - 1][j] == '#' && G[i][j] == '.')
                chmin(dp[i][j], dp[i - 1][j]);
            if (j - 1 >= 0 && G[i][j - 1] == '#' && G[i][j] == '.')
                chmin(dp[i][j], dp[i][j - 1]);
            if (i - 1 >= 0 && G[i - 1][j] == '#' && G[i][j] == '#')
                chmin(dp[i][j], dp[i - 1][j]);
            if (j - 1 >= 0 && G[i][j - 1] == '#' && G[i][j] == '#')
                chmin(dp[i][j], dp[i][j - 1]);
        }
    }

    cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	long long int A[100010] = {}; 
	int pos = 0; int neg = 0; int zero = 0; 
	long long int total = 0; 
	long long int dakyou = 1000000007; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
		if(A[i] > 0) pos ++; 
		else if(A[i] < 0) neg ++; 
		else zero ++; 
		total += abs(A[i]); 
		if(A[i] != 0) dakyou = min(dakyou, abs(A[i])); 
	}
	if((zero > 0) || (neg % 2 == 0)) cout << total << endl; 
	else cout << total - dakyou * 2 << endl; 
}

Measured memory_bytes: 1024