akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] S = Console.ReadLine().Split(' ');

            string answer = "";

            for(int i = 0; i < N; i++)
            {
                answer += S[0][i];
                answer += S[1][i];
            }

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 11092
def main():
    S = input()
    if S == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    elif len(S) != 26:
        for i in range(26):
            a = chr(ord('a') + i)
            if a not in S:
                print(S + a)
                return
    else:
        while len(S) > 1:
            S = S[:-1]
            last = S[-1]
            while ord(last) < ord('z'):
                last = chr(ord(last) + 1)
                if last not in S:
                    print(S[:-1] + last)
                    return
if __name__ == '__main__':
    main()

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
for(int i=0; i<4; i++){
cout<<s.at(i);}
cout<<" ";
for(int i=4; i<12; i++){
cout<<s.at(i);}
cout<<endl;}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    string a, b, c; cin >> a >> b >> c;
    char s1 = toupper(a.front());
    char s2 = toupper(b.front());
    char s3 = toupper(c.front());
    cout << s1 << s2 << s3 << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

vector<pair<int, int>> g[maxn];
int dist[maxn], parent[maxn], n, m, src;


void dijkstra(int src) {
    memset(dist, 63, sizeof dist);
    int inf = dist[0];
    dist[src] = 0;
    set<pair<int, int>> q;

//    dist , node
    q.insert({0, src});
    while (!q.empty()) {
        int len = q.begin()->first;
        int node = q.begin()->second;

        q.erase({len, node});
        for (auto x: g[node]) {
            if (dist[x.first] > dist[node] + x.second) {
                q.erase({dist[x.first], x.first});
                parent[x.first] = node;
                dist[x.first] = x.second + dist[node];
                q.insert({dist[x.first], x.first});
            }
        }
    }
    for (int i = 0; i < n; i++)
        if (dist[i] == inf)
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
}

vector<pair<pair<int, int>, int>> ed;

void bellman(int src) {
    memset(dist, 63, sizeof dist);
    int inf = dist[0];

    dist[src] = 0;
    int xx;
    for (int i = 0; i < n; i++) {
        xx = -1;
        for (auto x: ed) {
            if (dist[x.first.first] < inf and dist[x.first.first] + x.second < dist[x.first.second]) {
                dist[x.first.second] = x.second + dist[x.first.first];
                xx = 2;
            }
        }
    }
    if (xx == -1) {
        for (int i = 0; i < n; i++)
            if (dist[i] == inf)
                cout << "INF" << endl;
            else
                cout << dist[i] << endl;
    } else
        cout << "NEGATIVE CYCLE" << endl;
}

void solve() {
    cin >> n >> m >> src;

    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;

        ed.push_back({{a, b}, c});
    }
//    dijkstra(src);
    bellman(src);
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 6376
import sys

N = int(sys.stdin.readline().strip())
C = []
S = []
F = []
for i in range(N - 1):
    c, s, f = [int(x) for x in sys.stdin.readline().strip().split()]
    C.append(c)
    S.append(s)
    F.append(f)

def calc(n, t, cache={}):
    if n == N - 1:
        return t
    if (n, t) in cache:
        return cache[(n, t)]
    if t >= S[n]:
        st = S[n] + (t - S[n] + F[n] - 1) // F[n] * F[n]
    else:
        st = S[n]
    r = calc(n + 1, st + C[n])
    cache[(n, t)] = r
    return r

for i in range(N):
    print(calc(i, 0))


