akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <iomanip>

using namespace std;

int dp[100001][2];
vector<int> edge[100001];
int mod = 1000000007;
long long dfs(int cur, int color, int parent){
   if(dp[cur][color]!=-1) return dp[cur][color];
   long long ans = 1;
   for(int i = 0 ; i < (int)edge[cur].size(); i++){
      int next = edge[cur][i];
      if(next!=parent){
         if(color == 0){
            ans *= dfs(next, 0, cur)+dfs(next, 1, cur);
         }
         else{
            ans *= dfs(next, 0, cur);
         }
         ans %= mod;
      }
   }
   //cout << cur << ", "<< color <<" :" << ans << endl;
   return dp[cur][color] = ans;
}

int main(){
  int N;
  cin >> N;
  for(int i = 0 ; i <N-1; i++){
     int x,y;
     cin >> x >> y;
     x--;y--;
     edge[x].push_back(y);
     edge[y].push_back(x);
  }
  memset(dp,-1,sizeof(dp));
  cout << (dfs(0, 0, -1) + dfs(0,1,-1))%mod << endl;;
  return 0;
}


Measured memory_bytes: 14848
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m,x;
    int L=0,H=0;
    cin >> n >>m >>x;
    
    int a[100];
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    
    for(int i=0;i<x;i++){
        for(int j=0;j<m;j++){
            if(a[j] == i) L++;
        }
    }
    
    for(int i=x;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[j] == i) H++;
        }
    }
    
    if(L<=H) cout << L << endl;
    else if(L>H) cout << H << endl;
    
    
}


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

int main(){
	int i;
	double a, s[11], sum;
	while(cin>>a){
		s[0]=a;
		sum=a;
		for(i=1;i<10;i++){
			if(i%2){
				s[i] = s[i-1] * 2.0;
			}else{
				s[i] = s[i-1] / 3.0;
			}
			sum += s[i];
		}
		printf("%.8f\n", sum);
	}
	return 0;
}

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

