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

int main(){
  string s;
  cin >> s;
  int cnt1 = 0,cnt2;
  rep(i,s.length()) if(s[i] == 'g')cnt1++;
  cnt2 = s.length() - cnt1;
  int res = 0;
  
  res = s.length() / 2;
  cnt1 -= s.length() / 2;
  res -= cnt2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	ll A,B;
	char s;
	scanf("%lld %c %lld",&A,&s,&B);
	if(s=='+')printf("%lld\n",A+B);
	else printf("%lld\n",A-B);
	return 0;
}




Measured memory_bytes: 256
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:print(s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'='+'7')
elif a-b+c+d==7:print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'='+'7')
elif a+b-c+d==7:print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'='+'7')
elif a+b+c-d==7:print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'='+'7')
elif a-b-c+d==7:print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'='+'7')
elif a-b+c-d==7:print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'='+'7')
elif a+b-c-d==7:print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'='+'7')
elif a-b-c-d==7:print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'='+'7')

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int X = 110;

//head

int n, a[X], cnt[X];

void no() {cout << "Impossible" << endl;}
void yes() {cout << "Possible" << endl;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> a[i];
  if(n == 2) {
    if(a[0] == 1 and a[1] == 1) {
      yes();
    } else {
      no();
    }
    return 0;
  }

  bool check = false;
  rep(i, n) if(a[i] > 2) check = true;
  if(check) {
    bitset<X> bits(0);
    rep(i, n) {
      bits.set(a[i]);
    }
    int mi = -1, ma;
    rep(i, X) {
      if(bits.test(i)) {
        if(mi == -1) mi = i;
        ma = i;
      }
    }
    for(int i = mi; i <= ma; i++) {
      if(not bits.test(i) or (ma+1)/2 != mi) {
        no();
        return 0;
      }
    }
    rep(i, n) cnt[a[i]]++;
    for(int i = mi+1; i <= ma; i++) {
      if(cnt[i] == 1) {
        no();
        return 0;
      }
    }
    if(mi<<1 == ma) {
      if(cnt[mi] != 1) {
        no();
        return 0;
      }
    } else {
      if(cnt[mi] != 2) {
        no();
        return 0;
      }
    }

    yes();
  } else {
    rep(i, n) cnt[a[i]]++;
    if(cnt[1] != 1) {
      no();
      return 0;
    }
    yes();
  }
}

Measured memory_bytes: 3616
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	int n,k,ans=0;
	cin >> n >> k;
	rep(i, n) {
		int a;
		cin >> a;
		if (a >= k)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int C=A%2;
  int D=B%2;
  
  if (C==0||D==0) {
    cout<<"Even"<<endl;
  }
  else {
    cout<<"Odd"<<endl;
  }
  }

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;

