akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;

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

int main(){
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++){
        cin >> h[i];
    }
    long long dp[n];
    for (int i = 0; i < n; i ++){
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i > 1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1];
    
 
    return 0;
}

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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
vector<int> A;  
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
        //freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int n ;
    cin >> n ;
    for(int i = 0 ; i < 3*n ; i++){
    	int x ;
    	cin >> x ;
    	A.push_back(x) ;
    }
    sort(A.begin(), A.end()) ;
    int st = 0 ;int en = 3*n - 1 ;
    long long ans = 0 ;
    while(st < en){
    	ans += A[en-1] ;
    	st++ ;
    	en -= 2 ;
    }
    cout << ans << endl ;
    return 0 ; 
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main()
{
    if(LOCAL){
        freopen("input2.txt","r",stdin);
        freopen("A.out","w",stdout);
    }
    int n,a,b;
    si(n);si(a);si(b);
    int am=n-1-a;
    int bm=n-b;
    if((am-bm)%2==0) cout<<"Borys\n";
    else cout<<"Alice\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N; cin>>N;
    vector<int> a(N), b(N), c(N);
    vector<vector<int>>dp(N+10, vector<int>(3, 0));
    for (int i = 0; i < N; i++) {
        cin>>a[i]>>b[i]>>c[i];
    }

    for (int i = 0; i < N; i++) {
            dp[i+1][0]=max({dp[i+1][0], dp[i][1]+a[i], dp[i][2]+a[i]});
            dp[i+1][1]=max({dp[i+1][1], dp[i][0]+b[i], dp[i][2]+b[i]});
            dp[i+1][2]=max({dp[i+1][2], dp[i][0]+c[i], dp[i][1]+c[i]});
    }

    cout<<max({dp[N][0], dp[N][1], dp[N][2]})<<endl;

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s;
int main()
{
	cin>>s;
	rep(i,s.size())
	{
		if(s[i]=='?') s[i]='D';
		cout<<s[i];
	}
	cout<<endl;
	return 0;}

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

if x < a * a * b / 2:
    a2 = 2 * x / (a * b)
    print(math.degrees(math.atan2(b, a2)))
else:
    b2 = (2 * a ** 2 * b - 2 * x) / a ** 2
    print(90 - math.degrees(math.atan2(a, b2)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n; string s; cin>>n>>s;
    map<pair<string,string>,int> mp;
    rep(i,1<<n){
        string t="",u="";
        rep(j,n){
            if((1<<j)&i)t=s[j+n]+t;
            else u=s[j+n]+u;
        }
        mp[pair<string,string>(t,u)]++;
    }
    int ans=0;
    rep(i,1<<n){
        string t="",u="";
        rep(j,n){
            if((1<<j)&i)t+=s[j];
            else u+=s[j];
        }
        ans+=mp[pair<string,string>(t,u)];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 87040
#include <bits/stdc++.h>
using namespace std;
#define N 5010
const int mod=1e9+7;

struct edge {int nex,to;}e[N<<1];
int n,cnt;
int f[N][N],sz[N],g[N],h[N],head[N];

void add(int x,int y) {e[++cnt].to=y; e[cnt].nex=head[x]; head[x]=cnt;}

void dfs(int x,int fa) {
	f[x][sz[x]=1]=1;
	for (int i=head[x],v;i;i=e[i].nex)
		if ((v=e[i].to)!=fa) {
			dfs(v,x);
			for (int j=0;j<=sz[x]+sz[v];j++) g[j]=0;
			for (int j=1;j<=sz[x];j++)
				for (int k=0;k<=sz[v];k++)
					g[j+k]=(g[j+k]+1ll*f[x][j]*f[v][k])%mod;
			sz[x]+=sz[v];
			for (int j=1;j<=sz[x];j++) f[x][j]=g[j];
		}
	for (int i=2;i<=sz[x];i+=2)
		f[x][0]=(f[x][0]-1ll*f[x][i]*h[i]%mod+mod)%mod;
}

int x,y;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	h[2]=1;
	for (int i=4;i<=n;i+=2) h[i]=1ll*h[i-2]*(i-1)%mod;
	dfs(1,0);
	printf("%d\n",mod-f[1][0]);
	return 0;
}

Measured memory_bytes: 97280
#include<cstdio>
#include<algorithm>
using namespace std;
int n,W;
int v[100],w[100];
int dp[10001];
int main(){
    scanf("%d %d",&n,&W);
    for(int i=0;i<n;i++){
        scanf("%d %d",v+i,w+i);
    }
    fill(dp,dp+W+1,-1);
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=W;j>=0;j--){
            if(j-w[i]>=0&&dp[j-w[i]]>=0) dp[j]=max(dp[j-w[i]]+v[i],dp[j]);
        }
    }
    int res=0;
    for(int i=0;i<=W;i++){
        res=max(res,dp[i]);
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

int main(int argc,char **argv){
  int n;
  int min;
  int t;

  std::cin>>n;
  std::vector<int> a(n);
  for(int i=0;i<n;i++){
    std::cin>>a[i];
  }

  for(int i=1;i<n;i++){
    a[i]+=a[i-1];
  }

  min=1<<15;
  for(int i=0;i<n;i++){
    t=std::abs(2*a[i]-a[n-1]);
    if(t<min)min=t;
  }
  std::cout<<min<<std::endl;
  
  return 0;
}


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

int main()
{
    string S;
    cin >> S;
    for (auto c : S)
    {
        if (c == '7')
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A*B, C*D);
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N,K=map(int,input().split())
#lx=[]
lx=list(map(int,input().split()))


for i in range(N-K+1):
    ansi=min(abs(lx[i])+lx[i+K-1]-lx[i],abs(lx[i+K-1])+lx[i+K-1]-lx[i])
    if i==0:
        ans=ansi
    else:
        ans=min(ans,ansi)
print(ans)


Measured memory_bytes: 14720
/*input
2
*/

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n-1; ++i) {
    ans += (n-1)/i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		char matrix[][] = new char[h][w];
		for(int i = 0; i < h; i++){
			String str = sc.next();
			for(int j = 0; j < w ; j++){
				matrix[i][j] = str.charAt(j);
			}
		}

		boolean skipR[] = new boolean[h];
		boolean skipC[] = new boolean[w];
		for(int i = 0; i < h; i++){
			int count = 0;

			for(int j = 0; j < w; j++){
				if(matrix[i][j] == '#'){
					count++;
					break;
				}
			}

			if(count == 0){
				skipR[i] = true;
			}
		}

		for(int j = 0; j < w; j++){
			int count = 0;

			for(int i = 0; i < h; i++){
				if(matrix[i][j] == '#'){
					count++;
					break;
				}
			}

			if(count == 0){
				skipC[j] = true;
			}
		}

		for(int i = 0; i < h; i++){
			if(skipR[i]){
				continue;
			}

			for(int j = 0; j < w; j++){
				if(skipC[j]){
					continue;
				}

				System.out.print(matrix[i][j]);
			}
			System.out.println();
		}
	}

}


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


int main()
{
    int N;
    cin >> N;
    int array[N];
    int answer[N];
    answer[0] = 0;
    for(int i = 1;i < N ; i ++){
        answer[i] = 0;
        cin >> array[i];
        answer[array[i] - 1] ++;
    }

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

    

    



    

    return 0;
    

}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i = 0 ; i < n ; i++)
int main()
{
	int n, k;
	cin >> n >> k;
	int h[n];
	forn(i,n)cin >> h[i];

	int dp[n];
	forn(i,n)dp[i]=INT_MAX;
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i  = 2; i< n ;i++)
	{
		int j = 1 ;
		while(i-j >= 0 && j<=k)
		{
                      dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
		      j++;
		}
	}
	cout<<dp[n-1]<<"\n";


}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int n, a[1000005];
int vis[1000005], s, c[1000005];
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		a[i]=read();
		if(a[i]<1000) {
			c[a[i]]++;
			continue;
		}
		for(int j=a[i];j<=1000000;j=j+a[i]) {
			vis[j]++;
		}
	}
	for(int i=1;i<=n;i++) {
		int ok=1;
		for(int j=1;j<=1000;j++) {
			if(a[i]%j==0&&((a[i]==j&&c[j]>1)||(a[i]!=j&&c[j]))) {
				ok=0;
				break;
			}
		}
		if(vis[a[i]]>1) ok=0;
		if(ok) s++;
	}
	cout<<s; 
	
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int MAXN = 110;
int main(){
  int x[MAXN];
  int N, K,ans = 0;
  cin >> N >>K;
  double j;
  j = K /2;
  for (int i = 0; i < N; i++){
    cin >> x[i];
    if (x[i] > j){
      ans += 2*(K - x[i]);
    }
    else{
      ans += 2*x[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val abInput = scala.io.StdIn.readLine()
  val abArray = abInput.split(" ").map(_.toInt).toSeq
  val display = if (abArray(0) > abArray(1)) abArray(1) else abArray(0)
  val repeat = if (abArray(0) > abArray(1)) abArray(0) else abArray(1)
  var result = ""
  (1 to repeat).foreach(_ => result = result + display.toString)
  println(result)
}

Measured memory_bytes: 25300
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int i = 0;
        while(a > 0){
            a = a / b;
            i++;
        }
        System.out.println(i);

    }
}

Measured memory_bytes: 21972
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
        int x = sc.nextInt();
        int y = sc.nextInt();
      
        if ((x - (y * 2)) > 0) {
			System.out.println(x - (y * 2));
		} else {
			System.out.println(0);
		}
      
      
	} 
  
}

