akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 998244353;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;
const double eps = 1e-9;
int m[3], dp[N];
vector<int> adj[3][N], val[3];


int add(int x, int y) { return x+y < mod ? x+y : x+y-mod; }
int mul(int x, int y) { return x*1ll*y % mod; }

ll pw(ll x, ll y) {
  ll r = 1;
  while (y > 0) {
    if (y&1)
      r = r*x % mod, y--;
    else
      x = x*x % mod, y /= 2;
  }
  return r;
}

int main() {
  int n; scanf("%d", &n);
  for (int it = 0; it < 3; it++) {
    scanf("%d", &m[it]);
    for (int i = 0; i < m[it]; i++) {
      int u, v; scanf("%d %d", &u, &v);
      adj[it][u].pb(v);
      adj[it][v].pb(u);
    }
    for (int i = n; i; i--) {
      set<int> nx;
      trav(v, adj[it][i]) {
        if (v <= i)
          continue;
        nx.insert(dp[v]);
      }
      dp[i] = 0;
      while (nx.count(dp[i]))
        dp[i]++;
      while (sz(val[it]) <= dp[i])
        val[it].pb(0);
      val[it][dp[i]] = add(val[it][dp[i]], pw(10, 18ll*i));
    }
  }
  int ans = 0;
  for (int i = 0; i < sz(val[0]); i++)
    for (int j = 0; j < sz(val[1]); j++) {
      int k = i^j;
      if (k < sz(val[2]))
        ans = add(ans, mul(mul(val[0][i], val[1][j]), val[2][k]));
    }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 16000
n = int(input())
li = []

for i in range(n):
    s = input()
    t = list(s)
    t.sort()
    s = ''.join(t)
    li.append(s)

li.sort()

a = 1
ans = 0

for i in range(n):
    if i == n-1:
        ans += a*(a-1)/2
    elif li[i] == li[i+1]:
        a += 1
    else:
        ans += a*(a-1)/2
        a = 1

print(int(ans))



Measured memory_bytes: 10668
open Printf
open Scanf

let () =
  let n = scanf "%d " (fun x -> x) in
  let k = scanf "%d " (fun x -> x) in
  let rec loop x d =
    if x = 0 then d
    else loop (x - 1) (min (d * 2) (d + k)) in
  loop n 1 |> printf "%d\n"


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

using namespace std;

using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int INF = 1<<30;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> A(n);
    map<int, int> M;
    rep(i, n) {
        cin >> A[i];
        ++M[A[i]];
    }

    sort(all(A));
    A.erase(unique(all(A)), A.end());
    n = static_cast<int>(A.size());

    int maxA = A[n - 1];
    vector<bool> check_table(maxA + 1, false);
    int k;
    rep(i, n) {
        k = 2;
        while (A[i]*k <= maxA) {
            check_table[A[i]*k] = true;
            ++k;
        }
    }

    int ans = 0;
    rep(i, (int)A.size()) {
        if (! check_table[A[i]] && M[A[i]] == 1) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13684
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
    string s,t;
    cin >> s >> t;
    // cout << "hello" << endl;
    rep(i,s.length()) {
      if(s[i] != t[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 5944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BASE 400000

char Q[800001][13];
int top = BASE;
int tail = BASE;
char a[30];

int main() {
    int q;
    fgets(a, 30, stdin);
    q = atoi(a);
    while (q--) {
        fgets(a, 30, stdin);
        if (a[0] == '0') {
            if (a[2] == '0') strcpy(Q[--top], a+4);
            else             strcpy(Q[tail++], a+4);
        } else if (a[0] == '1') {
            printf(Q[top+atoi(a+2)]);
        } else {
            if (a[2] == '0') top++;
            else tail--;
        }
    }
}


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

typedef long long LL;
const int inf=2000000000;
const LL INF=LL(inf)*inf;
const LL mod=1000000000+7;
#define sc(x) scanf("%d",&(x))
const int maxn = 200000 + 5;

int A[maxn];
int main()
{
	int n;
	sc(n);
	A[0]=0;
	LL ans=0;
	int lastactive[21]={0};
	int maxconflict=0;
	for(int i=1;i<=n;i++)
	{
		sc(A[i]);
		for(int j=0;j<=20;j++)
		{
			if((A[i]&(1<<j))==0)
				continue;
			maxconflict=max(maxconflict,lastactive[j]);
			lastactive[j]=i;
		}
		// printf("i %d maxconflict %d\n", i,maxconflict);
		ans+=(LL)(i-maxconflict);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1152
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const int Maxn = 2e5;

int N;
long long K;

int A[Maxn + 5], F[Maxn + 5];

bool cmp(int lhs, int rhs) {
	return lhs > rhs;
}

bool check(ll mx) {
	ll cnt = 0;
	for(int i = 1; i <= N; i++)
		if(mx <= 1LL * A[i] * F[i]) {
			ll t = A[i] - (mx) / F[i];
			cnt += t;
		}
	return cnt <= K;
}

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %lld", &N, &K);
	ll sum = 0;
	for(int i = 1; i <= N; i++)
		scanf("%d", &A[i]), sum += A[i];
	for(int i = 1; i <= N; i++)
		scanf("%d", &F[i]);
	sort(A + 1, A + N + 1, cmp);
	sort(F + 1, F + N + 1);
	if(K >= sum) {
		puts("0");
		return 0;
	}
	ll lb = 1, ub = 1e12 + 1;
	while(lb + 1 < ub) {
		ll mid = (lb + ub) >> 1;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	printf("%lld\n", ub);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll a(N);
        rep(i, 0, N) cin >> a[i];
        cout << accumulate(all(a), 0LL) - N << endl;
}

Measured memory_bytes: 256
import java.awt.*; //????????¨???????????????(??????????????\??£???????????±??????)????????¨??????
import java.util.*;
import javax.swing.*; //GUI??¨???????????????????????¨??????

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(true){
		    int n = s.nextInt();
		    if(n==0){
		    	break;
		    }
			int[] list = new int[n];
		    for(int i=0;i<n;i++){
		    	list[i] = s.nextInt();
		    }
		    Arrays.sort(list);
		    int ans=0;
		    for (int i = 1; i < n-1; i++) {
		    	ans += list[i];
			}
		    System.out.println(ans/(n-2));
		}
	}
}

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

int main(){
  int N, A, B;
  
  cin >> N >> A >> B;
  
  if( N * A > B ){
    cout << B;
  }else if( N * A < B){
    cout << N * A;
  }else if( N * A == B){
    cout << B;
  }
}


Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
if n==1 and t[0] != a[0]:
    print(0)
    exit()
p = [False for i in range(n)]
p[0] = True
p[n - 1] = True

for i in range(1, n):
    if t[i] > t[i - 1]:
        p[i] = True
        if a[i] < t[i]:
            print(0)
            exit()

for i in range(n - 2, -1, -1):
    if a[i] > a[i + 1]:
        p[i] = True
        if t[i] < a[i]:
            print(0)
            exit()
h=[min(t[i],a[i]) for i in range(n)]
mod = 10**9 + 7
total = 1
for i in range(n):
    if not p[i]:
        total = (total * h[i]) % mod
print(total)


Measured memory_bytes: 18752
def digits(x)
    x.to_s.length
end

n = gets.to_i
ans = digits(n)
(2..Math.sqrt(n).ceil).each do |a|
    next if n % a != 0
    b = n/a
    t = [digits(a),digits(b)].max
    ans = t if t < ans
end
puts ans

Measured memory_bytes: 1788
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func sumInt(a ...int) int {s := 0; for _, v := range a {s += v}; return s}

func main() {
  var n int 
  fmt.Scan(&n)
  p := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&p[i])
  }
  res := sumInt(p...) - maxInt(p...) / 2
  fmt.Println(res)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	int q;
	scanf("%d", &n);
	scanf("%d", &q);
	string s;
	cin >> s;
	int count[n];
	count[0]= 0;
	if(s[0] == 'A' && s[1] == 'C') count[1] = 1;
	for(int i = 2; i < n; i++) {
		int add = 0;
		if(s[i-1] == 'A' && s[i] == 'C') add = 1;
		count[i] = max(count[i-2] + add, count[i-1]);
	}
	for(int i = 0; i < q; i++) {
		int l, r, ans;
		int sub = 0;
		scanf("%d", &l);
		scanf("%d", &r);
		if (l > 1) {
			sub = count[l-2];
			if(s[l - 2] == 'A' && s[l - 1] == 'C') sub++;
		}
		ans = count[r-1] - sub;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

int sum5,sum7;

int main(void){
    for(int i=1,temp;i<=3;i++){
        scanf("%d",&temp);
        if(temp==5)
            sum5++;
        else if(temp==7)
            sum7++;
    }
    if(sum5==2&&sum7==1)
        puts("YES");
    else
        puts("NO");
    //记得换行
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	for(int i=0;i*4<=N;i++){
		for(int j=0;i*4+j*7<=N;j++){
			if(i*4+j*7==N){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  
  cin >> a >> b;
  if(a % 3 == 0){
	  cout << "Possible"<<endl;
  }else if(b % 3 == 0){
	  cout << "Possible"<<endl;
  }else if((a+b) % 3 == 0){
	  cout << "Possible";
  }else{
	  cout << "Impossible";
  }
  return 0;
  }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <climits>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef pair<int, int> pii;

int main()
{
	double sum=0,n=0;
	int i=0;

	int val, num;
	char c;
	while (cin >> val >> c >> num)
	{
		i++;
		sum += val*num;
		n += num;
	}
	printf("%d\n%d\n", (int)sum, (int)(n / i + 0.5));
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    cout << N*N*N << endl;



}


Measured memory_bytes: 256
s = input()

l = list(s)
k = len(set(l))

f = 0
if k <= 2 :
    if len(s) <= k:
        f = 1
else:
    a = [s.count("a"), s.count("b"), s.count("c")]
    if max(a) - min(a) <= 1:
        f = 1
        
if f:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 46064
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

ll n;
double x[10], y[10];
bool used[10] = {};
ll cnt = 0;

double dfs(ll len, ll a, double dis){
    if(len == n){
        cnt++;
        return dis;
    }
    double res = 0;
    rep(i, n)if(!used[i]){
        used[i] = true;
        res += dfs(len+1, i, dis + sqrt(pow(x[a]-x[i], 2.0)+pow(y[a]-y[i], 2.0)));
        used[i] = false;
    }

    return res;
}
 
int main(){
    cin >> n;
    rep(i, n)cin >> x[i] >> y[i];

    double ans = 0;
    rep(i, n){
        used[i] = true;
        ans += dfs(1, i, 0);
        used[i] = false;
    }

    ans /= double(cnt);
    printf("%.12f", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int i = 1;
		while(true) {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			}else {
				while(true) {
					if(x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
					if(x == 0) {
						break;
					}
				}
			}
			if(++i <= N) {
				continue;
			}else {
				break;
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 28792
try:
    while True:
        int_line = input().split(",")
        int_list = [float(a) for a in int_line]
        num = int_list[1] / (int_list[2] ** 2)
        if num >= 25:
            print(int(int_list[0]))
            continue
        else:
            continue
except EOFError as e:
    m = 0


Measured memory_bytes: 5600
import java.util.Scanner;

// Java8
public class Main
{
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}
	
	void run()
	{
		String s = sc.nextLine();
		Parser parser = new Parser(s);
		Node node = parser.getFormula();
		System.out.println(node.get0() + " " + node.get1());
	}
}
abstract class Node {
	private int cost0 = 0;
	private int cost1 = 0;

	public final int get0() {
		if(cost0>0) return cost0;
		return cost0 = calc0();
	}

	public final int get1() {
		if(cost1>0) return cost1;
		return cost1 = calc1();
	}

	abstract int calc0();

	abstract int calc1();
}
class VarNode extends Node {

	@Override
	int calc0()
	{
		return 1;
	}

	@Override
	int calc1()
	{
		return 1;
	}

	@Override
	public String toString()
	{
		return "?";
	}
}
class AndNode extends Node {
	private Node left;
	private Node right;

	public AndNode(Node l, Node r)
	{
		left = l;
		right = r;
	}

	@Override
	int calc0()
	{
		return Math.min(left.get0(), left.get1() + right.get0());
	}

	@Override
	int calc1()
	{
		return left.get1() + right.get1();
	}

	@Override
	public String toString()
	{
		return "(" + left.toString() + "&" + right.toString() + ")";
	}
}
class OrNode extends Node {
	private Node left;
	private Node right;

	public OrNode(Node l, Node r)
	{
		left = l;
		right = r;
	}

	@Override
	int calc0()
	{
		return left.get0() + right.get0();
	}

	@Override
	int calc1()
	{
		return Math.min(left.get1(), left.get0() + right.get1());
	}

	@Override
	public String toString()
	{
		return "(" + left.toString() + "|" + right.toString() + ")";
	}
}
class Parser {
	private String text;
	int cur;

	public Parser(String s) {
		text = s + "$";
		cur = 0;
	}

	public Node getTerm() {
		char c = text.charAt(cur);
		if(c=='?') {
			cur++;
			return new VarNode();
		}
		if(c=='(') {
			cur++;
			Node node = getOrExpr();
			assert(text.charAt(cur) == ')');
			cur++;
			return node;
		}
		throw new IllegalStateException();
	}

	public Node getAndExpr() {
		Node node = getTerm();
		while(text.charAt(cur)=='&') {
			cur++;
			Node r = getTerm();
			node = new AndNode(node, r);
		}
		return node;
	}

	public Node getOrExpr() {
		Node node = getAndExpr();
		while(text.charAt(cur)=='|') {
			cur++;
			Node r = getAndExpr();
			node = new OrNode(node, r);
		}
		return node;
	}
	
	public Node getFormula() {
		return getOrExpr();
	}

}


Measured memory_bytes: 45648
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#n=int(input())
#li=input().split()
#n=int(input())
#l=len(S)

lis=list(map(int,input().split()))
S=input()

ans=0
a=[0]
b=[0]
i,flag=0,0
while i<lis[0]:
    j=1
    if S[i]=="0":
        while flag==0 and i+j<lis[0]:
            if S[i+j]=="0":
                j+=1
            elif S[i+j]=="1":
                flag=1
        a.append(j+a[-1])
        i+=j
    else:
        while flag==0 and i+j<lis[0]:
            if S[i+j]=="1":
                j+=1
            elif S[i+j]=="0":
                flag=1
        b.append(j+b[-1])
        i+=j
    flag=0

A=len(a)-1
B=len(b)-1

if A<=lis[1]:
    ans=lis[0]
else:
    if A>B:
        for i in range(A-lis[1]+1):
            if i==0:
                ans=a[lis[1]]+b[lis[1]]
            elif i>0 and i<A-lis[1]:
                tmp=a[i+lis[1]]-a[i]+b[i+lis[1]]-b[i-1]
                if ans<tmp:
                    ans=tmp
            elif i==A-lis[1]:
                tmp=a[-1]-a[-1-lis[1]]+b[-1]-b[-1-lis[1]]
                if ans<tmp:
                    ans=tmp
    elif A<B:
        for i in range(A-lis[1]+1):
            tmp=a[i+lis[1]]-a[i]+b[i+lis[1]+1]-b[i]
            if ans<tmp:
                ans=tmp
    else:
        if S[0]=="0":
            for i in range(A-lis[1]+1):
                if i==0:
                    ans=a[lis[1]]+b[lis[1]]
                else:
                    tmp=a[i+lis[1]]-a[i]+b[i+lis[1]]-b[i-1]
                    if ans<tmp:
                        ans=tmp
        else:
            for i in range(A-lis[1]+1):
                if i<A-lis[1]:
                    tmp=a[i+lis[1]]-a[i]+b[i+lis[1]+1]-b[i]
                    if ans<tmp:
                        ans=tmp
                else:
                    tmp=a[-1]-a[-1-lis[1]]+b[-1]-b[-1-lis[1]]
                    if ans<tmp:
                        ans=tmp
print(ans)


Measured memory_bytes: 7304
MOD = 10**9 + 7
n, m = [int(item) for item in input().split()]
s = [int(item) for item in input().split()]
t = [int(item) for item in input().split()]

dp = [[0] * (n+1) for _ in range(m+1)]
for i, tt in enumerate(t):
    val = 0 
    for j, ss in enumerate(s):
        # Update Partial
        if ss == tt:
            val += dp[i][j] + 1
            val %= MOD
        # Keep prev
        dp[i+1][j+1] += dp[i][j+1] + val
        dp[i+1][j+1] %= MOD 
print((dp[m][n]+1) % MOD)


Measured memory_bytes: 73692
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int max = (int) Math.pow(2, s.length - 1);
			System.out.println(IntStream.range(0, max).mapToLong(i -> eval(i, s)).sum());
		}
	}

	/**
	 * @param n 「+」ありなしの2進数
	 * @param s 入力数字の文字列
	 * @return 文字列に「+」を追加した後の数式の計算結果
	 */
	private static long eval(int n, char[] s) {
		StringBuilder sb = new StringBuilder();
		long sum = 0L;
		for (int i = 0; i < s.length - 1; i++) {
			sb.append(s[i]);
			if (1 == ((n >> i) & 1)) {
				sum += Long.parseLong(sb.toString());
				sb.setLength(0);
			}
		}
		// 最後の項目を追加
		sb.append(s[s.length - 1]);
		return sum + Long.parseLong(sb.toString());
	}
}


Measured memory_bytes: 36564
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
# a = [*1..m].repeated_combination(n).to_a
a,b,h,m = gets.split.map(&:to_i)
 
if ((30*h+0.5*m) - 6*m).abs < 180 
  w = ((30*h+0.5*m) - 6*m).abs
else
  w = ((360 - 6*m) + (30*h+0.5*m)).abs
end
 

 
# PI = 3.14159265358979323846264
h = a * Math.sin(w / 180.0 * Math::PI);
bs = a * Math.cos(w / 180.0 * Math::PI);
 
bn = (b - bs).abs
 
c2 = h*h + bn*bn
 
puts Math.sqrt(c2)


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

int N;

int X[201010];
int R[201010];

int cnt[201010];
int id=-1;

void solve() {
    int i,j,k,l,r,x,y; string s;
    
    cin>>N;
    REP(i,N) {
        cin>>X[i];
        R[X[i]]=i;
    }
    
    id=1;
    cnt[1]=1;
    for(i=2;i<=N;i++) {
        if(R[i]>R[i-1]) {
            cnt[i]=cnt[i-1]+1;
            if(cnt[i]>cnt[id]) id=i;
        }
        else {
            cnt[i]=1;
        }
    }
    
    x=id-cnt[id]+1;
    cout<<(x-1)+(N-id)<<endl;
}

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

    solve();
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> f(100000);
  REP(i,1,100){
    REP(j,1,100){
      REP(k,1,100){
        f.at(pow(i+j+k,2) - i*j - j*k - k*i)++;
      }
    }
  }
  rep(i,n) cout << f.at(i+1) << endl;
}

Measured memory_bytes: 3692
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  pair<pair<string,int>,int> data[N];

  for (int i = 0; i < N;i++){
    int b;
    string a;
    cin >> a >> b;
    data[i] = make_pair(make_pair(a, -b), i+1);
  }
  sort(data, data+N);
  for (int i = 0; i < N;i++){
    cout << data[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int n = Readint();
            Cout(n+n*n+n*n*n);
                

            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 27544
include Math
N = gets.to_i

ans = 10**12
1.upto Math.sqrt(N).floor do |i|
  d = 0
  if N % i == 0
    d = N / i
    ans = [(d-1) + (i-1), ans].min
    # puts "#{i} #{d}"
  end
end

puts ans

Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
char s[4];
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	a=max(a,c);
	b=min(b,d);
	if(b>=a)
	{
		cout<<b-a;
	}
	else cout<<"0";
}

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

int main()
{
    int N, A[100];
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    int flag = 1;
    int count = 0;
    while (flag)
    {
       flag = 0;
       for (int j = N - 1; j > 0; --j) {
         if (A[j] < A[j - 1]) {
            swap(A[j], A[j - 1]);
            flag = 1;
            ++count;
         }
       }
    }
    for (int i = 0; i < N; ++i)
    {
        cout << A[i];
        if (i < N - 1)
            cout << ' ';
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==
#define square(X) ((X)*(X))

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

const int MAX_N = 12;
double DP[1 << MAX_N][MAX_N];
int CAKE[MAX_N];
int N,L;


double rec(int se,int now){
    if(now != -1 and DP[se][now] >= 0) return DP[se][now];
    if(se == ((1 << N)-1)){
        return CAKE[now];
    }
    double ret = 10000000;
    for(int i=0;i<N;i++){
        if(!((se >> i) & 1)){
            // no one.
            if(now == -1){
                ret = min(ret,rec(se | (1 << i),i)+CAKE[i]);
            }else{
                ret = min(ret,rec(se | (1 << i),i)+
          sqrt(square(CAKE[i]+CAKE[now])-square(CAKE[i]-CAKE[now])));
            }
        }
    }
    if(now != -1){
        return (DP[se][now]=ret);
    }else{
        return ret;
    }
}

int main(){
    string s;
    while(getline(cin,s)){
        for(int i=0;i<(1<<MAX_N);i++){
            for(int j=0;j<MAX_N;j++){
                DP[i][j] = -1;
            }
        }
        stringstream ss;
        ss << s;
        ss >> L;
        N = 0;
        for(int i=0;!ss.eof();i++){
            ss >> CAKE[i];
            N++;
        }
        if(rec(0,-1) <= L){
            cout << "OK" << endl;
        }else{
            cout << "NA" << endl;
        }

    }
    return 0;
}

Measured memory_bytes: 1600
#include <iostream>

#define ll long long

using namespace std;

ll res = 0;

bool ask(ll a) {
    if (a == 0) return false;
    cout << "? " << a << "\n" << flush;
    char c;
    cin >> c;
    return c == 'Y';
}

int main() {
    for (int i = 0; i < 10; ++i) {
        if (i == 9) {
            res = 1e9;
            break;
        }
        if (ask(res * 10 + 9)) {
            if (i == 0 && (!ask((ll)9e9) || (!ask((ll)8e9) && ask(10)))) {
                res = 9;
            } else if (ask(res * 100)) {
                ll a = res * 10;
                while (a < (ll) 1e12) a = a * 10 + 9;
                if (ask(a)) {
                    res *= 10;
                    break;
                }
                res = res * 10 + 9;
            } else {
                int u = 0, o = 9;
                while (u < o) {
                    int m = (u + o) / 2;
                    if (ask(res * 100 + m * 10)) o = m;
                    else u = m + 1;
                }
                res = res * 10 + u;
                break;
            }
            continue;
        }
        int u = 0, o = 8;
        while (u < o) {
            int m = (u + o + 1) / 2;
            if (ask(res * 10 + m)) u = m;
            else o = m - 1;
        }
        res = res * 10 + u;
    }
    cout << "! " << res << "\n" << flush;
}


Measured memory_bytes: 648
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define inf (1000000007)
#define nil -1
int main() {
	int k, x;
	cin >> k >> x;
	int f = true;
	for (int i = max(-1000000,x - k+1); i <= min(x + k-1, 1000000); i++)
	{
		if (f) {

			f = false;
		}
		else {
			cout << " ";
		}

		cout << i;
	}
	cout << endl;
}


Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	p=raw_input().split()+["end"]
	sp=p[0]
	for i in range(n):
		if str(int(p[i])+1)!=p[i+1]:
			if sp!=p[i]:
				print sp+"-"+p[i],
			else:
				print sp,
			sp=p[i+1]
	print

Measured memory_bytes: 4208
#include <iostream>
using namespace std;
int main(void){
    long long s;
    cin >> s;
    long long a, b;
    a = s/1000000000;
    b = s%1000000000 + 1000000000*(a/1000000000);
    a = a - a/1000000000;
    
    cout << "1 0 0 1000000000 " << a + 1 << " " << b;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int d;
//inputの時にresize
vector<int> c(26);
vector<vector<int>> s;
vector<int> t;
vector<int> p;
vector<set<int>> day(26);
void input(){
    cin>>d;    
    s.resize(d,vector<int>(26));
    t.resize(d);
    p.resize(d);
    for(int i=0;i<26;i++)cin>>c[i];
    for(int i=0;i<d;i++){
        for(int j=0;j<26;j++){
            cin>>s[i][j];
        }
    }
}
void output(){
    for(int i=0;i<d;i++){
        cout<<t[i]<<endl;
    }
}
//aは全体の日程
void init(vector<int> a){
    for(int i=0;i<26;i++){
        day[i].insert(-1);
        day[i].insert(d);
    }
    for(int i=0;i<d;i++){
        day[a[i]].insert(i);
    }
    for(int i=0;i<d;i++){
        if(i==0)p[i]=0;
        else p[i]=p[i-1];
        p[i]+=s[i][a[i]];
        for(int j=0;j<26;j++){
            int last=-1;
            for(int k=i;k>=0;k--){
                if(a[k]==j){
                    last=k;
                    break;
                }
            }
            p[i]-=c[j]*(i-last);
        }
    }
}
//最終日のポイントを返す,aは更新するindex,bは更新後のコンテスト
int oneUpdate(int a,int b){
    int ret=p[d-1];
    ret-=s[a][t[a]];
    ret+=s[a][b];
    ret-=c[t[a]]*(*day[t[a]].set::upper_bound(a)-a)*(a-*(--day[t[a]].find(a)));
    ret+=c[b]*(*day[b].set::upper_bound(a)-a)*(a-*(--day[b].upper_bound(a)));
    day[t[a]].erase(a);
    t[a]=b;
    day[b].insert(a);
    p[d-1]=ret;
    return ret;
}

int main(){
    input();
    for(int i=0;i<d;i++){
        cin>>t[i];
        t[i]--;
    }
    init(t);
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int d,q;
        cin>>d>>q;
        cout<<oneUpdate(d-1,q-1)<<endl;
    }
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define MAXN 200010
using namespace std;
int n,q,val[MAXN],ans[MAXN];
vector<int> mp[MAXN];
bool v[MAXN];

void dfs(int now,int va){
	va+=val[now];
	ans[now]=va;
	int t=mp[now].size();
	for(int i=0;i<t;++i){
		if(v[mp[now][i]])	continue;
		v[now]=1;
		dfs(mp[now][i],va);
	}
}

int main(){
	v[1]=1;
	cin>>n>>q;
	for(int i=1,x,y;i<n;++i){
		cin>>x>>y;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	for(int i=1,x,y;i<=q;++i){
		cin>>x>>y;
		val[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++)	cout<<ans[i]<<' ';
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

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

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  for (int i = 1; i <= 5; ++i) {
    int x; cin >> x;
    if (x != i) {
      cout << i << '\n';
      return 0;
    }
  }
  assert(false);
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#define H 250
int A[H];
int left(int);
int right(int);
int parent(int);
int main(){
  int i,k,n;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  for(i = 0;i < n;i++){
    printf("node %d: ",i+1);
    printf("key = %d,",A[i]);
    if(i)printf(" parent key = %d,",parent(i));
    if(i*2+1 < n)printf(" left key = %d,",left(i));
    if(i*2+2 < n)printf(" right key = %d,",right(i));
    printf(" \n");
  }
  return 0;
}

int left(int i){
  return A[(2 * i)+1];
}
int right(int i){
  return A[(2 * i + 1)+1];
}
int parent(int i){
  if(i%2 == 1)return A[i/2];
  else return A[i/2-1];
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define FLASH ios_base::sync_with_stdio(0);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";


using namespace std;

char a;

int main(){
FLASH;
cin>>a;
if(isupper(a))cout<<'A'<<endl;
else cout<<'a'<<endl;







return 0;
} 


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int S;
    cin >> S;
    int s1, s2, s3;
    s3 = S % 10;
    s2 = (S  - s3) / 10 % 10;
    s1 = (S -s2*10 - s3) / 100 % 10;
    cout << s1 + s2 +s3 << endl;

}

Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
int C,goal,n,x,y,xs,ys,xg,yg,mas[110][110]={{0}};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int d[110][110];
typedef pair<int,int>P;

int bfs();
int main(){

  while(1){
    goal=0;
    memset(mas,0,sizeof(mas));
    //memset(d,0,sizeof(d));
    C = goal = n = x = y = xs = ys = xg = yg = 0;

    cin >> x >> y;//ボードの大きさ。 ※：x=横。y=縦。
    if(x==0 && y==0){
      break;
    }
    cin >> xs >> ys;//スタート地点。
    cin >> xg >> yg;//ゴール地点。
    cin >> n;//ブロックの数。
    
    //色染め。
    int color,dire,xx,yy;
    for(int t=0;t<n;t++){
      cin >> color >> dire >> xx >> yy;

      //横長。
      if(dire==0){
	for(int i=0;i<2;i++){
	  for(int j=0;j<4;j++){
	    mas[yy+i][xx+j]=color;
	  }
	}
      }
      
      //縦長。
      else{
	for(int i=0;i<4;i++){
	  for(int j=0;j<2;j++){
	    mas[yy+i][xx+j]=color;
	  }
	}
      }
      
    }
    
    //通る色　摘出。
    C=mas[ys][xs];
    //cout << "color:" << C << endl;
    
    if(C!=0 && mas[ys][xs]==mas[yg][xg]){

      bfs();

    
      if(goal==1){
	cout << "OK" << endl;
	goal=0;
      }
      else{
	cout << "NG" << endl;
      }
    }
    else{
      cout << "NG" << endl;
    }
  }
}

int bfs(){
  queue<P>que;
  memset(d,-1,sizeof(d));
  que.push(P(ys,xs));
  d[ys][xs]=0;
  while(!que.empty()){
    P p=que.front();
    que.pop();
    if(p.first==yg && p.second==xg){
      goal=1;
      break;
    }
    for(int i=0;i<4;i++){
      int ny=p.first+dy[i];
      int nx=p.second+dx[i];
      if(ny>=1 && ny<=y && nx>=1 && nx<=x && mas[ny][nx]==C && d[ny][nx]==-1){
	d[ny][nx] = 1;
	que.push(P(ny,nx));
      }
    }
  }
  return (0);
}

Measured memory_bytes: 1296
from sys import stdin
M,D = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(M+1):
    for j in range(D+1):
        d1 = j % 10
        d10 = j // 10
        if d1 >= 2 and d10 >= 2 and d1*d10 == i:
            ans += 1
print(ans)

Measured memory_bytes: 3060
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
map<string,int> mp;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	int n;cin>>n;
	for(int i=1;i<=n;i++) {
		string s;cin>>s;
		mp[s]++;
	}
	int res=-1;
	for(auto i:mp){
		res=max(res,i.second);
	}
	for(auto i=mp.begin();i!=mp.end();i++){
		if(i->second==res) cout<<i->first<<endl;
	}
	return 0;
}



Measured memory_bytes: 23808
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int n;
    cin>>n;
    vector<int> b(n-1);
    REP(i,n-1){
        cin>>b.at(i);
    }

    vector<int> a(n);

    REP(i,n){
        if(i==0){
            a.at(0) = b.at(0);
        } else if(i==n-1) {
            a.at(n-1) = b.at(n-2);
        } else {
            a.at(i) = min(b.at(i),b.at(i-1));
        }
    }

    int sum =0;
    REP(i,n){
        sum += a.at(i);
    }
    cout<<sum<<endl;

    // cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int gcd(int x,int y){
    return y ? gcd(y,x%y) : x;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    map<string,int> mp;
    vector<string> c(n);
    rep(i,0,n){
        string s; cin >> s;
        c[i]=s;
        mp[s]++;
        if(i!=0&&c[i-1].back()!=s.front()){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(auto v : mp){
        if(v.second!=1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine();
            var t = Console.ReadLine();
            int ans = 0;
            for (int i = 0; i < 3; i++)
			{
                if (s[i] == t[i]) ans++;
			}
            Console.WriteLine(ans);
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
A, B, C, X, Y = map(int, input().split())

xp, xc, np, nc = (A, X, B, Y) if X > Y else (B, Y, A, X)

x = xp * xc + np * nc
y = C * xc * 2
z = xp * (xc - nc) + C * nc * 2

print(min(x, y, z))


Measured memory_bytes: 3060
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, c = map(int, input().split())
    # v: cumulative sum
    x, v = [0] * (n+2), [0] * (n+2)
    for i in range(n):
        j, k = map(int, input().split())
        x[i+1] = j
        v[i+1] = v[i] + k
    x[n+1] = c
    v[n+1] = v[n]
    
    max_nut_clockwise = [0] * (n+1)
    for i in range(1, n+1):
        max_nut_clockwise[i] = max(max_nut_clockwise[i-1], v[i] - x[i])
    max_nut_counterclockwise = [0] * (n+1)
    for i in range(n-1, -1, -1):
        max_nut_counterclockwise[i] = max(max_nut_counterclockwise[i+1], v[-1] - v[i] - c + x[i+1])

    ans = 0
    # rotate clockwise, then rotate counterclockwise
    for i in range(n):
        if ans < v[i] - 2*x[i] + max_nut_counterclockwise[i]:
            ans = v[i] - 2*x[i] + max_nut_counterclockwise[i]
    # rotate counterclockwise, then rotate clockwise
    for i in range(2, n+2):
        if ans < v[-1] - v[i-1] - 2 * (c - x[i]) + max_nut_clockwise[i-1]:
            ans = v[-1] - v[i-1] - 2 * (c - x[i]) + max_nut_clockwise[i-1]
    
    print(ans)

main()


Measured memory_bytes: 26676
#include<bits/stdc++.h>
using namespace std;
string s,t;
int ans;
int main()
{
   cin>>s;
   cin>>t;
   int n=s.length();
   for(int i=0;i<n;i++)
   {
      if(s[i]!=t[i]) ans++;
   }
   cout<<ans;
   return 0;
}


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

using namespace std;

#define all(v)          v.begin(), v.end()
#define pb              push_back
#define sz(x)          (int) (x.size())
#define endl            "\n"
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

int n, k;
bool can(int a[], int mid){
    ll cost = 0;
    for(int i = 0; i < n; i++){
        cost += (a[i] - 1) / mid;
    }
    return cost <= k;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> k;
    int a[n];
    for(auto &i: a) cin >> i;
    int l = 1, r = *max_element(a, a + n), ans = r;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(can(a, mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4404
#include<stdio.h>
#include<stdlib.h>

#define MAX 2000001
#define VMAX 10001

int main(){
  unsigned short *N, *M;

  int L[VMAX];
  int n, i, j;
  
  scanf("%d", &n);

  N = malloc(sizeof(short)*n+1);
  M = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX-1; i++ ) L[i] = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%d", &N[i+1]);
    L[N[i+1]]++;
  }
  
  for ( i = 1; i <= VMAX-1; i++ ) L[i] = L[i] + L[i-1];
  for ( j = 1; j <= n; j++ ){
    M[L[N[j]]] = N[j];
    L[N[j]]--;
  }
  
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", M[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9660