akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;


int main(){

	int N,table[3] = {0,0,0},tmp;
	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		table[tmp%3]++;
	}

	if(table[1] == 0 && table[2] == 0){
		printf("1\n");
	}else if(table[1] != 0 && table[2] == 0){
		printf("%d\n",1+table[0]+min(2,table[1]-1));
	}else if(table[1] == 0 && table[2] != 0){
		printf("%d\n",1+table[0]+min(2,table[2]-1));
	}else{
		if(table[1] == table[2]){
			printf("%d\n",table[0]+2*table[1]);
		}else if(table[1] > table[2]){
			if(table[1] - table[2] == 1){
				printf("%d\n",1+table[0]+2*table[2]);
			}else{
				printf("%d\n",table[0]+2*(table[2])+min(3,table[1]-table[2]));
			}
		}else{ //table[1] < table[2]
			if(table[2] - table[1] == 1){
				printf("%d\n",1+table[0]+2*table[1]);
			}else{
				printf("%d\n",table[0]+2*(table[1])+min(3,table[2]-table[1]));
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define pii pair<int64_t,int64_t>
#define mp make_pair
#define whole(v) begin(v),end(v)
#define print(c,n) for(int64_t i=0;i<n;i++) cout << c[i] << " ";
#define MOD 1000000007
void solve(){
	string a,b;
	cin >> a >> b;
	int f1[26],f2[26];
	memset(f1,0,sizeof(f1));
	memset(f2,0,sizeof(f2));
	for(auto i : a){
		f1[i-'a']++;
	}
	for(auto i : b){
		f2[i-'a']++;
	}
	sort(f1,f1+26),sort(f2,f2+26);
	// if(f1==f2) cout << "Yes" ;
	// else cout << "No";
	bool b1=true;
	for(int i=0;i<26;i++){
		if(f1[i]!=f2[i]){
			b1=false;
			break;
		}
	}
	if(b1) cout << "Yes" ;
	else cout << "No";
}

int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(0);
	solve();
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>S;
    T = "ABC";
    ll ans = 0;
    rep(i,N - 2){
        bool ok = true;
        rep(j,3) if(S[i+j] != T[j]) ok = false;
        ans += ok;
    }
    cout<<ans<<endl;
}

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

ll inf=1e10;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> dp(n,inf);
  for(ll i=0;i<n;i++) {
    cin >> a[i];
  }
  for(ll i=0;i<n;i++) {
    *lower_bound(dp.begin(),dp.end(),a[i])=a[i];
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    if(dp[i]!=inf) {
      ans=i+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4416
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // long long64_t, long long*_t
#include <cstdio> // prlong longf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
using namespace std;
int main(){
  int n;
  long long sum=0;
  string s;
  cin >> n >> s;
  if(n>3){
    long long r=0,g=0,b=0;
    for(int i=n-1; i>=0; i--){
      if(s[i]=='R'){
        r++;
      }
      else if(s[i]=='G'){
        g++;
      }
      else{
        b++;
      }
    }
    if(r==0 || g==0 || b==0) sum=0;
    else{
     sum=r*g*b;
      for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
          if(s[i]!=s[j]){
            if(s[i]=='R'||s[j]=='R'){
              if(s[i]=='G'||s[j]=='G'){
                //B
                if(s[j+j-i]=='B') sum--;
              }
              else if(s[i]=='B'||s[j]=='B'){
                //G
                if(s[j+j-i]=='G') sum--;
              }
            }
            else{
              //R
              if(s[j+j-i]=='R') sum--;
            }
          }
        }
      }
    }
  }
  
  cout << sum << endl;
}


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

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

int N,M;
vector<vector<int> > G;
vector<int> deg;
int dp[110000];



int main(){
    cin >> N >> M;
    G.assign(N,vector<int>());
    deg.assign(N,0);
    for(int i=0;i<M;++i){
        int v,e;
        cin >> v >> e;
        v--;e--;
        G[v].push_back(e);
        deg[e]++;
    }

    queue<int> que;
    for(int i=0;i<N;++i) if(deg[i]==0) que.push(i);

    while(!que.empty()){
        int v = que.front();que.pop();
        for(auto nv : G[v]){
            deg[nv]--; 
            if(deg[nv]==0){
                que.push(nv);
                chmax(dp[nv],dp[v]+1);
            }
        }
    }

    int ans = 0;
    for(int i=0;i<N;++i) chmax(ans,dp[i]);

    cout << ans << endl;

    return 0;


}



Measured memory_bytes: 6528
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    double[] ps;
    foreach (p; readln.split.to!(int[])) ps ~= (1 + p).to!double / 2.0 ;
    double p = 0;
    foreach (i; 0..K) p += ps[i];
    auto max_p = p;
    foreach (i; K..N) {
        p = p - ps[i-K] + ps[i];
        max_p = max(max_p, p);
    }
    writefln("%.10f", max_p);
}

Measured memory_bytes: 11432
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  char a,b;
  cin>>a>>b;
  if(a=='H'){
    if(b=='H'){
      cout<<"H"<<endl;
    }
    else{
      cout<<"D"<<endl;
    }
  }
  else{
    if(b=='H'){
      cout<<"D"<<endl;
    }
    else{
      cout<<"H"<<endl;
    }
  }
}

Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())