Measured memory_bytes: 21716
class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1..self).inject(:*) / k.factorial
  end

  def factorial
    return 1 if self.zero?

    (1..self).inject(:*)
  end
end

s = gets.to_i
sum = 0
(1..s/3).each do |e|
  sum += (e+(s-e*3)-1).combination(s-e*3)
  sum = sum % 1000000007
end

p sum

Measured memory_bytes: 18464
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) cout << 0;
	else {
	    long long min = a * b;
	    if (min > a * c) min = a * c;
	    if (min > b * c) min = b * c;
	    cout << min;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int a = scanner.nextInt();
        String s= scanner.next();
        if (a >= 3200) out.println(s);
        else out.println("red");
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int iku[26];
    REP(i,26) iku[i] = INF;
    vector<char> yaju;
    int n;
    scanf("%d",&n);
    REP(i,n){
        string tmp;
        int kari[26]={};
        cin >> tmp;
        REP(j,LEN(tmp)){
            kari[tmp[j]-97]++;
        }
        REP(j,26){
            iku[j] = min(iku[j],kari[j]);
        }
    }

    REP(i,26){
        REP(j,iku[i]) yaju.pb(i+97);
    }
    REP(i,SZ(yaju)) printf("%c",yaju[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string S;
    cin >> S;
    int ans = 0, a = 0;
    for (int i=0; i<S.length(); i++) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
            a++;
        }else {
            ans = max(ans, a);
            a = 0;
        }
    }
    ans = max(ans, a);
    cout << ans << endl;

}


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