bool isExist(vector<int>& d, int i)
{
    for(auto it = d.begin(); it != d.end(); ++it)
    {
        if(*it == i)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int n, k;
    vector<int> d;
    cin >> n >> k;
    d.resize(k);
    for(auto it = d.begin(); it != d.end(); ++it)   cin >> *it;
    for(int i = n; ; i++)
    {
        stringstream ss;
        ss << i;
        string s = ss.str();
        bool f = false;
        for(auto it = s.begin(); it != s.end(); ++it)
        {
            if(isExist(d, *it - '0'))
            {
                f = true;
            }
        }
        if(!f)
        {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}


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

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


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

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<ll>())
#define P pair<int , int>
#define V vector<ll>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
ll gcd(ll a, ll b){
	return b ? gcd(b, a % b) : a;
}
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll N, K;  cin >> N >> K;
	V A(N);  VECCIN(A);

	ll lcn = A[0];
	for(int i = 1 ; i < N ; i++)
		lcn = gcd(lcn, A[i]);

	GSORT(A);
	if(K % lcn == 0 && K <= A[0])  cout << "POSSIBLE" << endl;
  	else                           cout << "IMPOSSIBLE" << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a (n), b (n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;

  reverse (b.begin(), b.end());
  int l = -1, r = -2;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) {
      if (l == -1) l = r = i;
      else r++;
    }
  }

  if (l == -1) {
    cout << "Yes\n";
    for (auto i : b) cout << i << " ";
    cout << '\n';
    return 0;
  }

  int p = lower_bound (a.begin(), a.end(), a[l]) - a.begin() - 1;
  int q = upper_bound (a.begin(), a.end(), a[l]) - a.begin();
  int lo = 0, hi = n - 1, k = n;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    if (b[mid] < a[l]) {
      k = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  q = max (q, k);
  k = -1;
  lo = 0, hi = n - 1;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    if (b[mid] > a[l]) {
      k = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  p = min (p, k);
  int idx = 0;
  if (p < 0) idx = q;
  for (int i = l; i <= r; i++) {
    if (idx == n) {
      cout << "No\n";
      return 0;
    }
    swap (b[i], b[idx]);
    idx++;
    if (idx == p + 1) idx = q;
  }

  cout << "Yes\n";
  for (auto i : b) cout << i << " ";
  cout << '\n';
}


Measured memory_bytes: 4776
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,r,t){"use strict";e.exports=function(e){for(var r=Number(e[0]),t=new Array(r+1),n=0;n<r;n++){var o=Number(e[n+1]);t[n]=o}t[r]=0;for(var u=0,i=0,f=0;f<r+1;f++)0==t[f]?(u+=Math.floor(i/2),i=0):i+=t[f];console.log(u)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 28120
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int max(int X, int Y) {
    return X > Y ? X : Y;
}

int min(int X, int Y) {
    return X < Y ? X : Y;
}

int abs(int X) {
    return X > 0 ? X : -X;
}

int main() {
    int N, K; cin >> N >> K;
    int x[N]; REP(0, i, N) cin >> x[i];

    int ans = 1000000000;
    REP(0, i, N - K + 1) {
        // cout << x[i] << ", " << x[i + K - 1] << endl;
        int a = min(abs(x[i]), abs(x[i + K - 1]));
        int b = max(abs(x[i]), abs(x[i + K - 1]));
        if (x[i] >= 0 || x[i + K - 1] < 0) {
            ans = min(ans, b);
        } else {
            ans = min(ans, 2 * a + b);
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] x = new int[m];
			int[] y = new int[m];
			int[] r = new int[n];
			int[] num = new int[n];
			r[0] = 1;
			
			for(int i=0;i<m;i++) {
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			
			for(int i=0;i<n;i++) {
				num[i] = 1;
			}
	       
			for(int i=0;i<m;i++) {
				num[x[i]-1]--;
				num[y[i]-1]++;
				if(r[x[i]-1]==1) {
					r[y[i]-1] = 1;
					
					if(num[x[i]-1]==0) {
						r[x[i]-1]=0;
					}
					
				}
				
			}
			
			int ret = 0;
			for(int i=0;i<n;i++) {
				ret += r[i];
			}
			
			System.out.println(ret);
		}
		
	}


Measured memory_bytes: 81212
S=list(input())
cnt1,cnt2=0,0
#S[0]='0'
for i,s in enumerate(S):
    if i%2==0:
        if s=='1':
            cnt1+=1
    else:
        if s=='0':
            cnt1+=1
#S[0]='1'
for i,s in enumerate(S):
    if i%2==1:
        if s=='1':
            cnt2+=1
    else:
        if s=='0':
            cnt2+=1
print(min(cnt1,cnt2))

Measured memory_bytes: 49520
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
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<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VL a(n);
    vector<char> c(n-1);
    REP(i,n){
        scanf("%lld", &a[i]);
        if (i < n-1) cin >> c[i];
    }
    VL cumsum(n+1), sum(n+1);
    REP(i,n) cumsum[i+1] = cumsum[i] + a[i];
    sum[0] = a[0];
    REP(i,n-1){
        if (c[i] == '+') sum[i+1] = sum[i] + a[i+1];
        else sum[i+1] = sum[i] - a[i+1];
    }
    ll ans = sum[n-1];
    // cout << ans << endl;
    VI neg;
    REP(i,n-1) if (c[i] == '-') neg.push_back(i);
    // cout << neg.size() << endl;
    REP(k,(int)neg.size()-1){
        int x = neg[k], y = neg[k+1];
        // cout << x << " " << y << endl;
        ll tmp = sum[x] - (cumsum[y+1] - cumsum[x+1]) + cumsum[n] - cumsum[y+1];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<int> tobit(ll n, int keta) {
    vector<int> res(keta, 0);
    for(int i = 0; i < keta; i++) {
        res[i] = n % 2;
        n /= 2;
    }
    return res;
}
int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    if(w == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<int> pm(w);
    for(int i = 0; i < w; i++) {
        pm[i] = i;
    }
    vector<vector<int>> pats;
    for(int i = 0; i < (1LL << (w - 1)); i++) {
        auto tmp = tobit(i, w - 1);
        bool flag = true;
        for(int j = 0; j < tmp.size() - 1; j++) {
            if(tmp[j] == 1 && tmp[j + 1] == 1) {
                flag = false;
                break;
            }
        }
        if(flag) {
            pats.push_back(tmp);
        }
    }
    vector<vector<int>> state;
    do {
        state.push_back(pm);
    } while(next_permutation(all(pm)));

    int sn = state.size();
    vector<vector<int>> seni(sn);
    map<vector<int>, int> mp;
    for(int i = 0; i < state.size(); i++) {
        mp[state[i]] = i;
    }
    for(int i = 0; i < state.size(); i++) {
        for(auto &pat : pats) {
            auto next = state[i];
            for(int x = 0; x < pat.size(); x++) {
                if(pat[x] == 1) {
                    swap(next[x], next[x + 1]);
                }
            }
            seni[i].push_back(mp[next]);
        }
    }
    vector<vector<ll>> dp(h + 1, vector<ll>(sn, 0));
    dp[0][0] = 1;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < sn; j++) {
            for(int x = 0; x < seni[j].size(); x++) {
                dp[i + 1][seni[j][x]] += dp[i][j];
                dp[i + 1][seni[j][x]] %= MOD;
            }
        }
    }
    k--;
    ll ans = 0;
    for(int i = 0; i < sn; i++) {
        if(state[i][k] == 0) {
            ans += dp[h][i];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 54688
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			cout << Ns[i][j] << endl;
		}
	}
}


int main() {
	int K;
	cin >> K;
	int even = K / 2;
	int odd;
	if (K % 2 == 0) {
		odd = K / 2;
	} else {
		odd = K / 2 + 1;
	}
	cout << even * odd << endl;
}

Measured memory_bytes: 256
row = input().split()
s = list(row[0])
count = 0
for bit in range(1<<(len(s)-1)):
    S=[]
    S.append(s[0])
    for i in range(len(s)-1):
        if bit & (1<<i):
            S.append("+")
        S.append(s[i+1])
    S = "".join(S)
    S = S.split("+")
    S = list(map(int, S))
    count += sum(S)
print(count)



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Read();

        Console.WriteLine(DateTime.Parse(input) <= new DateTime(2019,4,30) ? "Heisei" : "TBD");
    }


    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}





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

int main(){
		int x1,y1,x2,y2,a,b;
		cin >> x1 >> y1 >> x2 >> y2;
		a = y1-y2;
		b= x2-x1;
		printf("%d %d %d %d\n", a+x2,b+y2,a+x1,b+y1);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc155() {
	ll n;
	ll ans = 0;
	string str;

	cin >> n;

	V a(n);
	rep(i, n) {
		cin >> a[i];
	}

	str = "APPROVED";
	rep(i, n) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				str = "DENIED";
				break;
			}
		}
	}

	cout << str << "\n";
}

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

	solve_abc155();

	return 0;
}

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

