akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<long long int, int, greater<long long int> > mp;
    for(int n=0; n<N; n++) {
        long long int A;
        cin >> A;
        mp[A]++;
    }
    
    long long int x[2]={0};
    int cnt=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        if(itr->second>=2) {
            x[cnt] = itr->first;
            cnt++;
            itr->second -= 2;
        }
        
        if(cnt>1) break;
        
        if(itr->second>=2) {
            x[cnt] = itr->first;
            cnt++;
        }
        
        if(cnt>1) break;
    }
    
    cout << x[0]*x[1] << endl;

    return 0;
    
}

Measured memory_bytes: 6528
#include <iostream>
#include<string>
using namespace std;
int main(){
    string S;
    cin>>S;
    int sum;
    sum=700;
    for(int i=0; i<3; i++){
        if(S[i]=='o'){
            sum=sum+100;
        }
    }
        
    cout<<sum;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  vector<string> ss(3);
  cin >> ss[0] >> ss[1] >> ss[2];

  int now = 0;

  vector<int> cnt(3);
  rep(i, 3) cnt[i] = 0;
  
  int ans = 0;
  while(true){

    int next = int(ss[now][cnt[now]] - 'a');
    cnt[now]++;
    
    if(cnt[next] == ss[next].length()){
      ans = next;
      break;
    }
    
    
    now = next;

  }

  cout << char('A' + ans) << endl;



  return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};


int main() {
    cout<<fixed<<setprecision(10);

    int n,q; cin>>n>>q;
    dsu d(n);

    rep(_,q){
        int t,u,v;
        cin>>t>>u>>v;
        if(t==0){
            d.merge(u,v);
        }else{
            if(d.same(u,v)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }

    return 0;

}

Measured memory_bytes: 4024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAllGreen solver = new CAllGreen();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAllGreen {
        private int d;
        private int[] c;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            d = in.nextInt();
            int g = in.nextInt();
            int[] p = new int[d];
            c = new int[d];
            for (int i = 0; i < d; i++) {
                p[i] = in.nextInt();
                c[i] = in.nextInt();
            }
            out.println(solve(g, p));
        }

        private int solve(int g, int[] p) {
            if (g <= 0) {
                return 0;
            }
            int min = Integer.MAX_VALUE;
            for (int i = 0; i < d; i++) {
                if (p[i] == 0) {
                    continue;
                }
                int score = (i + 1) * 100;
                if (p[i] * score >= g) {
                    min = Math.min(min, (g + score - 1) / score);
                    //System.out.println(i+"-[a]->"+(g + score - 1) / score);
                    continue;
                }
                if (p[i] * score + c[i] >= g) {
                    min = Math.min(min, p[i]);
                    //System.out.println(i+"-[b]->"+p[i]);
                    continue;
                }
                int[] q = new int[d];
                System.arraycopy(p, 0, q, 0, d);
                q[i] = 0;
                int s = solve(g - c[i] - (p[i] * score), q) + p[i];
                //System.out.println(i+"-[c]->"+s);
                min = Math.min(min, s);
            }
            return min;
        }

    }
}



Measured memory_bytes: 145320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 998244353
#define N 200001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int t, n, k, a, b;
vector<pair<int,int>> off;
ll dp[N], suffDP[N + 1];
void printArray(int*, int);

ll sum(int idx, int l, int r) {
    if(r == n - 1)
        return suffDP[idx + l];
    
    return (suffDP[idx + l] - suffDP[idx + r + 1] + M) % M;
}

ll solve(int idx) {
    if(idx == n - 1) return 1;

    ll ans = 0;
    int f = 0;
    for(int i=0; i<k && !f; i++) {
        if(off[i].s + idx < n)
            ans = (ans + sum(idx, off[i].f, off[i].s)) % M;
        else if(off[i].f + idx >= n)
            f = 1;
        else {
            ans = (ans + sum(idx, off[i].f, n - 1)) % M;
            f = 1;
        }
    }

    return ans;
}

int main() {
    scanf("%d %d", &n, &k);
    for(int i=0; i<k; i++) {
        scanf("%d %d", &a, &b);
        off.push_back({a, b});
    }

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

    suffDP[n] = 0;
    for(int i=n-1; i>=0; i--) { 
        dp[i] = solve(i);
        suffDP[i] = (dp[i] + suffDP[i + 1]) % M;
    }

    printf("%lld\n", dp[0]);
	return 0;
}