Measured memory_bytes: 24428
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int x;
  cin >> x;
  cout << (1LL << (x + 2)) - 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int N, M;

    /**** 入力 ****/
    scanf("%d %d", &N, &M);
 
    int ai[N+1];
    for (int i=1; i<=N; i++) {
        scanf("%d", &ai[i]);
    }

    /**** 事前準備（累積和） ****/
    // 10^9 * 10^5が32bitを超えるので64bit確保
    long long sum[N+1];     // 全データの累積和
    long long plusSum[N+1]; // 正の数だけの累積和
    sum[0] = 0;
    plusSum[0] = 0;
    for (int i=1; i<=N; i++) {
        sum[i] = sum[i-1] + ai[i];
        if (ai[i] > 0) {
            plusSum[i] = plusSum[i-1] + ai[i];
        } else {
            plusSum[i] = plusSum[i-1];
        }
    }

    /**** 計算 ****/
    long long max = 0;
    for (int i=0; i<N-M+1; i++) {
        // 最後に塗るMマスがi番目のマスから始まる場合のスコアを計算
        int left = i;           // Mマスの左端
        int right = i + M - 1;  // Mマスの右端

        long long total = 0;        
        total += sum[right+1] - sum[left];   // 最後に黒く塗った領域のスコア
        if (total < 0) {
            total = 0;  // 黒く塗って負数になる場合は白く塗って0にする
        }
        total += plusSum[left];   // 左側の正の数の総和
        total += plusSum[N] - plusSum[right+1];  // 右側の正の数の総和

        if (max < total) {
            max = total;    // 過去最高なら保持
        }
    }

    /**** 出力 ****/
    printf("%lld\n", max);
  
	return 0;
}


Measured memory_bytes: 2176
fn main() {
    let s: String = read_line();
    let t: String = read_line();
 
	let mut ss = String::new();
	ss.push_str(&s[..]);
	ss.push_str(&s[..]);
 
    if let Some(_) = ss.find(&t[..]) {
        println!("Yes");
    } else {
        println!("No");
    }
}
 
fn read_line<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();

      Map<Integer, Integer> oddFreq = new HashMap<>();
      Map<Integer, Integer> evenFreq = new HashMap<>();

      for(int i = 0; i < n; i++) {
        if(i % 2 == 0)
          evenFreq.put(arr[i], evenFreq.getOrDefault(arr[i], 0) + 1);
        else
          oddFreq.put(arr[i], oddFreq.getOrDefault(arr[i], 0) + 1);
      }

      List<Map.Entry<Integer, Integer>> oddList = new ArrayList<>(oddFreq.entrySet());
      List<Map.Entry<Integer, Integer>> evenList = new ArrayList<>(evenFreq.entrySet());
      Collections.sort(oddList, (e1, e2) -> e2.getValue() - e1.getValue());
      Collections.sort(evenList, (e1, e2) -> e2.getValue() - e1.getValue());
      
      if(oddList.get(0).getKey() - evenList.get(0).getKey() != 0)
        System.out.println(n - oddList.get(0).getValue() - evenList.get(0).getValue());
      else {
          
        int oddCnt = oddList.size() <= 1 ? 0 : oddList.get(1).getValue();
        int evenCnt = evenList.size() <= 1 ? 0 : evenList.get(1).getValue();
        System.out.println(n - Math.max(oddList.get(0).getValue() + evenCnt, evenList.get(0).getValue() + oddCnt));
      }

  }
}

