akhauriyash/Code-Regression huggingface dataset:
def contact(a,b)
	ax,ay,bx,by = a
	cx,cy,dx,dy = b
	d = (bx-ax)*(dy-cy)-(by-ay)*(dx-cx)
	acx = cx-ax
	acy = cy-ay
	if d == 0
		nil
	else
		r = ((dy-cy)*acx-(dx-cx)*acy)/d
		s = ((by-ay)*acx-(bx-ax)*acy)/d
		if (0.0..1.0).include? r and (0.0..1.0).include? s
			[ax+(bx-ax)*r,ay+(by-ay)*r]
		else
			nil
		end
	end
end

gets.to_i.times {
	line = gets.split(" ").map(&:to_f)
	p Enumerator.new {|y|
		sx,sy = line
		gets.to_i.times {
			rail = gets.split(" ").map(&:to_f)
			if !(p = contact(rail,line)).nil?
				dx , dy = p
				_,_,_,_,o,l = rail
				arr = [[1,0],[0,1]]
				y << [(sx-dx)**2 + (sy-dy)**2,arr[o][l]]
			end
		}
	}.sort {|a,b|
		a[0] <=> b[0]
	}.each_cons(2).count {|a,b|
		a[1]!=b[1]
	}
}

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

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



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

int main (){
    
    //参加人数,合宿日数、余ったチョコレート
    int N,D,X;
    cin >> N >> D >> X;
    int ans = X;
    
    for (int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        
        for(int b = 1; b <= D; b += A){
            ans += 1;
        }
    }
    
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

vector<int> getYakusuu(int a){
  vector<int> Yakusuu;
  for(int i=1; i<=a; i++){
    if (a%i==0)
      Yakusuu.push_back(i);
  }
  return Yakusuu;
}

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

  auto yakusuu = getYakusuu(b);

  bool flag = false;
  rep(i, yakusuu.size()){
    if (yakusuu[i] == a){
      flag=true;
      break;
    }
  }
  if(flag){
    cout << a+b << endl;
  }else{
    cout << b-a << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1,n-1,1):
    if p[i+1] > p[i] > p[i-1]:
        count = count +1
    elif p[i+1] < p[i] < p[i-1]:
        count = count +1
    else:
        pass

print(count)

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


int main() {
	int h, w, k;
	int ans = 0;
	cin >> h >> w >> k;
	vector<vector<char>> vec(h, vector<char>(w));
	rep(i, h) {
		rep(j, w) {
			cin >> vec[i][j];
		}
	}
	for(int i = 0;i < (1 << h);i++) {
		for(int j = 0;j < (1 << w);j++) {
			int test = 0;
			rep(t, h) {
				if(i &(1<<t)) {
					rep(m, w) {
						if(j &(1<<m)) {
							if(vec[t][m] == '#') test++;
						}
					}
				}

			}
			if(test == k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int a, b, c;

int main(){
    cin >> a >> b >> c;
    int sum = a + b + c;
    int low = max(a, max(b, c));
    int cnt = 0;
    while(1){
        if(sum % 3 == 0 and sum / 3 >= low) break;
        sum += 2;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  rep(i, n) rep(j, n - 1) cin >> a[i][j];
  rep(i, n) rep(j, n - 1)-- a[i][j];

  vector<int> idx(n, 0);
  vector<bool> chk(n);
  int minidx = 0;
  int cnt = 0;

  vector<int> nowidx;
  vector<int> nextidx;
  while(minidx < n - 1) {
    minidx = n - 1;
    chk.assign(n, false);

    if(cnt) {
      nowidx = nextidx;
      nextidx.clear();
    } else {
      rep(i, n) nowidx.push_back(i);
    }
    rep(k, nowidx.size()) {
      int i = nowidx[k];
      if(chk[i]) continue;
      if(idx[i] == n - 1) continue;
      int j = a[i][idx[i]];
      if(chk[j]) continue;
      if(a[j][idx[j]] != i) continue;
      nextidx.push_back(i);
      nextidx.push_back(j);
      ++idx[i];
      chk[i] = true;
      ++idx[j];
      chk[j] = true;
    }

    bool ok = false;
    rep(i, n) ok = ok || chk[i];
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }
    rep(i, n) minidx = min(minidx, idx[i]);
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(n) for(int i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int a,b,c,tmp;
    cin >> a >> b >> c;
    //cout << a << b << c << endl;
    tmp = a;

    for(int i = 1;i < a*b;i++){
        if(a%b == c){
            cout << "YES" << endl;
            return 0;
        }else{
            a+=tmp;
            //cout << a << endl;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(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<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; i*i <= x; i++) if(x % i == 0) return false; return true; }

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

    ll p = n;
    while(!is_prime(p)) p++;

    cout << p << endl;
    return 0;
    }
    


  




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

#define rep(i, n) for (ll i=0;i<(n); 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; }

using namespace std;
//using ll=long long;
typedef long long ll;
typedef pair<ll, ll> pi;



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

  ll x[n];
  ll y[n];
  ll z[n];

  rep(i,n){
    cin >>x[i]>>y[i]>>z[i];
  }

  
  ll xxi,yyi,zzi;
  ll xx,yy,zz;

  ll ans = 0;
  
  rep(xi,2){
    rep(yi,2){
      rep(zi,2){
	priority_queue<ll> p;
	ll tmp = 0;
	rep(i, n){

	  if (xi==0) xxi = -1; else xxi=1;
	  if (yi==0) yyi = -1; else yyi=1;
	  if (zi==0) zzi = -1; else zzi=1;
	  xx = x[i]*xxi;
	  yy = y[i]*yyi;
	  zz = z[i]*zzi;

	  p.push(xx+yy+zz);
	    
	  }

	rep(j,m){
	  //cout << p.top()<<endl;
	  tmp += p.top();
	  p.pop();
	}
	chmax(ans, tmp);
	
      }
    }
  }


  
  cout << ans << endl;

}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 3510;
int N;

int main(){
	cin >> N;
	repp(i,1,MC){
		repp(j,i,MC){
			LL a = (LL)N * i * j;
			LL b = (LL)4 * i * j - (LL)(i + j) * N;
			if(b > 0 && a % b == 0){
				cout << i << ' ' << j << ' ' << a/b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int S = 0;

		S = r*r;
		System.out.println(S);
	}

}


Measured memory_bytes: 23380
N, M, Q = map(int, input().split())
ptn = []
for i in range(Q):
    a,b,c,d = map(int, input().split())
    ptn.append([a-1,b-1,c,d])
mx = 0
def calc(arr):
    if len(arr) == N:
        global mx
        tot = 0
        for i in range(Q):
            if arr[ptn[i][1]] - arr[ptn[i][0]] == ptn[i][2]:
                tot += ptn[i][3]
        mx = max(mx, tot)
        return
    for i in range(1,M+1):
        if i < arr[-1]: continue
        calc(arr+[i])
for i in range(1,M+1):
    calc([i])
print(mx)


Measured memory_bytes: 9224
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < 1000; ++i)
  {
    int v[3];
    int t = i;
    v[0] = t / 100;
    t %= 100;
    v[1] = t / 10;
    v[2] = t % 10;
    ll p[3] = {N, N, N};
    for (int j = 0; j < N; ++j)
    {
      if (S[j] - '0' == v[0] && p[0] == N)
        p[0] = j;
      else if (S[j] - '0' == v[1] && p[1] == N && p[0] < N)
        p[1] = j;
      else if (S[j] - '0' == v[2] && p[2] == N && p[0] < N && p[1] < N)
        p[2] = j;
    }
    if (p[0] < N && p[1] < N && p[2] < N)
    {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

  const int MOD = 1000000007;

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }


int main()
{
    int N;
    cin >> N;
    vector<int>A(N);
    REP(i, N) cin >> A.at(i);
    int target = 1;
    int cnt = 0;
    REP(i, N){
        if(A.at(i) == target){
            target++;
            cnt++;
        }
    }
    if(cnt != 0) print(N - cnt);
    else print(-1);
    }

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a > 0) cout << "Positive" << endl;
    else if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else if (b < 0) {
        if (a == b) cout << "Negative" << endl;
        else {
            if ((b - a + 1) % 2) cout << "Negative" << endl;
            else cout << "Positive" << endl;
        }
    }
    return 0;
}

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

int main()
{
  int N, A;
  cin >> N >> A;
  
  cout << N * N - A << endl;
}


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

int main(){
  long q, h, s, d, n;
  cin >> q >> h >> s >> d >> n; //1, 2, 4, 8;
  n*=4;
  vector<pair<double, int>>tea;
  tea.push_back(make_pair(q, 1));
  tea.push_back(make_pair(h/2.0, 2));
  tea.push_back(make_pair(s/4.0, 4));
  tea.push_back(make_pair(d/8.0, 8));
  sort(tea.begin(), tea.end());
  long ret=0L;
  for(int i=0; i<4; i++){
    ret+=int(tea[i].first*tea[i].second)*(n/tea[i].second);
    n%=tea[i].second;
  }
  cout << ret;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int arr[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,k;
       cin>>n>>k;
       rep(i,0,n)
       cin>>arr[i];
       if(n<=k)
        cout<<"0"<<el;
       else
       {
           sort(arr,arr+n);
           int sum = 0;
           for(int i=n-k-1;i>=0;--i)
           {
               sum+= arr[i];
           }
           cout<<sum<<el;
       }
    }
   return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 

#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

const int N =1e3+5;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};

char c[N][N];
int a[N][N];

void solve(){

	int n,m;
	cin>>n>>m;

	rep(i,1,n+1){
		rep(j,1,m+1)
			cin>>c[i][j];
	}

	int fr=0,fc=0;

	rep(i,1,n+1){
		rep(j,1,m+1){ 

			if(i==1 ){

              
		      if(c[i][j]=='#')
				  fr=1;
			  if(fr==0)
				  a[i][j]=1;
			 
			  continue;
			}

		if(j==1 ){
			 if(c[i][j]=='#')
				  fc=1;
              if(fc==0)
				  a[i][j]=1;
			 
			  continue;
			}


			if( c[i][j] == '.' and c[i-1][j]=='.'){
				a[i][j] += a[i-1][j];
				a[i][j] %= mod;
			}

			if(c[i][j] == '.' and c[i][j-1]=='.'){
				a[i][j] += a[i][j-1];
				a[i][j] %= mod;
			}
		}
	}

/*	rep(i,1,n+1){
		rep(j,1,m+1) 
			cout<<a[i][j]<<" ";
		cout<<endl;
	}
*/
	cout<<a[n][m]<<endl;
}





int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
		solve();


	return 0;	   
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}

int main(){
	double a, b, x;
	cin >> a >> b;
	x = (a+b)/2;
	
	int c=x;
	if(x==c) cout<<c<<endl;
	else cout<<c+1<<endl;
	
	return 0;
}




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

int main(){

  int n;
  int i;
  double D_1 = 0;
  double D_2 = 0;
  double D_3 = 0;
  double D_i = 0;
  cin >> n;

  int x[100];
  int y[100];

  for(i = 0;i < n;i++){
    cin >> x[i];
  }
  for(i = 0;i < n;i++){
    cin >> y[i];
  }

  for(i = 0;i < n;i++){
    D_1 += abs(x[i] - y[i]);
    D_2 += pow(abs(x[i] - y[i]),2);
    D_3 += pow(abs(x[i] - y[i]),3);
    D_i = max((double)abs(x[i] - y[i]),D_i);
  }

  D_2 = sqrt(D_2);
  D_3 = pow(D_3,(double)1/3);

  cout << fixed <<  D_1 << endl << D_2 << endl << D_3 << endl << D_i << endl;

  return 0;
}

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

int main() {
	string s,r="";
	int p=0;
	cin >> s;

	rep(i,s.size()) {
		r += ".";
		if(s.at(i) != 'B')
			r.at(p++) = s.at(i);
		else
			p = max(p-1,0);
	}

	cout << r.substr(0,p) << endl;
}

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

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

  int x, y;
  cin >> x >> y;
  for (int i = 0; i < y / 4 + 1; i++) {
    if (i * 4 + (x - i) * 2 == y) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3644
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2015
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int N, E;
ll a[MAXN], dp[MAXN], T;
set<pair<ll, ll> > s[2];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	scanf("%d%d%lld", &N, &E, &T);
	for (int i=0; i<N; i++) scanf("%d", &a[i]);
	
	for (int i=0; i<N; i++) dp[i] = oo;
	int cur = 0;
	for (int i=0; i<N; i++) {
		while (cur <= i && (a[i] - a[cur]) * 2 >= T) {
			ll now = T - (cur != 0 ? a[cur - 1] : 0) + (cur != 0 ? dp[cur - 1] : 0);
			
			ll nxt = -2 * a[cur] - (cur != 0 ? a[cur - 1] : 0) + (cur != 0 ? dp[cur - 1] : 0);
			if (s[0].find(mp(now, cur)) != s[0].end()) {
				s[0].erase(mp(now, cur));
				s[1].insert(mp(nxt, cur));
			}
			cur++;
		}
		dp[i] = a[i] - (i != 0 ? a[i-1] : 0) + (i != 0 ? dp[i-1] : 0) + T;
		if (!s[0].empty()) {
			ll now = s[0].begin()->FI;
			dp[i] = min(dp[i], a[i] + now);
		}
		if (!s[1].empty()) {
			ll now = s[1].begin()->FI;
			dp[i] = min(dp[i], 3 * a[i] + now);			
		}
		ll nxt = T - (i != 0 ? a[i - 1] : 0) + (i != 0 ? dp[i - 1] : 0);
		s[0].insert(mp(nxt, i));
	}
	cout << E - a[N - 1] + dp[N - 1];


}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 1000000

bool prime[MAX];
bool order[MAX+1];
int menu[30];
int n,money;

void init(){
	fill(prime,prime+MAX,true);
	prime[0]=prime[1]=false;
	for(int i=2;i<MAX;i++){
		if(prime[i]){
			for(int j=2;j*i<MAX;j++)
				prime[j*i]=false;
		}
	}
}
void search(){
	queue<int> que;
	int m,l;
	que.push(0);
	while(!que.empty()){
		m=que.front();
		que.pop();
		for(int i=0;i<n;i++){
			l = m+menu[i];
			if(l<=money && !order[l]){
				order[l]=true;			
				que.push(l);
			}
		}
	}
}
int main(){
	init();
	while(cin>>n>>money,n|money){
		for(int i=0;i<n;i++)cin>>menu[i];
		fill(order,order+(MAX+1),false);
		search();
		int ans=-1;
		for(int i=money;i>1;i--){
			if(prime[i] && order[i]){
				ans=i;
				break;
			}
		}
		if(ans!=-1)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
}

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

double ans;
int n;
double a[52];

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a, a+n);
    ans = (a[0]+a[1])/2;
    for (int i = 2; i < n; i++) {
        ans = (ans+a[i])/2;
    }
    
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  double a,b;
  cin >> a >> b;
  cout << ceil((a+b)/2.l) << endl;
  return 0;
}


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

// ABC119A -Still TBD
// https://atcoder.jp/contests/abc119/tasks/abc119_a

void ABC119A() {
	string S;
	cin >> S;

	int yyyy = atoi(S.substr(0, 4).c_str());
	if (yyyy < 2019) {
		cout << "Heisei" << endl;
		return;
	}

	int mm = atoi(S.substr(5, 2).c_str());
	if (mm < 5) {
		cout << "Heisei" << endl;
		return;
	}

	cout << "TBD" << endl;
}

int main() {
	ABC119A();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
// vector<vector<ll>> v(101,vector<ll>(101,0));
int main(){
	int N,x,y;
	ll h;
	cin >> N;
	struct V{
		int x;
		int y;
		ll h;
	};
	struct V v[N-1];
	int a,b,c;
	int flag = 0;
	int k = 0;
	for (int i = 0;i<N;i++){
		cin >> x >> y >> h;
		if (h > 0 && flag == 0){//最初に使う座標
			a = x;
			b = y;
			c = h;
			flag = 1;
		}
		else{
			v[k].x = x;
			v[k].y = y;
			v[k].h = h;
			k++;
		}
	}
	k = 0;
	struct V w[10201];
	for (int i = 0;i <=100;i++){
		for (int j= 0;j<= 100;j++){
			w[k].h = c + abs(a-i) + abs(b-j);
			w[k].x = i;
			w[k].y = j;
			k++;
		}
	}
	k = 0;
	while(k < 10201){
		flag = 0;
		for (int i = 0;i < N - 1;i++){
			ll q = w[k].h - abs(v[i].x -w[k].x) - abs(v[i].y -w[k].y);
			q = max(0LL,q);
			if (v[i].h != q){
				flag = 1;
				break;
			}
		}
		if (flag == 0){
			break;
		}
		k++;
	}
 
	// cout << a << " " << b << " " << c <<endl;
	cout << w[k].x << ' '  << w[k].y << ' ' << w[k].h <<endl;
	return 0;
}

Measured memory_bytes: 384
main(b,r,g,c,s,t){for(;scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),t;printf("%d\n",100+b*95+r*63+g*4-c-3*t+3*g+3*c+3*s));exit(0);}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			int a = sc.nextInt();
			if (i % 2 == 1 && a % 2 == 1) cnt++;
		}
		
		System.out.println(cnt);
				
		sc.close();
	}
	
}



Measured memory_bytes: 27036
import java.util.*

fun main(args:Array<String>):Unit {
    var (n, k) = readLine()!!.split(' ').map(String::toInt)
    while (n != 0) {
        val feeTable = Array(n) {x ->  Array(n) {y -> if (x != y) Int.MAX_VALUE.toLong() else 0L} }
        repeat(k){
            val query = readLine()!!.split(' ').map(String::toInt)
            when(query.first()){
                0 -> {
                    val (_, a, b) = query
                    println(when(feeTable[a - 1][b - 1]){
                        Int.MAX_VALUE.toLong() -> -1
                        else -> feeTable[a - 1][b - 1]
                    })
                }
                1 -> {
                    val (_, c, d, e) = query
                    for (from in 0 until n){
                        for (to in (from + 1) until n){
                            if (feeTable[from][to] > feeTable[from][c - 1] + feeTable[d - 1][to] + e){
                                feeTable[from][to] = feeTable[from][c - 1] + feeTable[d - 1][to] + e
                                feeTable[to][from] = feeTable[from][to]
                            }
                            if (feeTable[from][to] > feeTable[from][d - 1] + feeTable[c - 1][to] + e){
                                feeTable[from][to] = feeTable[from][d - 1] + feeTable[c - 1][to] + e
                                feeTable[to][from] = feeTable[from][to]
                            }
                        }
                    }
                }
            }
        }
        val (nn, nk) = readLine()!!.split(' ').map(String::toInt)
        n = nn
        k = nk
    }
}


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

int main()
{
	int k;
	scanf("%d", &k);
	long long rem = 0;
	if(k % 2 == 0) {
		printf("-1\n");
	} else {
		int step = 0;
		while(1) {
			step++;
			rem *= 10;
			rem += 7;
			rem %= k;
			if(rem == 0) break;
			if(step > 10000000) {
				printf("-1\n");
				return 0;
			}
		}
		printf("%d\n", step);
	}
}

Measured memory_bytes: 3812
n = int(input())
xl = [list(map(int,input().split())) for i in range(n)]
xl = sorted(xl)

pre = 0
cnt = 0
for x, l in xl:
    if pre == 0:
        pre = x + l
        continue

    if x - l < pre <= x + l:
        cnt += 1
    elif x + l < pre:
        cnt += 1
        pre = x + l
    else:
        pre = x + l

print(n - cnt)

Measured memory_bytes: 28640
#include <iostream>

int main() {
    int x, a, b;
    std::cin >> x >> a >> b;

    if(std::abs(x - a) < std::abs(x - b)) {
        std::cout << 'A' << std::endl;
    } else {
        std::cout << 'B' << std::endl;
    }
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();
		char[] C = sc.next().toCharArray();
		int ans = 0;
		for (int i = 0; i < N; i++) {
			HashSet<Character> set = new HashSet<>();
			set.add(A[i]);
			set.add(B[i]);
			set.add(C[i]);
			ans += set.size() - 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include<stdio.h>
int main()
{
  int num;
  int i,j;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      num=i*j;
      printf("%dx%d=%d\n",i,j,num);
    }
  }
return 0;
}

Measured memory_bytes: 524
#include <iostream>

int main(){
   std::string S;
   std::cin >> S;

   int n = 0;
   for(int i=0; i<S.size(); ++i){
      if(S[i]=='o') ++n;
   }
   if(n>=8 || (15-S.size()+n>=8)) std::cout << "YES" << std::endl;
   else std::cout << "NO" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
long long int MOD = 1000000007;

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	int num, pre, ans = 0, cnt = 0;
	cin >> pre;
	
	for(int i = 1; i < N; i++){
		cin >> num;
		if(pre == num){
			cnt++;
		}else{
			ans += (cnt + 1) / 2;
			cnt = 0;
		}
		pre = num;
	}
	ans += (cnt + 1) / 2;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())

l=[]

for i in range(N):
    a, b = map(int, input().split())
    l.append((a + b, a, b))

l.sort()
l.reverse()
tak = 0
aok = 0


for i in range(N):
    if i % 2 == 0:
        tak += l[i][1]
    else:
        aok += l[i][2]
print(tak-aok)

Measured memory_bytes: 20988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    double ans = 0;
    for (int i = 1; i <= 1000000; i++) {
        int time = i * (m * 1900 + (n - m) * 100);
        double prob = pow((1 - pow(0.5, m)), i - 1) * pow(0.5, m);
        ans += time * prob;
    }

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


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

#define INF (1<<20)
const int MAX_N = 1 << 18;

typedef pair<int,int> P;

int n;
P dat[2*MAX_N-1];

void init(int _n) {
	n = 1;
	while(n < _n) n *= 2;
	for (int i = 0; i < 2 * n - 1; i++) {
		dat[i].first = -1;
		dat[i].second = INT_MAX;
	}
}

int find(int k) {
	k += n-1;
	P p = dat[k];

	while (k > 0) {
		k = (k-1)/2;
		p = max(p, dat[k]);
	}

	return p.second;
}

void update(int a, int b, int k, P p, int l, int r) {
	if (r <= a || b <= l) return;
	
	if (a <= l && r <= b) {
		dat[k] = p;
	}
	else {
		update(a,b,k*2+1,p,l,(l+r)/2);
		update(a,b,k*2+2,p,(l+r)/2,r);
	}
}

int main() {
	int _n, q;
	cin >> _n >> q;
	init(_n);

	for (int i = 0; i < q; i++) {
		int j; cin >> j;
		if (j) {
			int u;
			cin >> u;
			cout << find(u) << endl;
		}
		else {
			int s, t, x;
			cin >> s >> t >> x;
			update(s,t+1,0,P(i,x),0,n);
		}
	}

}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (a<=b)cout << a;
  if (a > b) cout << a-1;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

ll get(ll a) {
    return a *(a+1) / 2;
}
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    ll res = 0;
    string s; cin >> s;
    ll cnt =1;
    vector<pair<char, int> > vs;

    for(int i=1; i<s.size(); i++) {
        if(s[i] == s[i-1]) {
            cnt++; 
        } else {
            vs.push_back({s[i-1], cnt});
            cnt=1;
        }
    }
    vs.push_back({s[s.size()-1], cnt});
    for(int i=0; i<vs.size(); i++) {
        if(vs[i].first == '>') {
            res += get(vs[i].second);
        } else {
            if(i < vs.size()-1) {

                
                if(vs[i].second > vs[i+1].second) {
                    res += get(vs[i].second);
                    res += get(vs[i+1].second-1);
                    i++;
                } else {
                    res += get(vs[i].second-1);
                    res += get(vs[i+1].second);
                    i++;
                }
            } else {
                res += get(vs[i].second);
            }
        }
        
    }
    cout << res << endl;
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 1000005
#define db double
#define mod 1000000007
using namespace std;
void solve(ll ind)
{
	ll x;
	cin >> x;
	db ans = (db)22/(db)7;
	ans = ans*2*(db)x;
	cout << ans;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(6);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve(i);
		i++;
	}
	return 0;
}

Measured memory_bytes: 3804
#include<iostream>
#include<algorithm>
#include<cmath>

int main(){
    
    size_t n;
    std::cin >> n;

    size_t min = std::numeric_limits<size_t>::max();

    for(size_t i = 1; i <= std::sqrt(n); i++){
        if(n % i == 0){
            min = std::min(min, i + (n / i));
        }
    }

    std::cout << min - 2 << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include <string>
using namespace std;

int main(){
    int ans=0;
    int X,A;
    cin>>X>>A;

    if(X<A){
        ans=0;
    }else{
        ans=10;
    }

    cout<<ans<<endl;

    return 0;
}

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

#define MOD (1000000000+7)

typedef long long ll;

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
    
    return strcmp(left_char,right_char);
}

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

ll modpow(ll a,ll n){
  ll res = 1;
  while(n>0){
    if(n % 2 == 1) res = res*a%MOD;
    a = a*a%MOD;
    n /= 2;
  }
  return res;
}

ll modinv(ll a){
  return modpow(a, MOD-2);
}

ll com(ll n, ll r){
  ll res = 1;
  for(int k=1;k<=r;k++){
    res = res * (n-(k-1)) % MOD;
    res = res * modinv(k) % MOD;
  }
  return res;
}

int main(void){
  int n, a, b, i, result=0;
  long int tmp=1;
  
  scanf("%d %d %d", &n, &a, &b);
  
  result = modpow(2,n);
  result--;
  if(result<0) result+=MOD;
  ll rm = com(n,a)+com(n,b);
  rm%=MOD;
  result-=rm;
  if(result<0)result+=MOD;
  
  printf("%d", (int) result%MOD);
}

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

int main(void){
    int s;
    string t;
    cin >> s >> t;
    int count = 0;
    if(s >= 3200){
        cout << t << endl;
    }else{
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, a, b;

  scanf("%d", &n);

  if(n == 1){
    printf("Hello World");
  }
  else{
    scanf("%d", &a);
    scanf("%d", &b);

    printf("%d", a+b);
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] a = new int[N];

    int sum = 0;

    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }

    sc.close();

    int average = (int) Math.round((double) sum / N);

    int cost = 0;

    for (int i = 0; i < N; i++) {
      int dif = (int) Math.abs(a[i] - average); 
      cost += dif * dif;
    }

    System.out.println(cost);

  }

}


Measured memory_bytes: 22100
k, n = map(int, input().split())
a = [int(i) for i in input().split()]
diff_a = [0] * n
diff_a[0] = (a[0] + k) - a[n - 1]
for i in range(1, n):
    diff_a[i] = a[i] - a[i - 1]
print(k - max(diff_a))

Measured memory_bytes: 26436
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

int p = 0;
int k;
string temp[5];
string s;

struct charpos {
    char c;
    int pos;

    charpos(char _c, int _pos) :c(_c), pos(_pos) {}
};

void func(vector<int> ps, string str) {
    vector<charpos> next;

    for (int p : ps) {
        if (p + 1 < s.length()) {
            next.push_back(charpos(s[p + 1], p + 1));
        }
    }

    sort(next.begin(), next.end(), [](charpos cp1, charpos cp2) {
        return cp1.c < cp2.c;
    });

    for (int i = 0; i < next.size(); ++i) {
        char c = next[i].c;

        vector<int> psn;

        while (next[i].c == c) {
            psn.push_back(next[i++].pos);
        }

        temp[p++] = str + c;

        if (p >= k) return;

        func(psn, str + c);

        if (p >= k) return;
    }
}

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

    cin >> s >> k;

    for (char i = 'a'; i <= 'z'; ++i) {
        vector<int> pos;

        for (int j = 0; j < s.length(); ++j) {
            if (s[j] == i) pos.push_back(j);
        }

        if (pos.size()) {
            temp[p++] = i;

            func(pos, string{i});

            if (p >= k) break;
        }
    }

    out(temp[k - 1]);
    
    int aaa;
    cin >> aaa;
}

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