int main() {
    int N, A;
    bool f = true;
    string r = "DENIED";

    cin >> N;

    rep(i, N) {
        cin >> A;
        if((A % 2) == 0) {
            if(((A % 3) != 0)&&((A % 5) != 0)) {
                f = false;
            }
        }
    }

    if(f) {
        r = "APPROVED";
    }

    cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ll mod=998244353;

map<ll,ll>dp;
ll a,b,c,d;

ll dfs(ll n)
{
    if(n==0)return 0;
    if(dp.count(n))return dp[n];
    if(n>4e18/d)dp[n]=4e18;
    else dp[n]=n*d;
    dp[n]=min(dp[n],dfs(n/2)+a+n%2*d);
    dp[n]=min(dp[n],dfs((n+1)/2)+a+n%2*d);
    dp[n]=min(dp[n],dfs(n/3)+b+n%3*d);
    dp[n]=min(dp[n],dfs((n+2)/3)+b+(3-n%3)%3*d);
    dp[n]=min(dp[n],dfs(n/5)+c+n%5*d);
    dp[n]=min(dp[n],dfs((n+4)/5)+c+(5-n%5)%5*d);
    return dp[n];
}

int main()
{
    ll T;
    scanf("%lld",&T);
    while(T--)
    {
        dp.clear();
        ll n;
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
        printf("%lld\n",dfs(n));
    }
    return 0;
}

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

int main()
{
 int n,m;
  cin>>n>>m;
  int p=n;
  vector<int> v(m+1);
  while(n--)
  {
    int t;
    cin>>t;
    while(t--)
    {
      int k;
      cin>>k;
      v[k]++;
    }
  }
  int ans=0;
  for(auto i:v)
    if(i==p)
      ans++;
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  string s;
  cin >> s;
  int left = 0;
  int right = s.size() - 1;
  int ans = 0;
  while (left <= right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    } else {
      if (s[left] == 'x') {
        left++;
        ans++;
      } else if (s[right] == 'x') {
        right--;
        ans++;
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*  Compro by NULL_CT©  */
//////////////////////////
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, lower, upper) for (long long i = lower; i < upper; i++)
#define ALL(list) (list.begin()), (list.end())

using namespace std;
typedef long long ll;
const int MOD = 10000007;
const long double PI = 3.14159265358979323846264338327950L;

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

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

vector<long long> divisor(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  return (ret);
}

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

//--------------------------------

void execute() {
  int n=input<int>();
  map<string,int> mp;
  REP(i,0,n){
    string s;
    cin>>s;
    mp[s]++;
  }

  int maxi=0;
  for(const auto& x : mp){
    int v=x.second;
    maxi=max(maxi,v);
  }
  for(auto it = mp.begin();it != mp.end();it++){
    if(it->second == maxi){
      cout<<it->first<<endl;
    }
  }
}

//--------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  execute();

  return(0);
}


Measured memory_bytes: 18628
while true
m,f,r=gets.split(" ").map(&:to_i)
break if m==-1 && f==-1 && r==-1

grade="F"
if m == -1 || f == -1
    grade="F"

elsif (m + f) >=80 
    grade= "A"
elsif (m + f) >=65
    grade= "B"
elsif (m + f)>=50
    grade="C"
elsif (m + f)>=30
    if r >= 50
        grade= "C"
    else
        grade= "D"
    end
end

puts grade


end








Measured memory_bytes: 6876
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_upd>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

const LL MOD = 998244353;
const LD EPS = 0.0000001 ;

LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

int main(void)
{
	int n, m; cin >> n >> m;
	LL ans = (n * (n - 1)) + (m * (m - 1));
	ans = ans / 2;
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		sc.close();
		System.out.println(a+a*a+a*a*a);

	}
}


Measured memory_bytes: 35712
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define MP(a, b) make_pair(a, b)
#define F first
#define S second

int main() {
	int N, M;
	while (cin >> N >> M, N || M) {
		vector<pair<int, int>> vp;
		REP(i, 0, N) {
			int d, p;
			cin >> d >> p;
			vp.push_back(MP(p, d));
		}

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

		int num = 0;
		bool flag = true;
		RREP(i, 0, vp.size()) {
			if (flag && vp[i].S < M) M -= vp[i].S;
			else if (flag && vp[i].S >= M) {
				num += (vp[i].S - M) * vp[i].F;
				M = 0;
				flag = false;
			}
			else num += vp[i].S * vp[i].F;
		}

		cout << num << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

int m, y, p, c, n;
ll f;
double r;

int main() {
	cin >> m;
	rep(t,m) {
		cin >> f >> y >> n;

		ll ans = 0;
		rep(i,n) {
			cin >> p >> r >> c;
			ll b = f;

			if(p == 0) {
				ll a = 0;
				rep(k,y) {
					a += (ll)(b * r);
					b -= c;
				}
				b = a + b;
			} else {
				rep(k,y) {
					b = (ll)(b * (1.0 + r) - c);
				}
			}

			if(b > ans) {
				ans = b;
			}
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1224
#include<iostream>
using namespace std;
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    if(n%x==0)
    {
        cout<<(n/x)*y<<endl;
    }
    else if(n%x!=0)
    {
        cout<<((n/x)+1)*y<<endl;
    }
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
int main(void)
{
char x[128], y[128], z[256], a[256];
int n, m, i, j, k = 0;

scanf("%s",&x);
scanf("%s",&y);

n = strlen(x);
m = strlen(y);

for(i = 0; i < 2 * n; i++){
z[i] = x[i % n];
}

for(i = 0; i < n; i++){
for(j = 0; j < m; j++){
a[j] = z[i + j];
}
a[m] = '\0';
//printf("%s\n",a);
if(strcmp(a, y) == 0){
	printf("Yes\n");
	k = 1;
break;
}
}
	if(k != 1)
	printf("No\n");

return 0;
}	

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
    if(s== "MON") puts("6");
    else
    if(s== "TUE") puts("5");
    else
    if(s== "WED") puts("4");
    else
    if(s== "THU") puts("3");
    else
    if(s== "FRI") puts("2");
    else
    if(s== "SAT") puts("1");
    else
    if(s== "SUN") puts("7");
    
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

t = []
if s[0] == '0':
    t.append(0)

c0 = 0
c1 = 0
for ss in s:
    if ss == '0':
        if c1 > 0:
            t.append(c1)
            c1 = 0
        c0 += 1
    else:
        if c0 > 0:
            t.append(c0)
            c0 = 0
        c1 += 1

if c1 > 0:
    t.append(c1)
if c0 > 0:
    t.append(c0)

if s[-1] == '0':
    t.append(0)

c_t = [0]
for tt in t:
    c_t.append(c_t[-1] + tt)

k2 = min(k, len(t) // 2)
ans = 0
j = 0
for i in range(k2 * 2 + 1, len(c_t), 2):
    ans = max(ans, c_t[i] - c_t[j])
    j += 2

# print(c_t)
print(ans)


Measured memory_bytes: 7932
class RmQ_segment_tree:
    """0 indexed"""

    def __init__(self, init_num, n):
        # represent tree as array
        # parent of k : (k - 1) // 2
        # children of k : 2 * k + 1 and 2 * k + 2
        self.ex = 0
        while(2 ** self.ex < n):
            self.ex += 1
        self.bottom = 2 ** self.ex - 1
        self.tree = [init_num for _ in range(2 ** (self.ex + 1) - 1)]

    def __str__(self):
        tmp = "tree structure\n"
        tree = str(self.tree)
        return tmp + tree + "\n"

    def update(self, position, new):
        # chi : child
        # par : parent
        chi = self.bottom + position
        self.tree[chi] = new
        for _ in range(self.ex):
            par = (chi - 1) // 2
            ano_chi = [chi + 1, chi - 1][chi % 2 == 0]
            self.tree[par] = min(self.tree[chi], self.tree[ano_chi])
            chi = par
        return True

    def find(self, left, right):
        left = self.bottom + left
        right = self.bottom + right
        ret = min(self.tree[left], self.tree[right])
        while(left != right):
            if left % 2 == 0:
                ret = min(self.tree[left], ret)
                left += 1
                continue
            if right % 2 == 1:
                ret = min(self.tree[right], ret)
                right -= 1
                continue

            left = (left - 1) // 2
            right = (right - 1) // 2
        ret = min(ret, self.tree[left])
        return ret


init_num = 2 ** 31 - 1
n, q = map(int, input().split())
RmQ = RmQ_segment_tree(init_num, n)

for _ in range(q):
    com, x, y = map(int, input().split())

    if com == 0:
        RmQ.update(x, y)
        # print(RmQ)
    else:
        print(RmQ.find(x, y))


Measured memory_bytes: 9028
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func mulMod(A, B [][]int) [][]int {
	H := len(A)
	W := len(B[0])
	K := len(A[0])
	C := make([][]int, W)
	for i := 0; i < W; i++ {
		C[i] = make([]int, W)
	}

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			for k := 0; k < K; k++ {
				C[i][j] += A[i][k] * B[k][j]
				C[i][j] %= mod
			}
		}
	}

	return C
}

func powModMatrix(A [][]int, p int) [][]int {
	N := len(A)
	ret := make([][]int, N)
	for i := 0; i < N; i++ {
		ret[i] = make([]int, N)
		ret[i][i] = 1
	}

	for p > 0 {
		if p&1 == 1 {
			ret = mulMod(ret, A)
		}
		A = mulMod(A, A)
		p >>= 1
	}

	return ret
}

// 思いつかなかったので写経
func main() {
	sc.Split(bufio.ScanWords)

	N, K := getInt(), getInt()
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, N)
		for j := 0; j < N; j++ {
			A[i][j] = getInt()
		}
	}

	ret := powModMatrix(A, K)

	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			ans += ret[i][j]
			ans %= mod
		}
	}

	out(ans)
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5;
int a,b;
int main()
{
	scanf("%d",&a);
	b=(int)(a/1.08);
	bool ok=0;
	for(int i=b-1;i<=b+1;++i){
		if((int)(i*1.08)==a){
		printf("%d\n",i);
		ok=1;
		break;
		}
	}
	if(!ok)printf(":(");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=998244353;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
int dp[3001][3001];
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int a,b,c,d;cin>>a>>b>>c>>d;
    for(int i=a;i<=c;i++)
    {
        for(int j=b;j<=d;j++)
        {
            if(i==a && j==b)
            {
                dp[i][j]=1;
            }
            else if(i==a)
            {
                dp[i][j]=MOD(dp[i][j-1]*i);
            }
            else if(j==b)
            {
                dp[i][j]=MOD(dp[i-1][j]*j);
            }
            else
                dp[i][j]=MOD(MOD(dp[i][j-1]*i)+MOD(dp[i-1][j]*j)-MOD(dp[i-1][j-1]*(i-1)*(j-1)));
            // cout<<dp[i][j]<<" ";
        }
        // cout<<endl;
    }
    cout<<dp[c][d]<<endl;
    return 0;
}

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

string s;
int n;
set<ll> st;

int main(){

  ll ans=0;
  
  cin>>s;
  n=s.size();
  int m=n-1;
  for(int i=0;i<(1<<m);i++){
    ll sum=0;
    ll num=0;
    for(int j=0;j<n;j++){
      num=num*10+(s[j]-'0');
      if(j==n-1 || i>>j&1){
        sum+=num;
        num=0;
      }
    }
    ans+=sum;
    st.insert(sum);
  }
  /*
  ll ans=0;
  for( ll x : st ){
    ans+=x;
    cout<<x<<endl;
  }
  */
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/10 10:54 下午
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double d = scanner.nextDouble();
        double t = scanner.nextDouble();
        double s = scanner.nextDouble();
        System.out.println(d/s <= t?"Yes":"No");
    }
}


Measured memory_bytes: 37188
import itertools
S = input()
L = [i for i in range(2*len(S)-1)]
i = 0
res = []
for j in range(len(L)):
    if j%2 == 0:
        L[j] = S[j//2]
    else:
        L[j] = ''
res.append(L)
def procedure(L,i,res):
    #L = List
    #i = number of '+' to put.(<=len(S)+1)
    #res = List witch we will accumulate [1,'',2,'+',3],[1,'+',2,'',3]
    Search_base = list(itertools.combinations([i for i in range(len(L)-1) if i%2 !=0], i))
    #[(1, 3), (1, 5), (3, 5)] for ([1,'',2,'',3,'',4],2)
    temp = []
    for element in L:
        temp.append(element)
    for j in range(len(Search_base)):
        for number in Search_base[j]:
            #print(number)
            temp[number] = '+'
        res.append(temp)
        #print('reboot')
        temp = [element for element in L]
        #print(temp)
    return res
Formulas = [procedure(L,i,[]) for i in range(len(S))]
#[[['1', '', '2', '', '3']], [['1', '+', '2', '', '3'], ['1', '', '2', '+', '3']], [['1', '+', '2', '+', '3']]]
#Formulas[1] = [['1', '', '2', '', '3']]
#Formulas[2] = [['1', '+', '2', '', '3'], ['1', '', '2', '+', '3']]
#Formulas[3] = [['1', '+', '2', '+', '3']]
#よって読み込みは：For liste in Formulas, for sous-liste in liste...

for liste in Formulas: #'+'i個ずつで見ていく。
    #スペースを除去して [1,2,'+',3] 除去する必要ないかも？🙄
    for sous_liste in liste:
        while '' in sous_liste:
            sous_liste.remove('')
#[[['1', '2', '3']], [['1', '+', '2', '3'], ['1', '2', '+', '3']], [['1', '+', '2', '+', '3']]]
res = 0
composant = ''
Found = []
for liste in Formulas:
    for sous_liste in liste:
        for i in range(len(sous_liste)):
            if sous_liste[i] != '+':
                composant += sous_liste[i] #'+'にぶち当たるまで、strの形でつなげて行く。
            elif sous_liste[i] == '+':
                res += int(composant)
                composant = '' #'+'にぶち当たったら、resに足して、リセットしてやり直す。
        if composant != '':
            Found.append(res+int(composant)) #Case 1への対応。
        else:
            Found.append(res)
        composant = ''
        res = 0
for element in Found:
    res += element
print(res)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#define bye return 0
#define speedOne ios::sync_with_stdio(false)
#define speedtwo cin.tie(0)
typedef long long int lli;
typedef long long ll;
using namespace std;
int main()
{
    speedOne;
    speedtwo;
    int t;
    string s;
    cin >> s;
    if(s=="RRR") cout << '3'<<endl;
    else if((s[0]=='R' && s[1]=='R') ||(s[1]=='R' && s[2]=='R')) cout << '2' << endl;
    else if(s=="SSS") cout << '0'<<endl;
    else cout << '1' << endl;
    
	bye;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split())) 
klists = []
B = [A[0]]
for i in range(N-1):
    if B[i] > A[i+1]:
        k = B[i]-A[i+1]
        klists.append(k)
        A[i+1] = A[i+1] + k
    B.append(A[i+1])
        
print(sum(klists))



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll n, m, k; cin >> n >> m >> k;
    vll a(n), suma(n+1, 0); 
    rep(i, n) {
        cin >> a[i];
        suma[i+1] = suma[i] + a[i];
    }
    vll b(m), sumb(m+1, 0);
    rep(i, m) {
        cin >> b[i];
        sumb[i+1] = sumb[i] + b[i];
    }
    
    ll kk;
    ll mx = 0;
    
    rep(i, n+1){
        kk = k;
        kk -= suma[i];
        if(kk < 0) {
            break;
        }
        auto it = upper_bound(all(sumb), kk);
        it--;
        ll tmp = it - sumb.begin();
        ll ans = i + tmp;
        mx = max(mx, ans);
    }
    
    cout << mx << endl;    
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1<<29;
const double PI = acos(-1);
int main() {
    int R; cin >> R;
    cout << setprecision(10) << 2 * R * PI << endl;

    return 0;
}

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

const long long int INF = 1e14;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

bool visited[100002];
int A[100002];

int howmany(int N){
    int now = 1;
    Rep(i,N){
        now = A[now];
        // visited[now]=true;
        // if (visited[now]) cout << -1 << endl; return 0;
        if (now==2) return i;
    }
    return -1;
}

int main(){
    int N,a,now;
    cin >> N;
    Rep(i,N){
        cin >> a;
        A[i] = a;
    }

    cout << howmany(N) << endl; return 0;
}


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

int main(){
  int N,num=0;
  string s;
  map<string, int> score;
  vector<pair<int, string>> pea;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> s;
    if (score.count(s)) {
    	score[s]+= 1;
    }else{
      score[s]=1;
    }
  }

  for (auto p : score) {
	auto a = p.second;
    auto b = p.first;
  	pea.push_back(make_pair(a,b));
  }
  sort(pea.begin(), pea.end());
  reverse(pea.begin(), pea.end());
  int max =0;
  stack<string> name;
  for(auto j: pea){
    if(max<=j.first){
    	name.push(j.second);
      	max=j.first;
    }
  }
  while(!name.empty() ){
    cout << name.top() << endl;
  	name.pop();
  }
}

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