Measured memory_bytes: 58320
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  ll max = -1;
  int n; cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);
  string ans = "Yes";
  rep(i,n){
    if(h.at(i)>max){
      chmax(max,h.at(i)-1);
    }else if(h.at(i)<max){
      ans = "No";
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
	a[i]//=400
free=0
b=set()
for i in range(n):
	if a[i]>=8:
		free+=1
	else:
		b.add(a[i])
cnt=len(b)
x=max(cnt,1)
y=(cnt+free)
print(x,y)

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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

int N, M, siz[200005];
bool canHas[200005];


int main() {
    scanf ("%d %d", &N, &M);
    canHas[0] = true;
    FO (i,0,N) siz[i] = 1;
    FO (i,0,M) {
        int x, y;
        scanf ("%d %d", &x, &y);
        x--; y--;
        if (canHas[x]) canHas[y] = true;
        siz[x]--;
        siz[y]++;
        if (siz[x] == 0) canHas[x] = false;
    }
    int ans = 0;
    FO (i,0,N) ans += canHas[i];
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 768
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.next();
        int ans = 0;
        for (int i = 0; i < s.length(); i++){
            if (s.charAt(i) == '1'){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif




int main() {
	ll x,ans=1e18;
	cin>>x;
	for(ll i=1;i*i<=x;++i) {
		if (x%i==0) {
			ans=min(ans,i+x/i-2);
		}
	}
	cout<<ans<<endl;
}









Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>

using namespace std;

/*
ソート：sort(v.begin(),v.end(), 0)
合計：accumulate(v.begin(),v.end(), 0)
最小値：*min_element(v.begin(),v.end())
最大値：*max_element(v.begin(),v.end())
最大公約数：__gcd(a,b)
*/

int main(int argc, char const *argv[]){
    int r;
    cin >> r;
    cout << r*r*3 << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
city=[]
for i in range(N):
    x,y,p=map(int,input().split())
    city.append((x,y,p))
 
xx=[[abs(city[j][0]) for j in range(N)] for i in range(2**N)]
yy=[[abs(city[j][1]) for j in range(N)] for i in range(2**N)]
 
for i in range(2**N):
    X=[0]
    rest=[]
    for j in range(N):
        if i>>j&1==1:
            X.append(city[j][0])
            xx[i][j]=0
        else:
            rest.append(j)
    for j in rest:
        res=10**15
        for k in X:
            res=min(res,abs(city[j][0]-k))
        xx[i][j]=res
 
for i in range(2**N):
    Y=[0]
    rest=[]
    for j in range(N):
        if i>>j&1==1:
            Y.append(city[j][1])
            yy[i][j]=0
        else:
            rest.append(j)
    for j in rest:
        res=10**15
        for k in Y:
            res=min(res,abs(city[j][1]-k))
        yy[i][j]=res
 
ans=[10**15 for i in range(N+1)]
for i in range(2**N):
    cond=i
    rest=[j for j in range(N) if i>>j &1==0]
    count=N-len(rest)
    while True:
        X=cond
        Y=i-cond
        temp=0
        for j in rest:
            temp+=min(xx[X][j],yy[Y][j])*city[j][2]
        ans[count]=min(ans[count],temp)
        if cond==0:
            break
        else:
            cond=(cond-1)&i
 
for i in range(N+1):
    print(ans[i])

Measured memory_bytes: 88836
#include<stdio.h>

int judge(char n[4]);

int main() {
   char N[4];
   scanf("%s", N);
   if(judge(N) == 1) {
      printf("Yes\n");
   }else {
      printf("No\n");
   }
   return 0;
}

int judge(char n[4]) {
   int i;
   for(i = 0; i < 4; i++) {
      if(n[i] == '7') {
         return 1;
      }
   }
   return 0;
}


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

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

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

int main(void) {
  char ch;
  while(1) {
    scanf("%c", &ch);

    if(islower(ch)) cout << (char)toupper(ch);
    else if(isupper(ch)) cout << (char)tolower(ch);
    else cout << ch;

    if(ch == '\n') break;
  }
}



Measured memory_bytes: 3132
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    LL a, b, x;
    while (cin >> a >> b >> x) {
        if (a)
            cout << b / x - (a - 1) / x << endl;
        else
            cout << b/x +1 << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int m, k;
    scanf("%d %d", &m, &k);
    if (m == 0) {
        if (k == 0) {
            puts("0 0");
        } else {
            puts("-1");
        }
    } else if (m == 1) {
        if (k != 0) {
            puts("-1");
        } else {
            puts("0 0 1 1");
        }
    } else if (k >= 1 << m) {
        puts("-1");
    } else {
        deque<int> dq;
        dq.push_back(k);
        for (int i = 0; i<1<<m; ++i) {
            if (i == k) continue;
            dq.push_back(i);
            dq.push_front(i);
        }
        dq.push_back(k);
        for (int i = 0; i<1<<m+1; ++i) {
            printf("%d%c", dq[i], i+1 == 1 << m+1 ? '\n' : ' ');
        }
    }

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
int main(){
int N, X;
cin >> N >> X;
vector<int> m(N);
int sum = 0;
for(int i = 0; i < N; i++){
  cin >> m.at(i);
}
for(int i = 0; i < N; i++){
  sum += m.at(i);
}
sort(m.begin(),m.end());
int amari = X - sum;
int A = amari/m.at(0);
cout << N + A  << endl;
}

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

Measured memory_bytes: 1024
use std::collections::*;
use std::io;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.clear();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<i32>>();
    let n = a.len();
    let mut dp = vec![10i32.pow(9)+7;n];
    dp[0] = 0;
    for i in 0..n{
        if i >= 1{
            dp[i] = min(dp[i],dp[i-1]+(a[i]-a[i-1]).abs());
        }
        if i >=2{
            dp[i] = min(dp[i],dp[i-2]+(a[i]-a[i-2]).abs());
        }
    }
    println!("{}",dp[n-1]);
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int n, m;
	cin >> n >> m;

	vector<int> c;
	inputVector(c, m);

	vector<int> cnt(n + 1, INT_MAX);
	cnt[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int cj : c) {
			if (i < cj) continue;
			cnt[i] = min(cnt[i], cnt[i - cj] + 1);
		}
	}

	cout << cnt[n] << endl;

    return 0;
}

Measured memory_bytes: 3176
N,A,B=[int(i) for i in input().split(" ")]
S=input()
past=0
bOrder=1
for s in S:
    if s=='a':
        if past<A+B:
            print('Yes')
            past+=1
        else:
            print('No')
    elif s=='b':
        if past<A+B and bOrder<=B:
            print('Yes')
            past+=1
        else:
            print('No')
        bOrder+=1
    else:
        print('No')


Measured memory_bytes: 4016
#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
  char buf[1024],*p;
  
  fgets(buf, 1024, stdin);
  while(p=strstr(buf,"apple")){
    strncpy(p,"*****", 5);
  }
  while(p=strstr(buf,"peach")){
    strncpy(p,"apple",5);
  }
  while(p=strstr(buf,"*****")){
    strncpy(p,"peach",5);
  }
  *strrchr(buf,10)=0;
  puts(buf);
  return 0;
}


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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N;
    long long P;
    cin >> N >> P;
    auto fac = prime_factorize(P);
    long long res = 1;
    for (auto p : fac) {
        for (int j = 0; j < p.second/N; ++j) res *= p.first;
    }
    cout << res << endl;
}

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

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

		Scanner sc=new Scanner(System.in);

		int x=sc.nextInt();
		int y=sc.nextInt();
		int z=sc.nextInt();
		
		System.out.println(z+ " " +x+ " " +y);
		
		sc.close();
	}

}


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

int a[200001],v[1000001];
bool b[1000001];

int main()
{
	int n,maxn;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		v[a[i]]++;
		maxn=max(maxn,a[i]);
	}
	
	if(n==1)
	{
		cout<<1<<endl;
		return 0;
	}
	
	for(int now=1;now<=n;now++)
	{
		int i=a[now];
		bool f=true;
		v[i]--;
		
		for(int j=1;j*j<=i;j++)
		{
			if(i%j!=0)
				continue;
			
			if(v[j]>0 || v[i/j]>0)
			{
				f=false;
				break;
			}
		}
		if(f)
			b[i]=1;
		
		v[i]++;
	}
	
	int cnt=0;
	for(int i=1;i<=n;i++)
		if(b[a[i]])
			cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 9256
# coding=utf-8

line = input().split(" ")
n = int(line[0])
m = int(line[1])

x = 0
line1 = input().split(" ")
for (k,nn) in enumerate(line1):
    nn = int(nn)
    x += k*nn - (n-k-1)*nn


y = 0
line2 = input().split(" ")
for (k,nn) in enumerate(line2):
    nn = int(nn)
    y += k*nn - (m-k-1)*nn

print((x*y)%(10**9+7))


Measured memory_bytes: 19452
# 2019/05/05
# AtCoder Beginner Contest 049 - C

# Input
s = input()
s = s + " "

# Init
sl = ["dream", "dreamer", "erase", "eraser"]

ans = "NO"
i = len(s)

# Check str
while(i > 1):
    wtflg = False
    for j in range(len(sl)):
        st = (len(s) - i + 1+ len(sl[j])) * -1
        ed = (len(s) - i + 1) * -1
        subs = s[st:ed]
            
        if subs == sl[j]:
            wtflg = True
            break
    
    if wtflg == False:
        break
    
    i = i - len(sl[j])

if i <= 1:
    ans = "YES"

# Output
print(ans)

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  double L;
  cin >> L;

  double x = L/3.0;
  cout << x*x*x << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		ll c=1,d=0;
		N--;
		REP(i, 100) {
			d++;
			c*=26;
			if(0<=N&&N<c) {
				break;
			}
			N-=c;
		}
//		DD(N);DD(d);
		string ans(d, ' ');
		REP(di, d) {
			ans[d-1-di] = 'a'+(N%26);
			N/=26;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3104
S = input()
N = len(S)
K = int(input())
ttl = []
for i in range(N):
    for j in range(N - i):
        ttl.append(S[j:j+i+1])
    if i > K:
        break
ttl = sorted(list(set(ttl)))
print(ttl[K-1])

Measured memory_bytes: 7600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, d, ans, x, y;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> d;
	REP(i, 0, n){
		cin >> x >> y;
		if (x*x + y*y <= d*d){
			ans++;
		}
	}
	cout << ans << endl;
}

//cout.flush()

Measured memory_bytes: 3656
X, Y, Z, K = [int(_) for _ in input().split()]
As = [int(_) for _ in input().split()]
Bs = [int(_) for _ in input().split()]
Cs = [int(_) for _ in input().split()]

As.sort()
Bs.sort()
Cs.sort()

choice_stack = [(As[-1] + Bs[-1] + Cs[-1], len(As) - 1, len(Bs) - 1, len(Cs) - 1)]
choice_log = set()

j = 0
while True:
    choice_stack.sort()
    chosen_sum, Ai, Bi, Ci = choice_stack.pop()

    print(chosen_sum)

    step_A = (As[max(0, Ai - 1)] + Bs[Bi] + Cs[Ci], max(0, Ai - 1), Bi, Ci)
    step_B = (As[Ai] + Bs[max(0, Bi - 1)] + Cs[Ci], Ai, max(0, Bi - 1), Ci)
    step_C = (As[Ai] + Bs[Bi] + Cs[max(0, Ci - 1)], Ai, Bi, max(0, Ci - 1))

    if not (step_A in choice_log):
        choice_stack.append(step_A)
        choice_log.add(step_A)
    if not (step_B in choice_log):
        choice_stack.append(step_B)
        choice_log.add(step_B)
    if not (step_C in choice_log):
        choice_stack.append(step_C)
        choice_log.add(step_C)

    j += 1
    if j >= K:
        break


Measured memory_bytes: 4872
#include <iostream>
using namespace std;
int main(){
int a,b;
cin >> a >> b;
if (a==1)
    a=14;
if (b==1)
    b=14;
if (a>b)
    cout <<"Alice"<<endl;
if (a==b)
    cout <<"Draw"<<endl;
if (a<b)
    cout <<"Bob"<<endl;
system("pause");
return 0;
}

Measured memory_bytes: 504
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <cmath>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;

struct C1 {
    ll A_{};
    ll B_{};
    ll C_{};
    C1(ll A, ll B, ll C) : A_(A), B_(B), C_(C){}
    ll resolve() {
        return max(0LL, C_ - (A_ - B_));
    }
};

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    C1 c{A, B, C};
    cout << c.resolve() << endl;
    return 0;
}


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

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int i = 1; i <= 3; ++i) {
		if ((a * b * i) % 2) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No");
}

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