if x >=a*a*b/2:
  Answer = math.degrees(math.atan(2*(a*a*b-x)/(a**3)))

else:
  Answer = 90-math.degrees(math.atan(2*x/(a*b*b)))

print(Answer)

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



int main(){
  int N, a, b, c; cin >> N;

  a = N / 100;
  b = (N % 100) / 10;
  c = (N % 10);
  
  cout << (10-a) * 100 + (10-b) * 10 + (10-c) << endl;

}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    q, h, s, d = map(int, input().split())
    n = int(input())
    t = min(q * 4, h * 2, s)

    if n == 1:
        print(int(t))
    else:
        if n % 2 == 0:
            print(int(min(t * n, d * n // 2)))
        else:
            print(int(min(t * n, d * ((n - 1) // 2) + t)))


if __name__ == '__main__':
    resolve()


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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i < 10) ans = "Yes";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int d=sc.nextInt();
    if(d==25) System.out.println("Christmas");
    if(d==24) System.out.println("Christmas Eve");
    if(d==23) System.out.println("Christmas Eve Eve");
    if(d==22) System.out.println("Christmas Eve Eve Eve");
  }
}


Measured memory_bytes: 20692
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define MOD 1000000007
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int n, cnt, b[555 * 555], x = 1;
P a[555];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i + 1;
		b[a[i].first] = i + 1;
	}
	sort(a, a + n);
	rep(i, n) {
		rep(j, a[i].second - 1) {
			if (!b[x])b[x] = a[i].second;
			else x++,j--;
		}
	}
	x = n * n;
	for (int i = n - 1; i >= 0; i--) {
		rep(j, n - a[i].second) {
			if (!b[x])b[x] = a[i].second;
			else {
				x--;
				j--;
			}
		}
	}
	rep(i, n) {
		int cnt = 0;
		for (int j = 1; j <= n * n; j++) {
			if (b[j] == a[i].second)cnt++;
			if (a[i].first == j) {
				if (a[i].second != cnt) {
					puts("No");
					END;
				}
			}
		}
	}
	puts("Yes");
	for (int i = 1; i <= n * n; i++) {
		if (i != 1)cout << " ";
		cout << b[i];
	}
	cout << endl;
	END;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int h, w, n;
    cin >> h >> w >> n;
    int m = max(h, w);
    cout << (n + m - 1) / m << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll a, b, c, ans = 0;
    cin >> a >> b >> c;
    rep(i, a, b + 1){
        if(!(c % i)) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
	//dp[i] is max happiness such that i was activity done on last day.
	//this is dp and not greedy as for any day we cannot acertain i is the best activity without knowing avout i+1
	int n; cin>>n;
	vector<int> dp(3);
	for(int dy=0;dy<n;dy++){
		vector<int> c(3),new_dp(3);
		for(auto &i:c)
			cin>>i;
		// trying all combinations and let it figure itself out
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j)
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
			}
		}
		//now update dp to new day;
		dp=new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N,M = imn()

graph = [[False for _ in range(N)] for _ in range(N)]
for i in range(M):
    A,B = map(lambda x:int(x)-1, input().split())
    graph[A][B] = True
    graph[B][A] = True

def dfs(v, visited):

    all_visited=True

    for i in range(N):
        if not visited[i]: all_visited=False
    if all_visited: return 1

    ret = 0

    for i in range(N):
        if not graph[v][i]: continue
        if visited[i]: continue

        visited[i] = True

        ret += dfs(i, copy.deepcopy(visited))
        visited[i] = False

    return ret

visited = [False for _ in range(N)]
visited[0] = True

print(dfs(0, visited))



Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define inf 100000000
#define _GLIBCXX_DEBUG
typedef vector<int> VI;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<int,int> PII;
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; }
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    cout<<max({a,b,c})-min({a,b,c})<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    vector<int> trans(26, -1);
    //変換表を作る
    for (int i = 0; i < n; i++) {
        if (trans[s[i] - 'a'] < 0) {
            trans[s[i] - 'a'] = t[i] - 'a';
        } else {
            if (trans[s[i] - 'a'] != t[i] - 'a') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    //単射か確認
    for (int i = 0; i < 26; i++) {
        for (int j = i + 1; j < 26; j++) {
            if (trans[i] == trans[j] && trans[i] != -1) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl
const double eps = 1e-6;

void solve(){
	int l,r,d; cin>>l>>r>>d;
	int cnt = 0;
	rep(i,l,r){
		if(i % d == 0) cnt++;
	}
	cout << cnt;
}

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_NK 100000

using namespace std;

int N, K;
string S;

vector<int> sct;

int solve() {
    if(S[0] == '0') sct.push_back(0);
    char prev = S[0];
    int sct_len = 0;
    S.push_back('2');
    for(int i = 0; i < S.size(); ++i) {
        if(S[i] == prev)
            ++sct_len;
        else {
            sct.push_back(sct_len);
            sct_len = 1;
        }
        prev = S[i];
    }
    if(S[S.size() - 2] == '0') sct.push_back(0);

    int start = 0;
    int end = min(K * 2, (int)sct.size() - 1);

    int sum = 0;
    for(int i = start; i <= end; ++i)
        sum += sct[i];
    int res = sum;

    while(end + 2 <= sct.size()) {
        sum -= sct[start];
        sum -= sct[start + 1];
        sum += sct[end + 1];
        sum += sct[end + 2];
        res = max(res, sum);
        end += 2;
        start += 2;
    }

    return res;
}

int main(int argc, char **argv) {
    cin >> N >> K;
    cin >> S;

    printf("%d\n", solve());
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define B 100000
using namespace std;

int main() {
    int n;
    cin >> n;
    unordered_map<int, vector<int> > es;
    unordered_set<int> rem;
    for (int j = 0; j < n; j++) {
        int x, y;
        cin >> x >> y;
        x--;
        y += B - 1;
        es[x].push_back(y);
        es[y].push_back(x);
        rem.insert(x);
        rem.insert(y);
    }
    long ans = -n;
    for (auto p: es) {
        if (rem.empty())
            break;
        if (rem.find(p.first) == rem.end())
            continue;
        long x_count = 0, y_count = 0;
        stack<int> dfs;
        dfs.push(p.first);
        while (!dfs.empty()) {
            int t = dfs.top();
            dfs.pop();
            if (rem.find(t) == rem.end())
                continue;
            rem.erase(t);
            if (t < B) {
                x_count++;
            } else {
                y_count++;
            }
            for (int v: es[t]) {
                dfs.push(v);
            }
        }
        ans += x_count * y_count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13256
// AtCoder ABC123: B - Five Dishes
// 2019.9.9 bal4u

#include <stdio.h>

int a[5];

int main()
{
	int i, x, k, mi, ans;
	
	mi = 10; for (i = 0; i < 5; i++) {
		scanf("%d", a+i);
		x = a[i] % 10;
		if (x != 0 && x < mi) mi = x, k = i;
	}
	ans = 0; for (i = 0; i < 5; i++) if (i != k) {
		ans += ((a[i]-1)/10+1)*10;
	}
	ans += a[k];
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    int n;
    cin >> n;

    int sum = 0, tmp = n;
    while(tmp > 0) {
        sum += tmp % 10;
        tmp /= 10;
    }

    cout << ((n % sum) ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
https://abc088.contest.atcoder.jp/tasks/abc088_d

"""
import sys
from sys import stdin
from collections import deque
input = stdin.readline


def bfs(grid, H, W):
    # 上下左右に移動する場合の座標の変化量
    dy = [-1, 1, 0, 0]
    dx = [0, 0, -1, 1]

    gx, gy = W-1, H-1

    # 地図のサイズ(移動によってはみ出さないかのチェックに使用)
    d = [[float('inf')] * W for _ in range(H)] #  スタート地点からの距離をINFで初期化
    # 迷路を歩いて、スタート地点からゴール地点までの距離を求める
    Q = deque()
    Q.append((0, 0))
    d[0][0] = 0               #  スタート地点のコストは0
    while Q:
        cx, cy = Q.popleft()        #  現在地の座標
        if cx == gx and cy == gy:
            return d[gy][gx]
        for i in range(4):
            nx = cx + dx[i]
            ny = cy + dy[i]
            # 移動先が 地図からはみ出しておらず and 壁になっておらず and 既に探索済でない 場合
            if (0 <= nx < W) and (0 <= ny < H) and grid[ny][nx] != '#' and d[ny][nx] == float('inf'):
                Q.append((nx, ny))
                d[ny][nx] = d[cy][cx] + 1
    return -1



def solve(grid, H, W):
    step = bfs(grid, H, W)
    if step < 0:
        return -1

    orig_black = 0
    for row in grid:
        orig_black += row.count('#')
    return H*W - orig_black - step -1


def main(args):
    grid = []
    H, W = map(int, input().split())
    for _ in range(H):
        grid.append(list(input().strip()))
    ans = solve(grid, H, W)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    

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

int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < E.size(); i++) {
    cout << O[i] << E[i];
  }
  if (O.size() - E.size() == 1) cout << O.back() << endl;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
l=list(map(int,input().split()))
S=min(M,N)
ans=0
for i in range(S+1):
   for j in range(S-i+1):
      mem=l[0:i]+l[N-j:]
      for k in range(min((M-i-j),len(mem))):
         if min(mem)<0:
            mem.remove(min(mem))
      ans=max(ans,sum(mem))
print(ans)

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

int main(){
	int n;
	cin >>n;
	int a[55];
	 
	for(int i=0;i<n;i++){
		cin >>a[i];
	}
	sort(a,a+n);
	double sum1=a[0];
	for(int i=1;i<n;i++){
		sum1=(sum1+a[i])/2;
	}
	cout<<sum1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	char a=s[s.size()-1];
	if(a=='3')
		cout<<"bon";
	else if(a=='0'||a=='1'||a=='6'||a=='8')
		cout<<"pon";
	else
		cout<<"hon";
	return 0;
 } 

Measured memory_bytes: 3628
#include<cstdio>
#define MAX_H 100
#define MAX_W 100
int H, W;
char fields[MAX_W + 1][MAX_H] = { };
int dx[4] = { -1, 1, 0, 0 }, dy[4] = {0, 0, -1, 1};

void
dfs (int x, int y)
{
  char ch = fields[x][y];
  fields[x][y] = '.';
  for (int i = 0; i < 4; i++)
    {
      int nx = x + dx[i], ny = y + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H && ch == fields[nx][ny])
		dfs (nx, ny);
    }
}
int
main (void)
{
  while (EOF != scanf ("%d %d\n", &H, &W))
    {
      if (H == 0 && W == 0)
	return 0;
      for (int y = 0; y < H; y++)
	for (int x = 0; x <= W; x++)
	    scanf ("%c", &fields[x][y]);
      int count = 0;
      for (int y = 0; y < H; y++)
	for (int x = 0; x < W; x++)
	  {
	    if ('.' != fields[x][y])
	      {
		dfs (x, y);
		count++;
	      }
	  }
      printf ("%d\n", count);
    }
  return 0;
}

Measured memory_bytes: 0
fun main(args:Array<String>):Unit {
    while(true){
        val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && k == 0) return
        val stock = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
        repeat(n){
            val b = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
            for (i in 0 until k){
                stock[i] -= b[i]
            }
        }
        println(if (stock.any{it < 0}) "No" else "Yes")
    }
}


Measured memory_bytes: 68828
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll long long
#define pi pair<ll,ll>
ll a[300008], b[400000], c[3][300];
string s, s1;
map<ll, ll>mp;

int main()
{
    IO;
    ll i, j, k=0, l, n, m, t, h, cnt=0, curr, mx=0;
    cin>>n>>m>>k;
    for(i=1; i<=n; i++) cin>>a[i];
    for(i=1; i<=m; i++){
        cin>>b[i]; b[i]+=b[i-1];
    }
    b[m+1]=INT_MAX; mx = (upper_bound(b+1,b+m+2, k)-b)-1;
    for(i=1; i<=n; i++){
         k-=a[i];
         j = (upper_bound(b+1,b+m+2, k)-b)-1;
         if(k>=0) mx=max(mx,j+i);
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 6744
#include <iostream>

int main(){
    int n, a, b, apt, bpt;
    while(std::cin >> n, n){
        for(apt = bpt = 0; n; n--){
            std::cin >> a >> b;
            if(a > b)
                apt += a + b;
            else if(b > a)
                bpt += a + b;
            else{
                apt += a;
                bpt += b;
            }
        }
        std::cout << apt << ' ' << bpt << std::endl;
    }
    return 0;
}

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

int main()
{
    int h,w;
    cin >> h >> w;
    int a[h];
    int b[w];
    for(int i = 0; i < h; i++){
        a[i] = 0;
    }
    for(int i = 0; i < w; i++){
        b[i] = 0;
    }
    char c[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(c[i][j] == '#'){
                a[i] = 1;
                b[j] = 1;
            }
        }
    }
    for(int i = 0; i < h; i++){
        int t = 0;
        for(int j = 0; j < w; j++){
            if(a[i] == 1 && b[j] == 1){
                cout << c[i][j];
                t = 1;
            }
        }
        if(t == 1) cout << '\n';
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================



ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
ll mch(ll n) {
	if (n == 1) return 1;
	else return n * mch(n - 1);
}
//1から整数nまでの階乗を出す(INFで割っていない)
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll cnt = 0;


// ========================================================================


int main() {
	ll n, t; cin >> n >> t;
	vl a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vl b(n);
	b[0] = 10000000000;
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			b[i] = min(b[i - 1], a[i]);
		}
		else b[i] = a[i];
	}
	vl c(n);
	for (int i = 0; i < n; i++) {
		c[i] = a[i] - b[i];
	}
	sort(c.begin(), c.end());
	ll ans = 1;
	for (int i = n - 1; i >= 0; i--) {
		if (c[i] == c[i - 1]) {
			ans++;
		}
		else break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5656
#include <cstdio>

int main(void)
{
	int n;
	while (scanf("%d", &n)){
		if (n == 0) break;
		
		int res = 0;
		while (n != 1){
			if (n % 2 == 0) n /= 2;
			else n = n * 3 + 1;
			res++;
		}
		
		printf("%d\n", res);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (A * N == B ){
    cout << B << endl;
  }
  else if (A * N > B){
    cout << B << endl;
  }
  else {
    cout << A * N << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n, k; cin >> n >> k;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = INFL;
    rep(i, n-k+1){
        ll left = a[i];
        ll right = a[i+k-1];
        if(left >= 0 && right >= 0){
            chmin(ans, right);
        }else if(left < 0 && right < 0){
            chmin(ans, -left);
        }else{
            ll t = right - left;
            chmin(ans, min(t + right, t - left));
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3896
// Vicfred
// https://atcoder.jp/contests/abc165/tasks/abc165_b
// simulation
import std.conv;
import std.stdio;
import std.string;

void main() {
    long x = readln.chomp.to!long;

    long current = 100;
    long answer = 0;

    while(current < x) {
        current += current/100;
        answer += 1;
    }

    answer.writeln;

}



Measured memory_bytes: 2732
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int n,k,onn;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 1){
			onn = i;
		}
	}
	if(n == k){
		cout << 1 << endl;
	}
	else{
		if(( n-1 ) % ( k-1 ) >0){
			cout << ( n-1 ) / ( k-1 )+1 <<endl;
		}
		else{
			cout << ( n-1 ) / ( k-1 ) <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
    cin>>n>>m;
    long long int a[100000];
// Print the number of 2s that divide n  
    if (n % 2 == 0)  
    {  if(m%2==0)
    a[o++]=2;
        //cout << 2 << " ";
        while(n%2==0)
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        if (n % i == 0)  
        {  if(m%i==0)
            a[o++]=i;
            while(n%i==0)
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)
    if(m%n==0)
        a[o++]=n;  
        cout<<(o+1);

 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[5],i,j,temp;
    scanf("%d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4]);
    for(i=0;i<5;i++){
        for(j=0;j<5;j++){
            if(a[i]>a[j]){
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    for(i=0;i<5;i++){
        printf("%d",a[i]);
        if(i<4){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}



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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((a - b) % 2ll == 0)
    {
        cout << abs(a - b) / 2ll << endl;
    }
    else
    {
        if (a > b)
        {
            swap(a, b);
        }
        int ans = min(a - 1ll, n - b) + (b - a + 1) / 2ll;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    dic = {}
    dic["AC"] = 0
    dic["WA"] = 0
    dic["TLE"] = 0
    dic["RE"] = 0
    for _ in range(n):
        s = input()
        dic[s] += 1
    print("AC x", dic["AC"])
    print("WA x", dic["WA"])
    print("TLE x", dic["TLE"])
    print("RE x", dic["RE"])

if __name__ == "__main__":
    main()

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;



ll gcd(ll a,ll b){
   if(b == 0)return a;
   gcd(b,a%b);
}

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

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

   int N;
   cin>>N;
   vector<ll>T(N);
   for(int i=0;i<N;i++)cin>>T[i];
   ll ans = 1;
   for(int i=0;i<N;i++){
      ans = lcm(ans,T[i]);
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,cnt,ans;
string s;
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='W')
            cnt++;
    for(int i=n-cnt;i<n;i++)
        if(s[i]!='W')
            ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3668
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n, k;
	
	return OUT(n % k == 0 ? 0 : 1);
}


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

int main () {
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << (((c + b - 1) / b <= (a + d - 1) / d) ? "Yes" : "No");
	return 0;
}


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

void Value_Check(int *p,int key){
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == key){
                *(p + i * 3 + j) = 0;
                return;
            }
        }
    }
}

void Hit_Check(int *p,bool *flag){

    int sum;
    
    //横チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + i * 3 + j) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //縦チェック
    for(int i=0;i<3;i++){
        sum = 0;
        for(int j=0;j<3;j++){
            if(*(p + j * 3 + i) == 0){
                sum++;
            }
        }
        
        if(sum == 3){
            *flag = true;
            return;
        }
    }
    
    //斜めチェック
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + i) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
    
    sum = 0;
    for(int i=0;i<3;i++){
        if(*(p + i * 3 + (2-i)) == 0){
            sum++;
        }
    }
    
    if(sum == 3){
        *flag = true;
        return;
    }
}

int main(void){
    
    int data[3][3];
    int N;
    bool flag = false;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> data[i][j];
        }
    }
    
    cin >> N;
    
    for(int i=0;i<N;i++){
        int b_i;
        cin >> b_i;
        Value_Check(&data[0][0],b_i);
    }
    
    Hit_Check(&data[0][0],&flag);
    
    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3552
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        s: String,
    }
    println!("{}", s.replace("2017", "2018"));
}


Measured memory_bytes: 4352
S = input()

while True:
    if len(S) == 0:
        print('YES')
        exit()
    if len(S) < 5:
        print('NO')
        exit()
    if S[:5] == 'dream':
        if len(S) > 6 and S[5:7] == 'er':
            if len(S) > 7 and S[7] == 'a':
                S = S[5:]
            else :
                S = S[7:]
        else :
            S = S[5:]
    elif S[:5] == 'erase':
        if len(S) > 5 and S[5] == 'r':
            S = S[6:]
        else :
            S = S[5:]
    else :
        print('NO')
        exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int n;

int main(){
	ri(n);
	int ans = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			for(int k=1; k<=n; k++){
				ans += gcd(i, gcd(j, k));
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0||n==1) return dp[n]=1;
  if(dp[n]!=-1) return dp[n];
  return dp[n] = fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i] = -1;

  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



Measured memory_bytes: 2048
a,b,c = gets.chomp.split(' ').map(&:to_i)
ans = 0

while a%2==0 && b%2 == 0 && c%2 == 0
  if [a,b,c].all?(a)
    ans = -1
    break
  end
  ans += 1
  newA = b/2+c/2
  newB = a/2+c/2
  newC = a/2+b/2
  a = newA
  b = newB
  c = newC
end
puts ans

Measured memory_bytes: 14292
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long n, a[200010];
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i-1], a[i-1] -= i;
	sort(a, a+n);
	long long ans = 0;
	for(int i=0; i<n; i++) ans += abs(a[i] - a[n/2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
using namespace std;


//---- Matrix Vector Multiplication
int main(void){
    int n, m;
    cin >> n >> m;
    int A[n][m], b[m], x[n];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }
    for(int i=0; i<m; i++){
        cin >> b[i];
    }
    for(int i=0; i<n; i++){
        x[i]=0;
        for(int j=0; j<m; j++){
            x[i]+=A[i][j]*b[j];
        }
        cout << x[i] << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int min_cost=1000000000;
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      cost+=(i-A.at(j))*(i-A.at(j));
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
}

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

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

    vector<vector<char>> c(h, vector<char>(w));
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> c.at(i).at(j);

    for (int i = 0, n = 2 * h; i < n; i++) {
        for (int j = 0; j < w; j++)
            cout << c.at(i / 2).at(j);

        cout << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll ar[3002][3002],dp[3002][3002][4];

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

	ll r,c,k,i,u,v,t,mx,j;

	cin >> r >> c >> k;
	for(i=1;i<=k;++i)
	{
		cin >> u >> v >> t;
		ar[u][v] = t;
	}

	for(i=1;i<=r;++i)
	{
		for(j=1;j<=c;++j)
		{
			for(t=0;t<=3;++t)
				dp[i][j][t] = dp[i][j-1][t];

			mx = 0;
			for(t=0;t<=3;++t)
				mx = max(mx,dp[i-1][j][t]);

			dp[i][j][0] = max(dp[i][j][0],mx);
			dp[i][j][1] = max(dp[i][j][1],mx+ar[i][j]);

			for(t=1;t<=3;++t)
				dp[i][j][t] = max(dp[i][j][t],ar[i][j]+dp[i][j-1][t-1]);
		}
	}

	mx = 0;
	for(t=0;t<=3;++t)
		mx = max(mx,dp[r][c][t]);

	cout << mx << "\n";
}

	

Measured memory_bytes: 355288
#include<cstdio>
#include<cstring>
#include<vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#pragma warning(disable:4996)
using namespace std;

int d[10];

int main()
{
	for (int i = 0; i < 3; i++) {
		int u, v;
		cin >> u >> v;
		d[u]++;
		d[v]++;

	}
	bool flag = true;
	for (int i = 1; i <= 4; i++)
		if (d[i] > 2)flag = false;
	if (flag)cout << "YES";
	else cout << "NO";
	return 0;
}

Measured memory_bytes: 256