void printArray(int *nums, int n) {
    for(int i=0; i<n; i++) printf("%d ", nums[i]);
    printf("\n");
}

Measured memory_bytes: 6944
x=int(input())
if 400 <= x < 600:
  print(8)
elif 600 <= x < 800:
  print(7)
elif 800 <= x < 1000:
  print(6)
elif 1000 <= x < 1200:
  print(5)
elif 1200 <= x < 1400:
  print(4)
elif 1400 <= x < 1600:
  print(3)
elif 1600 <= x < 1800:
  print(2)
elif 1800 <= x < 2000:
  print(1)

Measured memory_bytes: 9132
#include<string>
#include<set>
#include<map>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;
int n,a[101000],b[100100],g;
int find_(int l, int r, int x){
    if(l == r)
        return l;
    int m = (l+r) / 2;
    if(a[m] < x)
        return find_(m+1, r, x);
    return find_(l, m, x);
}
int gcd(int x, int y){
    if(y == 0)
        return x;
    if(x < y) x^=y^=x^=y;
    return gcd(y, x%y);
}

int main(){
    int flag = 0;
    scanf("%d%d",&n,&g);
    for(int i = 1; i <= n; i ++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    for(int i = 2; i <= n; i ++){
        b[i] = a[i] % a[1];
    }
    
    sort(b+1, b+1+n);
    int j = 0;
    for(; b[j] == 0 && j <= n; j ++);
    int tem = b[j];
    for(int i = j+1; i <= n; i ++){
        tem = gcd(b[j], tem);
    }
    if(g > a[n])
        flag = 0;
    else{
        int ss = find_(1, n+1, g);
        if(tem != 0)
            for(int i = ss; i <= n; i ++){
                if((a[i]-g) % tem == 0)
                    flag = 1;
            }
        else
            for(int i = ss; i <= n; i ++){
                if((a[i]-g) % a[1] == 0)
                    flag = 1;
            }
    }
    if(flag)
        printf("POSSIBLE");
    else
        printf("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,QQ;
  cin>>N>>QQ;
  Graph G(N+1);
  REP(i,N-1){
    ll A,B;
    cin>>A>>B;
    G[A].PB(B);
    G[B].PB(A);
  }
  
  ll CNT[N+1];
  bool SEEN[N+1];
  RREP(i,N){
    CNT[i]=0;
    SEEN[i]=false;
  }
  
  REP(i,QQ){
    ll P,X;
    cin>>P>>X;
    CNT[P]+=X;
  }
  
  queue<ll> Q;
  Q.push(1);
  SEEN[1]=true;
  
  while(!Q.empty()){
    ll v=Q.front();
    Q.pop();
    FORE(nv,G[v]){
      if(SEEN[nv]) continue;
      SEEN[nv]=true;
      Q.push(nv);
      CNT[nv]+=CNT[v];
    }
  }
  
  RREP(i,N) cout<<CNT[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 18404
# gcd
def gcd(a, b):
	return gcd(b, a % b) if b != 0 else a

N = int(input())
L = [int(x) for x in input().split()]

max_gcd = L[0]

for i in range(1, N):
    max_gcd = gcd(max_gcd, L[i])

print(max_gcd)


Measured memory_bytes: 14252
#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() {
  string a,x,c;
  cin >> a >> x >> c;

  cout << a.at(0) << x.at(0) << c.at(0) << endl;
}





Measured memory_bytes: 3564
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
    ll N,M;
    cin>>N>>M;
    if (M<N) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;





   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A = sc.nextInt()
  val B = sc.nextInt()

  val x = (A, B) match {
    case (a, b) if a == b => "Draw"
    case (1, _) => "Alice"
    case (_, 1) => "Bob"
    case (a, b) if a > b => "Alice"
    case (a, b) if a < b => "Bob"
  }

  println(x)
}


Measured memory_bytes: 25524
I,R=input,range
n=int(I())
s=[I()for i in R(n)]
a=0
for i in R(n):
 if all(s[(i+j)%n][k]==s[(i+k)%n][j]for j in R(n)for k in R(j+1,n)):a+=n
print(a)

Measured memory_bytes: 74452
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)) cout<<"B"<<endl;
	else cout<<"A"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define N 100005
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