int main() {
    int s;
    cin >> s;
    int a[2000000] = {};
    bool flag[10000] = {};
    a[0] = s;
    flag[a[0]] = true;
    int i = 1;
    while(1) {
        if (a[i - 1] % 2 == 0) a[i] = a[i - 1] / 2;
        else a[i] = a[i - 1] * 3 + 1;
        if (flag[a[i]]) {
            cout << i + 1 << endl;
            return 0;
        }
        flag[a[i]] = true;
        i++;
    }
}


Measured memory_bytes: 8064
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int vs[200000+10];
int cs1[200000+10];
int cs2[200000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%d", &vs[i]);
  }
  REP(i, n) {
    cs1[i+1] = max(cs1[i], vs[i]);
  }
  for(int i = n-1; i >= 0; --i) {
    cs2[i] = max(cs2[i+1], vs[i]);
  }
  REP(i, n) {
    printf("%d\n", max(cs1[i], cs2[i+1]));
  }
  
  return 0;
}


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

int main() {
 double n; cin >> n;
 double count = 0;
 for(int i = 1; i <= n; i++) {
   if (i % 2 == 1) {
     count++;
   }
 }
 cout << setprecision(9) << count / n << endl;
}


Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

nm = readints()
a = readints()
sum = 0
for i in range(nm[0]):
    sum += a[i]
