akhauriyash/Code-Regression huggingface dataset:
z,m=map(int,input().split());a=[[],[]];ans=0
for i in range(m):aa,bb=map(int,input().split());a[0].append(aa);a[1].append(bb)
def d(n,nl,ml):
  if sorted(nl+[n])==[i+1for i in range(z)]:return 1
  if n in nl:return 0
  l=len(ml[0]);ans=0
  for i in range(l):
    c=[ml[0][:i]+ml[0][i+1:],ml[1][:i]+ml[1][i+1:]]
    if ml[0][i]==n:ans+=d(ml[1][i],nl+[n],c)
    if ml[1][i]==n:ans+=d(ml[0][i],nl+[n],c)
  return ans
for i in range(m):
  if a[0][i]==1:
    c=[a[0][:i]+a[0][i+1:],a[1][:i]+a[1][i+1:]]
    ans+=d(a[1][i],[1],c)
print(ans)

Measured memory_bytes: 3064
n, C = map(int, input().split())
pro = [list(map(int, input().split())) for i in range(n)]

time = [0 for _ in range(2*10**5 + 2)]

for i in range(C):
    w = [0 for _ in range(2*10**5 + 2)]
    for s,t,c in pro:
        if c == i + 1:
            w[2*s-1] += 1
            w[2*t] -= 1
    for j in range(2*10**5+1):
        w[j+1] += w[j]
        if w[j+1]:
            time[j+1] += 1

print(max(time))


Measured memory_bytes: 119588
#include <stdio.h>
int main(){
 int a, b, d, r;
 double g, h, f;
 scanf("%d %d", &a, &b);
 g = a;
 h = b;
 d = a / b;
 r = a % b;
 f = g / h;
 printf("%d %d %lf\n", d, r, f);
 return 0;
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if (a == b){
		cout << "a == b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a < b" << endl;
	}

	return 0;
}

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

int main()
{

        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        scanf("%lld %lld %lld",&n,&k,&d); x=abs(n);

        fr=x/d; g=min(k,fr);  sc=g*d; tr=x-sc;  p=k-g;


        if(p%2==0)
        {
            printf("%lld\n",tr);
        }
        else
        {
            printf("%lld\n",d-tr);

        }








    return 0;
}





Measured memory_bytes: 3780
import math

n,d = map(int, input().split())
x = [0]*n
for i in range(n):
    x[i] = list(map(int, input().split()))

cnt = 0
for i in range(n):
    for j in range(n):
        value = 0
        if i<j:
            for k in range(d):
                value += (x[i][k]-x[j][k])**2
            if math.sqrt(value)%1 == 0:
                cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