int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++) {
		if (s.substr(i, 5) == "apple")s.replace(i, 5, "peach");
		else if (s.substr(i, 5) == "peach")s.replace(i, 5, "apple");
	}
	cout << s << endl;
}

Measured memory_bytes: 1184
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000

long long a[30][3][3];
long long b[3][3];
long long ans[3][3];
long long ans2[3][3];

void mult(long long x, long long y) {
	f(i, 3) {
		f(j, 3)ans2[i][j] = 0;
	}
	if (x == 0) {
		f(ii, 3) {
			f(jj, 3) {
				f(j, 3) {
					x = (a[y][ii][j] * ans[j][jj]) % MOD;
					ans2[ii][jj] = (ans2[ii][jj] + x) % MOD;
				}
			}
		}
	}
	else {
		f(ii, 3) {
			f(jj, 3) {
				f(j, 3) {
					x = (b[ii][j] * ans[j][jj]) % MOD;
					ans2[ii][jj] = (ans2[ii][jj] + x) % MOD;
				}
			}
		}
	}
	f(i, 3) {
		f(j, 3)ans[i][j] = ans2[i][j];
	}
	return;
}





int main() {
	long long n,nn, k;
	long long x, y, z;
	f(i, 30) {
		f(ii, 3) {
			f(jj, 3) {
				a[i][ii][jj] = 0;
			}
		}
	}
	f(ii, 3) {
		f(jj, 3) {
			b[ii][jj] = 0;
			ans[ii][jj] = 0;
			ans2[ii][jj] = 0;
		}
	}
	a[0][0][0] = 2;
	a[0][0][1] = 1;
	a[0][0][2] = 2;
	a[0][1][0] = 1;
	a[0][1][1] = 1;
	a[0][1][2] = 2;
	a[0][2][0] = 1;
	a[0][2][1] = 0;
	a[0][2][2] = 1;

	b[0][0] = 1;
	b[0][1] = 1;
	b[0][2] = 2;
	b[1][0] = 0;
	b[1][1] = 1;
	b[1][2] = 2;
	b[2][0] = 0;
	b[2][1] = 0;
	b[2][2] = 1;

	ans[0][0] = 1;
	ans[1][1] = 1;
	ans[2][2] = 1;
	f(i, 29) {
		f(ii, 3) {
			f(jj, 3) {
				f(j, 3) {
					x = (a[i][ii][j] * a[i][j][jj]) % MOD;
					a[i + 1][ii][jj] = (a[i + 1][ii][jj] + x) % MOD;
				}
			}
		}
	}

	scanf("%lld %lld", &n,&nn);
	k = 1;
	f(i, nn) {
		scanf("%lld", &x);
		y = x - k;
		f(j, 30) {
			if (y % 2 == 1)mult(0, j);
			y = y / 2;
		}
		mult(1, 1);
		k = x + 1;
	}
	y = n - k;
	f(j, 30) {
		if (y % 2 == 1)mult(0, j);
		y = y / 2;
	}

	z = 0;
	f(i, 3)z = (z + ans[0][i]) % MOD;
	printf("%lld\n", z);


	return 0;
}