touhyou = sum*(1/(4*nm[1]))
cnt = 0
for i in range(nm[0]):
    if a[i] >= touhyou:
        cnt += 1
if cnt >= nm[1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3832
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp = 0;
	int a, b;
	int n; cin >> n;
	string p = "", q = "", x;
	REP(i, n){
		cin >> x;
		p += x;
	}
	REP(i, n){
		cin >> x;
		q += x;
	}
	//cout << p << " " << q << endl;
	queue<pair<string, int>> qu;
	qu.push(make_pair("",0));
	while(!qu.empty()){
		string now;
		int used;
		tie(now, used) = qu.front();
		//cout << now << endl;
		qu.pop();
		if(now.size() == n){
			tmp++;
			if(now == p) a = tmp;
			if(now == q) b = tmp;
		}
		REP1(i, n){
			if(used & 1 << i) continue;
			else{
				qu.push(make_pair(now+to_string(i), used | 1 << i)); 
			}
		}
	}
	cout << abs(a-b) << endl;
}

Measured memory_bytes: 2816
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	if (N > 999) console.log('ABD')
	else console.log('ABC')
}

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


Measured memory_bytes: 21956
import java.util.*;

class Main {
    // 
    static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intの最大値 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a==b){
            if(a==c){
                System.out.println("No");
            }else{
                System.out.println("Yes");
            }
        }else if(b==c){
            System.out.println("Yes");
        }else if(a==c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 21844
x,y=map(int, input().split())
ans=10**10
if x<=y:ans=min(ans,y-x)
if -x<=y:ans=min(ans,y+x+1)
if x<=-y:ans=min(ans,-y-x+1)
if -x<-y:ans=min(ans,-y+x+2)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  map<string,int> blue;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    blue[S]++;
  }
  int M;
  cin >> M;
  map<string,int> red;
  for(int i=0; i<M; i++){
    string S;
    cin >> S;
    red[S]++;
  }
  int ans = 0;
  for(auto m: blue){
    chmax(ans,(int)(m.second - red[m.first]));
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    string s;
    cin >> s;

    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if(s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(){
  int N, S;
  cin >> N >> S;
  long int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  long long int F[N+1][S+1];
  F[0][0]=1;
  for(int j=1;j<S+1;j++){
    F[0][j]=0;
  }
  
  for(int i=1;i<N+1;i++){
    for(int j=0;j<S+1;j++){
      if(j-A[i-1]<0){
        F[i][j]=F[i-1][j]*2;
      }else{
        F[i][j]=F[i-1][j]*2 + F[i-1][j-A[i-1]];
      }
      F[i][j] = F[i][j]%998244353;
    }
  }
    
  cout << F[N][S];
  return 0;
}


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

int GCD(int a, int b){
    return b? GCD(b, a % b) : a;
}

int LCM(int a, int b) {
    return a * b / GCD(a, b);
}

int main(void) {
    int n;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout << LCM(n, 2) << "\n";
    return 0;
}

Measured memory_bytes: 256