akhauriyash/Code-Regression huggingface dataset:
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}

bool dfs(string& s,int i) {
    if (s.size() <= i) {
        return true;
    } else if (s.substr(i,5) == "dream") {
        if (s.substr(i+5,5) == "erase") {
            return dfs(s, i+5);
        } else if (s.substr(i+5,2) == "er") {
            return dfs(s, i+7);
        } else {
            return dfs(s, i+5);
        }
    } else if (s.substr(i,5) == "erase") {
        if (s[i+5] == 'r') {
            return dfs(s, i+6);
        } else {
            return dfs(s, i+5);
        }
    } else {
        return false;
    }
}

void solve(){
    string s;
    getline(cin ,s);

    if (dfs(s,0)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}

Measured memory_bytes: 2128
def solve(n, a):
    b0 = sum([((-1)**(i%2)) * a[i] for i in range(n)]) // 2
    b = [b0]
    for i in range(n-1):
        b.append(a[i]-b[i])
    b = [2*b[i] for i in range(n)]
    return " ".join(map(str, b))

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

using namespace std;

int main(){
	string C[105];
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>C[i];
	}
	
	for(int i=0;i<h;i++){
		cout<<C[i]<<endl;
		cout<<C[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
long long a,b,c;
cin>>a>>b>>c;
long long ar[11];
ar[0]=c;
for(int i=1;i<11;i++)
	ar[i]=a*ar[i-1]-b;
for(int i=1;i<11;i++)
	cout<<ar[i]<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
	int main()
{
	int b, f, r, v, n, i, j, w[3][10] = {0}, x[3][10] = {0}, y[3][10] = {0}, z[3][10] = {0};
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d %d", &b, &f, &r, &v);
		switch(b){
			case 1:	w[f-1][r-1] += v;
			break;
			case 2:	x[f-1][r-1] += v;
			break;
			case 3:	y[f-1][r-1] += v;
			break;
			case 4:	z[f-1][r-1] += v;
			break;
		}
	}
		for(i = 0; i < 3; i++){
			for(j = 0; j < 10; j++){
				printf(" %d", w[i][j]);
			}
			printf("\n");
		}
		printf("####################\n");
				for(i = 0; i < 3; i++){
			for(j = 0; j < 10; j++){
				printf(" %d", x[i][j]);
			}
			printf("\n");
		}
		printf("####################\n");
				for(i = 0; i < 3; i++){
			for(j = 0; j < 10; j++){
				printf(" %d", y[i][j]);
			}
			printf("\n");
		}
		printf("####################\n");
				for(i = 0; i < 3; i++){
			for(j = 0; j < 10; j++){
				printf(" %d", z[i][j]);
			}
			printf("\n");
		}
		return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main(){
  int a,x;
  int n;
  int l[100];
  int i;
  scanf("%d %d",&n,&a);
  for(i=0;i<n;i++)scanf("%d", &l[i]);
  int ans = 1;
  int now = 0;

  for(i=0;i<n;i++){
    now = now + l[i];
    if(now<=a)ans+=1;
    else break;

  }

  printf("%d\n", ans);


  return 0;
}


Measured memory_bytes: 128
n = int(input())
p = [list(map(int,input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    l = abs(p[i][1]-x) + abs(p[i][2]-y)
    if p[i][0] - t >= l and (p[i][0]-t) %2 == l %2:
        t = p[i][0]
        x = p[i][1]
        y = p[i][2]
    else:
        print("No")
        break
else:print("Yes")


Measured memory_bytes: 27300
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ");
//#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int MAX = 200060;
const double pi = acos(-1);

int getdig(ll x) {
	int ret = 0;
	while (x > 0) {
		x /= 10;
		ret++;
	}
	return ret;
}

void solve() {
	ll N; cin >> N;
	ll ans = 100;
	for (int i = 1; i*i <= N; i++) {
		if (N%i == 0) {
			int a = getdig(i), b = getdig(N / i);
			ans = min(ans, max(a, b));
		}
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	/*REP(i, 100) {
		test(i);
	}*/
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<ll> x(N);
	vector<ll> y(N);
	vector<ll> z(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i] >> z[i];
	}

	auto ans = 0ll;
	for (auto i = 0; i < 8; ++i)
	{
		vector<vector<ll>> dp(N + 1, vector<ll>(M + 1, LLONG_MIN));
		dp[0][0] = 0;
		for (auto j = 0; j < N; ++j)
		{
			for (auto k = 0; k <= M; ++k)
			{
				dp[j + 1][k] = dp[j][k];

				if (k < 1 || dp[j][k - 1] == LLONG_MIN)
				{
					continue;
				}

				auto sum = 0ll;
				if ((i & (1 << 0)) != 0)
				{
					sum += x[j];
				}
				else
				{
					sum -= x[j];
				}
				if ((i & (1 << 1)) != 0)
				{
					sum += y[j];
				}
				else
				{
					sum -= y[j];
				}
				if ((i & (1 << 2)) != 0)
				{
					sum += z[j];
				}
				else
				{
					sum -= z[j];
				}
				dp[j + 1][k] = max(dp[j + 1][k], dp[j][k - 1] + sum);
			}
		}
		ans = max(ans, dp[N][M]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    if(n%1000==0) cout << 0 << endl;
    else cout << 1000 - (n%1000) << endl;
    return 0;
}

Measured memory_bytes: 3632
S = input()
T = input()

score = []
for i in range(len(S)-len(T)+1):
    U = S[i: i+len(T)]
    cnt = 0
    for j in range(len(T)):
        if U[j] != T[j]:
            cnt = cnt + 1
    score.append(cnt)
print(min(score))

Measured memory_bytes: 9044
#include <stdio.h>
#define A 1
#define B 2
#define C 3
#define D 4
#define E 5
#define F 6
#define G 7

int main(void){
	int field[10][10];
	int i,j,c;
	int type;
	int end = 0;
	int s_end;
	for(i = 0; i < 10; i++){
		field[i][0] = 0;
		field[i][9] = 0;
	}
	for(j = 0; j < 10; j++){
		field[0][j] = 0;
		field[9][j] = 0;
	}
	while(1){
		type = 0;
		i = 1;
		j = 1;
		s_end = 0;
		while(1){		
			c = getchar();
			if(c == EOF){
				end = 1;
				break;
			}
			field[i][j] = c - '0';
			if(i == 8){
				getchar();
				i = 1;
				if(j == 8){
					getchar();
					break;
				}else{
					j++;
				}
			}else{
				i++;		
			}
		}
		if(end){break;}
		for(j = 1; j < 9; j++){
			for(i = 1; i < 9; i++){
				if(field[i][j]){
					if(field[i-1][j+1]){
						if(field[i+1][j  ]){
							type = G;
							s_end = 1;
							break;
						}else{
							type = D;
							s_end = 1;
							break;
						}
					}else{
						if(
							field[i  ][j+1] &&
							field[i+1][j  ] &&
							field[i+1][j+1]
						){
							type = A;
							s_end = 1;
							break;
						}else if(
							field[i  ][j+1] &&
							field[i  ][j+2] &&
							field[i  ][j+3]
						){		
							type = B;
							s_end = 1;
							break;
						}else if(
							field[i+1][j  ] &&
							field[i+2][j  ] &&
							field[i+3][j  ]
						){
							type = C;
							s_end = 1;
							break;
						}else if(
							field[i+1][j  ] &&
							field[i+1][j+1]	&&
							field[i+2][j+1]	
						){
							type = E;
							s_end = 1;
							break;
						}else if(
							field[i  ][j+1] &&
							field[i+1][j+1] &&
							field[i+1][j+2] 
						){
							type = F;
							s_end = 1;
							break;
						}
					}
				}
			}
			if(s_end){break;}
		}
		putchar(
			type == A ? 'A' :
			type == B ? 'B' :
			type == C ? 'C' :
			type == D ? 'D' :
			type == E ? 'E' :
			type == F ? 'F' : 'G'
		);
		putchar('\n');
	}

	return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#define _A_ true
using namespace std;
typedef pair<char,char> P; // P(1,0)

int main()
{
  map<char,P> graph;
  graph['A'] = P('Y','X');
  graph['X'] = P('Z','N');
  graph['Y'] = P('N','X');
  graph['Z'] = P('B','W');
  graph['W'] = P('Y','B');
  graph['B'] = P('X','Y');

  while(_A_)
    {
      string line; char now = 'A';
      cin >> line;
      if(line == "#")
	break;
      for(int i=0;i<line.size();i++)
	now = line[i] == '1'?graph[now].first:graph[now].second;
      now == 'B'?cout << "Yes" << endl:cout << "No" << endl;
    }

  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
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); }
//SOLVE

void solve (void)
{
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  if( K <= A)
  {
    cout<<K<<endl;
  }
  else if( K <= A+B)
  {
    cout<<A<<endl;
  }
  else if(K <= A + B + C)
  {
    cout<<A - (K - A - B)<<endl;
  }
  else
  {
    abort();
  }
  
  
  return; 
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int M,D,a=0;
    cin >>M>>D;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=D;j++){
            int b=j/10;
            if(b*(j-b*10)==i&&b>=2&&j-b*10>=2){
                a=a+1;
            }
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int[] num = new int[3];
		int wk;
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<3;i++){
			num[i] = sc.nextInt();
		}
		for(int j=0;j<3-1;j++){
			for(int i=j+1;i<3;i++){
				if(num[j]>num[i]){
					wk = num[i];
					num[i] = num[j];
					num[j] = wk;
				}
			}
		}
		System.out.println(num[0] +" "+ num[1] +" "+ num[2]);
		sc.close();
	}

}

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

int main(){
	int ans, N;
	cin >> N;
	ans = N;
	string S;
	cin >> S;
	for(int i = 0; i < N-1; i++){
		if(S[i] == S[i+1]){
			ans = ans-1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int H, W;
char maze[1010][1010];
vector<P>v, v2;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W;
	int mnX = INF, mxX = 0, mnY = INF, mxY = 0, mnXY = INF, mxXY = 0, mnXY2 = INF, mxXY2 = 0;
	REP(i, H) {
		REP(j, W) {
			cin >> maze[i][j];
			if (maze[i][j] == 'B') {
				mnX = min(mnX, i);
				mxX = max(mxX, i);
				mnY = min(mnY, j);
				mxY = max(mxY, j);
				mnXY = min(mnXY, i + j);
				mxXY = max(mxXY, i + j);
				mnXY2 = min(mnXY2, (i - j));
				mxXY2 = max(mxXY2, i - j);
				v.push_back({ i,j });
			}
		}
	}
	int N = v.size();
	int ans = 0;
	int s = 0;
	int mx = 0;
	int t = 0;
	//print("here");
	REP(i, N) {
		int x = v[i].first, y = v[i].second;
		if (x == mxX || x == mnX || y == mnY || y == mxY||x+y==mnXY||x+y==mxXY||x-y==mnXY2||x-y==mxXY2) {
			v2.push_back({ x,y });
		}
	}
	
	int M = v2.size();
	REP(i, M - 1) {
		FOR(j, i + 1, M) {
			int res = abs(v2[i].first - v2[j].first) + abs(v2[i].second - v2[j].second);
			ans = max(ans, res);
		}
	}
	/*FOR(j, 1, N) {
		int res = abs(v[s].first - v[j].first) + abs(v[s].second - v[j].second);
		if (res > mx) {
			t = j;
			mx = res;
		}
	}
	REP(i, N) {
		if (i == t)continue;
		int res = abs(v[t].first - v[i].first) + abs(v[t].second - v[i].second);
		ans = max(res, ans);
	}*/
	print(ans);
}



Measured memory_bytes: 20128
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=(b);a<(c);a++)
#define PER(a,b,c) for(ll a=(b);a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

ll f(map<ti,ll> &m, ti k, ll o){
    if(m.find(k)==m.end()){
        return LLONG_MIN;
    }
    if(m[k]==LLONG_MIN) return LLONG_MIN;
    return m[k]+o;
}

int main(){
    ll N = ii();
    vector<ll> A;
    REP(i,0,N) A.push_back(ii());

    map<ti,ll> dp;
    dp[make_tuple(0,0,0)]=0;

    REP(i,1,N+1){
        ll c=int(i/2);
        REP(j,c-1,c+2){
            dp[make_tuple(i,j,0)]=max(
             f(dp,make_tuple(i-1,j,0),0), 
             f(dp,make_tuple(i-1,j,1),0));
            dp[make_tuple(i,j,1)]=f(dp,make_tuple(i-1,j-1,0),A[i-1]);
        }
    }
    oie(max(
        dp[make_tuple(N,int(N/2),0)],
        dp[make_tuple(N,int(N/2),1)]
        ));

    return 0;
}


Measured memory_bytes: 98532
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

bool dfs(int value){
    if(value == 0)return true;
    if(value < 0)return false;

    return dfs(value - 4)+dfs(value - 7);
}
int main(){
    int n;
    cin >> n;
    if(dfs(n))cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((a - c) * (a - c) <= d * d){
        printf("Yes");
    }else if((a - b) * (a - b) <= d * d && (b - c) * (b - c) <= d * d){
        printf("Yes");
    }else{
        printf("No");
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n+1);
    for ( int i = 2; i <= n; ++i ) {
        int tmp_a;
        cin >> tmp_a;
        a[tmp_a].push_back(i);
    }
    for ( int i = 1; i <= n; ++i ) {
        cout << a[i].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 13956
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] nl = br.readLine().split(" ");
        int n = Integer.parseInt(nl[0]);
        int l = Integer.parseInt(nl[1]);
        String[] s = new String[n];
        
        for (int i = 0; i < n; i++) {
            s[i] = br.readLine();
        }
        Arrays.sort(s);
        String ans = String.join("", s);
        System.out.println(ans);
    }
}


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


int main(){
    string S;
    cin >> S;
    size_t len = S.size();

    string zero_first = "";
    string one_first = "";

    for(int i = 0; i < len; i++){
        if(i%2 == 0){
            zero_first += "0";
            one_first += "1";
        }else{
            zero_first += "1";
            one_first += "0";
        }
    }

    // 大きくなるほど離れている
    int zero_first_similarity = 0;
    int one_first_similarity = 0;

    for (int i = 0; i < len; i++){
        if (S[i] == zero_first[i]){
            one_first_similarity++;
        }else{
            zero_first_similarity++;
        }
    }

    int counter = 0;
    if (zero_first_similarity < one_first_similarity){
        for (int i = 0; i < len; i++){
            if (S[i] != zero_first[i]) {
                counter++;
            }
        }
    }else{
        for (int i = 0; i < len; i++){
            if (S[i] != one_first[i]) {
                counter++;
            }
        }
    }


    cout << counter << endl;


    return 0;
}

Measured memory_bytes: 832
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <math.h>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef  pair<long long, long long> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define mod 1000000000
#define INF 1000000007
#define PB push_back
#define eps 1e-8
#define X first
#define Y second

LL n, k;
PLL arr[100010];

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(9);

	scanf("%lld", &n);
	scanf("%lld", &k);
	For(i, 0, n)
	{
		scanf("%lld", &arr[i].X);
		scanf("%lld", &arr[i].Y);
	}

	int powK = 0;
	LL kk = k;
	while (kk != 0)
	{
		powK++;
		kk = kk >> 1;
	}

	LL ans = 0;
	For(i, 0, powK + 1)
	{
		LL currK;
		if (i == powK)
			currK = k;
		else
		{
			if (((k >> (powK - 1 - i)) & 1) != 1)
				continue;
			currK = k ^ (1 << (powK - 1 - i));
			currK = currK | ((1 << (powK - 1 - i)) - 1);
		}
		LL currAns = 0;
		For(j, 0, n)
		{
			if ((arr[j].X | currK) <= currK)
				currAns += arr[j].Y;
		}
		ans = max(ans, currAns);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[210000];
int main(){
	scanf("%s",in);
	long long ret=0;
	int ad=0;
	for(int i=0;in[i];i++){
		if(in[i]=='B')ad++;
		else ret+=ad;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 384
c = []
d = []
n,m = map(int, input().split())
for i in range(m):
    a,b = map(int,input().split())
    c.append(a)
    d.append(b)
minl = max(c)   
maxr = min(d)
if minl>maxr:
    print(0)
else:
    print(maxr-minl+1)

Measured memory_bytes: 10980
import java.util.Arrays;
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 Anext = A - 1;
		int Bnext = B - 1;

		int arr[] = new int[]{A, B, Anext, Bnext};
		Arrays.sort(arr);

		System.out.println(arr[3] + arr[2]);
	}
}


Measured memory_bytes: 23124
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 22
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

int dp[maxn][maxn][maxn][maxn], visited[maxn][maxn];
int n, m;

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
vector<string> v;

bool valid(int x, int y){
    if(x>=0 && x<n && y>=0 && y<m && (v[x][y] == '.') && (!visited[x][y]) ) return true;
    //cout << x << " "<< y << " " << v[x][y] << " " << visited[x][y] << endl;
    return false;
}

void bfs(int x, int y){
    memset(visited, 0, sizeof visited);

    queue<pair<int, int> > Q;
    visited[x][y] = 1;
    dp[x][y][x][y] = 0;
    Q.push({x, y});
    while(!Q.empty()){
        auto p = Q.front();
        Q.pop();
        for(int i=0;i<4;i++){
            int px = p.ff + dx[i];
            int py = p.ss + dy[i];
            if(!valid(px, py)) continue;
            //cout << "HI" << endl;
            visited[px][py] = 1;
            Q.push({px, py});
            dp[x][y][px][py] = dp[x][y][p.ff][p.ss] + 1;
        }
    }

}


int main() {
    cin >> n >> m;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        //cout << s << endl;
        v.pb(s);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            bfs(i, j);
        }
    }
    memset(visited, 0, sizeof visited);
    int res = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int x=0;x<n;x++){
                for(int y=0;y<m;y++){
                    if(!valid(i, j) || !valid(x, y)) continue;
                    res = max(res, dp[i][j][x][y]);
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    int a,b;
    int sum;
    int i;
    while (scanf("%d",&n)!=EOF)
    {
        sum=0;
        for (i=0;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            sum+=1+b-a;
        }
        printf("%d\n",sum);
    }
    return 0;
}

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

using namespace std;

int main(){
  int a, b;
  char s[109][109];
  cin >> a >> b;
  a--;b--;
  for(int i=0;i<50;i++){
    for(int j=0;j<100;j++){
      s[i][j]='.';
    }
  }
  for(int i=50;i<100;i++){
    for(int j=0;j<100;j++){
      s[i][j]='#';
    }
  }
  for(int i=0;i<50;i+=2){
    if(b==0)break;
    for(int j=0;j<100;j+=2){
      if(b==0)break;
      s[i][j]='#';
      b--;
    }
  }
  for(int i=51;i<100;i+=2){
    if(a==0)break;
    for(int j=0;j<100;j+=2){
      if(a==0)break;
      s[i][j]='.';
      a--;
    }
  }
  cout << 100 << ' ' << 100 << endl;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      cout << s[i][j];
    }
    cout << endl;
  }
}



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

int main() {
	int n,k;
	cin>>n>>k;
	int x[n],y[n];
	char c[n];
	int count[2*k+2*k+1][2*k+2*k+1];
	int ans=0;
	for(int i=0;i<3*k;i++){
		for(int j=0;j<3*k;j++){
			count[i][j]=0;
		}
	}
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i]>>c[i];
		if(c[i]=='W'){
			y[i]=y[i]+k;
		}
		x[i]=x[i]%(2*k)+k;
		y[i]=y[i]%(2*k)+k;
		count[x[i]-k+1][y[i]-k+1]++;
		count[x[i]+1][y[i]-k+1]--;
		count[x[i]-k+1][y[i]+1]--;
		count[x[i]+1][y[i]+1]++;
	}
//	for(int i=0;i<k*3;i++){
//		for(int j=0;j<k*3;j++){
//			cout<<count[i][j]<<' ';
//		}
//		cout<<endl;
//	}
	for(int i=0;i<3*k;i++){
		for(int j=1;j<3*k;j++){
			count[i][j]+=count[i][j-1];
		}
	}
	for(int i=1;i<3*k;i++){
		for(int j=0;j<3*k;j++){
			count[i][j]+=count[i-1][j];
		}
	}

	for(int i=k;i<2*k;i++){
		for(int j=k;j<2*k;j++){
			count[i][j]=count[i][j]+count[i-k][j+k]+count[i+k][j-k]+count[i+k][j+k]+count[i-k][j-k];
			if(ans<count[i][j]){
				ans=count[i][j];
			}
			if(ans<(n-count[i][j])){
				ans=n-count[i][j];
			}
		}
	}




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

Measured memory_bytes: 49024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n;
    cin>>n;
    if(n==3){
	cout<<"2 5 63"<<endl;
	return 0;
    }
    int x=2;
    for(int i=0;i<n/2;i++){
	if(x%12==2){
	    if(x>2)cout<<" ";
	    cout<<x<<" "<<x+2;
	    x+=1;
	}
	else if(x%12==3){
	    cout<<" "<<x<<" "<<x+6;
	    x+=5;
	}
	else if(x%12==6){
	    cout<<" "<<x<<" "<<x+6;
	    x+=8;
	}
	else if(x%12==8){
	    cout<<" "<<x<<" "<<x+2;
	    x-=2;
	}
    }
    if(n%2==1)cout<<" 30000";
    cout<<endl;
    return 0;
}


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

using namespace std;

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string s = string(tx - sx, 'R') + string(ty - sy, 'U') + string(tx - sx, 'L') + string(ty - sy, 'D')
            + 'D' + string(tx - sx + 1, 'R') + string(ty - sy + 1, 'U') + 'L'
            + 'U' + string(tx- sx + 1, 'L') + string(ty - sy + 1, 'D') + 'R';

  cout << s << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int ans = N;
	ll total = 0;
	int tn = 0;
	for (int i = 0; i < N - 1; i++) {
		total += A[i];
		tn++;
		if (total * 2 < A[i + 1]) {
			ans -= tn;
			tn = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int main() {
	int h, w;
	while (1) {
		scanf("%d %d", &h, &w);
		if (!h && !w) break;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				putchar(!((i + j) % 2) ? '#' : '.');
			}
			puts("");
		}
		puts("");
	}
}

Measured memory_bytes: 1020
#include<stdio.h>

int main(){
	int res;
	int N;
	res=scanf("%d",&N);
	int A[N+1];
	int subordinate[N+1];
	for(int i=0;i<N+1;i++){
		A[i]=0;
		subordinate[i]=0;
	}
	for(int i=2;i<=N;i++){
		res=scanf("%d",&A[i]);
	}
	for(int i=2;i<=N;i++){
		subordinate[A[i]]+=1;
	}
	for(int i=1;i<=N;i++){
		printf("%d\n",subordinate[i]);
	}
	return 0;
}


Measured memory_bytes: 3292
while True:
    a,b = [int(i) for i in input().split()]

    if a == 0 and b == 0:
        break

    if a < b:
        a,b = b,a

    c = 0
    while b > 0:
        a, b = b, a % b
        c += 1

    print(a, c)


Measured memory_bytes: 5612
#include<iostream>
 
using namespace std;
 
int GCD(int M, int N) {
     
    while(N != 0) { 
        int r = M % N; 
        M = N; 
        N = r; 
    } 
    return M;
}
 
int main() { 
    int m, n; 
 
    while(cin >> m >> n) {
 
    cout << GCD(m, n) << "\n"; 

}
     
    return 0; 
} 


Measured memory_bytes: 3040
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   int n ;
   cin >> n ;
   vector < int > a(n);
   ll ans = 0 ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] , ans+=a[i]-1;
   cout << ans ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


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

const int maxn = 2e5 + 10;
long long a[maxn], b[maxn];

int main()
{
    int n, m, ans = 0;
    long long k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) a[i] += a[i - 1];
    for (int i = 1; i <= m; i++) b[i] += b[i - 1];
    int j = m;
    for (int i = 0; i <= n; i++) {
        if (k < a[i]) break;
        while (b[j] > k - a[i]) j--;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

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

#define infile "../test/sample-3.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}

// Combination Table {{{
#define MAX_N 50
int C[MAX_N+1][MAX_N+1]; // C[n][k] -> nCk
void comb_table(int N){
  for(int i=1;i<=N;++i){
    for(int j=0;j<=N;++j){
      if(j==0 or j==i){
        C[i][j]=1LL;
      }else{
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  }
}  // }}}

int solve(){
  int n,a,b;cin>>n>>a>>b;
  int v[n]; rep(i, n){ cin>>v[i]; }
  sort(v, v+n, greater<int>());
  comb_table(50);

  dump_1d(v, n);

  double s = 0;
  rep(i, a){ s += v[i]; }
  double av = s/a;

  printf("%.7f\n", av);

  if (v[a-1]!=v[0]) {
    int cnt = 0;
    int incnt = 0;
    rep(i, n){
      if (v[i]==v[a-1]){
        cnt++;
        if (i <= a-1) incnt++;
      }
    }
    printf("%lld\n", C[cnt][incnt]);
  }
  else{
    int num=n;  // v[0]と同じ数の個数
    rep(i, n){
      if (v[i]!=v[0]) {
        num = i;
        break;
      }
    }
    dump(num);

    int ans = 0;
    rep(k, a, min(b, num)+1){
      ans += C[num][k];
    }
    printf("%lld\n", ans);
  }
  return 0;

}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int k[n], a[n][m];
	int i, j;
	for (i = 0; i < n; i++) {
		scanf("%d", &k[i]);
		for (j = 0; j < k[i]; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	int s[n][m+1];
	for (i = 0; i < n; i++) {
		for (j = 0; j < m+1; j++) {
			s[i][j] = 0;
		}
	}
	
	int ans=0;
	int count = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < k[i]; j++) {
			s[i][a[i][j]] = 1;
		}
	}
	for (i = 0; i < m+1; i++) {
		for (j = 0; j < n; j++) {
			if (s[j][i] == 1) {
				count++;
			}
		}
		if (count == n) {
			ans++;
		}
		count = 0;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
ppp = list(map(int, input().split()))
acc = 0
for i in range(K):
    acc +=  (ppp[i] + 1) / 2
ans = acc
for i in range(K, N):
    acc -= (ppp[i - K] + 1) / 2
    acc += (ppp[i] + 1 ) / 2
    ans = max(ans, acc)
print(ans)


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

double x,y,cc,mn,mx;
int t,m,n,z,i,j,k,q,ind,cnt;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int r,d;
    string s;
    cin>>s;
    n=s.length();
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]) cnt++;
    }
    cout<<cnt;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

const int MOD = 1e+9+7;

// MOD を取りながら nCm を計算する方法
// フェルマーの小定理を使って逆元を使う
template <typename T>
T pow_mod(T n, T p, T m)  // (n^p) % m
{
    if(p == 0) return 1;
    if(p%2 == 1) return pow_mod<T>(n, p-1, m) * n % m;
    else{
        T tmp = pow_mod<T>(n, p/2, m) % m;
        return tmp * tmp % m;
    }
}

// nCk を O(n) で求めるクラス
template <typename T>
class Combination 
{
    private:
        int _mod;
        std::vector<T> factorial, factorial_inv;

    public:
        Combination(int n, int mod): _mod(mod), factorial(n+1, 1), factorial_inv(n+1)
        {
            for(int i = 1; i <= n; ++i) factorial[i] = (i*factorial[i-1]) % _mod;
            factorial_inv[n] = pow_mod<T>(factorial[n], _mod-2, _mod);  // 逆元を取る操作は重いので一回のみ行う
            for(int i = n; i >= 1; --i) factorial_inv[i-1] = (i*factorial_inv[i]) % _mod;
        } 

        T operator()(int n, int k)
        {
            if(n < 0 or k > n) return 0;
            return factorial[n] * factorial_inv[k] %_mod * factorial_inv[n-k] %_mod;
        }
};

int main()
{
    int K;
    cin >> K;
    string S;
    cin >> S;
    int N = S.size();

    long long ans = 0;
    Combination<long long> comb(N+K, MOD);
    FOR(i, N, N+K+1){
        ans += comb(i-1, N-1) * pow_mod<long long>(25, i-N, MOD) % MOD * pow_mod<long long>(26, N+K-i, MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,k,i,p;
	double ans,tmp;
	cin >> n >> k;
	for(i=1; i<=n; ++i){
		tmp = 1.0;
		p = i;
		while(p<k){
			p *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	ans /= n;
	printf("%.15lf\n",ans);
	return 0;
}


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

int main(int argc, char** argv)
{
	int n, m, res = 0;
	scanf("%d%d", &n, &m);
	printf("%d\n", (n * (n - 1) >> 1) + (m * (m - 1) >> 1));
	return 0;
}

Measured memory_bytes: 128
n = int(input())
b = list(map(int, input().split()))

a = [0] * n

a[0] = b[0]
a[n - 1] = b[n - 2]

for i in range(1, n - 1) :
    a[i] = min(b[i], b[i - 1])


print(sum(a))

Measured memory_bytes: 3064
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n;
	string s;
	cin >> n >> s;
	int x = 0;
	int ans = 0;
	for( auto &c : s)
	{
		if(c == 'I') x++;
		if(c == 'D') x--;
		ans = max(ans,x);
	}
	cout << ans ;
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3576
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=a
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)

Measured memory_bytes: 3060
#include<iostream>
#include<set>
#include<math.h>
#include<limits.h>
#include<vector>
using namespace std;

int main()
{
	register int i, test;

	unsigned long long n;

	cin >> n;

	int tmp;

	vector<int> v;

	while (n > 0)
	{
		tmp = n % 26;
		if (tmp == 0) tmp = 26;

		v.push_back(tmp);

		n -= tmp;
		n /= 26;

	}


	for (i = v.size() - 1; i >= 0; i--)
		cout << (char)(96 + v[i]);


	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <bitset>
using namespace std;

long long int n, k;
long long int a[100001];
long long int res = 0;

int main()
{

    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    long long int tmp = k;

    for (int i = 1; i <= 50; i++)
    {
        long long int x, m;

        //mb~iビット目までkと共通
        m = (1ll << (i - 1)) - 1;

        m = ~m;
        x = k & m;
        //cout << x << endl;
        //i-1 ~ 1ビット目までを決定する
        for (int j = 1; j <= i - 1; j++)
        {
            int bit, ct = 0;

            //a[l]についてjビット目を調べる
            //0の出現回数をカウント
            for (int l = 0; l < n; l++)
            {
                bit = (a[l] >> (j - 1)) & 1;
                if (bit == 0)
                {
                    ct++;
                }

                //cout << a[l] << " " << j << "bit=" << bit << endl;
            }

            //0の方が多い
            if (ct > n - ct)
            {
                //jビット目を1にする
                x += (1ll << (j - 1));
            }
        }

        if (x > k)
            continue;

        long long int tmp = 0;
        for (int j = 0; j < n; j++)
        {
            tmp += (a[j] ^ x);
        }

        res = max(res, tmp);
    }

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


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ran(i, s, g) for (i = s; i <= g; i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main(void)
{
    int N, W;
    vector<int> w(110);
    vector<int> v(110);
    static ll dp[110][100010] = {0};
    int i, j, k;
    ll n;

    cin >> N >> W;

    ran(i, 1, N)
    {
        cin >> w[i] >> v[i];
    }

    ran(i, 1, N)
    {
        ran(j, 1, W)
        {
            if (j - w[i] < 0)
            {
                n = -1;
            }
            else
            {
                n = dp[i - 1][j - w[i]] + v[i];
            }

            if (dp[i - 1][j] > n)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = n;
            }
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String s;
    int K,N;

    private void solve() {
        s = next();
        N = s.length();
        K = nextInt();

        TreeSet<String> set = new TreeSet<>();
        for(int i = 0;i < N;i++) {
            for(int j = i + 1;j <= i + 5 && j <= N;j++) {
                set.add(s.substring(i,j));
            }
        }

        String ans = "";
        for(int i = 0;i < K;i++) {
            ans = set.pollFirst();
        }

        out.println(ans);

    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

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

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

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

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

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

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

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


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a[100003];
    int x;

    Scd2(n,x);
    ll tmp = 0;
    ll ans = 0;
    Rep(i,n){
        Scd(a[i]);
        tmp += a[i];
        if( i > 1 ){
            tmp -= a[i-2];
        }
        if( tmp > x ) {
            ans += tmp - x;
            a[i] -= tmp - x;
            tmp = x;
        }
    }


    printf ("%llu\n", ans);

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  while(true) {
      int n, a, b, c, x;
      cin >> n >> a >> b >> c >> x;
      if(!n) break;
      int y[105];
      REP(i, n) cin >> y[i];

      int ans = -1, idx = 0;
      if(x == y[idx]) {
        idx++;
        if(idx == n) {
          cout << 0 << endl;
          continue;
        }
      }

      FOR(i, 1, 10001) {
          int temp = (a*x+b) % c;
          if(temp == y[idx]) {
            idx++;
            if(idx == n) {
              ans = i;
              break;
            }
          }
          x = temp;
          //cout << "temp:" << temp << endl;
      }
      cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3020