akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();

        long ans = 0;

        int[] cntR = new int[n];
        int[] cntG = new int[n];
        int[] cntB = new int[n];

        int tmpR = 0;
        int tmpG = 0;
        int tmpB = 0;

        for (int i=0; i<n; i++) {
            if (arr[i]=='R') {
                cntR[i] = ++tmpR;
                cntB[i] = tmpB;
                cntG[i] = tmpG;
            } else if (arr[i]=='G') {
                cntG[i] = ++tmpG;
                cntB[i] = tmpB;
                cntR[i] = tmpR;
            } else {
                cntB[i] = ++tmpB;
                cntR[i] = tmpR;
                cntG[i] = tmpG;
            }
        }


        for (int i=0; i<n-2; i++) {
            inner:
            for (int j=i+1; j<n-1; j++) {
                char first = arr[i];
                char second = arr[j];
                if (first==second) continue inner;
//                char[] rgb = {'R', 'G', 'B'};
                int cR = 0;
                int cG = 0;
                int cB = 0;
                if (first=='R') cR++;
                if (first=='G') cG++;
                if (first=='B') cB++;
                if (second=='R') cR++;
                if (second=='G') cG++;
                if (second=='B') cB++;
                char third = 'X';
                if (cR==0) third = 'R';
                if (cG==0) third = 'G';
                if (cB==0) third = 'B';

                if (j+(j-i)>=n) {
                    if (third=='R') {
                        ans += cntR[n-1]-cntR[j];
                    } else if (third=='G') {
                        ans += cntG[n-1]-cntG[j];
                    } else {
                        ans += cntB[n-1]-cntB[j];
                    }
                } else {
                    if (third=='R') {
                        if (arr[j+(j-i)]=='R') ans += (cntR[n-1]-cntR[j]-1);
                        else ans += (cntR[n-1]-cntR[j]);
                    } else if (third=='G') {
                        if (arr[j+(j-i)]=='G') ans += (cntG[n-1]-cntG[j]-1);
                        else ans += (cntG[n-1]-cntG[j]);
                    } else {
                        if (arr[j+(j-i)]=='B') ans += (cntB[n-1]-cntB[j]-1);
                        else ans += (cntB[n-1]-cntB[j]);
                    }

                }
//                System.out.print(ans);
            }
        }

        System.out.println(ans);

    }

}


Measured memory_bytes: 28184
// Problem : B - Between a and b ...
// Contest : AtCoder - AtCoder Beginner Contest 048
// URL : https://atcoder.jp/contests/abc048/tasks/abc048_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll a,b,x;
	cin>>a>>b>>x;
	cout<<b/x-a/x+(a%x==0)<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a=n/1000;
	int b=(n%1000)/100;
	int c=(n%100)/10;
	int d=n%10;	
	for(int i=43;i<=45;i+=2)
		for(int j=43;j<=45;j+=2)
			for(int k=43;k<=45;k+=2){
				int ans=a;	
				if(i==43) ans+=b;
				else ans-=b;
				if(j==43) ans+=c;
				else ans-=c;
				if(k==43) ans+=d;
				else ans-=d;
				if(ans==7){cout<<a<<(char)i<<b<<(char)j<<c<<(char)k<<d<<"=7";return 0;}
				
			}
	
}

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

long long n,res;

int main(){

    std::cin>>n;

    for(long long i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(n/i-1<=i)break;
            res+=n/i-1;
        }
    }

    std::cout<<res<<std::endl;

    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

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

const int INF = 1001001001;


int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    vector<ll> aa(n - 1);
    int b = a[n - 1];
    int half = b / 2;

    int idx_half = lower_bound(all(a), half) - a.begin();

    for (int i = 0; i < idx_half; ++i) aa.push_back(a[i]);
    for (int i = idx_half; i < n - 1; i++) aa.push_back(b - a[i]);

    sort(all(aa));
    aa.erase(unique(all(aa)), aa.end());

    ll ans;
    ll m = aa.back();
    for (auto aaa: a) {
        if (aaa == m) {
            ans = m;
            break;
        } else if (aaa == (b - m)) {
            ans = b - m;
        }
    }
    cout << b << " " << ans << endl;
}

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