double eps=1e-9;
ll inf=1e13;
void prod(ll& x,ll y){
	x*=y;
	if(x>=inf) x=inf;
}
int main(){
	ll N,A;
	cin>>N>>A;
	ll ans=N;
	rep1(i,40){
//		show(i);
		int xo=floor(pow(N,1.0/(i+1))-eps);
		if(xo<0) xo=0;
		for(ll x=xo;x<xo+2;x++){
			rep(a,i+1){
				ll pro=1;
				rep(b,a+1) prod(pro,x);
				rep(b,i-a) prod(pro,x+1);
//				show(x);
//				show(a+1);
//				show(pro);
				if(pro>=N){
					chmin(ans,i*A+x*(i+1)+i-a);
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  unordered_map<ll, ll> numCount;
  for (int i = 0; i < n; i++) numCount[a[i]]++;

  ll base = 0;
  for (auto &x: numCount) base += (x.second * (x.second - 1)) / 2;

  vector<ll> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = base - (numCount[a[i]] * (numCount[a[i]] - 1)) / 2 + ((numCount[a[i]] - 1) * (numCount[a[i]] - 2)) / 2;
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 10696
import math
k=int(input())
A=[[0 for i in range(k+1)] for j in range(k+1)]
s2=0
for i in range(1,k+1):
    for j in range(1,k+1):
        if i!=j:
            s2=s2+math.gcd(i,j)
            A[i][j]=math.gcd(i,j)
s1=0
for i in range(1,k-1):
    for j in range(i+1,k):
        for l in range(j+1,k+1):
            s1=s1+A[A[i][j]][l]

print(6*s1+3*s2+(k*(k+1))//2)

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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;

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

  ll n, t;
  cin >> n >> t;
  vector < ll > a(n + 1), b(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];

  ll dp1[n + 1][t + 1];
  memset(dp1, 0, sizeof(dp1));
  for(int i = 1; i <= n; i++){
    for(int j = 0; j <= t; j++){
      if(j - a[i] >= 0){
        dp1[i][j] = max(dp1[i - 1][j], b[i] + dp1[i - 1][j - a[i]]);
      }else dp1[i][j] = dp1[i - 1][j];
    }
  }

  ll dp2[n + 1][t + 1];
  memset(dp2, 0, sizeof(dp2));
  for(int j = 0; j <= t; j++){
    if(j >= a[n]) dp2[n][j] = b[n];
  }
  for(int i = n - 1; i > 0; i--){
    for(int j = 0; j <= t; j++){
      if(j - a[i] >= 0){
        dp2[i][j] = max(dp2[i + 1][j], b[i] + dp2[i + 1][j - a[i]]);
      }else dp2[i][j] = dp2[i + 1][j];
    }
  }

  ll ans = 0;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < t; j++){
      if(i != n) ans = max(ans, dp1[i - 1][j] + dp2[i+ 1][t - 1 - j] + b[i]);
      else ans = max(ans, dp1[n - 1][j] + b[n]);
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 141056
#include<stdio.h>

int linearSearch(int [],int ,int );

int main()
{
  int S[100000],key,n,q,i,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&key);
      if(linearSearch(S,n,key)==1)c++;
    }
  printf("%d\n",c);

  return 0;
}


int linearSearch(int S[],int n,int key)
{
  int  i;
  for(i=0;i<n;i++)
    {
      if(S[i]==key)return 1;
    }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

ll f(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  if (a % b == 0) {
    return ((a / b) * 2 - 1) * b;
  }

  return (a / b) * 2 * b + f(b, a % b);
}

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

  cout << n + f(x, n - x) << endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
m = [int(input()) for i in range(n)]

m.sort()

ans = 0
for i in range(n):
    if x >= m[i]:
        ans += 1
        x -= m[i]

while x >= m[0]:
    ans += 1
    x -= m[0]
    
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] HN = readLine();
		int H = Integer.parseInt(HN[0]);
		int N = Integer.parseInt(HN[1]);
		String[] a = readLine();
		for(int i=0;i<N;i++) {
			H-=Integer.parseInt(a[i]);
		}
		print(H<=0?"Yes":"No");
		
		
		//String[] s = readLine();
	}
	
	//functions here
	//note that all methods should be STATIC
	private static double getDistance(int[] p1,int[] p2) {
		double s = 0;
		for(int i=0;i<p1.length;i++) {
			s+=(p1[i]-p2[i])*(p1[i]-p2[i]);
		}
		return Math.sqrt(s);
	}
	
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}

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

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

    vector<string> s(n);

    vector<int> t(n);

    for (int i=0; i<n; i++) {
        cin >> s.at(i) >> t.at(i);
    }

    string x;
    cin >> x;

    int a=0;

    for (int i=0; i<n; i++){
        if (s.at(i) == x) {
            a = i+1;
            break;
        }
    }

    int ans=0;
    if (a<n) {
        for (int i=a; i<n; i++) {
            ans += t.at(i);
        }
    }

    cout << ans << endl;

}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
  cin >> a[i];
  }
  int x=0;
  while(1){
    for(int j=0; j<n; j++){
      if(a[j]%2 == 0){
        a[j] = a[j]/2;
      }
      else{
        cout << x << endl;
        return 0;
      }
    }
    x++;
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    cout<<max(a+b, max(a-b,a*b))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009

int main(){
    string a;
    cin >> a;
    ll ans = 0;
    bool flag = true;
    for(int i = a.size()-1;i >= 0;i--){
        if(i != 0){
            ans += 9;
            if(a[i] != '9') flag = false;
        }
        else{
            if(flag) ans += a[i] - '0';
            else ans += a[i] - '0' - 1;
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let X = read int

    let dp = Array.create (X + 1) false
    dp.[0] <- true

    for i in [100 .. X] do
        dp.[i] <- List.fold (fun s x -> s || dp.[i - x]) false [100 .. 105]

    if dp.[X] then 1 else 0
    |> printfn "%i"

    0

Measured memory_bytes: 19396
/*
    Mbak Sana Dong
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int arr[200200];
int dp[200200];
int main()
{
    int a,b;
    cin >> a >> b;
    if(a > 8 || b > 8) cout << ":(";
    else cout << "Yay!";
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007

using namespace std;

class Test {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a,b;
		in >> a >> b;
		if(a<=8&&b<=8)
			out << "Yay!\n";
		else
			out << ":(\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Test solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
  int n,k;cin>>n>>k;
  vector<int> h(n+1,0);
  int i,j,l;
  for(i=1;i<=n;i++)cin>>h.at(i);
  long long ans=0;
  vector<vector<long long>> dp(n+1,vector<long long>(n+1,0));
  if(k>=n)ans=0;
  else if(k==0)
  {
    for(i=1;i<=n;i++)ans+=max(0,h.at(i)-h.at(i-1));
  }
  else
  {
    for(i=1;i<=n;i++)
    {
      dp.at(i).at(1)=max(0,h.at(i)-h.at(0));
    }
    for(j=2;j<=n;j++)
    {
      for(i=j;i<=n;i++)
      {
        long long kan=123456789123456;
        for(l=j-1;l<=i-1;l++)
        {
          if(dp.at(l).at(j-1)+max(0,h.at(i)-h.at(l))<kan)
          {
            kan=dp.at(l).at(j-1)+max(0,h.at(i)-h.at(l));
          }
        }
        dp.at(i).at(j)=kan;
      }
    }
      ans=123456789123456;
    for(i=n-k;i<=n;i++)
    {
      ans=min(ans,dp.at(i).at(n-k));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
s = input()
s1 = int(s[:2])
s2 = int(s[2:])


if 0 < s1 <= 12 and 0 < s2 <= 12:
    print('AMBIGUOUS')
elif (s1 == 0 or s1 > 12) and 0 < s2 <= 12:
    print('YYMM')
elif (s2 == 0 or s2 > 12) and 0 < s1 <= 12:
    print('MMYY')
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<int> R,A,W,T;

int dp[2020][2020];
const int INF=1e9;

void chmax(int &a,int b){
  if(a<b) a=b;
}

int main(){
  cin>>N;
  R.resize(N);
  A.resize(N);
  W.resize(N);
  T.resize(N);
  rep(i,N) cin>>R[i]>>A[i]>>W[i]>>T[i];

  rep(i,N) T[i]--;
  for(int i=0;i<=N;i++) for(int j=0;j<=2000;j++) dp[i][j]=-INF;

  vector<pair<int,int>> v;
  for(int i=0;i<N;i++) v.push_back(mkp(T[i]+R[i],i));
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());

  for(int i=0;i<N;i++){
    int tar=v[i].second;
    int ndp[2020];
    for(int j=0;j<=2000;j++) ndp[j]=-INF;
    ndp[T[tar]]=A[tar];
    for(int j=0;j<=2000;j++){
      if(dp[i][j]==-INF) continue;
      dp[i+1][j]=dp[i][j];
      if(j-R[tar]>=0) chmax(ndp[min(j-R[tar],T[tar])],dp[i][j]+A[tar]);
    }

    for(int j=2000;j>=0;j--){
      if(ndp[j]==-INF) continue;
      if(j-R[tar]>=0) chmax(ndp[j-R[tar]],ndp[j]+W[tar]);
    }
    for(int j=0;j<=2000;j++) chmax(dp[i+1][j],ndp[j]);
  }

  int ans=0;
  for(int i=0;i<=2000;i++) chmax(ans,dp[N][i]);
  cout<<ans<<endl;


  return 0;
}



Measured memory_bytes: 18984
import collections

s = input()

mod = 2019
n = len(s)
t = [0]*(n+1)
for i in range(1,n+1):
    t[i] = (t[i-1] + int(s[n-i]) * pow(10, i-1, mod)) % mod
c = collections.Counter(t)
num = c.values()
ans = 0
for i in num:
    ans += i*(i-1) // 2

print(ans)

Measured memory_bytes: 75704
import math
n,m = map(int,input().split())

if abs(n-m)>=2:
    print(0)
if abs(n-m)==1:
    print(math.factorial(m)*math.factorial(n)%1000000007)
if n==m:
    print(math.factorial(m)*math.factorial(n)*2%1000000007) 

Measured memory_bytes: 5192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first;
	rep(i,n)in[i].second=i;
	sort(all(in));
	int co=0;
	rep(i,n)if(in[i].second%2==(i+1)%2)co++;
	cout<<co/2<<endl;
}
 
 







Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double
 
int mod=1000000007;
int fact[200005];
int inverse[200005];
int inv(int x)
{
    int r,y;
    for(r=1,y=mod-2;y>0;x=(x*x)%mod,y/=2)
        if(y%2==1)
            r=r*x%mod;
    return r;
}
int nCr(int n, int m)
{
    return fact[n] *inverse[m]%mod *inverse[n-m]%mod ;
}
int32_t main()
{
    IOS;
    fact[0]=1;
    inverse[0]=1;
    for(int i=1;i<200005;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
        inverse[i]=inv(fact[i])%mod;
    }
    int n,h,w;
    cin>>h>>w>>n;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    v.push_back({h,w});
    sort(v.begin(),v.end());
    int store[n+2]={};
    for(int i=0;i<=n;i++)
    {
        int ans=nCr(v[i].first+v[i].second-2,v[i].first-1);
        for(int j=0;j<=n;j++)
            if(v[j].first<=v[i].first && v[j].second<=v[i].second)
            {
                ans-=(store[j]*nCr(v[i].first+v[i].second-v[j].first-v[j].second,v[i].first-v[j].first))%mod;
                ans+=mod;
                if(ans>=mod)
                    ans%=mod;
            }
        store[i]=ans;
    }
    cout<<store[n]<<endl;
}

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    string s,t;
    string ans;
    cin>>n>>s>>t;
    
    for (ll i = 0; i < n; ++i){
        cout <<s[i]<<t[i];
    }
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  REP(i, SZ(s)) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  cout << s << endl;
}

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

int n, m, a, b, ans, c[10][10], order[10];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		c[a][b] = 1;
		c[b][a] = 1;
	}

	for (int i = 0; i < n; i++) {
		order[i] = i+1;
	}

	do {
		bool valid = (order[0] == 1);
		for (int i = 0; i < n-1; i++) {
			if (!c[order[i]][order[i+1]]) {
				valid = 0;
			}
		}

		if (valid) {
			ans++;
		}
	} while (next_permutation(order, order+n));

	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var tyuumon = input[0];
    var plus = 0;
    for (var s of tyuumon) {
        if (s === 'o') plus++;
    }
    console.log(700 + plus * 100);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 101000;
ll r[MN];
ll v[MN],w[MN],u[MN];
ll vt[MN],vb[MN],sn[MN];
int main() {
	ll x,k,q;
	scanf("%lld %lld ",&x,&k);
	r[0] = 0;
	for(int i=0;i<k;i++) {
		scanf("%lld ",&r[i+1]);
	}
	k++;
	sn[0] = -1;
	vt[0] = 0;vb[0] = 0;
	v[0] = x;w[0] = 0;u[0] = 0;
	for(int i=1;i<k;i++) {
		u[i] = u[i-1]+sn[i-1]*(r[i]-r[i-1]);
		v[i] = v[i-1]+sn[i-1]*(r[i]-r[i-1]);
		w[i] = w[i-1]+sn[i-1]*(r[i]-r[i-1]);
		vt[i] = vt[i-1];vb[i] = vb[i-1];
		if(v[i] > x) {
			vt[i] += v[i]-x;
			v[i] = x;
		}
		if(w[i] > x) {w[i] = x;}
		if(w[i] < 0) {
			vb[i] -= w[i];
			w[i] = 0;
		}
		if(v[i] < 0) {v[i] = 0;}
		sn[i] = sn[i-1]*-1;
	}
	scanf("%lld ",&q);
	while(q--) {
		ll t,a;
		scanf("%lld %lld ",&t,&a);
		int id = upper_bound(r,r+k,t)-r-1;
		//printf("%lld -> %lld, id %ld\n",w[id],v[id],id);
		if(a <= vb[id]) {
			a = w[id];
		} else if(a >= x-vt[id]) {
			a = v[id];
		} else {
			a += u[id];
		}
		a += sn[id]*(t-r[id]);
		a = max(a,0LL);
		a = min(a,x);
		printf("%lld\n",a);
	}
}


Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<queue>

typedef std::pair<int, int> P;

int main(){

	int n, r, l;
	std::cin >> n >> r >> l;

	std::vector<int>point(n, 0);
	std::vector<int>time(n, 0);

	std::priority_queue<P>que;

	int betime = 0;
	for (int i = 0; i < r; i++){
		int d, t, x;
		std::cin >> d >> t >> x;
		d--;

		while (!que.empty()){
			P res = que.top();

			if (res.first == point[-res.second]){
				time[-res.second] += (t - betime);
				break;
			}
			que.pop();
		}

		point[d] += x;
		que.push(P(point[d], -d));

		betime = t;
	}

	while (!que.empty()){
		P res = que.top();

		if (res.first == point[-res.second]){
			time[-res.second] += (l - betime);
			break;
		}
		que.pop();
	}

	int max = 0;
	for (int i = 1; i < n; i++){
		if (time[i]>time[max])max = i;
	}

	std::cout << max + 1 << std::endl;

	return 0;
}

Measured memory_bytes: 12052
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define NMAX (500000)
#define NIL (-1)

typedef struct {
	int id;
	int x;
	int y;
} Point;

typedef struct {
	int pid;
	int ppos;
	int left;
	int right;
} Node;

Point P[NMAX];
Node T[NMAX];
int num = 0;
priority_queue<int, vector<int>, greater<int> > ans;

bool lessX(Point& p1, Point& p2) { return p1.x < p2.x; }
bool lessY(Point& p1, Point& p2) { return p1.y < p2.y; }

void setPoint(int n)
{
	int x, y;

	rep(i, n) {
		scanf("%d %d", &x, &y);
		P[i].id = i;
		P[i].x = x;
		P[i].y = y;
	}
}

void init_kDTree(int n)
{
	rep(i, n) {
		T[i].pid = NIL;
		T[i].ppos = NIL;
		T[i].left = NIL;
		T[i].right = NIL;
	}
}

int make_kDTree(int left, int right, int depth)
{
	int mid, index;

	if (left >= right) return NIL;

	if (depth % 2 == 0) sort(P + left, P + right, lessX);
	else sort(P + left, P + right, lessY);

	mid = (left + right) / 2;
	index = num++;

	T[index].pid = P[mid].id;
	T[index].ppos = mid;
	T[index].left = make_kDTree(left, mid, depth + 1);
	T[index].right = make_kDTree(mid + 1, right, depth + 1);

	return index;
}

void search_kDTree(int index, int depth, Point* sp, Point* tp)
{
	int Pid, Ppos, Px, Py, Tleft, Tright;

	Pid = T[index].pid;
	Ppos = T[index].ppos;
	Tleft = T[index].left;
	Tright = T[index].right;

	Px = P[Ppos].x;
	Py = P[Ppos].y;

	if (((sp->x) <= Px && Px <= (tp->x))
		&& ((sp->y) <= Py && Py <= (tp->y))) {
		ans.push(Pid);
	}

	if (depth % 2 == 0) {
		if ((sp->x) <= Px && Tleft != NIL) search_kDTree(Tleft, depth + 1, sp, tp);
		if ((tp->x) >= Px && Tright != NIL) search_kDTree(Tright, depth + 1, sp, tp);
	}
	else {
		if ((sp->y) <= Py && Tleft != NIL) search_kDTree(Tleft, depth + 1, sp, tp);
		if ((tp->y) >= Py && Tright != NIL) search_kDTree(Tright, depth + 1, sp, tp);
	}
}

int main()
{
	int n, q, sx, tx, sy, ty;
	Point sp, tp;

	scanf("%d", &n);

	setPoint(n);
	init_kDTree(n);
	make_kDTree(0, n, 0);

	scanf("%d", &q);
	rep(i, q) {
		scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
		sp.x = sx;
		sp.y = sy;
		tp.x = tx;
		tp.y = ty;

		search_kDTree(0, 0, &sp, &tp);

		while (!ans.empty()) {
			printf("%d\n", ans.top());
			ans.pop();
		}
		putchar('\n');
	}

	return 0;
}


Measured memory_bytes: 16420
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,h,w,j,k;
    cin>>h>>w;
    char a[h][w];
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            cin>>a[i][j];
        }
    }
    bool ok=1;
    for(i=0; i<h; i++)
    {
        for(j=0; j<w; j++)
        {
            bool black=0;
            if(a[i][j]=='#')
            {
                if(i!=0&&a[i-1][j]=='#')
                    black=1;
                if(i!=h-1&&a[i+1][j]=='#')
                    black=1;
                if(j!=0&&a[i][j-1]=='#')
                    black=1;
                if(j!=w-1&&a[i][j+1]=='#')
                    black=1;
            if(!black){
              ok=0;break;
            }
            }
        }

    }
    if(ok)
    cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';

    return 0;
}





Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, 0, n)
    {
        cin >> h.at(i);
    }

    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());

    ll ans = 0L;
    rep(i, k, n) {
        ans += h.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#define pow2(x) ((x)*(x))
using namespace std;
struct three_d{
  double x, y, z;
} stars[31];
int n;


double distancex(three_d from, int to){
  return pow2(from.x-stars[to].x) + pow2(from.y-stars[to].y) + pow2(from.z-stars[to].z);
}

int main(){
  while((cin >> n), n){
    for(int i=0; i<n; i++) cin >> stars[i].x >> stars[i].y >> stars[i].z;
    double move = 0.5, maxdis;
    three_d now = {0, 0, 0};
    int moveto = 0, i;
    while(move > 0.000000001){
      for(int j=0;j<1000;j++){
	now.x = now.x * (1-move) + stars[moveto].x * move;
	now.y = now.y * (1-move) + stars[moveto].y * move;
	now.z = now.z * (1-move) + stars[moveto].z * move;
	moveto = 0; maxdis = 0;
	for(i=0; i<n; i++)
	  if(distancex(now, i) > maxdis){
	    maxdis = distancex(now, i);
	    moveto = i;
	  }
      }
      move /= 2;
    }
    printf("%.5lf\n", sqrt(maxdis));
  }
}

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

int main(){
    

    long long a,b,k;
    cin >> a >> b >> k;

    if(a >= k){

        cout << a -k << " " << b << endl;
    }else if(a + b >= k){

        cout << 0 << " " << a + b - k <<endl;
    }else {

        cout << 0 << " " << 0 <<endl;
    }
return 0;
}

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

int main() {
  long long N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  long long sum = 0;
  for (int i = 0; i < N; i++) sum ^= A.at(i);
  for (int i = 0; i < N; i++) {
    if (i) cout << " ";
    cout << (sum ^ A.at(i));
  }
  cout << endl;
}

Measured memory_bytes: 4668
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] input = Console.ReadLine().Split(' ');
            int b = int.Parse(input[0]);
            int c = int.Parse(input[1]);
            int[] output = new int[]{ b, c };
            if (b == 0 && c == 0) break;

               var d = from p in output orderby p select p;
               Console.WriteLine(string.Join(" ", d));
            
            
        }
    }
}


Measured memory_bytes: 18256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, n;std::cin >> n;
  vll num(3, 0);
  re(i, n){
    std::cin >> a;
    ll tmp = 0;
    if(a%2==0) tmp++;
    if(a%4==0) tmp++;
    num[tmp]++;
  }
  if(num[1]==0){
    if(num[2]>=num[0]-1) std::cout << "Yes" << '\n';
    else std::cout << "No" << '\n';
  }else{
    if(num[2]>=num[0]) std::cout << "Yes" << '\n';
    else std::cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    int N, K;
    cin>>N>>K;
    int a[N];
    rep(i, N){
        a[i]=0;
    }
    int d, b;
    rep(i, K){
        cin>>d;
        rep(j, d){
            cin>>b;
            a[b-1]=1;
        }
    }
    int cnt=0;
    rep(i, N){
        if(a[i]==0){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

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

const int N = (int)5e5 + 5 ;
const int LogN = (int)22 ;

int L[4 * N * LogN] ;
int R[N * 4 * LogN] ;
int T[N * 4 * LogN] ;
int version ;
int root[N * 4 * LogN] ;
int src[N] ;
unordered_map< int, int > pos ;

void build(int i, int b, int e) {
    if (b == e) {
        T[i] = 0 ;
        return ;
    }
    L[i] = ++version ;
    R[i] = ++version ;
    int mid = (b + e) >> 1 ;
    build(L[i], b, mid) ;
    build(R[i], mid + 1, e) ;
}

int update(int i, int b, int e, int pos, int v) {
    if (b > pos or e < pos)return i ;
    int cur = ++version ;
    if (b == e) {
        T[cur] = v ;
        return cur ;
    }
    int mid = (b + e) >> 1 ;
    L[cur] = update(L[i], b, mid, pos, v) ;
    R[cur] = update(R[i], mid + 1, e, pos, v) ;
    T[cur] = T[L[cur]] + T[R[cur]] ;
    return cur ;
}

int query(int i, int b, int e, int l, int r) {
    if (e < l or b > r)return 0 ;
    if (l <= b and e <= r)return T[i] ;
    int mid = (b + e) >> 1 ;
    return query(L[i], b, mid, l, r) + query(R[i], mid + 1, e, l, r) ;
}

int main() {
    //cout << N * 4 * LogN<< '\n' ;
    int test = 1, tc = 0;
    //scanf("%d", &test) ;
    while (test--) {
        int n, q; scanf("%d %d", &n, &q) ;
        // memset(L, 0, sizeof L) ;
        // memset(R, 0, sizeof R) ;
        // memset(T, 0, sizeof T) ;
        // memset(root, 0, sizeof root) ;
        // memset(src, 0, sizeof src) ;
        // pos.clear() ;
        version = 0 ;
        int cnt = 0 ;
        root[0] = 0 ;
        build(0, 1, n) ;
        for (int i = 1 ; i <= n ; ++i) {
            int x ; scanf("%d", &x) ;
            int k = pos[x] ;
            if (k) {
                ++cnt ;
                root[cnt] = update(root[cnt - 1], 1, n, k, 0) ;
            }
            ++cnt ;
            root[cnt] = update(root[cnt - 1], 1, n, i, 1) ;
            pos[x] = i ;
            src[i] = cnt ;
        }
        //printf("Case %d:\n", ++tc);
        while (q--) {
            int l, r ; scanf("%d %d", &l, &r) ;
            int res = query(root[src[r]], 1, n, l, r) ;
            printf("%d\n", res);
        }
    }
    return 0 ;
}

Measured memory_bytes: 254908
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll              long long int
#define ld              long double
#define mk              make_pair
#define pb              push_back
#define f               first
#define s               second
#define fo(i,a,b)       for(i=a;i<b;i++)
#define foe(i,a,b)      for(i=a;i<=b;i++)
#define all(x)          x.begin(),x.end()
#define vi              vector<int>
#define vl              vector <long long int>
#define pii             pair <int,int>
#define pll             pair <long long int, long long int>
#define vpii            vector< pair<int,int> >
#define vpll            vector < pair <long long int,long long int> >
#define MOD             1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
    boost;
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll sum=0;
    sum += min(k,a);
    k -= min(k,a);
    k -= min(b,k);
    sum -= k*(1);
    cout << sum;
    
    return 0;
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  bool x = false;
  int j = 0, ans = 0;
  for(int i = 0; i < N; i++){
    ans++;
    if(a.at(j) == 2){
      x = true;
      break;
    }
    j = a.at(j) - 1;
  }
  if(x){
    cout << ans;
  }else{
    cout << -1;
  }
  return 0;
}

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

int main(){
  int N; cin>> N;
  vector<pair<pair<string, int>, int>> rs(N);
  
  for(int i=0; i<N; i++){
    cin >> rs[i].first.first >> rs[i].first.second;
    rs[i].second = i+1;
    rs[i].first.second *= -1;
  }
  sort(rs.begin(), rs.end());
  
  for(int i=0; i<N; i++) cout << rs[i].second << endl;
  
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<cstdio>
#include<cmath>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int q = N;
  int ans[40];
  for (int i=0 ; i<40 ; i++) ans[i] = -1;
  int idx = 0;
  while (true) {
    if (q % 2 == 0) {
      q = q/(-2);
      ans[idx] = 0;
    } else {
      q = (q-1)/(-2);
      ans[idx] = 1;
    }

    if (q == 0) {
      ans[0] = 0;
      break;
    }

    if (q == 1) {
      ans[++idx] = 1;
      break;
    }

    idx++;
  }
  for (int i=39 ; i>=0 ; i--) {
    if (ans[i] != -1) printf("%d", ans[i]);
  }
  printf("\n");
}


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

int main() {
    long long A, B, C;
    cin >> A >> B >> C;
    if (A == B && A == C) {
        if (A % 2 == 1) {
            cout << 0 << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    long long ans = 0;
    while (true) {
        if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
            cout << ans << endl;
            return 0;
        }
        long long divA = A / 2;
        long long divB = B / 2;
        long long divC = C / 2;

        A = divB + divC;
        B = divA + divC;
        C = divA + divB;
        ans++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  trace(A, n);

  for(j=2;j<=n;j++)
    {
      key = A[j];
      i = j -1;
      while(i > 0 && A[i] > key)
	{
	  A[i+1] = A[i];
	  i = i - 1;
	}
      A[i+1] = key; 
      trace(A, n);
    }


  return 0;
}

Measured memory_bytes: 604
#include <iostream>

bool once = false;

using namespace std;
void dfs(string S, int i){
    if (i == 3){
        int sum = S[0] - '0';
        if(S[1] == '+') sum += S[2] - '0';
        else sum -= S[2] - '0';
        if(S[3] == '+') sum += S[4] - '0';
        else sum -= S[4] - '0';
        if(S[5] == '+') sum += S[6] - '0';
        else sum -= S[6] - '0';
        //cout << "debug:" << S << endl;
        if(sum == 7 && once == false) {
            cout << S << "=7" << endl;
            once = true;
        }
    } else {
        string Splus = S;
        string Sminus = S;
        dfs(Splus.insert(2 * i + 1, "+"), i + 1);
        dfs(Sminus.insert(2 * i + 1, "-"), i + 1);
    }
}

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

    dfs(S, 0);
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int x = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < N; i++) {
        cout << (x ^ a[i]) << endl;
    }
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k, x, y, cost;
    scanf("%d %d %d %d", &n, &k, &x, &y);
    int diff = n-k;
    if(diff>0){
        cost = (diff*y)+(k*x);
    }
    else{
        cost = (n*x);
    }
    printf("%d\n", cost);
    return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
// ver1.8
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  Vi a(n+1,-5),b(n+1),c(n);
  rep(i,0,n) cin >> a[i];
  rep(i,0,n) cin >> b[i];
  rep(i,0,n-1) cin >> c[i];
  
  int ans=0;
  rep(i,0,n){
    ans += b[a[i]-1];
    if(a[i+1]-a[i]==1) ans += c[a[i]-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 1000000007ll
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

bool cmp(pair <ll,string> a,pair <ll,string> b){
    if(a.F == b.F)
        return  b.S > a.S;
    return a.F > b.F;

}

void solve(){
   ll n;
   cin >> n;
   map <string,ll> ma;
   for(ll i=1;i<=n;i++){
    string s;
    cin >> s;
    ma[s]++;
   }    
   vector <pair <ll,string > > ve;
   for(auto it:ma){
    ve.pb({it.S,it.F});
   }
   sort(all(ve),cmp);
  // reverse(all(ve));
   ll mx = ve[0].F;
   for(auto it:ve){
    if(mx == it.F){
      cout << it.S << endl;
    }
   }
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
  //  cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

Measured memory_bytes: 28400
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int H, W, K;
	scanf("%d", &H);
	scanf("%d", &W);
	scanf("%d", &K);
	getchar_unlocked();
	char S[300][300];

	int kara[300] = {};
	int hajimete = 500;
	rep(i, H) {
		int aru = 0;
		rep(j, W) if ((S[i][j] = getchar_unlocked()) == '#') aru = 1;
		getchar_unlocked();
		if (!aru) kara[i] = 1;
		if (aru && hajimete == 500) hajimete = i;
	}

	int k = 0;
	int kotae[300][300];
	rep(i, H) {
		if (!kara[i]) {
			k++;
			int aru = 0;
			rep(j, W) {
				if (S[i][j] == '#') {
					if (aru == 0) aru = 1;
					else k++;
				}
				kotae[i][j] = k;
			}
		}
		else if (hajimete < i) {
			rep(j, W) kotae[i][j] = kotae[i - 1][j];
		}
	}
	for (int i = H - 1; i >= 0; i--) {
		if (kara[i] && hajimete > i) {
			rep(j, W) kotae[i][j] = kotae[i + 1][j];
		}
	}

	rep(i, H) rep(j, W) putint(kotae[i][j]);

	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 1792
using System;

public class AtCoderF
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        int[] hs = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                hs[i] = int.Parse(words[i]);
            }
        }

        int[] costs = new int[n];
        costs[0] = 0;
        costs[1] = Math.Abs(hs[0] - hs[1]);

        for (int i = 2; i < n; i++)
        {
            int a = costs[i - 2] + Math.Abs(hs[i] - hs[i - 2]);
            int b = costs[i - 1] + Math.Abs(hs[i] - hs[i - 1]);
            costs[i] = Math.Min(a, b);
        }

        Console.WriteLine(costs[n - 1]);
    }

}

Measured memory_bytes: 18912
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int a[] = new int[N];
		int max = 0;

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

		Arrays.sort(a);

		// maxは除いてよい。
		int end = N - 1 - 1;

		int r_max = max / 2;
		int result;
		int r = a[end];
		int pre_result = Math.abs(a[end] - r_max);

		for (i = end; i >= 0; i--) {
			result = Math.abs(a[i] - r_max);
			if (result == 0) {
				r = a[i];
				break;
			} else {
				if (result < pre_result) {
					r = a[i];
					pre_result = result;
				}

			}
		}
		System.out.println(max + " " + r);
	}
}


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

int main(){
  
  int N;
  int sum = 0;
  cin >> N;
  
  for(int i=0; i<N; i++){
    int l = 0, r = 0;
    cin >> l >> r;
    
    sum += r - l + 1;
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
bool dp[5010][5010];
int main(){
    int n,k;cin>>n>>k;
    ll a[5010];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    int ok=0;int ng=n+1;
    while(ng-ok>1){
        int mid=(ok+ng)/2;
        int s=a[mid];a[mid]=0;
        memset(dp,false,sizeof(dp));
        dp[0][0]=true;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=k;j++){
                dp[i][j]|=dp[i-1][j];
                if(j-a[i]>=0){
                    dp[i][j]|=dp[i-1][j-a[i]];
                }
            }
        }
        bool ans=false;
        for(int i=max(0,k-s);i<k;i++){
            ans|=dp[n][i];
        }
        a[mid]=s;
        if(ans){
            ng=mid;
        }else{
            ok=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 24832
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
	//for(Map.Entry<Object, Object> e: map.entrySet()){ ...
	public static void main(String[] args){
		try{
//-*-*- tp start -*-*-
			final int INF = Integer.MAX_VALUE, MINF = Integer.MIN_VALUE;
			SpecialComparator scomparator = new SpecialComparator();
			Scanner s = new Scanner(System.in);
//-*-*- tp end -*-*-
			//write a program...
			int[] in = new int[10];
			for(int i = 0; i < 10; i++) in[i] = s.nextInt();
			Arrays.sort(in);
			for(int i = 0; i < 3; i++) debugl(in[9-i]);
//-*-*- tp start -*-*-
		}catch(Exception e){
			e.printStackTrace();
		}
	}
//-*-*- tp end -*-*-
	//functions
//-*-*- tp start -*-*-
	private static void debugl(Object obj){
		System.out.println(obj);
	}
	private static void debug(Object obj){
		System.out.print(obj);
	}
	private static String toStrmd(Object[] obj){
		return Arrays.deepToString(obj);
	}
}

class SpecialComparator implements Comparator{
	private int index = 0;
	public void setIndex(int index){
		this.index = index;
	}
	public int compare(Object a, Object b){
		String[] sa = (String[])a;
		String[] sb = (String[])b;
		return (sa[index].compareTo(sb[index]));
	}
}
//-*-*- tp end -*-*-

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;
 
int main(){
  double r;
  cin >> r;
  cout << 2*r*3.1415 << endl;
 
}


Measured memory_bytes: 3788
n,a=int(input()),sorted(list(map(int,input().split())))
m,s=a[-1],[0]*(a[-1]+1)
for i in a:
  s[i]+=1
for i in set(a):
	if s[i]:
		for j in range(i*2,m+1,i):s[j]=0
print(s.count(1))

Measured memory_bytes: 40028
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)

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

cout<<abs(n-2)*abs(m-2)<<endl;
  return 0;
}


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

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

    string S;
    cin >> S;

    int ans = 1;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] != S[i + 1]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto m = readMatrix!char(H, W);
	int[][][] arr;
	arr ~= new int[][](H, W);
	arr ~= new int[][](H, W);
	arr ~= new int[][](H, W);
	arr ~= new int[][](H, W);

	foreach(y; 0..H) {
		int tmp;
		foreach(x; 0..W) {
			if(m[y][x] == '.') tmp++;
			else tmp = 0;
			arr[0][y][x] = tmp;
		}
	}
	foreach(x; 0..W) {
		int tmp;
		foreach(y; 0..H) {
			if(m[y][x] == '.') tmp++;
			else tmp = 0;
			arr[1][y][x] = tmp;
		}
	}
	foreach(y; 0..H) {
		int tmp;
		foreach_reverse(x; 0..W) {
			if(m[y][x] == '.') tmp++;
			else tmp = 0;
			arr[2][y][x] = tmp;
		}
	}
	foreach(x; 0..W) {
		int tmp;
		foreach_reverse(y; 0..H) {
			if(m[y][x] == '.') tmp++;
			else tmp = 0;
			arr[3][y][x] = tmp;
		}
	}

	int res;
	foreach(y; 0..H) {
		foreach(x; 0..W) {
			res = max(res, arr[0][y][x] + arr[1][y][x] + arr[2][y][x] + arr[3][y][x] - 3);
		}
	}
	res.writeln;
}

// =======================111=1===========

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii : toLower;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 74492