bool check(int mid){
  return false;
}

ll serch(ll ok,ll ng) {
	while (abs(ok-ng) > 1) {
		int mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

ll dp[N][3];

int main(){
  ll n,k,r,s,p;
  string t;
  ll ans=0,m=0;
  cin>>n>>k>>r>>s>>p>>t;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      dp[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
      if(i<k){
        if(t[i]=='r'){
          dp[i][2]+=p;
        }else if(t[i]=='s'){
          dp[i][0]+=r;
        }else{
          dp[i][1]+=s;
        }
      }else{
        if(t[i]=='r'){
          dp[i][2]=max(dp[i][2],max(dp[i-k][0],dp[i-k][1])+p);
          dp[i][0]=max(dp[i][0],max(dp[i-k][1],dp[i-k][2]));
          dp[i][1]=max(dp[i][1],max(dp[i-k][2],dp[i-k][0]));
        }else if(t[i]=='s'){
          dp[i][2]=max(dp[i][2],max(dp[i-k][0],dp[i-k][1]));
          dp[i][0]=max(dp[i][0]+r,max(dp[i-k][1],dp[i-k][2])+r);
          dp[i][1]=max(dp[i][1],max(dp[i-k][2],dp[i-k][0]));
        }else{
          dp[i][2]=max(dp[i][2],max(dp[i-k][0],dp[i-k][1]));
          dp[i][0]=max(dp[i][0],max(dp[i-k][1],dp[i-k][2]));
          dp[i][1]=max(dp[i][1]+s,max(dp[i-k][2],dp[i-k][0])+s);
        }
      }
  }
  for(int i=n-1;i>=n-k;i--){
    for(int j=0;j<3;j++){
      m=max(m,dp[i][j]);
    }
    ans+=m;
    m=0;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    println(min(a * n, b))
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<string> ans;
  REP(i, n-m+1){
    bool ok = true;
    REP(j, m){
      if(s[i+j] != t[j] && s[i+j] != '?') ok = false;
    }
    if(ok){
      ans.emplace_back(s.substr(0, i)+t);
      if(i+m < n) ans.back() += s.substr(i+m);
    }
  }
  m = ans.size();
  if(!m){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  REP(i, m){
    REP(j, n) if(ans[i][j] == '?') ans[i][j] = 'a';
  }
  sort(ALL(ans));
  cout << ans[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;

int n,m;

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b)
{
	return a/gcd(a,b)*b;
}

int main()
{
	while(cin>>n>>m)
	{
		cout<<gcd(n,m)<<" "<<lcm(n,m)<<endl;
	}

	return 0;
}

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

using namespace std;

int f(int x){
  if (x % 2 == 0) return x / 2;
  else return 3*x + 1;
}

int main(){
	int s;
  	cin >> s;
  	int i = 1, now = f(s);
  	vector<int> buf;
  	buf.push_back(s);
  	while(find(buf.begin(), buf.end(), now) == buf.end()){
      i++;
      buf.push_back(now);
      now = f(now);
    }
  	cout << i + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, Z, W;
  cin >> N >> Z >> W;
  vector<ll> a(N);
  for (auto &it : a)
    cin >> it;
  vector<vector<ll>> dp(N + 1, vector<ll>(2));
  for (int i = N - 1; i >= 0; i--)
  {
    // 先手番
    dp[i][0] = -INF;
    ll Y = (i ? a[N - 1] : W);
    chmax(dp[i][0], abs(Y - a[N - 1]));
    for (int j = i + 1; j < N; j++)
      chmax(dp[i][0], dp[j][1]);

    // 後手番
    dp[i][1] = INF;
    ll X = (i ? a[i - 1] : Z);
    chmin(dp[i][1], abs(X - a[N - 1]));
    for (int j = i + 1; j < N; j++)
      chmin(dp[i][1], dp[j][0]);
  }
  cout << dp[0][0] << endl;
  return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    map<int, int> a;

    for (int i = 0; i < N; ++i) {
        int t ; is >> t;
        a[t]++;
    } // end i

    bool yes = a.size() == 3;
    if(yes){
        yes = false;
        auto p = a.begin();
        auto x = *p;
        ++p;
        auto y = *p; ++p;
        auto z = *p;
        if((x.first ^ y.first) == z.first){
            if(x.second == y.second and x.second == z.second){
                yes = true;
            }
        }
    }
    if(a.size() == 2) {
        auto p = a.begin();
        auto x = *p;
        ++p;
        auto y = *p;
        if(x.first == 0 and x.second * 2 == y.second) yes = true;

    }

    yes |= a.size() == 1 and a.begin()->first == 0;
    cout << (yes ? "Yes" : "No") << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}



Measured memory_bytes: 3840
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#define maxn 1000005
using namespace std;
int a[maxn],b[maxn];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	long long n,h;
	cin>>n>>h;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n,cmp);
	long long max_1=a[n-1];
	long long tmp=0;
	for(int i=0;i<n;i++)
	{
		if(b[i]>max_1){
			h-=b[i];
			tmp++;
			if(h<=0){
				cout<<tmp<<endl;
				return 0;
			}
		}
	}
	tmp+=h/max_1;
	if(h%max_1!=0){
		tmp++;
	}
	//tmp+=(h+max_1-1)/max_1;
	cout<<tmp<<endl;
	return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  string s;
  cin>>s;
  int l=0;
  rep(i,3){if(s.at(i)=='1'){l++;}}
  cout<<l<<endl;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<string> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  
  vector<int> c(4);
  
  for(int i=0; i<n; i++){
    if(s[i] == "AC") c[0]++;
    if(s[i] == "WA") c[1]++;
    if(s[i] == "TLE") c[2]++;
    if(s[i] == "RE") c[3]++;
  }
  
  cout << "AC x " << c[0] << endl;
  cout << "WA x " << c[1] << endl;
  cout << "TLE x " << c[2] << endl;
  cout << "RE x " << c[3] << endl;
  
	return 0;
}


Measured memory_bytes: 6424
#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;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    int K;
    cin >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    vector<int> B(M);
    for(int i=0; i<M; i++) cin >> B[i];

    vector<ll> cumA(N);
    cumA[0] = A[0];
    for(int i=1; i<N; i++) cumA[i] = A[i] + cumA[i-1];
    vector<ll> cumB(M);
    cumB[0] = B[0];
    for(int i=1; i<M; i++) cumB[i] = B[i] + cumB[i-1];
    // for(auto b : cumB) cout << b << endl;

    int ans = 0;
    {
        auto itr = lower_bound(cumB.begin(), cumB.end(), K);
        if(itr == cumB.end())
        {
            ans = M;
        }
        else if(*itr == K)
        {
            ans = distance(cumB.begin(), itr) + 1;
        }
        else
        {
            ans = distance(cumB.begin(), itr);
        }
    }
    // cout << "ans:" << ans << endl;
    for(int i=0; i<N; i++)
    {
        ll k = cumA[i];
        if(k > K) break;
        int lans = i+1;
        auto itr = lower_bound(cumB.begin(), cumB.end(), K-k);
        if(itr == cumB.end())
        {
            lans += M;
        }
        else if(*itr == K-k)
        {
            lans += distance(cumB.begin(), itr) + 1;
        }
        else
        {
            lans += distance(cumB.begin(), itr);
        }
        chmax(ans, lans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7952
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
int main() {
	int g[] = {0, 1,3,1,2,1,2,1,1,2,1,2,1 };
	int a, b;
	cin >> a >> b;
	if (g[a] == g[b])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

using P = pair<ll, ll>;
int main(){
    ll h,w,m;
    cin >> h >> w >> m;
    ll h_cnt[h]; ll w_cnt[w];
    rep0(i, h-1) h_cnt[i] = 0; rep0(i, w-1) w_cnt[i] = 0;
    ll max_h = 0; ll max_w = 0;
    queue<P> bom;
    rep1(i, m){
        ll x,y;
        cin >> x >> y;
        x--; y--;
        bom.push(P(x,y));
        h_cnt[x]++; w_cnt[y]++;
    }
    rep0(i, h-1) if(max_h < h_cnt[i]) max_h = h_cnt[i];
    rep0(i, w-1) if(max_w < w_cnt[i]) max_w = w_cnt[i];
    ll max_h_cnt = 0; ll max_w_cnt = 0;
    rep0(i, h-1) if(max_h == h_cnt[i]) max_h_cnt++;
    rep0(i, w-1) if(max_w == w_cnt[i]) max_w_cnt++;

    ll cnt_maxmaax = max_h_cnt*max_w_cnt;
    ll cnt_overlap = 0;
    if(cnt_maxmaax > m){
        cout << max_h + max_w << endl;
        return 0;
    }

    while(!bom.empty()){
        ll bomx = bom.front().first;
        ll bomy = bom.front().second;
        bom.pop();
        if(h_cnt[bomx] == max_h && w_cnt[bomy] == max_w){
            cnt_overlap++;
        }
    }

    if(cnt_overlap < cnt_maxmaax){
        cout << max_h + max_w << endl;
        return 0;
    }else{
        cout << max_h + max_w - 1 << endl;
        return 0;
    }
}

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


public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		boolean[][] f = new boolean[n][10];

		for(int i = 0; i < n; ++i) {
			for(int j = 0; j < 10; ++j) {
				f[i][j] = in.nextInt() == 1;
			}
		}

		int[][] p = new int[n][11];
		for(int  i = 0; i < n ; ++i) {
			for(int j = 0; j < 11; ++j) {
				p[i][j] = in.nextInt();
			}
		}


		long max = Long.MIN_VALUE;
		for(int mask = 1; mask < 1024; ++mask) {

			long localMax = 0;
			for(int s = 0; s < n; ++s){
				int cnt = 0;
				for(int b = 0; b < 10; ++b) {
					if((mask & (1 << b)) != 0 && (f[s][b])) {
						++cnt;
					}
				}


				localMax += p[s][cnt];
			}

			
			max = Math.max(max, localMax);
		}

		System.out.println(max);

	}


}

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

int main() {
    string s,t;
    cin >> s >> t;
    sort(begin(s), end(s));
    sort(begin(t), end(t));

    int n = min(s.size(), t.size());
    for(int i=0; i<n; ++i) {
        if(s[i] < t[t.size() - 1 - i]) {
            cout << "Yes" << endl;
            return 0;
        } else if(s[i] > t[t.size() - 1 - i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    if(s.size() < t.size()) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = 0;
  while (n!=0) {
    ans++;
    n/=k;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;

int main() {
	char S[51], T[51];
	scanf("%s %s", S, T);

	int size_s, size_t;
	for (size_s = 0; S[size_s] != 0; size_s++);
	for (size_t = 0; T[size_t] != 0; size_t++);

	int last_match = -1;
	for (int i = 0; (i + size_t) <= size_s; i++) {
		bool match = true;
		for (int j = 0; j < size_t; j++)
			match &= (S[i + j] == '?') || (S[i + j] == T[j]);
		if (match)
			last_match = i;
	}
	if (last_match != -1) {
		for (int i = 0; i < size_t; i++)
			S[last_match + i] = T[i];
		for (int i = 0; i < size_s; i++)
			if (S[i] == '?')
				S[i] = 'a';
		printf("%s\n", S);
	} else {
		printf("UNRESTORABLE\n");
	}
}

Measured memory_bytes: 128
from subprocess import*
call(('pypy3','-c',"""
import sys
from collections import*
from itertools import*
input=sys.stdin.readline
n=int(input())
d=defaultdict(count().__next__)
es=[]
for i in range(1,n+1):
    *a,=map(int,input().split())
    for j,k in zip(a,a[1:]):
        x,y=i,j
        if y<x:x,y=y,x
        v,w=i,k
        if w<v:v,w=w,v
        es+=(d[x*n+y],d[v*n+w]),
s=len(d)
outs=[[]for _ in range(s)]
ins=[0]*s
f=set(range(s))
for i,j in es:
    outs[i]+=j,
    f-={j}
    ins[j]+=1
q=deque(f)
l=0
data=[0]*s
m=0
while q:
    i=q.popleft()
    l+=1
    t=data[i]+1
    if t>m:m=t
    for j in outs[i]:
        if ins[j]>1:ins[j]-=1
        else:q+=j,
        if t>data[j]:data[j]=t
print(-(l<s)or m)
"""))

Measured memory_bytes: 213712
#include<iostream>
#include<math.h>

#define PI 3.14159265358979

using namespace std;

double cos(double x1, double y1, double x2, double y2,double x3, double y3)
{
	double xa,xb,ya,yb;
	xa=x2-x1;
	ya=y2-y1;
	xb=x2-x3;
	yb=y2-y3;
	return (xa*xb+ya*yb)/(sqrt(xa*xa+ya*ya)*sqrt(xb*xb+yb*yb));
}

int main(void)
{
	double xa,ya,xb,yb,xc,yc,xd,yd,theta;
	char c;
	while(cin>>xa>>c>>ya>>c>>xb>>c>>yb>>c>>xc>>c>>yc>>c>>xd>>c>>yd)
	{
		theta=0;
		theta+=acos(cos(xa,ya,xb,yb,xc,yc));
		theta+=acos(cos(xb,yb,xc,yc,xd,yd));
		theta+=acos(cos(xc,yc,xd,yd,xa,ya));
		theta+=acos(cos(xd,yd,xa,ya,xb,yb));
		if(theta<2*PI)
		{
			cout<<"NO"<<endl;
		}
		else
		{
			cout<<"YES"<<endl;
		}
	}
}

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

#define MAX 4000000
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void fact() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; ++i){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    fact();
    ll r1;
    cin >> r1;
    ll c1;
    cin >> c1;
    ll r2;
    cin >> r2;
    ll c2;
    cin >> c2;
    ll ans=0;
    ans+=comb(r1+c1,r1);
    for(ll i=r1+1;i<=r2;++i){ans+=comb(i+c2,c2);ans%=MOD;}
    for(ll i=c1+1;i<=c2;++i){ans+=comb(i+r2,r2);ans%=MOD;}
    prt(ans)

    return 0;
}


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

int main(){
  int n;
  cin >>n;
  vector<ll> a(n);
  rep(i,n) cin >>a[i];
  sort(a.begin(), a.end());
  bool can = true;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String s = "";
		for (int i = 0; i < S.length(); i++) {
			s += "x";
		}
		System.out.println(s);
	}

}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/


  string s,t;

  cin>>s>>t;

  int cnt=0;
  
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      cnt++;
    }
  }
  

  cout<<cnt<<endl;

  return 0;

}


Measured memory_bytes: 256
// 2013/09/17 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;

			if(pm==100 || pe==100 || pj==100){
				cout << 'A' << endl;
			}
			else if((pm+pe)/2>=90){
				cout << 'A' << endl;
			}
			else if((pm+pe+pj)/3>=80){
				cout << 'A' << endl;
			}
			else if((pm+pe+pj)/3>=70){
				cout << 'B' << endl;
			}
			else if((pm+pe+pj)/3>=50 && (pm>=80 || pe>=80)){
				cout << 'B' << endl;
			}
			else{
				cout << 'C' << endl;
			}
		}
        }

	return 0;
}

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


A='abcdefghijklmnopqrstuvwxyz'
P=['a']
X=[[] for _ in range(n)]
X[0].append('a')
for i in range(n-1):
    P.append(A[i+1])
    for j in range(len(X[i])):
        flag=False
        for k in range(len(P)):
            X[i+1].append(X[i][j]+P[k])
            if not P[k] in X[i][j]:
                flag=True
            if flag:
                break
Y=X[n-1]
for i in range(len(Y)):
    print(Y[i])

Measured memory_bytes: 14532
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	if((n==1)||(n%2!=0)){
		printf("No\n");
		return 0;
	}
//	cout<<s<<endl; 
	int flag=1;
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			flag=0;
			break;
		}
	}
	if(!flag){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll modpow(ll b, ll e, ll p) {
  if(e==0) return 1;
  if(e%2==0) {
    ll t = modpow(b,e/2,p);
    return (t*t)%p;
  }
  return (b*modpow(b,e-1,p))%p;
}

ll modinv(ll n, ll p) {
  return modpow(n,p-2,p);
}

ll modcomb(ll n, ll k, ll p) { // O(k)
  ll ans=1;
  for(ll i=n; i>=n-k+1; i--) {
    ans*=i;
    ans%=p;
  }
  for(ll i=1; i<=k; i++) {
    ans*=modinv(i,p);
    ans%=p;
  }
  return ans;
}

const ll p = 1e9+7;
const int MX = 1000000;
ll modFact[MX+1];
ll modFactInv[MX+1];
void precalc() {
  modFact[0]=1;
  modFactInv[0]=1;
  repeat(i,1,MX+1) {
    modFact[i]=(modFact[i-1]*i)%p;
    modFactInv[i]=modinv(modFact[i],p);
  }
}

ll fastModComb(ll n, ll k, ll p) {
  // call precalc() first.
  ll ret=modFact[n];
  ret=ret*modFactInv[n-k];
  ret%=p;
  ret=ret*modFactInv[k];
  ret%=p;
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  ll ans=0;
  precalc();
  // rep(i,10) {
  //   cout << "modFact["<<i<<"]="<<modFact[i]<<endl;
  //   cout << "modFactInv["<<i<<"]="<<modFactInv[i]<<endl;
  // }
  for(ll i=b+1; i<w+1; i++) {
    ans+=(fastModComb(h-a-1+i-1,i-1,p)*fastModComb(a-1+w-i,w-i,p))%p;
    ans%=p;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    map<string, int> ma;
    rep(i, n) {
        string s;
        cin >> s;
        ma[s]++;
    }
    int m = 0;
    for(auto i : ma) {
        if(i.second > m) {
            m = i.second;
        }
    }
    for(auto i : ma) {
        if(i.second == m) cout << i.first << endl;
    }
    return 0;
}

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

int main() {
    long long ans;
    string s;
    cin >> s;
    for (long long i=s.length()-1; i>0; i--)
        if (s[i] != s[i-1])
            ans++;
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n;
    string s; 
    cin>>n>>s;

    ll cnt=0;
    rep(i,1000){
        ll c[3]={i/100,(i/10)%10,i%10};
        ll f=0;
        rep(j,n){
            if(s[j]==('0'+c[f])) f++;
            if(f==3) break;
        }
        if(f==3) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3648
#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 <cstring>

using namespace std;

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  cout << min(A,B) << " " << max(A+B-N, 0)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vll vector<ll>
#define vpll vector<pll>
#define eb emplace_back
#define MAX 999999999999999
int main(){
	ll n;
	cin >> n;
	ll a[n], ans = 0;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n), reverse(a, a + n);
	for (int i = 1; i < n; i++){
		ans += a[i / 2];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 5220
#include <iostream>
using namespace std;
int main(){
	int n,k; cin >> n >> k;
	for(int i=1;i<=n;i++){
		char in;	cin >> in;
		if(i==k){
			if(in=='A')		cout << 'a';
			else if(in=='B')	cout << 'b';
			else				cout << 'c';
		}else{
			cout << in;
		}
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,d;
  cin>>n>>d;
  long long c=0;
  //double D=d*1.0;

  long long p,q;

  for(int i=0;i<n;i++){

    cin>>p>>q;
    long long dis =(p*p+q*q);
    if(dis<=d*d)
        c++;
    }

  cout<<c;
}

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



int main()
{
 ios_base::sync_with_stdio(0); cin.tie(0);    
int k,x;
cin>>k>>x;
//if(k==1) {cout<<x<<endl;  return 0;}
for( int i=x-k+1;i<=x+k-1 ;i++)
    cout<<i<<" ";
cout<<endl;
}


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

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

  int n = s.size() - 1;
  long long sum = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    long long t = s.at(0) - '0';
    for (int i = 0; i < n; i++) {
      if ((bit >> i) & 1) {
        sum += t;
        t = s.at(i+1) - '0';
      } else {
        t *= 10;
        t += s.at(i+1) - '0';
      }
    }
    sum += t;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
constexpr ll INF = 1'010'000'000'000'000'017LL;
constexpr ll MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;
 
#define FOR(i, start, end) for(ll i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
 
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
 
template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
using pint = pair<int, int>;
using pll = pair<ll, ll>; using vp = V<pll>;
 
ll mod(ll val, ll m){ ll res = val % m; if(res < 0) res += m; return res;}
ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
ll modpow(ll a, ll n, ll mod) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }
 
 
//---------------------------------------------------------------
 
void Main()
{
    double N, K, ans;
    cin >> N >> K;
 
    ans = log(N) / log(K);
    cout << (ll)(ans+1) << endl;
}
 
//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    char S[100010];
    scanf("%s",S);
    int i=0;
    int count=0;
    while(S[i]=='0'||S[i]=='1')
    {
        if(S[i]=='0')
        {
            if(S[i+1]=='0')
            {
                S[i+1]='1';
                count++;
            }
        }

        if(S[i]=='1')
        {
            if(S[i+1]=='1')
            {
                S[i+1]='0';
                count++;
            }
        }
        i++;

        
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	long double x;
	cin >> x;
	x=x/3;
	cout << setprecision(20) << x*x*x ;
}

Measured memory_bytes: 256
n,m,x=gets.split.map(&:to_i)
a=[]
c=[]
ans=1/0.0
n.times do
  a << gets.split.map(&:to_i)
  c << a[-1].shift
end
[1,0].repeated_permutation(n) do |b|
  aa=[0]*m
  n.times do |i|
    if b[i]==1
      m.times do |j|
        aa[j]+=a[i][j]
      end
    end
  end
  f=true
  if aa.min>=x
    cc=0
    n.times do |i|
      if b[i]==1
        cc+=c[i]
      end
    end
    ans=cc if cc<ans
  end
end
if ans==1/0.0
  puts "-1"
else
  puts ans
end


Measured memory_bytes: 14648
#include <bits/stdc++.h>
using namespace std;
int main (){
  long long int i,j,k,t=0;
  long long int n;
  string s;
  cin>>n>>s;
  long long int r=0,g=0,b=0;
  for(i=0;i<n;i++){
    if(s[i]=='R')
      r++;
    else if(s[i]=='G')
      g++;
    else 
      b++;
  }
  for(i=1;i*2<n;i++){
    for(j=0;j+i*2<n;j++){
      if(s[j]!=s[j+i]&&s[j+i]!=s[j+i*2]&&s[j]!=s[j+i*2]){
        t++;
        //cout<<s[j]<<s[j+i]<<s[j+i*2]<<j<<','<<i*2<<endl;
      }
        
    }
  }
  cout<<r*b*g-t<<endl;
  return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
const int MAXN = 4e5 + 10;
using namespace std;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N;
int a[MAXN], b[MAXN], ta[MAXN], tb[MAXN], sa, sb, tot = 0, date[MAXN], fa[MAXN];
map<int, bool> ti;
int find(int x) {
    return fa[x] == x ? fa[x] : fa[x] = find(fa[x]);
}
int unionn(int x, int y) {
    fa[x] = y;
}
int main() {
    N = read();
    for(int i = 1; i <= N; i++) a[i] = read(), sa ^= a[i]; a[N + 1] = sa;
    for(int i = 1; i <= N; i++) b[i] = read(), sb ^= b[i]; b[N + 1] = sb;
    N++;
    memcpy(ta, a, sizeof(a)); memcpy(tb, b, sizeof(b));
    sort(ta + 1, ta + N + 1); sort(tb + 1, tb + N + 1);
    for(int i = 1; i <= N - 1; i++) if(ta[i] != tb[i]) return puts("-1"), 0;

    int ans = 0, num = 0;
    for(int i = 1; i <= N; i++) 
        if(a[i] != b[i] || (i == N)) {
            date[++num] = a[i]; date[++num] = b[i];
            if(i < N)ans++;//最后一块单独考虑
        }
    if(ans == 0) return puts("0"), 0;

    sort(date + 1, date + num + 1);
    num = unique(date + 1, date + num + 1) - date - 1;
    for(int i = 1; i <= num; i++) fa[i] = i;
    for(int i = 1; i <= N; i++)
        if(a[i] != b[i]) {
            a[i] = lower_bound(date + 1, date + num + 1, a[i]) - date,
            b[i] = lower_bound(date + 1, date + num + 1, b[i]) - date;
            if(!ti[a[i]]) ti[a[i]] = 1;
            if(!ti[b[i]]) ti[b[i]] = 1;
            unionn(find(a[i]), find(b[i]));
        }

    for(int i = 1; i <= num; i++)
        if(fa[i] == i) ans++;
    printf("%d", ans - 1);

    return 0;
}

Measured memory_bytes: 13568
from sys import stdin
n,W=map(int,input().split())
k=[[0 for i in range(W+1)] for i in range(n+1)]
for i in range(1,n+1):
    w,v=map(int,stdin.readline().split())
    for j in range(1,W+1):
        if w<=j:
            k[i][j]=max(v+k[i-1][j-w],k[i-1][j])
        else:
            k[i][j]=k[i-1][j]
print(k[n][W])
        

Measured memory_bytes: 171400