int main(){
  int N;
  string str;
  cin >> N>> str;

  int ans= 0;
  int tmp= 0;
  for(int i=0; i<N; i++){
    if(str.at(i)=='I') tmp++;
    else             tmp--;
    ans= max(ans, tmp);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(long long i=0; i<n; i++)

long long MOD = 1000000007;

int main(){
  long long N;
  cin >> N;
  long long A[N];
  rep(i, N)
    cin >> A[i];
  //

  long long sum[N];
  rep(i, N)
    sum[i] = 0;

  sum[0] = A[0];
  rep(i, N-1){
    sum[i+1] = (sum[i]+A[i+1]);
  }

  long long ans = 0;
  rep(i, N-1){
    ans = (ans + (A[i]*( (sum[N-1]-sum[i])%MOD) )%MOD) % MOD;
  }

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


Measured memory_bytes: 6724
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    rep(i,n-1)a[i+1]+=a[i];
    int ans=inf;
    rep(i,n){
        ans = min(ans,abs(2*a[i]-a[n-1]));
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int N,K,ans=0;
	cin >> N >> K;
	vector<int> V(N);
	priority_queue<int,vector<int>,greater<int>> minus;
	for(auto &i:V)cin >> i;
	
	for(int k=1;k<=min(N,K);k++){
		int remove=K-k;
		for(int l=0;l<=k;l++){
			int tmp=0;
			int r=k-l;
			for(int i=0;i<l;i++){
				tmp+=V[i];
				if(V[i]<0)minus.push(V[i]);
			}
			for(int i=0;i<r;i++){
				tmp+=V[N-i-1];
				if(V[N-i-1]<0)minus.push(V[N-i-1]);
			}
			int rm=0;
			while(!minus.empty()){
				if(remove>rm)tmp-=minus.top();
				rm++;
				minus.pop();
			}
			ans=max(ans,tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k,dp[100009],a[100009],mx=1e9+8;
int bt(int x)
{
    if(x==0)return 0;
    if(x==1)return abs(a[x]-a[x-1]);
    if(dp[x]!=-1)return dp[x];
    dp[x]=mx;
    for(int i=1;i<=k&&x-i>=0;i++)
    {
        dp[x]=min(bt(x-i)+abs(a[x]-a[x-i]),dp[x]);
    }
    return dp[x];
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<bt(n-1);
}


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

using namespace std;

int main() {
    string a, b, c;

    cin >> a >> b >> c;

    int p = 0;
    while(true) {
        if(p == 0) {
            if(a.size() == 0) { cout << "A" << endl; break; }
            switch(a[0]) {
                case 'a':
                    p = 0; break;
                case 'b':
                    p = 1; break;
                case 'c':
                    p = 2; break;
            }

            a = a.substr(1);
        }

        if(p == 1) {
            if(b.size() == 0) { cout << "B" << endl; break; }
            switch(b[0]) {
                case 'a':
                    p = 0; break;
                case 'b':
                    p = 1; break;
                case 'c':
                    p = 2; break;
            }

            b = b.substr(1);
        }

        if(p == 2) {
            if(c.size() == 0) { cout << "C" << endl; break; }
            switch(c[0]) {
                case 'a':
                    p = 0; break;
                case 'b':
                    p = 1; break;
                case 'c':
                    p = 2; break;
            }

            c = c.substr(1);
        }
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
// #define int long long

using namespace std;

typedef int Val_TYPE;
typedef vector<Val_TYPE> Container_TYPE;
typedef priority_queue<Val_TYPE, Container_TYPE> pri_queue;

class Queue: public pri_queue{
public:
    Container_TYPE::iterator begin(){
        return pri_queue::c.begin();
    }
    Container_TYPE::iterator end(){
        return pri_queue::c.end();
    }
}Q;

//v.push_back(123);
//sort(v.begin(), v.end(),greater<int>());
//for(int x : v) {cout << x << endl;}

//for(int x: v) cout << x << endl;
//vector<vector<char>> v(H, vector<char>(W));
// vector<int> v(1000);

long long pow_mod(long long x, long long y, long long MOD){
	long long ret = 1;
	while(y){
		if (y & 1) ret = ret * x % MOD;
		x = x * x % MOD;
		y>>=1;
	}
	return ret;
}

signed main(){
  int N;
  cin>>N;
  int A[N];
  rep(i, N) cin >> A[i];
  int count = 0;
  int flag=1;
  
//   pri_queue<int, vector<int>, greater<int>> q;
  vector<int> q;
  int minimum=1000000009;
  rep(i, N){
    flag=1;
    if(i==0){
      q.push_back(A[i]);
//       minimum = A[i];
      count++;
      continue;
    }
    vector<int>::iterator tmp;
    if(q[0]<A[i]){
      tmp = lower_bound(q.begin(), q.end(), A[i]);
      if((tmp-q.begin())!=0){
        q[tmp-q.begin()-1]=A[i];
      }else{
        q[tmp-q.begin()] = A[i];
      }
//       q.push(A[i]);
      flag=0;
    }
    if(flag){
      tmp = lower_bound(q.begin(), q.end(), A[i]);
      
      if((tmp-q.begin())!=0){
        q.insert(tmp-1, A[i]);
      }else{
        q.insert(tmp, A[i]);
      }

//       sort(q.begin(), q.end(), greater<int>());
//       minimum = A[i];
      count++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <string.h>


int main(void){
    int n;
    scanf("%d\n", &n);

    char slime[n];
    scanf("%s", slime);

    int counter = 1;
    for (int i = 0; i < n; i++) {
        if (slime[i+1] != slime[i]) {
            counter++;
        }
    }

    printf("%d\n", counter-1);
    return 0;
}


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

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)

#ifdef MyDebug
	#define debug(x) cerr << #x << " : " << x << endl
	#define debugP(x) cerr << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

ll k;
ll a[50];
void solve() {
	cin >> k;
	cout << 50 << endl;
	for (ll i = 49, j = 0; i >= 0; --i, ++j) {
		a[j] = i;
	}
	ll tmp = k % 50;
	ll tmp2 = k / 50;
	rep (i, 0, tmp) {
		a[i] += 1;
	}
	cout << (a[0] + tmp2);
	rep(i, 1, 50) {
		cout << " " << (a[i] + tmp2);
	}
	cout << endl;
}

int main() {
	solve();
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;0<=i;--i)
#define rRep(i,n) for(int i=n;0<i;--i)
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define EPS 1e-8
#define INF 1e8

typedef double Real;
typedef int Int;
typedef vector<Int> vi;
typedef vector<vector<Int> > vvi;
typedef pair<Int,Int> pii;

inline Real sr(Real a) {return sqrt(max(a, (Real)0));}
const vi dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};

template <typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << '[';
    rep(i, v.size()) out << v[i] << ",";
    out << "\b], " << v.size() << "\n";
    return out;
}

// vars


void solve()
{
    string str;
    cin >> str;
    int len = str.size();
    bool c = false;
    rep(i, len) {
        if(c) {
            if(str[i] == 'F') {
                cout << "Yes" << endl;
                return;
            }
        } else {
            if(str[i] == 'C') {
                c = true;
                continue;
            }
        }
    }

    cout << "No" << endl;
}

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

    solve();

    return 0;
}


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

using namespace std;

int main()
{
  	int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      a[i] = make_pair(x, i);
    }
  	sort(a.begin(), a.end());
  	for(auto i : a){
    	cout << i.second + 1 << " ";
    }
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void init(int x){
        n = x;
        bit.assign(n+1, 0);
    }

    void add(int i, ll x){
        x %= mod;
        x = (x + mod) % mod;
        i++;
        while (i <= n){
            (bit[i] += x) %= mod;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            (ret += bit[i]) %= mod;
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return (sum(r-1) - sum(l-1) + mod) % mod;
    }
};

int main() {
    ll n, h, d;
    cin >> n >> h >> d;

    VL fact(n + 1);
    fact[0] = 1;
    REP(i,n) fact[i + 1] = (fact[i] * (i + 1)) % mod;

    ll s = 0;
    FOR(i,1,n) s = (s + fact[i]) % mod;

    VL dp(h + d + 1);
    BIT bit(h + 2);
    bit.add(1, fact[n]);
    bit.add(d + 1, -fact[n]);
    FOR(i,1,h-1){
        ll p = bit.sum(i);
        p = (p * s) % mod;
        bit.add(i + 1, p);
        bit.add(i + d + 1, -p);
    }
    cout << bit.sum(h) << endl;
    return 0;
}


Measured memory_bytes: 31488
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for _ in range(Q)]

ans = sum(A)

R = {}
for i in A:
  if i in R:
    R[i] += 1
  else:
    R[i] = 1

for b, c in BC:
  if b in R:
    t = R[b]
    R[b] = 0
    ans += t * (c - b)
    if c in R:
      R[c] += t
    else:
      R[c] = t
  print(ans)


Measured memory_bytes: 104876
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 200200;
char s[N];
int l[N], r[N];
int main() {
  int n, k, c; scanf("%d%d%d", &n, &k, &c);
  scanf(" %s", s + 1);
  int pw = -inf, z = 0;
  Rep(i, n) {
    if (s[i] == 'o') {
      if (pw + c < i) {
        ++z;
        pw = i;
      }
    }
    l[i] = max(l[i - 1], z);
  }
  pw = inf, z = 0;
  for (int i = n; i >= 1; --i) {
    if (s[i] == 'o') {
      if (i + c < pw) {
        ++z;
        pw = i;
      }
    }
    r[i] = max(r[i + 1], z);
  }
  //Rep(i, n) cout << l[i] << " " ; cout << endl;
  //Rep(i, n) cout << r[i] << " " ; cout << endl;

  Rep(i, n) if (s[i] == 'o') {
    int x = l[i - 1], y = r[i + 1];
    if (x + y < k) {
      printf("%d\n", i);
    }
  }
  return 0;
}



Measured memory_bytes: 3200
(n,m),*t=[map(int,t.split())for t in open(0)]
*e,=eval('[],'*-~n)
for a,b in t:e[a]+=b,;e[b]+=a,
q=[1]
d=[0]*-~n
for v in q:
 for w in e[v]:
  if d[w]<1:d[w]=v;q+=w,
print('Yes',*d[2:])

Measured memory_bytes: 200996
from itertools import permutations 
s=""
n=int(input())
p=[]
for i in range(n):
    h,m=list(map(int,input().split()))
    p.append([h,m])
for i in range(n):
    s+=str(i+1)
a=[''.join(p) for p in permutations(s)] 
k=0
l=len(a)
import math
for i in range(l):
    z=0
    for j in range(n-1):
        x=int(a[i][j])-1
        y=int(a[i][j+1])-1
        z+=math.sqrt((p[x][0]-p[y][0])**2+(p[x][1]-p[y][1])**2)
    k+=z
        
print(k/l)        

Measured memory_bytes: 12028
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 998244353;

void add(long long& a, const long long& b)
{
	a = (a + b) % mod;
}

void mul(long long& a, const long long& b)
{
	a = (a * b) % mod;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	int sum = 0;
	for(int i = 0; i < N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}
	vector<vector<long long>> dp(N + 1, vector<long long>(sum + 301, 0)); //dp[i][j]: first i nums has been painted, total value of red color is j, the number of ways to paint first i colors is dp[i][j].
	vector<vector<long long>> dp2(N + 1, vector<long long>(sum + 301, 0)); //dp[i][j]: first i nums has been painted into red or green(exclude blue), total value of red color is j, the number of ways to paint first i colors is dp[i][j].
	dp[0][0] = 1;
	dp2[0][0] = 1;
	for(int i = 0; i < N; i++)
	{
		for(int j = 0; j <= sum; j++)
		{
			add(dp[i + 1][j + A[i]], dp[i][j]); //paint i-th into red color
			add(dp[i + 1][j], 2 * dp[i][j]); //paint i-th into other color
			add(dp2[i + 1][j + A[i]], dp2[i][j]); //paint i-th into red color
			add(dp2[i + 1][j], dp2[i][j]); //paint i-th into green color
		}
	}
	long long neg = 0;
	for(int j = (sum + 1) / 2; j <= sum; j++)
	{
		add(neg, dp[N][j]);	
	}
	if(sum % 2 == 0)
	{
		add(neg, mod - dp2[N][sum / 2]);
	}
	mul(neg, 3);
	long long ans = 1;
	for(int i = 0; i < N; i++) mul(ans, 3);
	add(ans, mod - neg);

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


Measured memory_bytes: 424512
#include <stdio.h>
  
int main(void){
	int h,w,i,j;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)	break;
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				if(i == 0 || i == (h-1)){
					printf("#");
				}else{
					if(j == 0 || j == (w - 1)){
						printf("#");
					}else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
return 0;
}

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

point = 0
memory = -10
for cnt in range(n):
    point += b[a[cnt] - 1]
    if memory + 1 == a[cnt] - 1:
        point += c[a[cnt] - 2]
    memory = a[cnt] - 1

print(point)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int N = sc.nextInt();
      System.out.println((N - 2) * 180);
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = ((b-1) + (a-1) -1) / (a-1);
    cout << ans << endl;
}

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    ll N,A,B; cin >> N >> A >> B;
    ll ans;
    if(N==1&&(A!=B)) ans=0;
    else if(A>B) ans=0;
    else ans=(N-1)*B+A-(N-1)*A-B+1;
    cout << ans << endl;
}

Measured memory_bytes: 3624
from collections import deque
from collections import defaultdict

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

def main():
    N, M = ZZ()
    E = defaultdict(list)
    michi = [-1] * (N+1)
    for _ in range(M):
        a, b = ZZ()
        E[a].append(b)
        E[b].append(a)

    d = deque()
    d.append(1)
    while d:
        v = d.popleft()
        if v == 1: michi[v] = 0
        for to in E[v]:
            if michi[to] != -1: continue
            michi[to] = v
            d.append(to)
    print('Yes')
    print(*michi[2:], sep='\n')

    return

if __name__ == '__main__':
    main()


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

int main(){
  int N;
  long long sum=0;
  cin >> N;
vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
  sum += vec.at(i);
  }
  sort(vec.begin(), vec.end());
  cout << vec.at(0) << " " << vec.at(N-1) << " " << sum << endl;
}


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

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;

int n, m;
vector<int> vs[N];
int memo[N];

int dp(int at) {
    int &ans = memo[at];
    if(ans != -1) return ans;
    ans = 0;
    for(int v:vs[at]) {
        int cur = 1 + dp(v);
        ans = max(ans, cur);
    }
    return ans;
}

void solve() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        vs[u].push_back(v);
    }
    memset(memo, -1, sizeof(memo));
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans = max(ans, dp(i));
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 7552
H,W = map(int,input().split())
a = []
row = []
for i in range(H):
    tmp = list(input())
    if tmp.count(".") == len(tmp):
        row.append(i)
    a.append(tmp)
column = []
for i in range(W):
    count = 0
    for j in range(H):
        if a[j][i] == ".":
            count += 1
    if count == H:
        column.append(i)

for i in range(H):
    if i not in row:
        for j in range(W):
            if j not in column:
                print(a[i][j],end="")
        print("")

Measured memory_bytes: 4596
import string

n = int(input())

imanoatai = n

length = 0
cnt = 0
while True:
    length += 1
    cnt += 26 ** length
    if n <= cnt:
        break
    imanoatai -= 26 ** length

imanoatai -= 1
buf = []
for i in list(range(length))[::-1]:
    syou = imanoatai // 26**i
    amari = imanoatai % 26**i
    buf.append(syou)
    imanoatai = amari
    
for i in range(len(buf)):
    print(string.ascii_letters[buf[i]], end='')

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    string s;
    cin >> s;
    int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';
    // 0は-，1は+とする
    REP(i, 1<<3) {
        int ans = a;
        if(i >> 2 & 1) ans += b; else ans -= b;
        if(i >> 1 & 1) ans += c; else ans -= c;
        if(i >> 0 & 1) ans += d; else ans -= d;
        if(ans == 7) {cout << a << (i >> 2 & 1 ? "+" : "-") << b << (i >> 1 & 1 ? "+" : "-") << c 
                << (i >> 0 & 1 ? "+" : "-") << d << "=7" << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  int num[3][3]; //番号
  bool isHole[3][3]; //穴があいてるか
  
  //入力
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      isHole[i][j] = false;
    }
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin>>num[i][j];
    }
  }
  
  //でた番号の配列
  int N;
  cin>>N;
  int b[N];
  for(int i=0; i<N; i++){
    cin>>b[i];
  }
  
  
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      for(int x=0; x<N; x++){
        if(num[i][j] == b[x]){
          isHole[i][j] = true;
          break;
        }
      }
    }
  }
  bool ans = false;
  if(isHole[0][0] && isHole[0][1] && isHole[0][2]) ans=true;
  else if(isHole[1][0] && isHole[1][1] && isHole[1][2]) ans=true;
  else if(isHole[2][0] && isHole[2][1] && isHole[2][2]) ans=true;
  else if(isHole[0][0] && isHole[1][0] && isHole[2][0]) ans=true;
  else if(isHole[0][1] && isHole[1][1] && isHole[2][1]) ans=true;
  else if(isHole[0][2] && isHole[1][2] && isHole[2][2]) ans=true;
  else if(isHole[0][0] && isHole[1][1] && isHole[2][2]) ans=true;
  else if(isHole[0][2] && isHole[1][1] && isHole[2][0]) ans=true;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

int n;
const int INF = 1e9;
set<pii> used;

using T = tuple<int, int, int>;
// dis, v, pre

vector<int> dijkstra(int s, vector<vector<pii>> G) {
  priority_queue<T, vector<T>, greater<T>> que;
  vector<int> d(n, INF);
  d[s] = 0;
  que.push(T(0, s, s));

  while(!que.empty()) {
    T p = que.top(); que.pop();
    int dis = get<0>(p);
    int v = get<1>(p);
    int pre = get<2>(p);

    if (d[v] < dis) continue;
    if (v != pre) used.insert(pii(min(v, pre), max(v, pre)));
    for (auto&& e : G[v]) {
      if (d[e.first] > d[v] + e.second) {
        d[e.first] = d[v] + e.second;
        que.push(T(d[e.first], e.first, v));
      }
    }
  }
  return d;
}

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

  int m;
  cin >> n >> m;
  vector<vector<pii>> graph(n);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    graph[a].push_back(pii(b, c));
    graph[b].push_back(pii(a, c));
  }


  vector<vi> ans(n);
  rep(i, n) {
    ans[i] = dijkstra(i, graph);
    //for (auto&& j : ans[i]) {
    //  cerr << j << " ";
    //}
    //cerr << endl;
  }
  //cerr << endl;
  for (auto&& i : used) {
    cerr << i.first << " " << i.second << endl;
  }
  cout << m - used.size() << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