using namespace std;

int main(void) {
  long long n,k;

  cin >> n >> k;

  int i;
  long long m = k;

  for (i = 1;;i++,m *= k) {
    if (m > n) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a,b,c;
int main() {
  cin>>a>>b>>c;
  if (a+b==c || c+a==b || b+c==a) {
  	cout<<"Yes"<<endl;
  } else {
  	cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b;
char c;
string s;
signed main()
{
	cin>>c;
	if(c=='A'){
		cout<<'T';
	}elif(c=='C'){
		cout<<'G';
	}elif(c=='G'){
		cout<<'C';
	}else{
		cout<<'A';
	}
}

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

string S;

int main() {
    cin >> S;
    int cnt = 0;
    for (int i = 1; i < S.size(); i++) {
        if (S[i] == S[i - 1])  continue;
        cnt++;
    }
    cout << cnt << endl;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll w,h;cin>>w>>h;
  vector<P>p(w+h);
  rep(i,0,w){
    cin>>p[i].fi;
    p[i].se=0;
  }
  rep(i,0,h){
    cin>>p[w+i].fi;
    p[w+i].se=1;
  }
  sort(ALL(p));
  ll tmp=h+w;
  h++;w++;
  rep(i,0,tmp){
    if(p[i].se==0){
      if(h>0){
        res+=p[i].fi*h;
        w--;
      }
    }
    else{
      if(w>0){
        res+=p[i].fi*w;
        h--;
      }
    }
    //cout<<res spa p[i].fi spa h spa w<<endl;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


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

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

int main() {
	cin >> n;
	vector<ll> a(n+1);
	vector<ll> b(n);
	ll cnt = 0;
	rep(i, n + 1) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	rep(i, n) {
		cnt += min(a[i]+a[i+1], b[i]);
		if (a[i] + a[i + 1] > b[i]) {
			if (a[i] < b[i]) {
				a[i + 1] -= (b[i] - a[i]);
			}
		}
		else {
			a[i] = 0;
			a[i + 1] = 0;
		}
	}
	cout << cnt << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n, c;
	cin >> n >> c;
	vvi d(c, vi(c));
	rep(i, 0, c) rep(j, 0, c) cin >> d[i][j];
	vvi cou(3, vi(c));
	rep(i, 0, n) rep(j, 0, n) {
		int x;
		cin >> x;
		cou[(i + j) % 3][x - 1]++;
	}
	int ans = INF;
	rep(i, 0, c) rep(j, 0, c) rep(k, 0, c) {
		if (i == j || j == k || k == i) continue;
		int tmp = 0;
		rep(x, 0, c) tmp += cou[0][x] * d[x][i];
		rep(x, 0, c) tmp += cou[1][x] * d[x][j];
		rep(x, 0, c) tmp += cou[2][x] * d[x][k];
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val n = br.readLine().toLong()

  tailrec fun digit(acc: Int, i: Long):Int =
    if(i == 0L) acc else digit(acc+1, i/10)

  tailrec fun rec(a: Long): Int =
    if(n % a == 0L) {
      val b = n / a
      Math.max(digit(0, a), digit(0, b))
    }
    else rec(a-1)

  val nSqrt = Math.sqrt(n.toDouble()).toLong()
  val ans = rec(nSqrt)

  println(ans)
}

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

using namespace std;

typedef long long int ll;

int main(){
    int n, k;
    cin>>n>>k;
    int val[n];
    for(int i =0;i< n;i++)cin>>val[i];
    // sort(val, val+n);
    double exp[n];
    double curr_sum = 0, max_sum;
    for(int i =0;i<n;i++)exp[i] = (val[i]*1.0+1.0)/2;
    // for(int i =0;i< n;i++)cout<<exp[i]<<' ';
    for(int i = 0;i< n;i++){
        if(i<k )curr_sum += exp[i];
        else{
            curr_sum = curr_sum - exp[i-k];
            curr_sum = curr_sum + exp[i];
        }
        if(max_sum < curr_sum )max_sum = curr_sum;
    }
    cout<<setprecision(10)<<max_sum;
}

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

string s;
string ans;

int main() {
    cin >> s;
    int frontM = 0, backM = 0;
    int front = stoi(s.substr(0,2));
    int back = stoi(s.substr(2,2));
    if (1 <= front && front <= 12) frontM = 1;
    if (1 <= back && back <= 12) backM = 1;
    if (frontM && backM) ans = "AMBIGUOUS";
    else if (frontM) ans = "MMYY";
    else if (backM) ans = "YYMM";
    else ans = "NA";
    cout << ans << endl;
    return 0;
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if (n >= 0) prime[0] = false;
    if (n >= 1) prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

vector<bool> like2017(int n) {
    auto pt = prime_table(n);
    vector<bool> like(n + 1, false);
    for (int i = 1; i <= n ; i += 2) {
        if (pt[i] & pt[(i + 1) / 2]) like[i] = true;
    }

    return like;
}

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

    auto like = like2017(100005);
    vi sum(100005, 0);
    for (int i = 1; i <= 100000; i++) {
        sum[i] = sum[i - 1] + (like[i] ? 1 : 0);
    }

    rep(i, Q) {
        int l, r; cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }





}

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


int main()
{
  string s, t;
  cin >> s >> t;
  int m = t.size();
  int c;
  string sub;
  int slen = (int)s.size();
  int tlen = (int)t.size();
  for(int i = 0; i<= slen - tlen; ++i){
    sub = s.substr(i, tlen);
    c = 0;
    for(int j = 0; j< tlen; ++j){
      if(sub[j] != t[j]) c++;
    }
    if(m > c) m = c;
  }
  cout << m << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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


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

int n;
signed main(){
  cin>>n;
  cout << (n+1)/2 << endl;
}




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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        ll t;
        std::cin >> t;
        t--;
        a[t] = i;
    }
    for (int i = 0; i < n; i++) {
        std::cout << a[i]+1<<" ";
    }
     cout << std::endl;
}


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

str="abcdefghijklmnopqrstuvwxyz"
char=[]
for i in range(26):
    char.append(str[i])
#print(char)
index=[i for i in range(26)]
#print(index)

alphabet=dict(zip(char,index))

#print(alphabet)
Taro=0
Hanako=0
for i in range(n):
    s = input().split()
    str1 = s[0]
    str2 = s[1]



    len1=len(str1)
    len2=len(str2)
    if len1>len2:
        for i in range(len2):
            if alphabet[str1[i]]>alphabet[str2[i]]:
                Taro+=3
                break
            elif alphabet[str1[i]]<alphabet[str2[i]]:
                Hanako+=3
                break
            elif i==len2-1:
                Taro+=3
    elif len1<len2:
        for i in range(len1):
            if alphabet[str1[i]]>alphabet[str2[i]]:
                Taro+=3
                break
            elif alphabet[str1[i]]<alphabet[str2[i]]:
                Hanako+=3
                break
            elif i==len1-1:
                Hanako+=3
    else:
        for i in range(len1):
            if alphabet[str1[i]]>alphabet[str2[i]]:
                Taro+=3
                break
            elif alphabet[str1[i]]<alphabet[str2[i]]:
                Hanako+=3
                break
            elif alphabet[str1[i]]==alphabet[str2[i]] and i==len1-1:
                Taro+=1
                Hanako+=1
    #print(i,":",Taro,Hanako)

print(Taro,Hanako)




Measured memory_bytes: 5616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

LL Q,H,S,D,n;
unsigned long long int sum;
int main()
{
	cin>>Q>>H>>S>>D;
	H=min(H,Q*2);
	S=min(H*2,S);
	S=min(Q*4,S);
	D=min(H*4,D);
	D=min(S*2,D);
	D=min(Q*8,D);
	cin>>n;
	sum=n/2*D+n%2*S;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
//import java.util.Scanner;
import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		//Scanner scan = new Scanner(System.in);
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String a = br.readLine();
		a = a.replaceAll("apple","1");
		a = a.replaceAll("peach","2");
		a = a.replaceAll("1","peach");
		a = a.replaceAll("2","apple");
		System.out.println(a);
	}
}

Measured memory_bytes: 24336
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323


#define TST 0

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    char input;
    cin >> input;
    if('A' <= input && input <= 'Z'){
        cout << 'A' << endl;
    }else{
        cout << "a" << endl;
    }

#if TST==1

#endif
}



Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int N,K,Y,X;
	
	scanf("%d",&N);
	scanf("%d",&K);
	scanf("%d",&X);
	scanf("%d",&Y);
	
	
	if(K<N){
		printf("%d\n",X*K+(N-K)*Y);
	}else{
		printf("%d\n",X*N);
	}
	
	
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

void SolveA()
{
	string s;
	cin >> s;

	const char *ss = s.c_str();

	int bee = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (ss[i] == '1')
		{
			bee++;
		}
	}
	printf("%d\n", bee);
}

void SolveB()
{
	int n;
	scanf("%d", &n);

	vector<int> A;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	int counter = 0;
	bool flagLoop = true;
	while (flagLoop)
	{
		bool flagAllEven = true;
		for (int i = 0; i < n; i++)
		{
			if (A[i] % 2 != 0)
			{
				flagAllEven = false;
				flagLoop = false;
			}
		}
		if (flagAllEven == true)
		{
			for (int i = 0; i < n; i++)
			{
				A[i] /= 2;
			}
			counter++;
		}
	}

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

// 公式の解説版
void AtCoderSolveB()
{
	// 個数の入力
	int N;
	scanf("%d", &N);

	// 番犬かつ答えを保持する変数
	int dmin = INT_MAX;

	for (int i = 0; i < N; i++)
	{
		// 要素の入力
		int A;
		scanf("%d", &A);
		
		// 2で割る操作を行った回数
		int d = 0;

		// 要素が偶数の間
		while (A % 2 == 0)
		{
			// 要素を2で割る
			A /= 2;
			// 割った回数を保持する
			d++;
		}

		// 割った回数の最小を保持する
		dmin = min(dmin, d);
	}

	// 結果出力
	printf("%d\n", dmin);
}

//bool vector_finder(std::vector<int> vec, int number) {
//	auto itr = std::find(vec.begin(), vec.end(), number);
//	size_t index = std::distance(vec.begin(), itr);
//	if (index != vec.size()) { // 発見できたとき
//		return true;
//	}
//	else { // 発見できなかったとき
//		return false;
//	}
//}

void SolveC()
{
	int N, K;
	scanf("%d %d", &N, &K);

	//int *numKind = new int[N]();
	vector<int> numKind;
	numKind.resize(N + 1, 0);
	int clock = 0;
	vector<int> kind;
	
	for (int i = 1; i < N + 1; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		//if (vector_finder(kind, tmp))
		//{
		//	numKind[tmp]++;
		//}
		//else
		//{
		//	kind.push_back(tmp);
		//	numKind[tmp]++;
		//	clock++;
		//}
		if (std::find(kind.begin(), kind.end(), tmp) != kind.end())
		{
			numKind[tmp]++;
		}
		else
		{
			kind.push_back(tmp);
			numKind[tmp]++;
			clock++;
		}
	}

	if (clock <= K)
	{
		printf("0\n");
		return;
	}

	int cntChange = 0;
	while (clock > K)
	{
		int minIdx = kind[0];
		for (int i = 0; i < kind.size(); i++)
		{
			if (numKind[minIdx] == 0)
			{
				minIdx = kind[i];
			}
			else
			{
				if (numKind[kind[i]] < numKind[minIdx])
				{
					minIdx = kind[i];
				}
			}
		}
		while (numKind[minIdx] > 0)
		{
			numKind[minIdx]--;
			cntChange++;
		}
		clock--;
	}

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

void AtCoderSolveC()
{
	// 個数, 種類制限数の入力
	int N, K;
	scanf("%d %d", &N, &K);

	// 要素数のカウントするvector
	vector<int> counter;
	// 0(1) ~ Nを0に初期化(1 ~ Nの範囲にしたほうがわかりやすいと思ったので)
	counter.resize(N + 1, 0);
	// 要素
	for (int i = 1; i <= N; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		counter[tmp]++;
	}

	// 降順にソートする
	sort(counter.rbegin(), counter.rend());

	// 数値を変更しなくていいボールの総数を求める
	int sumKeep = 0;
	for (int i = 0; i < K; i++)
	{
		sumKeep += counter[i];
	}

	// 書き換える必要がある回数(書き換えるボールの個数)
	int ans = N - sumKeep;

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

int main()
{
	//SolveA();
	//SolveB();
	//SolveC(); // ✕

	//AtCoderSolveB();
	AtCoderSolveC();
}



Measured memory_bytes: 1024
/*
 * Created by Dipta Das on 29-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, a[30];
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	for(int i = 2; i < n; i++){
		vector<int> vec;
		for(int j = 0, k = i - 1; j < 3; j++){
			vec.push_back(a[k++]);
		}
		
		sort(vec.begin(), vec.end());
		if(a[i] == vec[1]) {
			ans++;
		}
	}
	
	cout << ans << endl;
    


    return 0;
}



Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

r, d, x2000 = wi()
for i in range(10):
    x2000 = r * x2000 - d
    print(x2000)

Measured memory_bytes: 6736
#include<iostream>

using namespace std;

int main()
{
	int r, g, b, n, ans = 0;
	cin >> r >> g >> b >> n;

	for (int i = 0; i <= n; i += r)
	{
		for (int j = 0; j <= n - i; j += g)
		{
			if (i + j == n)
			{
				++ans;
				break;
			}
			else if ((n - i - j) % b == 0)
			{
				++ans;
			}
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define STB(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

const int inf = 0x3f3f3f3f;
const int N = 210;
int n, ans;
int dis[N]; bool vis[N];
int mp[N][N]; 
char s[N];

void DJ(int S) {
	int i, j, u;
	memset(dis, 0x3f, sizeof dis); dis[S] = 1;
	memset(vis, 0, sizeof vis); 
	STB(i, 1, n-1) {
		u = 0;
		STB(j, 1, n)
		if(!vis[j] && dis[j] < dis[u]) u = j;
		vis[u] = 1;
		
		STB(j, 1, n)
		if(mp[u][j]) dis[j] = min(dis[j], dis[u] + 1);
	}
	
	STB(i, 1, n) STB(j, 1, n)
	if(mp[i][j] && abs(dis[i] - dis[j]) != 1) return;
	STB(i, 1, n) ans = max(ans, dis[i]);
}

int main() {
	int i, j;
	scanf("%d", &n);
	STB(i, 1, n) {
		scanf("%s", s+1);
		STB(j, 1, n) mp[i][j] = s[j] - '0';
	}
	
	ans = -1;
	STB(i, 1, n) DJ(i);
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  vector<int> vec;
  REP(n,3) {
    int p; cin >> p;
    vec.push_back(p);
  }

  sort(begin(vec), end(vec));

  cout << vec[0] + vec[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //エラーの出ないエラーを起こした時にデバッグできる
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(){
  int  n, k;
  cin >> n >> k;
  vector<int> p(n);
  
   for (int i = 0; i < n; i++){
    cin >> p.at(i);
   }
  sort(p.begin(), p.end());
  int ans = 0;
  int index = 0;
  
  while(k>0){
    ans += p.at(index);
    index += 1;
    if (index == n)
      index = 0;
    k --;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

//非再帰トポロジカルソート 隣接リストを渡す 返り値のサイズがnじゃないならnot DAG
std::vector<ll> topo_sort(std::vector<std::vector<ll>>& graph) {
  ll n = graph.size();
  std::vector<ll> ret, num(n, 0);
  std::queue<ll> que;
  for(ll i=0;i<n;i++){
    for (ll j : graph[i]) num[j]++;
  }
  for (ll i = 0; i < n; i++) {
    if (num[i] == 0) que.push(i);
  }
  while (!que.empty()) {
    ll u = que.front();
    que.pop();
    ret.push_back(u);
    for (ll i : graph[u]) {
      num[i]--;
      if (num[i] == 0) que.push(i);
    }
  }

  return ret;
}
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n;
  std::cin>>n;

  std::vector<std::vector<ll>> graph(n);

  rep(i,1,n){
    ll a;
    std::cin>>a;

    a--;
    graph[a].push_back(i);
  }

  std::vector<ll> topo=topo_sort(graph),depth(n,MOD);

  for(ll i=n-1;i>=0;i--){
    ll now=topo[i];

    ll value=0;
    std::vector<ll> temp;
    for(ll next:graph[now])temp.push_back(depth[next]);

    std::sort(all(temp));

    rep(i,0,temp.size()){
      chmax(value,temp[i]+temp.size()-i);
    }

    depth[now]=value;
  }

  std::cout<<depth[0];

  return 0;
}

Measured memory_bytes: 7672
=begin
N M
P1 Y1
...
Pn Yn
=end

n, m = gets.chomp.split(" ").map(&:to_i)
pys = m.times.map do
  gets.chomp.split(" ").map(&:to_i)
end

pys_ordered = pys.sort_by do |p, y|
  y
end

prefectures = {}
results = {}

pys_ordered.each do |p, y|
  prefectures[p] ||= 0
  current = (prefectures[p] += 1)

  results[[p, y]] = sprintf("%06d%06d", p, current)
end

pys.each do |py|
  puts results[py]
end


Measured memory_bytes: 38100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct UnionFind{
	vector<int> d;
	UnionFind(int n) : d(n, -1){}
	int find(int x){
		if(d.at(x) < 0) return x;
		return d.at(x) = find(d.at(x));
	}
	bool unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d.at(x) > d.at(y)) swap(x, y);
		d.at(x) += d.at(y);
		d.at(y)= x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d.at(find(x)); }
};

int main(){
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> vp(m);
	rep(i, m){
		int a, b;
		cin >> a >> b;
		a--; b--;
		vp.at(i) = make_pair(a, b);
	}
	int ans = 0;
	rep(i, m){
		UnionFind uf(n);
		rep(j, m){
			if(j == i) continue;
			int a, b;
			tie(a, b) = vp.at(j);
			uf.unite(a, b);
		}
		int count = 0;
		rep(i, n){
			if(uf.d.at(i) < 0) count++;
		}
		if(count > 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), K = sc.nextInt();
		int ans = 1;
		for (int i = 0; i < N; i++) {
			if (ans * 2 > ans + K) {
				ans += K;
			} else {
				ans *= 2;
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()	
{
    showoff;
    int n,m,sum = 0;
    cin >> n >> m;
    vector<int>v(m+5);
    FOR(i,1,m+1)cin >> v[i],sum += v[i];
    if(n >= sum)cout << n-sum;
    else cout << -1;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int calc(int n){
    if(n == 1)return 1;
    return 1 + calc(n-1) * 2;
}

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

    int n,k;cin >> n >> k;
    vi a(n);
    rep(i,n)cin >> a[i];
    n--;
    int ans = 0;
    while(1){
        n -= (k-1);
        ans++;
        if(n <= 0)break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2,s3,s4;
    cin>>s1>>s2;
    cin.ignore();
    s3=s1;
    s4=s2;
    reverse(s1.begin(),s1.end());
 
    reverse(s2.begin(),s2.end());
 
    if(s1==s4 && s2==s3 ) cout<<"YES"<<endl;
    else                  cout<<"NO"<<endl;

    return 0;
}


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

int main()
{
    int a = 0, b = 0, c = 0;

    while (1) {
        int x, y, z;
        cin >> x >> y >> z;

        if (x < y) swap(x, y);
        if (y < z) swap(y, z);
        if (x < y) swap(x, y);

        if (x >= y + z) break;

        int tmp = x*x - y*y - z*z;
        if (tmp == 0) ++a;
        else if (tmp < 0) ++b;
        else ++c;
    }

    cout << a+b+c << " " << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 3020
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n,s;
	int a[101];
	while(cin >> n){
		if(n == 0)break;
		for(int i = 0; i < n; i++) cin >> a[i];
		cin >> s;

		int left = 0,right = n-1;
		int cnt = 0;
		while(1){
			if(left > right)break;
			int mid = (left + right) / 2;
			cnt++;
			if(a[mid] == s){
				break;
			}
			else if(a[mid] < s){
				left = mid + 1;
			}
			else
				right = mid - 1;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1144
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n,k=map(int,input().split())
    X=[0]*n
    Y=[0]*n
    for i in range(n):
        X[i],Y[i]=map(int,input().split())
    ans=INF
    for a in range(n):
        for b in range(n):
            for c in range(a+1,n):
                for d in range(b+1):
                    x0,x1=sorted([X[a],X[c]])
                    y0,y1=sorted([Y[b],Y[d]])
                    count=0
                    for i in range(n):
                        if x0<=X[i]<=x1 and y0<=Y[i]<=y1:
                            count+=1
                    if count>=k:
                        ans=min(ans,(x1-x0)*(y1-y0))
    print(ans)
resolve()

Measured memory_bytes: 47068
def main():

    a, b, c, d = map(int, input().split())

    while c > 0:
        c = c - b
        if c <= 0:
            print("Yes")
            return
        a = a - d
        if a <= 0:
            print("No")
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  dic = defaultdict(int)
  for i in range(N):
    dic[input()[:-1]] += 1

  max_ = max(dic.values())
  out = []
  for key, val in dic.items():
    if val == max_:
      out.append(key)

  print(*sorted(out), sep='\n')


if(__name__ == '__main__'):
  main()


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

int cnt[2][E5+1], mx[2][2], v[E5+1];

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cnt[0][i] = cnt[1][i] = 0;
	}

	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		cnt[i%2][v[i]]++;
	}

	for (int i = 0; i < n; ++i) {
		if (cnt[i%2][v[i]] > cnt[i%2][mx[i%2][1]]) {
			if (cnt[i%2][v[i]] > cnt[i%2][mx[i%2][0]]) {
				mx[i%2][1] = mx[i%2][0];
				mx[i%2][0] = v[i];
			} else if (v[i] != mx[i%2][0]) {
				mx[i%2][1] = v[i];
			}
		}
		/*if (i%2) {
			cout << '#' << mx[i%2][0] << ' ' << mx[i%2][1] << '\n';
		}*/
	}
	
	//cout << mx[0][0] << ' ' << mx[0][1] << '\n';
	//cout << mx[1][0] << ' ' << mx[1][1] << '\n';

	if (mx[0][0] == mx[1][0]) {
		cout << min(n-cnt[0][mx[0][0]]-cnt[1][mx[1][1]],n-cnt[0][mx[0][1]]-cnt[1][mx[1][0]]) << '\n';
	} else {
		cout << n-cnt[0][mx[0][0]]-cnt[1][mx[1][0]] << '\n';
	}

}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1408
S=input()
N=len(S)
list1=list(map(int,S))
ans1=0
for i in range(len(list1)):
    if i%2==0:
        if list1[i]==1:
            ans1+=1
    elif i%2==1:
        if list1[i]==0:
            ans1+=1
ans2=min(ans1,(N-ans1))
print(ans2)
        

Measured memory_bytes: 3956
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=15;
char s[N];int n;
int main(){
	scanf("%s",s+1),n=strlen(s+1);
	fp(i,1,n-1)if(s[i]=='A'&&s[i+1]=='C')return puts("Yes"),0;
	puts("No");
	return 0;
}

Measured memory_bytes: 256
<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
printf("%s %s %s%s", "a", hikaku($a,$b), "b", PHP_EOL);

function hikaku($A, $B){
    if($A > $B){
        return ">";
    }elseif($A == $B){
        return "==";
    }elseif($A < $B){
        return "<";
    }
}

Measured memory_bytes: 15176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int d, t, s, a, b, c;
    cin >> d >> t >> s >> a >> b >> c;
    if (t * s >= d) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        ans += s[i] == t[i];
    }
    cout  << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict';

function main(stdin) {
  const loses = stdin.split('').map(s => s === 'x' ? 1 : 0);

  if (loses.filter(s => s).length > 7) {
    console.log('NO');
  } else {
    console.log('YES');
  }  
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
def main():
    n = int(input())
    a = []
    for i in range(n):
        x, u = input().split()
        a.append((float(x), u))

    ans = 0
    for ai in a:
        x = ai[0]
        u = ai[1]
        if u == "JPY" :
            ans += x
        else:
            ans += 380000 * x

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] np;
            while (!(np = readNums()).SequenceEqual(new int[] { 0, 0 }))
            {
                var i = 0;
                var n = np[0];
                var p = np[1];
                var m = p;
                var a = new int[n];

                while(true)
                {
                    if (p == 0)
                    {
                        p = a[i];
                        a[i] = 0;
                    }
                    else
                    {
                        p--;
                        a[i]++;
                    }
                    if (a[i] == m)
                    {
                        Console.WriteLine(i);
                        break;
                    }
                    i = (++i % n);
                }
            }
        }
        
        static int[] readNums()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
    }
}