#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C 9/++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()
 
//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(2e4+20)

#define fori(i,n) for(int i=0; i<n; i++)
#define forl(i,n) for(ll i=0; i<n; i++)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
const  llu int_max = pow(2,32) - 1 ;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.ff < j.ff;
}

int main(){

	fastio
	int n,d;
	cin>>n>>d;
	if(n % (2*d+1) == 0)
		cout<<n/(2*d+1);
	else
		cout<<n/(2*d+1) + 1;


	
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<cctype>
using namespace std;
int main(){
	map<string, int> mpa;
	string most_frequent_word, longest_word;
	string s;
	int max_frequency = 0, max_length = 0;
	while(cin >> s){
		if(s.length() > max_length){
			max_length = s.length();
			longest_word = s;
		}
		for(int i = 0; i < s.length(); i++) s[i] = tolower(s[i]);
		mpa[s]++;
	}
	map<string, int>::iterator itr;
	for(itr = mpa.begin(); itr != mpa.end(); itr++){
		if(itr -> second > max_frequency){
			max_frequency = itr -> second;
			most_frequent_word = itr -> first;
		}
	}
	cout << most_frequent_word << ' ' << longest_word << endl;
	return 0;
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S;
	cin >> S;

	cout << (S.find("AC") != string::npos ? "Yes" : "No") << endl;
	
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    S = [0]*(N+1)           # S[i] means sum(A[0:i])%M
    for i in range(N):
        S[i+1] = (S[i] + A[i]) % M
    
    d = defaultdict(int)
    ans = 0
    for i in range(N+1):
        ans += d[S[i]]
        d[S[i]] += 1
        # print([S[i], ans])
        # print(d)
    
    print(ans)


if __name__ == '__main__':
    main()

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

int main(){
    int n;
    cin >> n;
    vector<long> x(n);
    rep(i,n) cin >> x[i];
    long ans = 1e10;
    rep(i,101){
        long res = 0;
        rep(j,n) res += (x[j]-i) * (x[j]-i);
        ans = min(ans,res);
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::f64::consts::*;
use std::f64;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i32,
    }
    let x1 = n as f64 / 1.08_f64;
    let x2 = (n + 1) as f64 / 1.08_f64;
    if x2.floor() >= x1 && x2.floor() < x2  {
        println!("{}", x2.floor());
    } else {
        println!(":(");
    }
}

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());

  if(s.size()%2 == 1) {
    cout << "No" << endl;
  }
  else {
    bool btf = true;
    for(int i=1; i<s.size(); i+=2) {
      if(s[i]!=s[i-1]) {
        btf = false;
        break;
      } 
    }
    if(btf) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,k;
cin>>n>>k;
int h[n];
for(int i=0;i<n;++i)
cin>>h[i];
long long int dp[n];
dp[0]=0;
dp[1]=abs(h[1]-h[0]);
for(int i=2;i<n;++i)
{ dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
if(i<k)
  
  for(int j=1;j<i;++j) 
  dp[i]= min(dp[i-j-1]+abs(h[i-j-1]-h[i]),dp[i]);
  else
  for(int j=1;j<k;++j)
  dp[i]= min(dp[i-j-1]+abs(h[i-j-1]-h[i]),dp[i]);
  	
	
	
	
} cout<<dp[n-1];
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    ll a,b,c; cin >> a >> b >> c;
    if(c - a - b <= 0){
        cout << "No" << endl;
        return 0;
    }
    if(4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include<string.h>
using namespace std;
int main(void)
{
	int n,a,b,t[101],i,j,temp,k,x,y,z,c;
	cin>>n;
	cin>>a>>b;
	cin>>k;
	for(i=0;i<=n;i++){
	t[i]=0;
	}
	for(i=0;i<n;i++){
		cin>>t[i];
	}	
	for(i=0;i<n;i++){
		for(j=n-1;j>i;j--){
			if(t[i]<t[j]){
				temp=t[j];
				t[j]=t[i];
				t[i]=temp;
			}
		}
	}
	x=k;
	y=a;
	c=x/y;
	for(i=0;i<n;i++){
	x=x+t[i];
	y=y+b;
	z=x/y;
		if(z>=c){
			c=z;
		}
		else{
			break;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b;
  cin >> s;
  rep(i, 0, a)
  {
    if (s[i] != '0' && s[i] != '1' && s[i] != '2' && s[i] != '3' && s[i] != '4' && s[i] != '5' && s[i] != '6' && s[i] != '7' && s[i] != '8' && s[i] != '9')
    {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  rep(i, a + 1, a + b + 1)
  {
    if (s[i] != '0' && s[i] != '1' && s[i] != '2' && s[i] != '3' && s[i] != '4' && s[i] != '5' && s[i] != '6' && s[i] != '7' && s[i] != '8' && s[i] != '9')
    {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  if (s[a] == '-')
  {
    cout << "Yes"
         << "\n";
  }
  else
  {
    cout << "No"
         << "\n";
  }
}

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

int main()
{
    ll K;
    cin >> K;

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

    for (size_t i = A; i <= B; i++)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
const int mu=  int(1E9) + 7,MOD=1000000007;
const int N=300005;
int n,m,l,r,p[N*2],inv[N*2];
int c(int x,int y){
	if (x<y) return 0;
	return p[x]*1ll*inv[y]%mu*inv[x-y]%mu;
}
int solve2(int n,int m,int s,int x,int y){
	int ans=0;
	if (s-1ll*m*x<0) return 0;
	else s=s-1ll*m*x;
	int f=1;
	for (int i=0,f=1;i<=n-m && s>=0;i++,f=1ll*f*(mu-1)%mu,s=s-y){
		ans=(ans+1ll*f*c(s+n,n)%mu*c(n-m,i)%mu)%mu;
	}
	return 1ll*ans*c(n,m)%mu;
}
int solve(int n,int m,int s){
	int ans=c(s+n,n);
	for (int i=s;i>=1;i--){
		//枚举第m个数 
		int del=(solve2(n,m,s,i,i)+mu-solve2(n,m,s,i+1,i))%mu;
		ans=(ans+mu-del)%mu;//容斥 
	}
	return ans;
}
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1ll*x*x%mu) 
		if (y&1) ans=ans*1ll*x%mu;
	return ans;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&l,&r);
	p[0]=1;
	for (int i=1;i<=n+r;i++)p[i]=1ll*p[i-1]*i%mu;
	inv[n+r]=ksm(p[n+r],mu-2);
	for(int i=n+r-1;i>=0;i--) inv[i]=inv[i+1]*1ll*(i+1)%mu; 
	printf("%d\n",(solve(n,m,r)-solve(n,m,l-1)+mu)%mu);
}

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

int main() {
    //freopen("input1.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    string s1, s2;
    cin >> s1 >> s2;
    int n = s1.length();
    int m = s2.length();
    vector<vector<int>> dp(n+1, vector<int> (m+1, 0));
    
    for (int i=1; i<=n; i++){
        for (int j=1; j<=m; j++){
            if (s1[i-1]==s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    string ans = "";
    int i = n, j = m;
    while(i>0 && j>0){
        if (s1[i-1]==s2[j-1]){
            ans+=s1[i-1];
            i--;
            j--;
        }
        else if (dp[i-1][j]>=dp[i][j-1])
            i--;
        else
            j--;    
        
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 38628
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll  C=0;
    string S;
    cin >> S;
    rep(i,S.size()){
        if(S[i]=='x'){
            C++;
        }
    }
    cout <<  (C>=8 ? "NO" : "YES") << endl;
}

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

int main() {
	ll n,a[114514];
	cin>>n;
	for(int i=0;i<n;i++){
		ll num;
		cin>>num;
		a[num-1]=i+1;
	}
	for(int i=0;i<n;i++)cout<<a[i]<<' ';
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
#define ll long long
ll mod = 1000000000+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    ll T;
    T=1;
    //cin>>T;
    start:
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n+1] = {0};
        for(ll i=1;i<=100;i++){
            for(ll j=1;j<=100;j++){
                for(ll k=1;k<=100;k++){
                    ll val = i*i+j*j+k*k+i*j+j*k+k*i;
                    if(val>n){continue;}
                    a[val]++;
                }
            }
        }
        for(ll i=1;i<=n;i++)
        {
            cout<<a[i]<<endl;
        }
        
    }
    return 0;
}



Measured memory_bytes: 3612
a,b=map(int,input().split())
c=[0]+[list(map(int,input().split()))for i in range(a)]
def f(t,s):
    if t==0:
        return 10**9
    l=min(s//(t*100),c[t][0])
    k=100*t*l
    if l==c[t][0]:
        k+=c[t][1]
    if k<s:
        l+=f(t-1,s-k)
    return min(l,f(t-1,s))
print(f(a,b))

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

int main() {
  int H,W;
  cin >> H >> W;
  for(int i=0; i<W+2; i++){
    cout << "#";
  }
  cout << endl;
  for(int j=0; j<H; j++){
    vector<string> s(H);
    cin >> s.at(j);
    cout << "#" << s.at(j) << "#\n";
  }
  for(int k=0; k<W+2; k++){
    cout << "#";
  }
}

Measured memory_bytes: 256
N = int(input())
blist = list(map(int, input().split()))
#print(blist)
ans = []
for n in range(N):
    if n == 0:
        ans.append(blist[0])
    elif n>0 and n<N-1:
        mina = min(blist[n-1],blist[n]) 
        ans.append(mina)
    else:
        ans.append(blist[n-1])    
#print(ans)
ansnum = sum(ans)
print(ansnum)

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

int main() {
  int a,count=50;
  cin >>a ;
  for(int i=0;i<a;i++){
    int x,flag=0;
    cin>>x;
   while(x%2==0){
       x=x/2;
     flag++;
   }
  if(count>flag){count=flag;}
  
  }
  
  cout<<count <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	
	int n, k; scanf("%d%d", &n, &k);
	long long ans = 0;
	for(int i = k; i<=n+1; i++){
		long long lb = (i *1ll* (i-1))/(1ll*2);
		long long ub = n *1ll* i - lb;
		ans = ans + (ub - lb  + 1);
		ans %= MOD;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main(void){
	int n, i, ans, numw, nume;
	char* s;

	cin >> n;
	s = new char [n + 1];
	cin >> s;
	nume = 0;
	for(i = 1; i < n; i++) {
		if(s[i] == 'E')
			nume++;
	}
	numw = 0;
	ans = nume + numw;
	for(i = 1; i < n; i++) {
		if(s[i] == 'E')
			nume--;
		if(s[i - 1] == 'W')
			numw++;
		if(nume + numw < ans)
			ans = nume + numw;
	}
	cout << ans << endl;
	delete [] s;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define N 2050
string ss[2][N+1];
int c[N+1][N+1];
string lcs(string X,string Y){
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  ss[0][0] = "";
  memset(c,0,sizeof(c));
  for(int i=0;i<N+1;i++) ss[0][i]=ss[1][i]="";
  for(int i=0;i<=m;i++) c[i][0]=0;
  for(int j=1;j<=n;j++) c[0][j]=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1, ss[i%2][j] = ss[(i-1)%2][j-1] + X[i];
      else {
    if(c[i-1][j] >= c[i][j-1]) c[i][j]=c[i-1][j], ss[i%2][j] = ss[(i-1)%2][j];
    else c[i][j] = c[i][j-1], ss[i%2][j] = ss[i%2][j-1];
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  string ret=ss[m%2][n],ret2=ret;
  reverse(ret2.begin(),ret2.end());
  //assert(ret==ret2);
  assert((int)ret.size()==maxl);
  return ss[m%2][n];
}
int main(){
  string s;
  while(cin >> s) {
    string t = s;
    reverse(t.begin(), t.end());
    cout << lcs(s, t) << endl;
  }
  return 0;
}

Measured memory_bytes: 25592
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<string,pair<ll,ll>> p[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n){
        cin>>s>>a;
        p[i]=m_p(s,m_p(-a,i+1));
    }
    sort(p,p+n);
    rep(i,n)Cout(p[i].se.se);
    return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int k,l;
    cin >> s >>k;
    l=s.size();
    REP(i,l){
        if(s.at(i)=='a') continue;
        else{
            if('z'-s.at(i)+1<=k){
                k-='z'-s.at(i)+1;
                s.at(i)='a';
            }
        }
        //cout << s << k <<endl;
    }
    REP(i,k%26){
        if(s.at(l-1)=='z'){
            s.at(l-1)='a';
        }else{
            s.at(l-1)++;
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 592
import java.util.*;

class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int p,int c){
		p=root(p);
		c=root(c);
		if(p==c)
			return false;
		if(a[p]>a[c]){
			int buf=c;
			c=p;
			p=buf;
		}
		a[p]+=a[c];
		a[c]=p;
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

class Main{

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),m=s.nextInt();
		UF uf=new UF(n);
		for(int i=0;i<m;++i) {
			uf.connect(s.nextInt()-1,s.nextInt()-1);
			s.nextInt();
		}
		System.out.println(Arrays.stream(uf.a).filter(i->i<0).count());
	}
}

Measured memory_bytes: 92696
#include <bits/stdc++.h>
using namespace std;
 
#define int long long

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

    int n, k;
    cin >> n >> k;
    int a[n], dp[n]={0};
    for(int i=0; i<n; ++i) cin >> a[i];
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2; i<n; ++i){
        dp[i]= dp[i-1]+abs(a[i]-a[i-1]);
        int j = i-2, c = k-1;
        while(c>0&&j>=0){
            dp[i]=min(dp[i], dp[j]+abs(a[i]-a[j]));
            j--, c--;
        }
    }
    cout << dp[n-1];

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#define ll long long
#define INF 10000000

using namespace std;

//ifstream cin ("input.txt"); ofstream cout ("output.txt");

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    map<int, int> m;
    for(int i = 0; i < n; i++) {
        int t; cin >> t;
        m[t]++;
    }
    vector <int> g;
    for(auto i:m){
        g.push_back(i.first);
    }
    int ans = 0;
    for(int i=0; i<g.size(); i++){
        int tans = 0;
        for(int j = i; j < g.size(); j++){
            if(g[j] - g[i] <= 2){
                tans += m[g[j]];
            } else break;
        }
        ans = max(ans, tans);
    }
    cout << ans;
}

Measured memory_bytes: 3584
from bisect import bisect_left

N, *L= map(int, open(0).read().split())
X = sorted(L)
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ub = bisect_left(X, X[i] + X[j])
        ans += ub - (j + 1)
        
print(ans)



Measured memory_bytes: 44968
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[10000000],n,i;
int main(){
  cin>>n;
  r(i,n)cin>>a[i];
  for(i=1;i<=n;i++)if(n%i==0){
    int c=0;
    r(j,i)for(int k=j;k<n;k+=i)
      if(a[k]!=a[j])c++;
    if(!c)break;
  }
  cout<<(n/i)<<endl;
}

Measured memory_bytes: 3864
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define CLAMP(a) _min(_max(a,0),19)
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) { LLI res = 1; while (b > 0) { if (b & 1)res = res * a % MOD; a = a * a % MOD; b >>= 1; }return res; }

struct ST
{
    // 2 5
    int f2, f5;
};

int cm[40][40];

int main()
{
    cout << fixed << setprecision(10);

    int n;
    cin >> n;


    vector<ST> v(n);
    REP(i, n)
    {
        long double d;
        cin >> d;
        LLI a=(d * 1e9+0.5);
        int cnt = 0;
        while (a % 2 == 0)
        {
            a /= 2;
            cnt++;
        }
        v[i].f2 = cnt;


        a = (d * 1e9 + 0.5);
        cnt = 0;
        while (a % 5 == 0)
        {
            a /= 5;
            cnt++;
        }
        v[i].f5 = cnt;


        REP(i2, 20)
        {
            REP(i5, 20)
            {
                if (18-v[i].f2<=i2 && 18 - v[i].f5 <= i5)
                {
                    cm[i2][i5]++;
                }
            }
        }

    }

    LLI ans = 0;
    REP(i, n)
    {
        ans+= cm[CLAMP(v[i].f2)][CLAMP(v[i].f5)];
        if (18 <= _min( v[i].f2 * 2, v[i].f5 * 2))
        {
            ans--;
        }
    }
    cout << ans / 2;
    return 0;
}

Measured memory_bytes: 4844
n = int(input())
s = list(input() for i in range(n))
m = int(input())
t = list(input() for i in range(m))
ss = set(s)
ans = []

for i in ss:
    ans.append(s.count(i)-t.count(i))

if max(ans) < 0:
    print(0)
else:
    print(max(ans))

Measured memory_bytes: 3064