bool char_isin(char c, string s){
    for(auto cc: s){
        if(c == cc) return true;
    }
    return false;
}

bool is_vowel(char c){
    return char_isin(c, "aiueo");
}
bool is_unv_con(char c){
    return char_isin(c, "ksthp");
}

string solve(string s){
    vector<string> syl;
    int n = s.length();
    syl.emplace_back();
    for(int i=0; i<n; i++){
        syl.back() += s[i];
        if(is_vowel(s[i]) or s[i]=='\'' or (i!=n-1 and s[i]==s[i+1]) or 
            (s[i]=='n' and i==n-1) or
            (s[i]=='n' and !is_vowel(s[i+1]) and s[i+1]!='y' and s[i+1]!='\'')){
            syl.emplace_back();
        }
    }
    syl.back() = "k";

    string res = "";
    bool unvoiced = false;
    for(int i=0; i<(int)syl.size()-1; i++){
        if(unvoiced){
            res += syl[i];
            if(is_vowel(syl[i].back())){
                unvoiced = false;
            }
            continue;
        }
        char cc=syl[i][0], cv=syl[i].back();
        char nc=syl[i+1][0], nv=syl[i+1].back();
        if(((cv=='i' or cv=='u') and (is_unv_con(cc) and is_unv_con(nc))) or
            ((cv=='a' or cv=='o') and cv==nv and (is_unv_con(cc) and is_unv_con(nc))) ){
            res += syl[i].substr(0, syl[i].length()-1);
            res += "(" + syl[i].substr(syl[i].length()-1, 1) + ")";
            unvoiced = true;
        }else{
            res += syl[i];
        }
    }
    return res;
}