int main(){
    int N; cin >> N;
    vector<int> S(N); rep(i,N) cin >> S[i];
    int Q; cin >> Q;
    vector<int> T(Q); rep(i,Q) cin >> T[i];

    int C = 0;
    rep(i,Q){
        int left = 0,right = N;
        while(left <= right){
            int mid = (left + right) / 2;
            if(S[mid] == T[i]){++C;break;}
            else if(S[mid] > T[i]) right = mid-1;
            else left = mid+1;
        }
    } 

    cout << C << endl;
}


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

int main() {
  string S;
  cin >> S;
  string chr;
  int counter = 0;
  
  for (int i = 0; i < 6; i++) {
	  chr = S.at(i);
	  if (chr == "1") {
		  counter++;
	  }
  }
  
  cout << counter << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b && b!=c)
    {
        printf("Yes\n");
    }
    else if(a==c && c!=b)
    {
        printf("Yes\n");
    }
    else if(b==c && a!=c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

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

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

struct UnionFind {
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep1(i,n) a[i] = a[i] + a[i-1];
    ll ans = INFL;
    rep(i,n-1) {
        ans = min(ans, abs(a[n-1] - a[i]*2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <stdio.h>
 
int main(void) {

	int a, b, c, d, i;
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	while(1){
		c = c - b;
		if(c <= 0){
			printf("Yes");
			break;
		}
		a = a - d;
		if(a <= 0){
			printf("No");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1724
/*
 * atcoder/abc158/a.cpp
 */

// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cstring>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  Point operator + (Point v) { return Point(x + v.x, y + v.y); }
  Point operator - (Point v) { return Point(x - v.x, y - v.y); }
  bool operator == (const Point &v) const {
    return x == v.x && y == v.y;
  }
  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}


vector<Int> slice(vector<Int> &vec, int s, int t) {
  return vector<Int>(vec.begin()+s, vec.begin()+t);
}

vector<Int> trim(vector<Int> &vec, int n) {
  auto init = slice(vec, 0, n);
  auto tail = slice(vec, n+2, vec.size());
  init.insert(init.end(), tail.begin(), tail.end());
  return init;
}


string S;

void input() {
  cin >> S;
}

void solve() {
  int count = 0;
  for (auto &&a: S) {
    count += a == 'A';
  }

  if (count == 0 || count == 3) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        ++mp[s];
    }
    vector<string> cnt[n+1];
    for(auto &p: mp) cnt[p.se].push_back(p.fi);
    rrep(i, n+1)if(!cnt[i].empty()){
        for(auto &s: cnt[i]) cout << s << "\n";
        return 0;
    }
}

Measured memory_bytes: 31604
N, D = map(int, input().split())
X_Y = []
for i in range(N):
    X_Y.append(list(map(int, input().split())))
    
ans = 0
for n in range(N):
  x, y = X_Y[n]
  # ルートを計算すると計算誤差が生じるので、距離の2乗を比較する
  if(x**2 + y**2 <= D*D): ans += 1

print(ans)

Measured memory_bytes: 45408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, T;
    cin >> N >> T;

    VI A(N);
    rep(i, N){
        cin >> A.at(i);
    }

    ll sum = 0;
    ll t = 0;
    rep(i, N){
      if(t+T<=A[i]){
        sum += T;
      }
      else{
        sum += A[i]-t;
      }
      t = A[i];
    }
    p(sum + T);
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

	int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
  return 0;
}


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

int main(){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  int res = A1 + A2 + A3;
  if (res >= 22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

#define MAX 2010
int dp[4][MAX][MAX];
//RLUD

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	int K;
	cin >> S >> K;
	string RL, UD;

	fill(dp[0][0], dp[4][0], -INF);
	rep(h, 0, 4)dp[h][0][0] = 0;

	rep(i, 0, S.size()) {
		if (S[i] == 'R' || S[i] == 'L')RL += S[i];
		else UD += S[i];
	}
	dump(RL, UD);

	rep(h, 0, 2) {
		rep(i, 0, RL.size()) {
			rep(k, 0, K + 1) {
				if (RL[i] == "RLUD"[h]) {
					if (k % 2 == 0) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
				else {
					if (k % 2 == 1) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
			}
		}
	}

	//rep(i, 0, RL.size() + 1) {
	//	rep(k, 0, K + 1) {
	//		dump(i, k, dp[0][i][k]);
	//	}
	//}

	rep(h, 2, 4) {
		rep(i, 0, UD.size()) {
			rep(k, 0, K) {
				if (UD[i] == "RLUD"[h]) {
					if (k % 2 == 0) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
				else {
					if (k % 2 == 1) {
						chmax(dp[h][i + 1][k], dp[h][i][k] + 1);
					}
					else {
						chmax(dp[h][i + 1][k], dp[h][i][k] - 1);
						chmax(dp[h][i + 1][k + 1], dp[h][i][k] + 1);
					}
				}
			}
		}
	}

	int ans = -INF;
	rep(j, 0, K + 1) {
		rep(k, 0, K + 1) {
			if (j + k > K)break;
			rep(a, 0, 2)rep(b, 2, 4) {
				chmax(ans, dp[a][RL.size()][j] + dp[b][UD.size()][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 66288
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int N;
    cin >> N;
 
	int i = N / 111;
	if (N % 111 != 0) ++i;
 
	cout << i * 111 << endl;
	return 0;
 	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		char[]c = sc.next().toCharArray();
		
		int sum = 1;
		for(int i = 0; i < n-1 ; i++) {
			if(c[i] != c[i+1]) {
				sum++;
			}
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 26708
def main():
    a,b,c,d = map(int,input().split())
    takahashi_hp = a
    takahashi_at = b
    aoki_hp = c
    aoki_at = d

    takahashi_win = False

    while takahashi_hp >= 0 and aoki_hp >= 0:
        aoki_hp -= takahashi_at
        if aoki_hp <= 0:
            takahashi_win = True
            break
        takahashi_hp -= aoki_at
        if takahashi_hp <= 0:
            takahashi_win = False
            break

    print("Yes" if takahashi_win else "No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
const int PRIME_MAX = 51000;

int main() {
  vector<int> primes(PRIME_MAX);
  iota(primes.begin(), primes.end(), 0);
  primes[0] = primes[1] = -1;
  for (int i = 2; i * i <= PRIME_MAX; i++) {
    if (primes[i] == -1) {
      continue;
    }
    for (int j = (i << 1); j < PRIME_MAX; j += i) {
      primes[j] = -1;
    }
  }
  primes.erase(remove(primes.begin(), primes.end(), -1), primes.end());

  int n;
  while (cin >> n) {
    cout << *(lower_bound(primes.begin(), primes.end(), n) - 1) << ' ' << *(upper_bound(primes.begin(), primes.end(), n)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace  std;
struct node
{
	int a,b;
}edge[101010];
bool cmp(node x,node y)
{
	return x.a < y.a;
}
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>edge[i].a;
		edge[i].b=i;
	}
	sort(edge+1,edge+1+n,cmp);
	for(int i=1;i<=n;i++)
		cout<<edge[i].b<<" ";
	
	return 0;
}





Measured memory_bytes: 1536
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c;        
        c = a*b;
        if(c%2==0){
            System.out.println("Even");
        }
        else{
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 21588
fun main(args: Array<String>) {
    val (n, k) = readStringList().map(String::toDouble)
    println(Math.floor(Math.log(n) / Math.log(k)).toInt() + 1)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 36012
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int main() {
	unsigned long long x, ans = 0;
	cin >> x;
	ans = (x / 11) * 2;
	if (x % 11 == 0) {
		cout << ans << endl;
	}
	else if (x % 11 <= 6) {
		cout << ans + 1 << endl;
	}
	else {
		cout << ans + 2 << endl;
	}
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
import sys

n, a, b, c, d = map(int, input().split())
a, b, c, d = a - 1, b - 1, c - 1, d - 1
s = input()

for i in range(a + 1, max(c, d) - 1):
    if s[i: i + 2] == '##':
        print('No')
        sys.exit()

if c < d:
    print('Yes')
    sys.exit()

for i in range(b, d + 1):
        if s[i - 1: i + 2] == '...':
            print('Yes')
            sys.exit()

print('No')

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mod=1e9+7;
map<int,int>d;
inline int read() 
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)
{
	if(d[x])
		return d[x];
	else
	return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
	//初始条件
	d[0]=1;//a=b=0一组 
	d[1]=2; //a=b=0一组 ，a=b=1第二组； 
	int n;
	n=read(); 
	int ans=solve(n);
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
    int a;
    cin >> a;
    vint x(a);
    vint y(a);
    vint ans(a);
    rep(i,a) ans.at(i) = i+1;
    vint tmp = ans;
    rep(i,a) cin >> x.at(i);
    rep(i,a) cin >> y.at(i);
    int xco = 0;
    int yco = 0;
    do{
        xco++;
        if(ans == x)
            break;

    }while(next_permutation(ans.begin(),ans.end()));
    ans = tmp;
    do{
        yco++;
        if(ans == y)
            break;

    }while(next_permutation(ans.begin(),ans.end()));
    cout << abs(xco - yco) << endl;
}
    

Measured memory_bytes: 256
N, M, X = gets.chomp.split(' ').map(&:to_i)
C = Array.new
N.times do |i|
  C[i] = gets.chomp.split(' ').map(&:to_i)
end
min = Float::INFINITY
 
N.times do |i|
  combinations = (0..N-1).to_a.combination(i+1).to_a
  combinations.each do |combination|
    sum = Array.new(M+1, 0)
    (M+1).times do |k|
      (i+1).times do |j|
      	sum[k] += C[combination[j]][k]
      end
    end
    if sum.slice(1..-1).all?{ |value| value >= X }
      min = [min, sum[0]].min
    end
  end
end
 
p (min.infinite? ? -1 : min)

Measured memory_bytes: 14420