Measured memory_bytes: 128
(require 'clojure.set)
(defn Not-Found [S]
  (let [S' (set S)]
    (if (= 26 (count S'))
      "None"
      (-> #{\a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \z}
        (clojure.set/difference S')
        sort
        first))))



(-> (read-line)
  Not-Found
  println)

Measured memory_bytes: 68120
#include<stdio.h>
#include<math.h>

int main(){

int N;
long D;
scanf("%d%ld",&N,&D);
long a,b;
long X,Y;
long long Z;
Z = D*D;
int ans=0;
for (int i = 0; i < N; i++)
{
  scanf("%ld%ld",&a,&b);
  X=(a*a);
  Y=(b*b);
  if (Z>=(Y+X))
  {
    ans++;
  }  
}

printf("%d",ans);

return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

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

int main(){
	char c;
	int count = 0;
	REP(i, 4){
		cin >> c;
		if(c == '+')count++;
		else count--;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define mod (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}

void solve() {
    int h, w, x;
    cin >> h >> w >> x;
    cout << (x + max(h, w) - 1) / max(h, w) << endl;
}


Measured memory_bytes: 256
import bisect

def main():
    n = int(input())
    A = list(map(int,input().split()))
    m = int(input())
    B = list(map(int,input().split()))
    left,right = 0,n
    for i in range(m):
        mid = bisect.bisect_left(A,B[i],left,right)
        if mid<left or right==mid or A[mid]!=B[i]:
            print (0)
            return
        left = mid+1
    print (1)



if __name__ == '__main__':
    main()




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



int main(){
  long long X,Y;
  cin>>X>>Y;
  
  int suu=1;
  while(true){
    if(X<=Y/2){
      X=X*2;
      suu++;
    }
    else{
      cout<<suu<<endl;
      return 0;
    }
  }
  
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;
#define TENS(n) int(1e##n + n)
const int max_value = TENS(3) * 100;

// dp[i][j] : i番目までから価値がjとなるよう選んだときの重さの最小値
long long dp[101][max_value + 1];

void solve()
{

    unsigned int N, W;
    cin >> N >> W;
    vector<int> value(N);
    vector<LL> weight(N);

    REP0(i, N)
    {
        cin >> weight[i] >> value[i];
    }

    REP1(i, max_value)
    {
        dp[0][i] = LLINF;
    }

    dp[0][value[0]] = weight[0];
    int ans = (weight[0] <= W) ? value[0] : 0;

    REP1(i, N - 1)
    {
        dp[i][0] = 0;
        REP1(j, max_value)
        {
            if (0 <= j - value[i])
                dp[i][j] = min(dp[i - 1][j],
                               dp[i - 1][j - value[i]] + weight[i]);
            else
                dp[i][j] = dp[i - 1][j];

            if (dp[i][j] <= W)
                ans = max(ans, j);
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
#include <climits>

using namespace std;
#define MAX 100
int n,k,u,v,w;
int D[MAX+10][MAX+10],W[MAX+10][MAX+10];

int Fkoyd()
{
    for(int k=0;k<n;k++)
    {
        for(int i=0;i<n;i++)
        {
            if(W[i][k]==INT_MAX) continue;
            for(int j=0;j<n;j++)
            {
               if(W[k][j]==INT_MAX) continue;
               W[i][j]=min(W[i][j],W[i][k]+W[k][j]);
            }
        }
    }
}

int main()
{
    int negative=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
     for(int j=0;j<n;j++)
    {

        W[i][j]=(i==j)?0:INT_MAX;
    }
    for(int i=0;i<k;i++)
    {
        cin>>u>>v>>w;
        W[u][v]=w;
    }
    Fkoyd();
    for(int i=0;i<n;i++)
      if(W[i][i]<0) negative=1;


    if(negative) cout<<"NEGATIVE CYCLE"<<endl;
    else
    {
        for(int i=0;i<n;i++)
        {
          for(int j=0;j<n;j++)
          {
            if(j) cout<<" ";
            if(W[i][j]==INT_MAX) cout<<"INF";
            else cout<<W[i][j];
          }
          cout<<endl;
        }
    }
    return 0;
}



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


int main(){
  int n,m;
  cin>>n>>m;
  int sum = 0;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  sort(a.begin(),a.end(),greater<>());//降順
  
  if(a[m-1]*4*m >=sum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]
H = H[::-1]

r = 0
now = -1
result = 0
for h in H:
    if now < 0:
        now = h
        continue
    if h >= now:
        r += 1
        now = h
    else:
        now = h
        if r > result:
            result = r
        r = 0
if r > result:
    result = r
print(result)

Measured memory_bytes: 14224
import sys
f = sys.stdin


while True:
    n = int(f.readline())
    if n == -1:
        break
    location = 1 + 0j
    for i in range(1, n):
        location += (location * 1j) / abs(location)
    print('{:.2f}'.format(location.real))
    print('{:.2f}'.format(location.imag))
    

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  string s;
  cin >> s;
  if(s=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl; 
  return 0;
}

Measured memory_bytes: 3628