Measured memory_bytes: 6380
i_nums = []
x = True
while x == True:
    i_nums.append(list(map(int, input().split())))
    if i_nums[-1][0] == i_nums[-1][1] == 0:
        x = False
i_nums.pop()

for nums in i_nums:
    for i in range(nums[0]):
        for j in range(nums[1]):
            if i%2 == 0 and j%2 == 0:
                print('#', end='')
            elif i%2 == 0 and j%2 == 1:
                print('.', end='')
            elif i%2 == 1 and j%2 == 0:
                print('.', end='')
            elif i%2 == 1 and j%2 == 1:
                print('#', end='')
        print('')
    print('')



Measured memory_bytes: 7020
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001


int main(){
	
	int H,W;
	cin>>H>>W;
	
	int K;
	cin>>K;
	
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	
	int ans = Inf;
	
	for(int i=0;i<(1<<(H-1));i++){
		vector<vector<int>> X;
		X.push_back(vector<int>(1,0));
		int temp = 0;
		for(int j=0;j<H-1;j++){
			if((1<<j)&i){
				temp++;
				X.push_back(vector<int>(1,j+1));
			}
			else{
				X.back().push_back(j+1);
			}
		}
		
		/*
		for(int j=0;j<X.size();j++){
			for(int k=0;k<X[j].size();k++){
				cout<<X[j][k]<<',';
			}
			cout<<endl;
		}
		*/
		
		bool f2 = true;
		int C = 0;
		vector<int> cnt(X.size(),0);
		for(int j=0;j<W;j++){
			C++;
			if(C>=3000){
				f2=false;
				break;
			}
			for(int k=0;k<X.size();k++){
				for(int x=0;x<X[k].size();x++){
					if(S[X[k][x]][j]=='1')cnt[k] ++;
				}
			}
			bool f= true;
			for(int k=0;k<X.size();k++){
				if(cnt[k]>K){
					f=false;
					break;
				}
			}
			if(!f){
				temp++;
				for(int k=0;k<X.size();k++){
					cnt[k] = 0;
				}
				j--;
			}
		}
		if(f2)ans = min(ans,temp);
		
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include <unordered_set>
#include<set>
#include<time.h>
#include<queue>
#include<map>
#include<vector>
#define inf 1000000000
#define LL long long
#define ULL unsigned long long
#define dinf ~0uLL>>1
#define FO(i,n) for(LL i=0;i<n;i++)
#define FOD(i,n) for(LL i=n-1;i>=0;i--)
#define FOR(i,a,b,c) for(LL i=a;i<=b;i+=c)
#define FORD(i,a,b,c) for(LL i=a;i>=b;i-=c)
#define clr(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
#define H_J(a) ((a)*180.0/pi)
#define J_H(a) ((a)*pi/180.0)
#define lson l,mid,rt<<1
#define rson mid+1,r,(rt<<1)+1
#define eps 1e-8
#define zero(x) (abs(x)<eps?0:(x<0?-1:1))
#define printime printf("%.3lf\n",(double)clock() / CLOCKS_PER_SEC)

using namespace std;

const int maxn = 1e3+5;

int a[maxn],v[maxn];

struct H{
    int x,y;
}num[maxn];

bool cmp(H x,H y){
    return x.y > y.y || (x.y == y.y && x.x < y.x);
}


int main() {

    int num[15] = {0,111,222,333,444,555,666,777,888,999};
    int x;
    cin>>x;
    int ans = 0;
    for (int i =0;i<10;i++){
        if(x <=num[i]){
            ans = num[i];
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256