akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

class data {
	public:
		int a, b;
		int c;

		data(int p1, int p2, int cost) {
			a = p1;
			b = p2;
			c = cost;
		}

		bool operator<(const data & c_) const {
			return c < c_.c;
		}
};

int n, m;
vector<data> cost;
vector<data> modefied_cost;
vector<vector<int> > used_point;

void init() {
	cost.clear();
	modefied_cost.clear();
	used_point.clear();
}

bool input() {
	cin >> n;
	if(!n)
		return false;

	cin >> m;
	for(int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d,%d,%d", &a, &b, &c);
		cost.push_back(data(a, b, c));
	}

	return true;
}

void modefy_cost() {
	for(int i = 0; i < cost.size(); i++) {
		modefied_cost.push_back(data(cost[i].a, cost[i].b, cost[i].c / 100 - 1));
	}
}

pair<pair<int,int>,pair<int,int> > find_point(const data & d) {
	pair<pair<int, int>, pair<int, int> > ij_pair(pair<int,int>(-1, -1), pair<int,int>(-2, -2));
	for(int i = 0; i < used_point.size(); i++) {
		for(int j = 0; j < used_point[i].size(); j++) {
			if(used_point[i][j] == d.a) {
				ij_pair.first.first = i;
				ij_pair.first.second = j;
			}
			else if(used_point[i][j] == d.b) {
				ij_pair.second.first = i;
				ij_pair.second.second = j;
			}
		}
	}

	return ij_pair;
}

int solve() {
	modefy_cost();
	sort(modefied_cost.begin(), modefied_cost.end());
	int ans = 0;

	for(int i = 0; i < modefied_cost.size(); i++) {
		pair<pair<int,int>,pair<int,int> > tmp;
		tmp = find_point(modefied_cost[i]);

		if(tmp.first.first == tmp.second.first) {
			continue;
		}

		else if(tmp.first.first > -1 && tmp.second.first < 0) {
			used_point[tmp.first.first].push_back(modefied_cost[i].b);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first < 0 && tmp.second.first > -1) {
			used_point[tmp.second.first].push_back(modefied_cost[i].a);
			ans += modefied_cost[i].c;
		}
		else if(tmp.first.first > -1 && tmp.second.first > -1) {
			used_point[tmp.first.first].insert(used_point[tmp.first.first].end(),
					used_point[tmp.second.first].begin(), used_point[tmp.second.first].end());
			used_point.erase(used_point.begin() + tmp.second.first, used_point.begin() + tmp.second.first + 1);
			ans += modefied_cost[i].c;
		}
		else {
			used_point.push_back(vector<int>(2));
			used_point[used_point.size() - 1][0] = modefied_cost[i].a;
			used_point[used_point.size() - 1][1] = modefied_cost[i].b;
			ans += modefied_cost[i].c;
		}
	}
	return ans;
}

int main() {
	while(init(), input()) {
		cout << solve() << endl;
	}
}

Measured memory_bytes: 1404
#include <iostream>

using namespace std;