int main(){
    while(1){
        string s;
        cin >> s;
        if(s == "#") break;

        cout << solve(s) << endl;
    }
    return 0;
}



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

int main() {
  int x;
  cin >> x;
  int a = x / 500;
  int b = (x - a * 500) / 5;
  cout << a * 1000 + b * 5 << endl;
  return 0;
}


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

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    std::cin >> n>>k;
    
    vector<ll> p(n);
    vector<ll> s(n+1,0);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
        s[i+1] = s[i]+p[i];
    }
    
    ll ans = 0;
    
    for (int i = 0; i+k-1 < n; i++) {
        ans = max(ans,s[i+k]-s[i]);
    }
    
    std::cout<<setprecision(20) << (ans+k)/2.0 << std::endl;
}



Measured memory_bytes: 3456
program main
implicit none
integer N,i
character(52) S1,S2
integer(16)::mo=10**9+7,ans
character Pat
read*,N
read*,S1
read*,S2
ans=1
do i=1,N

  if(i==1)then
    if(S1(i:i)==S2(i:i))then
      ans=mod(ans*3,mo)
      Pat="X"
    else
      ans=mod(ans*6,mo)
      Pat="Y"
    endif
    cycle
  endif
  
  if(S1(i-1:i-1)==S1(i:i))cycle
  
  select case(Pat)
    case("X")
      if(S1(i:i)==S2(i:i))then
        ans=mod(ans*2,mo)
        Pat="X"
      else
        ans=mod(ans*2,mo)
        Pat="Y"
      endif
    case("Y")
      if(S1(i:i)==S2(i:i))then
        Pat="X"
      else
        ans=mod(ans*3,mo)
        Pat="Y"
      endif
  end select
