akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll flag1 = 0;  // 奇数が1つでもあれば1
    rep(i, n) {
        ll a;
        cin >> a;
        if(a%2 == 1) {
            flag1 = 1;
        }
    }

    ll ans = 1;
    rep(i, n-1) {
        ans *= 2;
    }

    if(!flag1) {  // すべて偶数のとき
        if(p == 1) {
            out(0);
            re0;
        }
        else {
            ans *= 2;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
def yoko():
    for h, line in enumerate(L):
        if line[q-1:q-1+p] != [' ']*p:
            h = h-1
            break
    for i in range(q-1, q-1+p):
        L[h][i] = '#'
    check(h, 1)
    
def tate():
    for h, line in enumerate(L):
        if line[q-1] != ' ':
            h = h-1
            break
    for i in range(h-p+1, h-p+1+p):
        L[i][q-1] = '#'
    check(h-p+1, p)

def check(h, c):
    while 0 < c:
        if L[h] == ['#']*5:
            del L[h]
        else:
            h += 1
        c -= 1
     
def add():
    c = 0
    for line in L:
        if line == [' ']*5:
            c += 1
        else:
            break
    for i in range(5-c):
        L.insert(0, [' ']*5)
        
def result():
    ans = 0
    for line in L:
        for v in line:
            if v == '#':
                ans += 1
    else:
        print ans

while True:
    n = input()
    if n == 0: break
    L = [[' ']*5 for i in range(5)]
    for i in range(n):
        d, p, q = map(int, raw_input().split())
        if d == 1:
            yoko()
        else:
            tate()
        add()
    else:
        result()

Measured memory_bytes: 4796
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int> s1;
int n,m,x[1000000+100],y[1000000+100];

int main()
{
    scanf("%d %d",&n,&m);
    for (int i=1;i<=m;i++)
    {

        scanf("%d %d",&x[i],&y[i]);
        if (y[i]==n)s1.insert(x[i]);
    }
    for (int i=1;i<=m;i++)
    {
        if (x[i]==1)
        {
            if (s1.find(y[i])!=s1.end()){cout<<"POSSIBLE"<<endl;return 0;}
        }
    }
    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
string ans="";
void make(string s,string t,int curs)
{
	int i;
	for(i=0;i<s.size();i++)
	{
		if(i<curs||i>=curs+t.size())
		{
			if(s[i]=='?')
				s[i]='a';
		}
		else
		{
			if(s[i]=='?')
				s[i]=t[i-curs];
			if(s[i]!=t[i-curs])
				return;
		}
	}
	ans=min(ans,s);
	if(ans=="")
		ans=s;
}
int main(){
	int i;
	string s,t;
	cin>>s>>t;
	for(i=0;i<s.size()-t.size()+1;i++)
		make(s,t,i);
	if(ans=="")
		cout<<"UNRESTORABLE";
	else
		cout<<ans;
	return 0;
}

Measured memory_bytes: 768
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H;
    cin >> W >> H;
    vector<pii> P(W+H);
    for (int i = 0; i < W; i++) {
        cin >> P[i].first;
        P[i].second = 0;
    }
    for (int i = 0; i < H; i++) {
        cin >> P[i+W].first;
        P[i+W].second = 1;
    }
    sort(P.begin(), P.end());
    int w = 0, h = 0;
    ll ans = 0;
    for (int i = 0; i < H+W; i++) {
        auto p = P[i];
        if (p.second == 0) {
            ans += (ll)(p.first) * (H+1-h);
            w++;
        } else {
            ans += (ll)(p.first) * (W+1-w);
            h++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(int argc,char** argv){
	int n;
	cin>>n;
	cout<<(n+1)/2;
	return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let (h, w, m): (usize, usize, usize) = (sc.input(), sc.input(), sc.input());

    let mut bombs = vec![];
    let mut h_cnt = vec![0usize; h];
    let mut w_cnt = vec![0usize; w];
    for _ in 0..m {
        let (h, w): (usize, usize) = (sc.input(), sc.input());
        bombs.push((h - 1, w - 1));
        h_cnt[h - 1] += 1;
        w_cnt[w - 1] += 1;
    }

    let h_max = h_cnt.iter().max().unwrap();
    let mut h_indices = vec![];
    for i in 0..h {
        if h_cnt[i] == *h_max {
            h_indices.push(i);
        }
    }

    let w_max = w_cnt.iter().max().unwrap();
    let mut w_indices = vec![];
    for i in 0..w {
        if w_cnt[i] == *w_max {
            w_indices.push(i);
        }
    }

    let point = h_indices.len() * w_indices.len();
    let mut point_cnt = 0;
    for &(y, x) in &bombs {
        if h_cnt[y] == *h_max && w_cnt[x] == *w_max {
            point_cnt += 1;
        }
    }
    let a = if point == point_cnt { 1 } else { 0 };
    println!("{}", h_max + w_max - a);
}


Measured memory_bytes: 16160
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
void Yay(bool condition){

    if(condition){
        p("Yay!");
    }else{
        p(":(");
    }
    return;
}

//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[500005],y[500005],z[500005];
ll sum[500005],lsum[500005];
char s[500005],t[500005];
bool dame;


int main(){
	cin >> n >> k;
	ll ans = 0;
	ll num = INF;
	for(i=k;i<k+n;i++){
		ans += i;
		if(abs(num) > abs(i))num = i;
	}
	ans -= num;
	p(ans);
	return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int a , b;
  cin >> a >> b;
  int k = a + b;
  if(a % 3 == 0 || b % 3 == 0 || k % 3 == 0)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define ff first
#define ss second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define pr pair<ll,ll>
#define mps map<string ,ll>
#define mpc map<char ,char>
#define mpl map<ll,ll>
#define tpl tuple<ll,ll,ll>
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
//	   cin>>t;
	      while(t--)
{

/*
2/*/
ll n;
cin>>n;
cout<<n+n*n+n*n*n;
ee;
}
return 0;
}



Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>
int main(){
double a,b,c,d,e;
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
e=(c-a)*(c-a)+(d-b)*(d-b);
printf("%lf\n",sqrt(e));
return 0;
}



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

using namespace std;

int N, K;
long long int A[100005];
long long int S[100005];

long long int MOD = 1000000007;

long long int p[200005];

long long int POW(long long int a, long long int k) {
	if (k == 0) {
		return 1;
	}

	if (k % 2 == 1) { return (a*POW(a, k - 1)) % MOD; }

	long long int ret = POW(a, k / 2);
	return (ret*ret) % MOD;
}

long long int INV(long long int K) {
	return POW(K, MOD - 2);
}

long long int C(long long int m, long long int n) {

	return (((p[m] * INV(p[m-n])) % MOD)*INV(p[n])) % MOD;
}

vector<long long int> V;

long long int geta = 1000000000;

int main(void) {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]+geta);
	}

	V.push_back(0);

	for (int i = 1; i <= N; i++) {
		S[i] = S[i - 1] + V[i];
		S[i] %= MOD;
	}

	p[0] = 1;
	for (long long int i = 1; i <= 200000; i++)
	{
		p[i] = p[i - 1] * i;
		p[i] %= MOD;
	}

	sort(V.begin(), V.end());

	long long int MAX = 0;

	for (int i = K; i <= N; i++) {
		MAX += (V[i] * C(i - 1, K - 1)) % MOD;
		MAX %= MOD;
	}

	long long int MIN = 0;
	for (int i = 1; i + K - 1 <= N; i++) {
		MIN += (V[i] * C(N - i, K - 1)) % MOD;
		MIN %= MOD;
	}

	long long int ans = (MAX - MIN + MOD) % MOD;

	//cout << "MAX= " << MAX << "  MIN= " << MIN << endl;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>

using namespace std;

const int maxN = 510, maxM = maxN * maxN;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < ll, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

struct edge {
    int u, v, w;
} e[maxM];

int n, m, res, ans, parent[maxN], d;
vector < int > a;

bool cmp(edge i, edge j) {
    return (i.w < j.w);
}

int get_root(int u) {
    ++d;
    if (u == parent[u]) return u;
    return (parent[u] = get_root(parent[u]));
}

bool unite(int u, int v) {
    d = 0; u = get_root(u); int du = d;
    d = 0; v = get_root(v); int dv = d;
    if (u == v) return false;
    if (du > dv) parent[u] = v;
    else parent[v] = u;
    return true;
}

int main() {
    cin >> n >> m;
    FORU(i, 1, m)
        cin >> e[i].u >> e[i].v >> e[i].w;
    sort(e + 1, e + m + 1, cmp);
    int sum = 0;
    FORU(i, 1, n) parent[i] = i;
    FORU(i, 1, m) {
        if (unite(e[i].u, e[i].v)) {
            a.PB(i); 
            sum += e[i].w;
        }
    }
    REPU(j, a.size()) {
    	auto ss = 0;
        FORU(i, 1, n) parent[i] = i;
        FORU(i, 1, m) {
            if (i == a[j]) continue;
            if (unite(e[i].u, e[i].v)) 
                ss += e[i].w;
        }
        bool check = true;
        FORU(i, 1, n)
            if (get_root(i) != get_root(1)) check = false;
        if (!check || ss != sum)
            ++res, ans += e[a[j]].w;
    }
    cout << res << " " << ans << endl;
}

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

int main() {
    int n,i,x;
    string com;
    list<int> L;
    list<int>::iterator it;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>com;
        if(com=="insert"){
            cin>>x;
            L.push_front(x);
        }else if(com=="delete"){
            cin>>x;
            for(it=L.begin();it!=L.end();it++){
                if((*it)==x){L.erase(it);break;}
            }
        }else if(com=="deleteFirst"){
            L.pop_front();
        }else if(com=="deleteLast"){
            L.pop_back();
        }
    }
    if(!L.empty()){
        it=L.begin();
        cout<<(*it);
        for(it++;it!=L.end();it++) cout<<" "<<(*it);
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 34256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int n; cin >> n;
  int d = 0;
  const int N = n;
  while (n) {
    d += n % 10;
    n /= 10;
  }
  cerr << "d: " << d << nl;
  if (N % d == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 256
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))
L = int(sys.stdin.readline())
Q = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

N += 2
X = [X[0]] + X + [X[-1]]
X = np.array(X, dtype=int)
# dp[d][i]: i番のホテルから(2^d)日で何個右までいけるか
dp = np.zeros((N.bit_length() + 1, N), dtype=int)
dp[0] = np.searchsorted(X, X + L, side="right") - 1
for d in range(1, N.bit_length() + 1):
    dp[d] = dp[d - 1][dp[d - 1]]
dp = dp.tolist()


def solve(l, r):
    ret = 0
    d = len(dp) - 1
    while l + 1 < r:
        while d > 0 and dp[d][l] >= r:
            d -= 1
        ret += 1 << d
        l = dp[d][l]
    if l < r:
        ret += 1
    return ret


ans = []
for a, b in AB:
    ans.append(solve(min(a, b), max(a, b)))
print(*ans, sep='\n')


Measured memory_bytes: 123048
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

#define MOD 1000000007

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

    ll count = 0;
    FOR(i, K, N + 2) {
        // select i numbers
        ll s = (0 + i - 1) * i / 2;
        ll g = (N - i + 1 + N) * i / 2;
        count = (count + (g - s + 1)) % MOD;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1000000007;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}

int printintN(int array[],const int num){
    for(int i=0;i<num;i++){printf("%d ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int experiment(){
    int N;cin>>N;
    vector<pair<string,pair<int,int> > > arr(N);
    for(int i=0;i<N;i++){
        cin >> arr[i].first >> arr[i].second.first;
        arr[i].second.second=i;
    }
    for(int i=0;i<N;i++){
        arr[i].second.first *= -1;
    }
    sort(arr.begin(),arr.end());
    FOR(i, 0, N){
        pf("%d\n",arr[i].second.second +1);
    }
    return 0;
}
signed main(){
    assert(1);
    experiment();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<P,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(5,0);
    for(ll i=0;i<5;i++)cin>>A[i];
    ll ans=0;
    for(ll i=0;i<5;i++){
        chmax(ans,(N+A[i]-1)/A[i]);
    }
    print(ans+4)

    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();
        String[] W = new String[N];
        String result = "Yes";

        for (int i = 0; i < N; i++) {
            W[i] = sc.next();
        }

        for (int i = 0; i < N - 1; i++) {
            if (W[i].charAt(W[i].length() - 1) != W[i + 1].charAt(0)) {
                result = "No";
                break;
            }
            for (int j = i + 1; j < N; j++) {
                if (W[i].equals(W[j])) {
                    result = "No";
                    break;
                }
            }
            if ("No".equals(result)) {
                break;
            }
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 22612
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ac = [0 for i in range(10**6+2)]



for i in a:
    ac[i] +=1
a = sorted(set(a))
count =0

for i in a:
    if ac[i]>0:
        if ac[i] == 1:
            count += 1
        for j in range(i,10**6+2,i):
            if not ac[j]==0:
                ac[j]=0


print(count)



Measured memory_bytes: 166312
#include<bits/stdc++.h>
	
	using namespace std;
	string st;
	int cs[90+5],s,P;
	int main()
	{
		cin>>st;
		for(int i=0;i<st.length();i++)
		{
			cs[st[i]]++;
			if(s==0)
			{
				if(st[i]==67)P=1;
				else if(P==1&&st[i]==70)P=2,s=1;
			}
			else break;
		}
		if(cs[67]>=1&&cs[70]>=1&&P==2)cout<<"Yes\n";
		else cout<<"No\n";
		
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
int main( void ){
	string S; cin >> S;
	ll N = S.size();
	ll cnt = 0, ans = 0;
	rep(i,0,N){
		if (S[N-i-1] == 'B'){
			ans +=i-cnt;
			cnt++;
		}
	}
	cout << ans << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(int n) {
    foreach (i; 1..10) {
        foreach (j; 1..10) {
            if (i * j == n) return true;
        }
    }
    return false;
}

void main() {
    int n = readint;
    writeln(calc(n) ? "Yes" : "No");
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,n=0,m=0;
  cin>>N;
  int ans=100000000;
  for(int i=0;i<=N;i++){
    int cnt=0;
    for(int j=i;j>0;cnt+=j%9,j/=9);
    for(int j=N-i;j>0;cnt+=j%6,j/=6);
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3560
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))

def dict(a):
    d={}
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_right(a, x)
    if i != len(a):
        return i
    else:            
        return -1

def main():
    try:
        n,k=In()
        ans=0
        for x in range(n):
            a,b=In()
            if (a**2+b**2)**0.5<=k:
                ans+=1
        print(ans)

    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    #for _ in range(I()):main()
    for _ in range(1):main()




Measured memory_bytes: 9940
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    for i in range(110):
        C -= B
        if C <= 0:
            print(YES)
            return
        A -= D
        if A <= 0:
            print(NO)
            return
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9208
#include<iostream>

int main(){
  int num = 0;
  char s[100000] = {0};
  char c[27] = {0};
  std::cin >> s;

  for(int i = 0; s[i]; i++)
    c[s[i] - 'a'] = 1;

  for(num = 0; c[num]; num++);

  if(num != 26) std::cout << (char)('a' + num);
  else std::cout << "None";

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>
#include <set>

using ul = unsigned long;

using namespace std;

using BS = bitset<10>;

struct edge {
    BS from;
    int to;
    ul hash() const { return ((ul)to << 10) + from.to_ulong(); }
};

bool operator<(const edge l, const edge r) {
    return l.hash() < r.hash();
}

int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) break;
        string s;
        cin >> s;
        set<edge> st[11];
        BS acc;
        bool safe = true;
        for (auto &c:s) {
            if (c == 'u') {
                acc.reset();
            } else {
                int d = c - '0';
                if (acc[d]) {
                    safe = false;
                    break;
                } else {
                    st[acc.count()].insert(edge{acc, d});
                    acc.set(d);
                }
            }
        }

        for (int i=1; i<=10; i++) {
            for (int j=1; j<=i; j++) {
                for (auto &ex:st[i]) {
                    for (auto &ey:st[j]) {
                        if ((ex.from & ey.from).count()) continue;
                        if (ey.from[ex.to] && ex.from[ey.to]) {
                            safe = false;
                            break;
                        } else if (ey.from[ex.to]) {
                            st[i+j].insert(edge{ex.from | ey.from, ey.to});
                        } else if (ex.from[ey.to]) {
                            st[i+j].insert(edge{ex.from | ey.from, ex.to});
                        }
                    }
                }
            }
        }
        cout << (safe ? "SAFE" : "UNSAFE") << '\n';
    }
    return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> lp(n, int(1e9));
    vector<bool> prime(n, true);
    ll ans = 1;
    for (int num = 2; num < n; ++num) {
        if (prime[num]) {
            lp[num] = num;
            for (int j = num; j < n; j += num) {
                prime[j] = false;
                lp[j] = min(lp[j], num);
            }
        }
    }
    for (int num = 2; num < n; ++num) {
        ll mul = 1;
        int number = num;
        int lastmul = 0;
        int previous = -1;
        while (number != 1) {
            if (lp[number] == previous) {
                ++lastmul;
            } else {
                mul *= (lastmul + 1);
                lastmul = 1;
                previous = lp[number];
            }
            number /= lp[number];
        }
        mul *= (lastmul + 1);
        ans += mul;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
    
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
    
using namespace std;
    
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    bool ok = 1;
    string s; cin >> s;
    for(int i = 0; i < (int)s.size() && ok; ++i){
        if(i & 1){
            if(s[i] == 'R') ok &= 0;
        }else{
            if(s[i] == 'L') ok &= 0;
        }
    }
    puts(ok ? "Yes":"No");
    return 0;
    
}

Measured memory_bytes: 3620
#include <stdio.h>
main()
{
	int a,b,c,x,y,z;
	scanf("%d%d%d",&a,&b,&c);

	if(a > b){
		x = a;
		a = b;
		b = x;
	}

	if(b > c){
		y = b;
		b = c;
		c = y;
	}

	if( a > b) {
		z = a;
		a = b;
		b = z;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <queue>

typedef long long ll;
using namespace std;

int main() {

    string s;
    cin >> s;
    if (s[0] != s[1] and s[1] != s[2] and s[2] != s[3]) 
        cout << "Good\n";
    else 
        cout << "Bad\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k;
    cin>>n>>k;
    int ara[n+5],dp[n+5];
    int i;
    for(i=0;i<n;i++)
    {
        cin>>ara[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(ara[i]-ara[j]));
        }
    }
    //for(int i=0;i<n;i++)
        //cout<<dp[i]<<" ";
    //puts("");
    cout<<dp[n-1]<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vi32> dic(n + 1, vi32(10, -1));
  rrep(i, n) {
    rep(j, 10) {
      dic[i][j] = dic[i + 1][j];
    }
    dic[i][s[i] - '0'] = i + 1;
  }
  int ans = 0;
  rep(d, 1000) {
    int x = d / 100;
    int y = (d - x * 100) / 10;
    int z = d % 10;
    vi32 ds = {x, y, z};
    int now = 0;
    bool ok = true;
    rep(i, 3) {
      if (dic[now][ds[i]] == -1) {
        ok = false;
        break;
      }
      now = dic[now][ds[i]];
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include<string.h>
int main(void)
{
    int n,i,a=0,b=0;
    char t1[100],t2[100];
    
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s %s",t1,t2);
        if(strcmp(t1,t2)==0)a++,b++;
        if(strcmp(t1,t2)>0)a+=3;
        if(strcmp(t1,t2)<0)b+=3;
    }
    printf("%d %d\n",a,b);

    return 0;
    
}



Measured memory_bytes: 2084
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N1, N2, N3, N4): (i64, i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let mut N = vec![N1, N2, N3, N4];
    N.sort();
    let ans = if N == vec![1, 4, 7, 9] { "YES" } else { "NO" };

    println!("{}", ans);
}


Measured memory_bytes: 4476
/*
 	安部NANA先輩大好き

 */
#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e9 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef vector<int> vi;
typedef pair<int,int> pii;
vector<pii> vii;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    int a=0,b=0,ans=0;
    cin >> n ;
    rep(i,0,n.size()){
        if((i%2)==0){
            if(n[i]=='p'){
                ans--;
              //  cout << "hiku" << i;
            }
        }else{
            if(n[i]=='g'){
                ans++;
                //cout << "kati" << i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int MAXX = 1e3 + 10;
int n, a[MAXX], b[MAXX];

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i] >> b[i];
	for(int i = 0; i + 2 < n; i++)
		if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2])
			return cout << "Yes" << endl, 0;
	return cout << "No" << endl, 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm> 
using namespace std;
long long n,ma,se,a[100100];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,greater<int>());
	for(int i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			if(ma==0)
				ma=a[i];
			else
				se=a[i];
			i++;		
		}
		if(ma!=0 && se!=0)
			break;
	}		
	cout<<ma*se<<endl;
} 

Measured memory_bytes: 1024
#define ll long long
#define ldd long double
#define mpp make_pair
#define pb push_back
#define ff first
#define ss second
#include<bits/stdc++.h>
using namespace std;
int main(){
    ll n,m,y,x,z,h,t,i,j,k;
    ll cnt=0,cnt1=0,sum=0,sum1=0,flag=0,flag1=0,maxi=LLONG_MIN,mini=LLONG_MAX,temp=0,ans=0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    sum=n+m;
    //cout<<sum<<"fg"<<endl;
    if(sum%2==0){
        cout<<sum/2<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }


return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
flg = True
for i in range(n//2):
    if s[i] != s[n-1-i]:
        flg = False
for i in range(n//4):
    if s[i] != s[n//2-1-i]:
        flg = False
print('Yes') if flg else print('No')

Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    string ans[n];
    //s[n]="zzzz";
    sort(s,s+n);
    ans[0]=s[0];
    int x=1;
    int max=0;
    int k=0;
    for(int j=0;j<n;j++){
        if(j<n-1){
            if(s[j]==s[j+1]){
                x++;
            }
            else{
                if(max<x){
                    k=0;
                    ans[k]=s[j];
                    max=x;
                }
                else if(max==x){
                    k++;
                    ans[k]=s[j];
                }

                x=1;
            }
        }
        else{
            if(max<x){
                k=0;
                ans[k]=s[j];
                max=x;
            }
            else if(max==x){
                k++;
                ans[k]=s[j];
            }
        }
    }
    
    
    for(int l=0;l<=k;l++){
       cout << ans[l] << endl;
    }

    
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<numeric>
#include<limits>
#include <cstdint>
#include<stack>
#include<queue>
using namespace std;
#define ll long long int
#define rep(N) for(ll i=0;i<N;i++)
#define rep2(N1,N2) for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(ll i=0;i<N1;i++)for(ll j=0;j<N2;j++)for(ll k=0;k<N3;k++)
#define For(i,N) for(ll i=0;i<N;i++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}

ll kai(ll x) {
	ll a = 1;
	if (x <= 0)
		return 1;
	else {
		for (ll i = 0; i < x; i++)
			a = a * (i + 1);
		return a;
	}
}

ll rui(ll x, ll y) {
	ll a = 1;
	for (ll i = 0; i < y; i++)
		a = a * x;
	return a;
}
const int nmax = 150;
int cccc[nmax][nmax];
ll comb(ll n, ll k) {
	if (n < k) {
		cout << "error n<k" << endl;
		return -1;
	}
	if (cccc[n][k] > 0)return cccc[n][k];
	if (k == 0 || n == k)return 1;
	return cccc[n][k] = comb(n - 1, k - 1) + comb(n - 1, k);
}

ll keta(ll a) {
	ll i = 1;
	while (1) {
		if (a < pow((ll)10, i))
			return i;
		i++;
	}
}
vector<ll> v;
ll n, m;
//m進数全探索
ll inc(ll a = n - 1) {
	if (a == 0 && v[0] == m) {
		v[0] = -1;
		return v[0];
	}
	if (v[a] == m) {
		v[a] = 0;
		inc(a - 1);
		return v[a];
	}
	else {
		++v[a];
		return v[a];
	}
}

ll mod = 1000000007;

ll modpowl(ll a, ll b) {
	if (b == 0) {

		return 1;
	}
	if (b == 1) {

		return a;
	}
	if (b >= 2) {
		if (b % 2 == 0) {
			ll c = modpowl((a*a) % mod, b / 2);
			c = c % mod;

			return c;
		}
		else {
			ll c = (modpowl((a*a) % mod, b / 2) % mod)*a;
			c = c % mod;

			return c;
		}
	}
}
ll gyo(ll N, ll A, ll B, ll y) {
	if (A != y && B != y)
		return y;
	else if (A == y)
		return B;
	else
		return A;
}

ll retsu(ll N, ll A, ll B, ll x) {
	if (A != x && B != x)
		return x;
	else if (A == x)
		return B;
	else
		return A;
}

pair<ll,ll> tenchi(ll x, ll y) {
	return make_pair(y, x);
}
int main() {
	cout.precision(20);
	ll a, b;
	cin >> a >> b;
	if (a< b) {
		rep(b)cout << a;
	}
	else
		rep(a)cout << b;
}




Measured memory_bytes: 256
/*
 *
 *  1. sprawdz corner cases
 *  2. sprawdz limity, jesli sie da pozamieniaj wszystkie lokalne zmienne na LL!
 *  3.  MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE
 *  4. lokalne zmienne, iteracja po tablicach dwuwymiarowych uwazaj
 *  5. SPRAWDZ CZY input jest POSORTOWANY jaki jest niezmiennik
 *
 *
 */
#include <algorithm>
#include <cstdio>
#include <iomanip> // std::setprecision
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>
#define FOR(x, y, z) for (int x = (y); x < (z); x++)
#define FORD(x, y, z) for (int x = (y); x >= z; x--)
#define REP(r, n) for (int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define SIZE(c) ((int)((c).size()))
#define FOREACH(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define ALL(u) (u).begin(), (u).end()
#define RALL(u) (u).rbegin(), (u).rend()
#define PB push_back
#define PF push_front
#define SZ(x) long long((x).size())
#define IS_IN(x, t) (t.find(x) != t.end())
#define BIT(n, i) (((n) >> (i)) & 1)

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) \
    {              \
    }
#endif

#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<LL> VI;
typedef pair<LL, LL> PR;

inline LL GCD(LL a, LL b)
{
    LL r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
};
inline LL LCM(LL a, LL b) { return a / GCD(a, b) * b; };
inline LL fpow(LL n, LL k, LL p)
{
    LL r = 1;
    for (; k; k >>= 1) {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
};
inline LL inv(LL a, LL p) { return fpow(a, p - 2, p); }

[[maybe_unused]] const LL MOD = (LL)1e9 + 7;
[[maybe_unused]] const LL MAXUS = 100001; //TYPEMAX(LL);
[[maybe_unused]] const LD PI = acos((LD)-1);
[[maybe_unused]] const LD epsilon = 1e-9;

template <typename T>
T input()
{
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e)
{
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

LL F[MAXUS];
LL ccnk(LL n, LL k)
{
    cout << n << " " << k;
    if (k < 0 || k > n)
        return 0;
    return F[n] / F[k] / F[n - k];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string inp;
    cin >> inp;
    int n = inp.size();
    list<int> cur;
    REP(i, n)
    {
        int v = inp[i];
        if (cur.size() >= 3) {
            cur.pop_front();
        }
        cur.PB(v);
        multiset<char> occ(cur.begin(), cur.end());
        for (auto e: occ) {
          if (occ.count(e) >= 2) {
              cout << i+2-cur.size() << " " << i+1 << endl;
            return 0;
          }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll A[111111];
  ll N,i;
  ll ans = 1;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> A[i];
  for(i=0;i<=N-1;i++){
    if(A[i]==0){ ans = 0;
   	 goto END;
               }
  }
  for(i=0;i<=N-1;i++){
    ans *= A[i];
    if(i<N-1){
      if(A[i+1] > 1000000000000000000 / ans) {
        ans = -1;
        goto END;
        }
      }
      }
  END:;
  cout << ans << endl;
}

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

int isPrime(int x) {
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	int i = 3;
	while (i <= sqrt(x)) {
		if ((x % i) == 0) return false;
		i += 2;
	}
	return true;
}

int main() {
	int in, num;
	cin >> num;
	int ans = 0;
	for (int i = 0; i < num; i++) {
		cin >> in;
		if(isPrime(in)) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3084