int main(){
  int A[5]={0,6000,4000,3000,2000};
  for(int i=0;i<4;++i){
    int t,n,sum;
    cin>>t>>n;
    sum=A[t]*n;
  cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void) {
	int n,x,A,B,q=0,w=0,e=0;cin>>n>>A>>B;
	while(n--){cin>>x;
		if(x<=A){q++;}
		else if(x<=B){w++;}
		else {e++;}
	}
	cout<<min(q,min(w,e))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S; cin >> S;
	cout << S[0] << S.size() - 2 << S[S.size() - 1] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	ll n, T;
	cin >> n >> T;
	vector<ll> t(n);
	rep(i, n) cin >> t[i];

	ll ans = 0;
	
	for (ll i = 0; i < n-1; i++)
	{
		ans += min(T, t[i + 1] - t[i]);
	}
	ans += T;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
  using namespace std;
  #define ll long long
  int main()
  {
 
       ll n,f,i,j;
          while(cin>>n)
          {
              f=0;
 
          vector<bool>v(n+1);
 
          for(i=0;i<=n;i++)
                  v[i]=1;
 
          v[0]=0;
          v[1]=0;
 
          for(i=2;i<=n;i++)
          {
                  if(v[i])
                  {
                          for(j=2*i;j<=n;j+=i)
                                  v[j]=0;
                  }
          }
 
 
 
          v.erase(v.begin());
          vector<bool>a(n);
          copy(v.rbegin(),v.rend(),a.begin());
 
          for(i=0;i<=n;i++)
          {
              if(a[i]&&v[i])
                 f++;
          }
          cout<<f<<endl;
 
          }
 
          return 0;
  }

Measured memory_bytes: 3060
s = input()
ans = 0
if s[0] == "<":
    s = ">" + s
    ans -= 1
if s[-1] == ">":
    s = s + "<"
    ans -= 1

s = s.split("><")
for t in s:
    t = "<"+t+">"
    t = t.split("<>")
    #print(t)
    M = int(max(len(t[0]),len(t[1])))
    m = int(min(len(t[0]),len(t[1])))
    ans += (m*(m+1) + (M+2)*(M+1))/2
print(int(ans))


Measured memory_bytes: 8732
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
a = sorted(LI(), reverse=True)
ans = []
s = 0
if all([i < 0 for i in a]):
    tmp = a[0]
    for i in range(1, n):
        ans.append((tmp, a[i]))
        tmp -= a[i]
    print(tmp)
    for i in ans:
        print(i[0], i[1])
else:
    tmp = a[-1]
    for i in range(1, n - 1):
        if a[i] < 0:
            break
        ans.append((tmp, a[i]))
        tmp -= a[i]

    ans.append((max(a), tmp))
    tmp = max(a) - tmp

    for i in range(1, n - 1):
        if a[i] >= 0:
            continue
        ans.append((tmp, a[i]))
        tmp -= a[i]
    print(tmp)
    for i in ans:
        print(i[0], i[1])


Measured memory_bytes: 91036
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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



int main() {

	int n;

	cin >> n;
	if (n % 10 == 9 || n / 10 == 9)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long w,h,x,y,a,b;
	while(~scanf("%lld%lld%lld%lld",&w,&h,&x,&y))
	printf("%lf %d\n",double(w)*double(h)/2,x+x==w&&y+y==h);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;
int m[4][4] = {};

bool flag[4] = {};

// 連結かどうか
bool dfs(int j)
{
  flag[j] = true;
  REP(i, 4)
  {
    if (!flag[i] && m[i][j] == 1)
    {
      dfs(i);
    }
  }
}

int main()
{
  REP(i, 3)
  {
    int a, b;
    cin >> a >> b;
    m[a - 1][b - 1] = 1;
    m[b - 1][a - 1] = 1;
  }

  dfs(0);
  bool connected = flag[0] && flag[1] && flag[2] && flag[3];

  int edge[4] = {};
  // 各頂点から出る辺が(2,2,1,1)になっているかどうか
  REP(i, 4)
  {
    REP(j, 4)
    {
      edge[i] += m[i][j];
    }
  }
  sort(edge, edge + 4);
  bool ok = connected && edge[0] == 1 && edge[1] == 1 && edge[2] == 2 && edge[3] == 2;

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

Measured memory_bytes: 256
from math import log
def main():
    N = int(input())
    A = list(map(int,input().split()))
    mod = 10**9+7
    
    digits_cnt1 = [0]*60
    for ai in A:
        if ai == 0:
            continue
        #2**60-1みたいな時にfloatの桁落ちが生じるが、元々の桁数を超えるとai>>dがfalseになるのでlist index out of rangeは生じない
        for d in range(int(log(ai)/log(2))+1):
            if ai>>d & 1:
                digits_cnt1[d] += 1
    
    ans = 0
    for i in range(60):
        ans += digits_cnt1[i]*(N-digits_cnt1[i])*pow(2,i,mod)
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 125624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)2e3+5;


pair<int,int> a[maxn];
typedef long long ll;
ll dp[maxn][maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n){
        int x;cin>>x;
        a[i]={x,i};
    }
    sort(a+1,a+1+n,greater<pair<int,int>>());
    rep(s,1,n)rep(x,0,s){
        
        ll y=s-x;
        ll ai=a[s].first,i=a[s].second;//debug(ai);
        ll c=0;
        if(x>0){
            c=dp[x-1][y]+(n+1-x-i)*ai;
            dp[x][y]=max(c,dp[x][y]);
        }
        if(y>0){
            c=dp[x][y-1]+(i-y)*ai;
            dp[x][y]=max(c,dp[x][y]);
        }
    }
    ll ans=0;
    rep(i,0,n)ans=max(ans,dp[i][n-i]);
    cout<<ans<<endl;
}
/* 
ana:
xjb贪心：从大到小移到两边 wr:没有正确性，因为考虑两边的那个数换到中间后，轮到它时选较大的一边不是最优的（要选和初始移动方向相同的那一边）

考虑终态。记Ai 最终移动到p[i]，ans=sum(Ai|i-p[i]|)

注意到方向，即|i-p[i]|=max(i-p[i],p[i]-i)，将其分为两组。

考虑 i-p[i]， 贪心地按照Ai降序 给pi 赋值1，2，3.因为调换不会更优

实现：dp[x][y]: 考虑前x+y 个，y个选i - pi
1 3 4 2
4 2 1 3
 */

Measured memory_bytes: 26276
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
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 EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1
 
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 10000000000;
#define NMAX 50
#define MAX 10
		
		ll A,B,C,N,M,ans=0,sum=0;
		ll T[100010],P[100010],X[100010];
		
		char S;
		
	
int main(){
	cin>>N;
	REP(i,N){
		cin>>T[i];
		sum+=T[i];
		}
	cin>>M;
	REP(i,M){
		cin>>P[i]>>X[i];
	}
	ans=INF;
	ll temp;
	REP(i,M){
		temp=sum;
		temp-=T[P[i]-1];
		temp+=X[i];
			cout<<temp<<endl;
		
	}
	
 
}

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

int main(void)
{
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  if(abs(x-a)<abs(x-b))
    printf("A\n");
  else
    printf("B\n");
  return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {

	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}


template<typename T>
bool same(T x_b, T x_e, T y_b, T y_e) {
	for (auto i = x_b, j = y_b; i != x_e && j != y_e; ++i, ++j) {
		if (*i != *j) {
			return false;
		}
	}
	return true;
}


int main(void) {
	int s, w;
	cin >> s >> w;
	if (s <= w) {
		cout << "unsafe";
	}
	else {
		cout << "safe";
	}
}

/*

*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
 	LL(n,q);
	STR(s);
	for(int i = 0; i < n-1; ++i){
		if(s[i]=='A'&&s[i+1]=='C')s[i]='a';
	}
	vector<ll> rui(n+2,0);
for(int i = 0; i < n; ++i){
		rui[i+1]+=rui[i];
		if(s[i]=='a')rui[i+1]++;
	}
 
	for(int i = 0; i < q; ++i){
		ll l,r;
		cin>>l>>r;
		cout<<rui[r-1]-rui[l-1]<<endl;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> cnt(13,0),now(24,0),ser;
  cnt[0]=1;
  rep(i,n){
    int d;
    cin>>d;
    cnt[d]++;
  }
  rep(i,13){
    if(i==0 || i==12){
      if(cnt[i]>=2){
        cout<<0<<endl;
        return 0;
      }else if(cnt[i]==1) now[i]++;
    }else if(cnt[i]>=3){
      cout<<0<<endl;
      return 0;
    }else if(cnt[i]==2){
      now[i]++;
      now[24-i]++;
    }else if(cnt[i]==1) ser.push_back(i);
  }
  int m=len(ser);
  int ans=0;
  rep(i,1<<m){
    vector<int> cop(now);
    int ch=1e9;
    rep(j,m){
      if((1<<j) & i) cop[ser[j]]++;
      else cop[24-ser[j]]++;
    }
    vector<int> ind;
    rep(j,24){
      if(cop[j]) ind.push_back(j);
    }
    ind.push_back(24);
    FOR(j,1,len(ind)){
      ch=min(ch,ind[j]-ind[j-1]);
    }/*
    rep(j,24) cout<<cop[j];
    cout<<' '<<ch<<endl;*/
    //cout_vec(ind);
    ans=max(ans,ch);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <deque>
    #include <algorithm>
    #include <string>
    #include <string.h>
     
    using namespace std;
    
	char S[100001];

    int main()
    {
        cin >> S;
		scanf("%s", S);
		size_t L = strlen(S);
     
        char* p = S;
		char* E = S + L;
        while (p < E) {
            if (strncmp(p, "dreamera", 8) == 0) { // dream
                p += 5;
            } else if (strncmp(p, "dreamer", 7) == 0) {
                p += 7;
            } else if (strncmp(p, "eraser", 6) == 0) {
                p += 6;
            } else if (strncmp(p, "dream", 5) == 0 || strncmp(p, "erase", 5) == 0) {
                p += 5;
            } else {
                break;
            }
        }
     
        cout << (p == E ? "YES" : "NO") << endl;
     
        return 0;
    }

Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int k;
	int x;
	int max;
	int min;
	scanf("%d %d",&k,&x);
	min=x-k+1;
	if(min< -1000000)
		min=-1000000;
	max=x+k-1;
	if(max> 1000000)
		max=1000000;
	for(int i=min;i<=max;i++)
		printf("%d ",i);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, k;cin >> n >> k;
	vector<ll> v(n);REP(i, n)cin >> v[i];
	sort(ALL(v));

	ll ans = 0;
	REP(i, k)ans += v[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n,m,pi[500010],inv[500010],dist[500010];
char s[2000010],t[500010];
bool vis[500010];
vector<int> topo,adj[500010];
void dfs(int u) {
	if(vis[u]) return;
	vis[u]=true;
	for(auto& it:adj[u])dfs(it);
	topo.push_back(u);
	inv[u]=sz(topo)-1;
}
int main() {
	scanf("%s%s",s,t);
	n=strlen(s);
	m=strlen(t);
	int i,j,k;
	int N=n;
	for(i=1;i<=(n+m)/n;i++) {
		for(j=0;j<n;j++) {
			s[N]=s[N-n];
			N++;
		}
	}
	i=0,j=-1;
	pi[0]=-1;
	while(i<m) {
		if(j==-1||t[i]==t[j]) pi[++i]=++j;
		else j=pi[j];
	}
	i=0,j=0;
	while(i<N) {
		if(j==-1||s[i]==t[j]) i++,j++;
		else j=pi[j];
		if(j==m) {
			if((i-m)%n==i%n) {
				puts("-1");
				return 0;
			}
			adj[(i-m)%n].push_back(i%n);
			j=pi[j];
		}
	}
	for(i=0;i<n;i++) dfs(i);
	for(i=0;i<sz(topo);i++) {
		for(auto& it:adj[topo[i]]) {
			if(i<inv[it]) {
				puts("-1");
				return 0;
			}
			dist[topo[i]]=max(dist[topo[i]],dist[it]+1);
		}
	}
	int res=0;
	for(i=0;i<n;i++) {
		res=max(res,dist[i]);
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 61300
n = int(input())

x = list(map(int, input().split()))
x_sorted = sorted(x)
med_low = x_sorted[(n // 2) - 1]
med_upper = x_sorted[(n // 2)]

for i in range(n):
    if x[i] <= med_low:
        print(med_upper)
    else:
        print(med_low)


Measured memory_bytes: 30860
import sys
input = sys.stdin.readline

n,k=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort(reverse=True)
divisors=[]
aa=sum(A)
for i in range(1,int(aa**0.5)+1):
  if aa%i==0:
    divisors.append(i)
    if i!=n//i:
      divisors.append(aa//i)
divisors.sort(reverse=True)

def f(d):
  count=0
  res1,res2=[],[]
  q=aa//d
  for i in range(n):
    if A[i]%d<(A[i]//d+1)*d-A[i]:
      count+=A[i]//d
      res2.append(A[i]%d)
    else:
      count+=A[i]//d+1
      res1.append((A[i]//d+1)*d-A[i])
  if count==q:
    return sum(res1)
  elif count<q:
    r2=len(res2)
    res2.sort(reverse=True)
    if r2==0:
      return sum(res1)+d*(q-count)
    else:
      if r2>q-count:
        return sum(res1)+d*(q-count)-sum(res2[:q-count])
      else:
        return sum(res1)+d*(q-count)-sum(res2)
  else:
    r1=len(res1)
    res1.sort(reverse=True)
    if r1==0:
      return sum(res2)+d*(count-q)
    else:
      if r1>q-count:
        return sum(res2)+d*(count-q)-sum(res1[:count-q])
      else:
        return sum(res2)+d*(count-q)-sum(res1)

ans=1
for d in divisors:
  if f(d)<=k:
    ans=d
    break
print(ans)



Measured memory_bytes: 3188
while True:
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a + b)
    if op == '*':
        print(a * b)
    if op == '-':
        print(a - b)
    if op == '/':
        print(a // b)

Measured memory_bytes: 7632
#include "bits/stdc++.h"

using namespace std;

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

    int n,q;
    while(cin>>n>>q,n||q){
        vector<int> v(101,0);
        for(int i=0;i<n;i++){
            int m;cin>>m;
            for(int j=0;j<m;j++){
                int d;cin>>d;
                v[d]++;
            }
        }
        int date,ma=0;
        for(int i=1;i<=100;i++){
            if(v[i]>ma){
                ma=v[i];
                date=i;
            }
        }
        if(ma<q) cout<<0<<endl;
        else cout<<date<<endl;
    }
}

Measured memory_bytes: 3136
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize,
        x: usize,
        t: usize,
    }
    let ans = (n / x + if n % x != 0 { 1 } else { 0 }) * t;
    println!("{}", ans);
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String s ;
		int ac=0;
		int wa=0;
		int tle=0;
		int re =0;

		for(int i=0; i<n; i++) {

			s = scan.next();

			if(s.equals("AC")) {
				ac++;
			}else if(s.equals("WA")) {
				wa++;
			}else if(s.equals("TLE")) {
				tle++;
			}else {
				re++;
			}

		}
		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);



		}

	}



Measured memory_bytes: 57668
#include <iostream>
#include <string>
using namespace std;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

void permutation(string s, int N, string target, int &count, bool &found) {
	if (found) return;
	if (s.length() == N) {		
		if (s == target) {
			found = true;
			return;
		}
		count++;
	}
	else {
		for (int i = 1; i <= N; i++) {
			if (s.find(to_string(i)) != string::npos) continue;
			permutation(s + to_string(i), N, target, count, found);
		}
	}
}

int main()
{
	int N;
	cin >> N;
	string s, P, Q;
	rep(i, N) {
		cin >> s;
		P += s;
	}
	rep(i, N) {
		cin >> s;
		Q += s;
	}

	int a = 1, b = 1;
	bool flag = false;
	permutation("", N, P, a, flag);
	flag = false;
	permutation("", N, Q, b, flag);
	cout << abs(a - b) << endl;

	return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		PriorQueue que = new PriorQueue();
		String op = null;
		int x = 0;
		while(true) {
			op = sc.next();
			if(op.equals("insert")) {
				x = sc.nextInt();
				que.insert(x);
			}else if(op.equals("extract")) {
				System.out.println(que.pop());
			}else {
				break;
			}
		}
	}

	
}
class PriorQueue{
	
	int value[] = new int[30000000];
	int h = 0;
	
	public void insert(int x) {
		h++;
		value[h] = x;
		int index = h;
		
		while(index>1 && value[index]>value[index/2]) {
			value[index] ^= value[index/2];
			value[index/2] ^= value[index];
			value[index] ^= value[index/2];
			index /= 2;
		}
		return;
	}
	
	public int pop() {
		int result = value[1];
		value[1] = value[h];
		h--;
		
		int index = 1;
		while(index<=h) {
			int l = index * 2;
			int r = index * 2 + 1;
			int maxi = index;
			if(l<=h && value[l]>value[maxi]) {
				maxi = l;
			}
			if(r<=h && value[r]>value[maxi]) {
				maxi = r;
			}
			if(maxi != index) {
				value[maxi] ^= value[index];
				value[index] ^= value[maxi];
				value[maxi] ^= value[index];
				index = maxi;
			}else {
				break;
			}
		}
		
		return result;
	}
	
	public int top() {
		return value[1];
	}
	
	public boolean isEmpty() {
		return h==0;
	}
	
}



Measured memory_bytes: 565032
import sys

def dp(n, size):
  list = [[sys.maxint for i in range(n)] for j in range(n)]
  for i in range(n):
    list[i][i] = 0
  for l in range(2, n+1):
    for i in range(0, n-l+1):
      for it in range(1, l):
        list[i][i+l-1] = min(list[i][i+l-1], list[i][i+it-1] + list[i+it][i+l-1] + size[i]*size[i+it]*size[i+l])
  print list[0][n-1]

n = int(raw_input())
size = [0 for i in range(n+1)]
for i in range(n):
  line = raw_input().split()
  size[i] = int(line[0])
  size[i+1] = int(line[1])
dp(n, size)

Measured memory_bytes: 6580
#include <iostream>
#include <string>
#include <vector>
using namespace std;
string make(string s, string a, string b)
{
	string x;
	for (int i = 0; i < s.size(); i++)
	{

		bool flag = true;

			for (int j = 0; j < a.size(); j++)
			{
				if (i + j >= s.size() || s[i + j] != a[j])
				{
					flag = false;
					break;
				}
			}
		
		if (flag)
		{
			i += a.size() - 1;
			x += b;
		}
		else
		{
			x += s[i];
		}
	}
	return x;
}

int dfs(string s, string ans, int t, int n, vector<string> a, vector<string> b)
{
	if (s.size() > ans.size() || t > 10)
		return 11;
	string w;
	int l = 11;
	for (int i = 0; i < n; i++)
	{
		w = make(s, a[i], b[i]);
		if (w == ans)
		{
			return t + 1;
		}
		if (s != w)
		{
			l = min(l, dfs(w, ans, t + 1, n, a, b));
		}
	}

	return l;
}

int main(void)
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0)
			break;
		vector<string> a(n), b(n);
		for (int i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i];
		}
		string s, ans;
		cin >> s >> ans;
		int k = dfs(s, ans, 0, n, a, b);
		if (k == 11)
		{
			cout << -1 << endl;
		}
		else
		{
			cout << k << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */
bool visited[100000];
int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        --x; --y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    int ans = 0;
    for(int i = 0;i < N;++i) {
        if(visited[i] == true)continue;
        else ++ans;
        queue<int> Q;
        Q.push(i);
        while(!Q.empty()){
            int q = Q.front();Q.pop();
            for(int v : G[q]) {
                if(visited[v])continue;
                visited[v] = true;
                Q.push(v);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6648
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(){
    int cnt = 0;
    string P,W;

    cin >> W;
    for (int i = 0; i < W.size(); i++)
    {
        W[i] = tolower(W[i]);
    }
    
    while (1)
    {
        cin >> P ;
        if(P == "END_OF_TEXT")break;
        for (int i = 0; i < P.size(); i++)
        {
            P[i] = tolower(P[i]);
        }
        
        if (W == P)cnt++;
    }
    cout << cnt << endl;
return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;
 
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;
 
 
const int mod=1000000007;
//const int mod=998244353;

 
 

 
int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r,p;
    char cc;
    cin >> cc;
    if(cc-'a'>=0&&'z'-cc>=0){
        cout << 'a' << el;
    }
    else
        cout << 'A' << el;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
using namespace std;

int INF=1e9;
int N,A,B,C;
int l[8];
int dfs(int cur,int a,int b,int c){
    if(cur==N){
        return abs(a-A)+abs(b-B)+abs(c-C)+INF*(a==0||b==0||c==0)-30;
    }
    else{
    int ret0=dfs(cur+1,a,b,c);
    int ret1=dfs(cur+1,a+l[cur],b,c)+10;
    int ret2=dfs(cur+1,a,b+l[cur],c)+10;
    int ret3=dfs(cur+1,a,b,c+l[cur])+10;
    return min(ret0,min(ret1,min(ret2,ret3)));
    }
}

int main(){  
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    cout<<dfs(0,0,0,0)<<endl;
    
}

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

int main(){
  string p,s;
  cin>>p>>s;
  p=p+p;
  bool flag=false;
  for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
    
    // pのi文字目から連続したs.size() 文字を抜き出す
    string t=p.substr(i, s.size() );
    
    if( t == s ){
      flag=true;
      break;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3220
import java.util.Scanner;

/**
 * https://abc046.contest.atcoder.jp/tasks/arc062_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Fraction[] fractions = new Fraction[N];
		for(int i=0; i<N; i++){
			fractions[i] = new Fraction(sc.nextLong(), sc.nextLong());
		}
		sc.close();
		
		long t = fractions[0].t;
		long a = fractions[0].a;
		for(int i=1; i<N; i++){
			Fraction f = fractions[i];		
			long num = (long) Math.max(t/f.t+( t%f.t==0 ? 0 : 1), a/f.a+( a%f.a==0 ? 0 : 1));
			t = num*f.t;
			a = num*f.a;
		}
		System.out.println(t+a);

	}
	
	static class Fraction{
		long t;
		long a;		
		Fraction(long t, long a){
			this.t = t;
			this.a = a;
		}
	}

}

Measured memory_bytes: 25212
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                             \
  cerr << __LINE__ << ": " << #x << " = {";          \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) { \
    cerr << ((hoge) ? "," : "") << x[hoge];          \
  }                                                  \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<998244353>;
  int N, S;
  cin >> N >> S;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  Mint ans = 0;
  Mint dp[S + 1];
  for (int i = 0; i < N; i++) {
    dp[0] += 1;
    for (int j = S; j >= A[i]; j--) dp[j] += dp[j - A[i]];
    ans += dp[S];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3688
N = int(input())
mod = 10**9+7
def power_naive(n, base=8):
  ret = 1
  for _ in range(n):
    ret = (ret*base)%mod

  return ret

ret = 0

if N >= 2:
  ret = power_naive(N, base=10)
  subt = (2*power_naive(N, base=9))%mod
  ret = (ret-subt)%mod
  ret = (ret+power_naive(N, base=8))%mod

print(ret)

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

using namespace std;

int main(){
    int n;char ch[10] = {'0','1','2','3','4','5','6','7','8','9'};
    int64_t count = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < 10;i++){
        for(int j = 0;j < 10;j++){
            for(int k = 0;k < 10;k++){
                int a = s.find(ch[i]);
                int b = s.find(ch[j],a+1);
                int c = s.find(ch[k],b+1);
                if(a < b && b < c && a != -1 && b != -1 && c != -1){
                    count++;
                }
            }
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val a = Scanner.nextInt()
  val b = Scanner.nextInt()

  val answer = Seq(a+a-1,a+b,b+b-1).max

  println(answer)
}

Measured memory_bytes: 27068
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;

using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int M1,D1,M2,D2;
    
    cin >> M1>>D1>>M2>>D2;
    
    cout << (D2 == 1 ? 1 : 0) << endl;
    
    return 0;
}






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

int main() {
  int s;
  cin >> s;
  
  int count = 0;
  
  if (s == 1 || s == 2) {
    cout << 4 << endl;
  }
  else {
    while (s != 4) {
      count++;
      if (s % 2 == 0) {
        s /= 2;
      }
      else {
        s = 3 * s + 1;
      }
    }
    cout << count + 4 << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
int N;
void sub( int min, int* array ){
	for(int i = 0; i < N; i++){
		array[ i ] -= min;
	}
}
int main( void ){
	if(!scanf( "%d", &N ))
		return -1;
	int* array = ( int* )malloc( sizeof( int ) * N );
	int min = 100;
	for(int i = 0; i < N; i++){
		if(!scanf( "%d", array + i ))
			return -1;
		if (array[ i ] < min)
			min = array[ i ];
	}
	sub( min, array );
	// return 0;
	int count = min;
	bool can = true;
	while(can){
		min = 100;
		can = false;
		int not_zero_count = 0;
		bool is_pre_zero = true;
		for(int i = 0; i < N; i++){
			if(array[ i ] <= 0){
				is_pre_zero = true;
				continue;
			}
			can = true;
			if (is_pre_zero && array[ i ] > 0){
				not_zero_count++;
			}
			is_pre_zero = false;
			if (array[i] < min){
				min = array[i];
			}
		}
		sub( min, array );
		count += min * not_zero_count;
	}
	printf("%d\n", count);
}


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

int main() {
    int n,m;
    while(cin>>n>>m, n|m) {
        int t[n],h[m],tsum=0,hsum=0;
        for(int i=0; i<n; ++i) { cin>>t[i]; tsum+=t[i]; }
        for(int i=0; i<m; ++i) { cin>>h[i]; hsum+=h[i]; }

        int hh = -1, tt = -1, tp = 1<<29;
        for(int i=0; i<n; ++i) {
            for(int j=0; j<m; ++j) {
                if(tsum-t[i]+h[j] == hsum-h[j]+t[i]) {
                    if(t[i]+h[j] < tp) {
                        tt = t[i];
                        hh = h[j];
                        tp = t[i]+h[j];
                    }
                }
            }
        }

        if(hh == -1) cout<<-1<<endl;
        else cout<<tt<<" "<<hh<<endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    queue<int> a;
    rep(i, n){
        int x;
        cin >> x;
        rep(j, x){
            a.push(i+1);
        }
    }
    rep(i, h/2){
        rep(j, w){
            cout << a.front() << " ";
            a.pop();
        }
        cout << endl;
        stack<int> tmp;
        rep(j, w){
            tmp.push(a.front());
            a.pop();
        }
        rep(j, w){
            cout << tmp.top() << " ";
            tmp.pop();
        }
        cout << endl;
    }
    if(!a.empty()){
        rep(i, w){
            cout << a.front() << " ";
            a.pop();
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3608
from collections import deque
import math
N = int(input())
x = [0] * N
y = [0] * N
al = 1
l = 0
for i in range(N):
    al *= (i+1)
    x[i], y[i] = map(int, input().split())

que = deque()
for i in range(N):
    que.append([i])
while que:
    seq = que.popleft()
    if len(seq) == N:
        for i in range(N-1):
            l += math.sqrt((x[seq[i+1]]-x[seq[i]]) ** 2 + (y[seq[i+1]]-y[seq[i]]) ** 2)
    else:
        for i in range(N):
            if i in seq:
                continue
            seq_next = seq + [i]
            que.append(seq_next)

print(l / al)

Measured memory_bytes: 14724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[100005];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[a[i]]++;
		}
		
		int pair=0;
		long sum=0;
		for(int i=0;i<b.length;i++){
			if(b[i]>=3) {
				b[i] = (b[i]%2==0)? 2:1; 
			}
			if(b[i]==1)sum++;
			if(b[i]==2){sum+=2;pair++;}
		}
		sum-= (pair%2==0)?pair:pair+1;
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 56632
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, k;
	cin >> n >> k;
	vector<int> hs(n);
	for(auto &h : hs) cin >> h;
	FSRT(hs);
	int answer = 1e9 + 1;
	for(int i = 0; i < n - k + 1; ++i) answer = min(answer, hs[i + k - 1] - hs[i]);
	cout << answer << '\n';
}

Measured memory_bytes: 3708