end do
print"(i0)",ans
end program main

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

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

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

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

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

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

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

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

fn main() {
    input! {
        a: u16,
        b: u16,
    }

    if (a * b) % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
from sys import stdin
readline = stdin.buffer.readline
read = stdin.buffer.read
def i_input(): return int(input().rstrip())
def i_map(): return map(int, input().rstrip().split())
def i_list(): return list(i_map())

def main():
    N = i_input()
    A = i_list()
    ans = 0
    c = True
    while c:
        for i in range(N):
            if A[i] % 2 == 0 and A[i] > 0:
                A[i] //= 2
            else:
                c = False
                break
        else:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 63428
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll cnt[200001];
ll nxt[200001];
ll prev[200001];
ll sum = 0;
bool used[200001];
vector<ll> idx[200001];
ll idx_ans[200001];
ll A[200001];

int main(){
    ll N, K;
    cin  >> N >> K;
    ll M = N*K;
    for(ll i = 0; i < N; i++) {
        cin >> A[i+1];
        idx[A[i+1]].push_back(i+1);
    }
    for(ll i = 1; i <= 200000; i++){
        for(ll j = 0; j+1 < idx[i].size(); j++){
            nxt[idx[i][j]] = idx[i][j+1];
        }
        if(idx[i].size() != 0) nxt[idx[i][idx[i].size()-1]] = idx[i][0]+N;
    }
    ll cur = 1;
    while(true){
        //cout << cur << ' ';
        if(used[cur]) break;
        used[cur] = true;
        sum += (nxt[cur]-cur+1);
        cur = nxt[cur]+1;
        cur %= N;
        if(cur == 0) cur = N;
    }
    //cout << endl;
    ll ans[200000];
    ll cur_ = cur;
    ll cnt = 0;
    if(cur_ == cur) cnt++;
    ll sum_ = 0;
    while(true){
        ll n_sum = sum_ + (nxt[cur_]-cur_+1);
        sum_ = n_sum;
        cur_ = nxt[cur_]+1;
        cur_ %= N;
        if(cur_ == 0) cur_ = N;
        if(cur_ == cur) {
            cnt++;
            if(cnt == 2) break;
        }
    }
    bool flag = false;
    //cout << cur << ' '<< sum << ' '<< sum_ << endl;
    ll m = (M-sum)/sum_;
    ll d = (M-sum)%sum_;
    if(M > sum){
        //cout << d << endl;
        cur = cur_;
        sum = 0;
        while(true){
            ll n_sum = sum + (nxt[cur]-cur+1);
            if(n_sum >= d) {
                if(d-sum > N) flag = true;
                break;
            }
            sum = n_sum;
            cur = nxt[cur]+1;
            cur %= N;
            if(cur == 0) cur = N;
        }
    }else{
        sum = 0;
        cur = 1;
        while(true){
            ll n_sum = sum + (nxt[cur]-cur+1);
            if(n_sum >= M) {
                if(M-sum > N) flag = true;
                break;
            }
            sum = n_sum;
            cur = nxt[cur]+1;
            cur %= N;
            if(cur == 0) cur = N;
        }
    }
    ll cur_idx = 0;
    for(ll i = 1; i <= 200000; i++) idx_ans[i] = -1;
    int N_ = N;
    if(flag) N_ += N;
    //cout << cur << ' ' << N_ << endl;
    //cout << A[cur] << endl;
    for(ll i = cur; i <= N_; i++){
        int i_ = i%N;
        if(i_ == 0) i_ = N;
        //cout << A[i_] << endl;
        if(idx_ans[A[i_]] == -1){
            ans[cur_idx] = A[i_];
            idx_ans[A[i_]] = cur_idx;
            cur_idx++;
        }else{
            //cout << "cur: " << idx_ans[A[i_]] << ' ';
            int prev_idx = idx_ans[A[i_]];
            for(int j = cur_idx-1; j > prev_idx; j--){
                int a = ans[j];
                //cout << a << endl;
                idx_ans[a] = -1;
            }
            cur_idx = idx_ans[A[i_]];
            //cout << cur_idx << ' ';
            idx_ans[A[i_]] = -1;
        }
    }
    //cout << cur_idx << endl;
    if(d == 0){
        cout << endl;
        return 0;
    }
    for(ll i = 0; i < cur_idx-1; i++){
        cout << ans[i] << ' ';
    }
    if(cur_idx != 0) cout << ans[cur_idx-1];
    cout << endl;
}

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

int main(){
  int a, b, sum;
  cin >> a >> b;
  sum = a + b;
  if (sum % 2 == 0){
  cout << sum/2 << endl;
  }
  
  else {
  cout << sum/2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    REP(i, n) cin >> a[i];
    SORT(a); REV(a);
    ll ans = a[0];
    REP1(i, (n - 2) / 2) ans += a[i] * 2;
    if (n % 2 == 1) ans += a[n / 2];
    cout << ans << endl;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

int main() {

	int n, m;
	scanf("%d%d", &n, &m);

	if (n == 1 || m == 1) printf("%d\n", n == 1 && m == 1 ? 1 : max(0, max(n, m) - 2));
	else printf("%lld\n", 1ll * (n - 2) * (m - 2));

	return 0;
}

Measured memory_bytes: 256
import collections
import heapq

n, m = map(int, input().split())
que = []
for _ in range(n):
    a, b = map(int, input().split())
    que.append((-b, a))
que.sort(key=lambda x: x[1])
que = collections.deque(que)
h = []
heapq.heapify(h)
ans = 0
for i in range(1, m + 1):
    while len(que) != 0 and que[0][1] <= i:
        tmp = que.popleft()
        heapq.heappush(h, tmp)
    if len(h) == 0: continue
    tmp = heapq.heappop(h)
    ans -= tmp[0]
print(ans)

Measured memory_bytes: 24260
#include<bits/stdc++.h>
using namespace std;
#define outc cout
#define int long long
signed main(){
  int b=0,f=0,g=0,c,d,q=0,w=0;
  int a;
  int z[1000000];
  cin>>a>>d;
  for(int i=0;i<a;i++){
    cin>>c>>z[i];
    g=max(g,c);
  }
  sort(z,z+a,greater<int>());
  for(int i=0;i<a;i++){
    if(g<z[i]&&d>0) d-=z[i],w++;
  }
  if(d>0){
    q=d/g;
    if(d%g!=0) f=1;
  }
  cout<<q+f+w<<"\n";}


Measured memory_bytes: 2816
#include<map>
#include<queue>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=510;
template<class o>void qr(o&x) {
	char c=gc;int f=1;x=0;
	while(!isdigit(c)){if(c=='-')f=-1;c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o>void qw(o x) {
	if(x/10)qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o>void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x);puts("");
}

int n,d[N][N],ans;
bool f[N][N];

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

void dfs(int x,int y) {
	for(int t=0;t<4;t++) {
		int tx=x+dx[t],ty=y+dy[t];
		if(tx&&tx<=n&&ty&&ty<=n&&d[tx][ty]>d[x][y]+f[x][y]) {
			d[tx][ty]=d[x][y]+f[x][y];
			dfs(tx,ty);
		}
	}
}

int main() {
	qr(n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans+=(d[i][j]=min(min(i-1,n-i),min(j-1,n-j)));
	ans=0; memset(f,1,sizeof f);
	for(int i=1,t,x,y;i<=n*n;i++) {
		qr(t); x=(t-1)/n+1; y=t-(x-1)*n;
		ans+=d[x][y];f[x][y]=0; dfs(x,y);
	}
	pr2(ans);
	return 0;
}


Measured memory_bytes: 17820
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    
    int N, T;
    cin >> N >> T;

    vec<int> t(N);
    for (auto& x : t) cin >> x;


    ll sum {};
    ll stopTime {};
    
    for (auto x : t)
    {
        if (x >= stopTime)
            sum += T;
        else
            sum += T - (stopTime - x);
        stopTime = x + T;
    }


    cout << sum << endl;
}

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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; }

int main() {
    int n, m; cin >> n >> m;
    vector<ll> a(n), b(n), c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int ans = 0;
        ll dist = LLINF;
        rep(j, m) {
            if (chmin(dist, abs(a[i] - c[j]) + abs(b[i] - d[j]))) {
                ans = j;
            }
        }
        cout << ans + 1 << endl;
    }
}


Measured memory_bytes: 3532
function Main(input) {
  input = input.trim()
  var ans = "Christmas"
  switch(input){
    case "22":
      ans += " Eve"
    case "23":
      ans += " Eve"
    case "24":
      ans += " Eve"
    default:
      break;
              }
  console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468