akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;

void solve()
{
	int n, k;
	cin >> n >> k;

	int index = 0, a[100];
	while (n)
	{
		a[++index] = n % k;
		n = n / k;
	}

	cout << index;
}

int main()
{
	//freopen("Testin.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示


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

	ll n;
	cin >> n;

	for (int x = 1; x <= 50000; x++)
	{
		if ((ll)(x * 1.08) == n)
		{
			cout << x << endl;
			ret;
		}
	}

	cout << ":(" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
count = 0
for i in range(n - 1):
    if i+1 == p[i]:
        p[i],p[i+1] = p[i+1],p[i]
        count+=1
if n == p[n-1]:
    count+=1
print(count)

Measured memory_bytes: 13880
N, A, B = map(int, input().split())
S = input()
count_a = 0
count_b = 0
for i in range(N):
    if S[i] == 'a':
        if count_a+count_b < A+B:
            count_a+=1
            print('Yes')
        else:
            print('No')
    elif S[i] == 'b':
        if count_a+count_b < A+B and count_b < B:
            count_b+=1
            print('Yes')
        else:
            print('No')   
    else:
        print('No')    

Measured memory_bytes: 4016
#include<stdio.h>
#include<iostream>
using namespace std;

#define NILL -1
#define MAX 10000

struct ID { int parent, left, right; };
struct ID id[MAX];

void preParse(int u) {
	if (u == NILL) return;
	printf(" %d", u);
	preParse(id[u].left);
	preParse(id[u].right);
}

void inParse(int u) {
	if (u == NILL)return;
	inParse(id[u].left);
	printf(" %d", u);
	inParse(id[u].right);
}

void postParse(int u) {
	if (u == NILL)return;
	postParse(id[u].left);
	postParse(id[u].right);
	printf(" %d", u);
}

int main()
{
	int n, i, v, l, r, root;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		id[i].parent = NILL;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &l, &r);
		id[v].left = l;
		id[v].right = r;
		if (l != NILL)id[l].parent = v;
		if (r != NILL)id[r].parent = v;
	}

	for (i = 0; i < n; i++)if (id[i].parent == NILL)root = i;

	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");

	return 0;
}


Measured memory_bytes: 3208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		//System.out.println("starts...");
		//int n; 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		int h = Integer.parseInt(br.readLine());
		System.out.print((a+b)*h/2+"\n");
	}

}

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

int main() {
  int A ;
  cin >> A ;
  int o, p, q, r;
  o = A / 1000;
  p = A / 100 - 10 * o;
  q = A / 10 - (100 * o + 10 * p);
  r = A - (1000 * o + 100 * p + 10 * q);
  if (o == p && p == q) {
    cout << "Yes" << endl;
  }
  else if (p == q && q == r) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }

  vector<int> bak = a;

  // pattern1. odd position sum is positive.
  long long count = 0;
  if (a[0] >= 0) {
    count += 1 + a[0];
    a[0] = -1;
  }

  long long sum = 0;
  rep(i, N-1) {
    sum += a[i];
    long long next_sum = sum + a[i+1];

    if (i % 2 == 0) {
      if (next_sum <= 0) {
        // next_sum to +1
        count += 1 - next_sum;
        a[i+1] += 1 - next_sum;
      }
    } else {
      if (next_sum >= 0) {
        // next_sum to -1
        count += next_sum + 1;
        a[i+1] -= (next_sum + 1);
      }
    }
  }
  long long count1 = count;

  // pattern2. even position sum is positive.
  a = bak;
  count = 0;
  if (a[0] <= 0) {
    count += 1 - a[0];
    a[0] = 1;
  }

  sum = 0;
  rep(i, N-1) {
    sum += a[i];
    long long next_sum = sum + a[i+1];

    if (i % 2 != 0) {
      if (next_sum <= 0) {
        // next_sum to +1
        count += 1 - next_sum;
        a[i+1] += 1 - next_sum;
      }
    } else {
      if (next_sum >= 0) {
        // next_sum to -1
        count += next_sum + 1;
        a[i+1] -= (next_sum + 1);
      }
    }
  }

  cout << std::min(count1, count) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int c, sum;
	
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		sum = 0;
		for (i = 0; i < n / 4; i++) {
			scanf("%d", &c);
			sum += c;
		}
		printf("%d\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s; cin >> s;
    for (int i = 0; i < s.length(); i += 2) {
        if (s.substr(i, 2) != "hi") {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            var a = new int[3][];

            for (int i = 0; i < 3; i++) {
                // 整数配列の入力
                a[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            }

            // 整数の入力
            int n = int.Parse(Console.ReadLine());

            var b = new int[n];

            for(int i = 0; i < n; i++) {
                b[i] = int.Parse(Console.ReadLine());
            }

            foreach(var bingo in b) {
                for(int x = 0; x < 3; x++) {
                    for(int y = 0; y < 3; y++) {
                        if(a[y][x] == bingo) {
                            a[y][x] = 0;
                        }
                    }
                }
            }

            for(int i =0; i < 3; i++) {
                if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) {
                    Console.WriteLine("Yes");

                    Console.Out.Flush();
                    return;
                }
            }

            for (int i = 0; i < 3; i++) {
                if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) {
                    Console.WriteLine("Yes");

                    Console.Out.Flush();
                    return;
                }
            }

            if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
                Console.WriteLine("Yes");

                Console.Out.Flush();
                return;
            }

            if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) {
                Console.WriteLine("Yes");

                Console.Out.Flush();
                return;
            }

            Console.WriteLine("No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
char s[1000];
cin.getline(s,sizeof(s));
for(int i=0;s[i]!='\0';i++){
if((s[i]!=' ')&&(s[i]!='.')){
putchar(s[i]-'a'+'A');
}else{
putchar(s[i]);
}
}cout<<endl;
return 0;
}

Measured memory_bytes: 1112
import sys
import math

N=int(input())
x=[0 for i in range(N)]
y=[0 for i in range(N)]

for i in range(N):
    x[i],y[i]=map(int,input().split())

ans=0
for i in range(N):
    for j in range(i):
        ans+=math.sqrt( abs(x[i]-x[j])**2 + abs(y[i]-y[j])**2 )

print(ans*2/N)

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

int main(){
    int sum;
    sum=0;

    int N;
    cin >> N;

    int B[N-1];

    for (int i = 0;i<N-1;i++) cin >> B[i];

    sum+=B[0];
    sum+=B[N-2];
    for (int i = 0;i<N-2;i++){
        sum+=min(B[i],B[i+1]);
    }
    cout << sum << endl;
}

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

using namespace std;

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int m;
    cin >> m;
    cout << 48 - m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	std::cin >> n;
	int counter=0;
	for (int i = 1; i <= n; i++) {
		/* code */
		if(i>=1&&i<=9)counter++;
			if(i>=100&&i<=999)counter++;
				if(i>=10000&&i<=99999)counter++;
					
		
	}
	std::cout << counter << std::endl;
}

Measured memory_bytes: 256
export class Main {
  main(input: string): string {
    const tmp: string[] = input.split("\n");
    const num = parseInt(tmp[0]);
    const t = tmp[1];
    if (num % 2 != 0) {
      return 'No';
    }
    if (t.substring(0, num / 2) === t.substring(num / 2)) {
      return 'Yes';
    } else {
      return 'No';
    }
  }
}

console.log(new Main().main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100

int n;
int G[MAX][MAX];

void init();

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

    for(int i = 0; i < n; i++){
        int u,k; cin >> u >> k;
        for(int j = 0; j < k; j++){
            int v; cin >> v;
            G[u-1][v-1] = 1;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cout << G[i][j];
            if(j != n-1) cout << " ";
        }
        cout << endl;
    }
    return 0;
}

void init(){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            G[i][j] = 0;
        }
    }
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m,q;
	cin >>n >>m >>q;
	vector<VI> ct(n+2, VI(n+2, 0));
	rep(i, m){
		int l,r;
		cin >>l >>r;
		ct[l-1][r-1]++;
	}
	vector<VI> sk(n+3, VI(n+3, 0));
	rep(i,n+2) rep(j,n+2){
		sk[i+1][j+1] = sk[i+1][j] + sk[i][j+1] - sk[i][j] + ct[i][j];
	}
	//puts("");for(auto xl: sk){for(auto x :xl) printf("%d ",x); puts("");}
	rep(i, q){
		int p,q;
		cin >>p >>q;
		int w = sk[q][q] - sk[p-1][q] - sk[q][p-1] + sk[p-1][p-1];

		cout << w <<"\n";
	}
	
	
	
	return 0;
}


Measured memory_bytes: 2944
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
a=[-1]*n
ans=0
if sum([i<0 for i in c])==n:
    print(max(c))
    exit()
#一周した時のスコアを計算
for i in range(n):
    if a[i]!=-1:
        continue
    b=[i+1]
    while len(b)==len(set(b)):
        b.append(p[b[-1]-1])
    b.pop()
    e=len(b)
    d=sum([c[i-1] for i in b])
    for i in b:
        a[i-1]=[d,e]
for i in range(n):
    score=0
    tmp=i
    t=k%a[i][1]
    if a[i][0]>=0:
        score=a[i][0]*(k//a[i][1])
    tscore=score
    for j in range(t):
        tmp=p[tmp]-1
        tscore+=c[tmp]
        score=max(score,tscore)
    ans=max(ans,score)
for i in range(n):
    score=0
    tmp=i
    t=k%a[i][1]
    if k//a[i][1]==0:
        continue
    if a[i][0]>=0:
        score=a[i][0]*(k//a[i][1]-1)
    tscore=score
    for j in range(a[i][1]):
        tmp=p[tmp]-1
        tscore+=c[tmp]
        score=max(score,tscore)
    ans=max(ans,score)
print(ans)

Measured memory_bytes: 86768
#######################################
def csi(s=gets,spst=" ")
  if s==nil
    return 0
  end
  return s.chomp.split(spst).map(&:to_i)
end
def css(s=gets,spst=" ")
  if s == nil
    raise "nil!"
  end
  return s.chomp.split(spst).map(&:to_s)
end
def ml(n,datatype=:int)
  t = []
  case datatype
  when :int
    n.times do
      t.push(gets.to_i)
    end
  when :str
    n.times do
      t.push(gets.chomp.to_s)
    end
  else
    raise "n!"
  end
end
#######################################
N,S = gets.to_i , gets.chomp

puts S.scan('ABC').length


Measured memory_bytes: 1788
#include<stdio.h>
int main(void){

  //９X９までの計算結果を先に用意する
  int ans[10][10];
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      ans[i][j] = i*j;
    }
  }
  
  //変数を受け取る
  int N;
  scanf("%d", &N);
  
  //受け取った変数と一致するものがあるか調べる
  char flg = 0;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(N == ans[i][j]){
      	flg = 1;
        break;
      }
    }
  }
  
  //結果を出力
  if(flg){
  	printf("Yes\n");
  }else{
  	printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int n,a[500003],ans,lst; 
int add0,lzy[2197152];
ll num[2197152][2];
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),lst^=a[i];
	if(lst==0){
		int cur=0;
		ans=1;
		for(int i=1;i<n;i++){
			cur^=a[i];
			if(cur==0)ans=ans*2%MOD;
		}
		cur=0;
		for(int i=1;i<(1<<21);i++)num[i][0]=1; 
		for(int i=1;i<n;i++){
			cur^=a[i];
			if(cur==0)add0++;
			else{
				int go=add0-lzy[cur];
				lzy[cur]=add0; 
				num[cur][0]=(num[cur][0]+num[cur][1]*go)%MOD;
				num[cur][1]=(num[cur][1]+num[cur][0])%MOD;
			}
		}
		for(int i=1;i<(1<<21);i++)
			ans=(ans+num[i][1])%MOD;
		cout<<ans;
		return 0;
	}
	num[lst][0]=1;
	int cur=0;
	for(int j=1;j<n;j++){
		cur^=a[j];
		if(cur==0)num[lst][0]=(num[lst][1]+num[lst][0])%MOD;
		if(cur==lst)num[lst][1]=(num[lst][0]+num[lst][1])%MOD;
	}
	ans+=num[lst][0];
	ans%=MOD;
	cout<<ans;
}

Measured memory_bytes: 42480
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    vector<int> X(M);
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }
    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }
    
    sort(X.begin(), X.end());
    vector<int> dist(M - 1);
    for (int i = 0; i < M - 1; i++) {
        dist[i] = X[i + 1] - X[i];
    }
    
    sort(dist.begin(), dist.end());
    long long ans = 0;
    for (int i = 0; i < M - N; i++) {
        ans += dist[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N , K = map(int,input().split())
 
A = list(map(int,input().split()))
 
A.sort()
 
maxDigit = max(K,A[-1]).bit_length()
 
# 前計算
maxVal = [0] * maxDigit
for i in range(maxDigit) :
    count = 0
    mask = 2**i
    for a in A :
        count += (a & mask) // mask
    count = max(N - count, count)
    if i == 0 :
        maxVal[0] = count
    else :
        maxVal[i] = count * mask + maxVal[i-1]
 
valK = [0] * (maxDigit + 1)
for i in range(maxDigit-1, -1, -1) :
    mask = 2**i
    maskK = K & mask
    sumK = 0
    for a in A :
        val = a & mask
        if maskK != val :
            sumK += mask
    valK[i] = sumK + valK[i+1]
 
ans = valK[0]  # X = K
for i in range(maxDigit-1, -1, -1) :  # 上からi+1桁まではKと同じ
    if not K & (2**i) > 0  :  # i桁目が0の場合
        continue
 
    sumXor = valK[i+1]
 
    # i桁目 0にする
    mask = 2**i
    for n in range(N) :
        if A[n] & mask > 0 :
            sumXor += mask
 
    if i > 0 :
        sumXor += maxVal[i-1]
 
    ans = max(ans, sumXor)
 
print(ans)

Measured memory_bytes: 68696
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 1000000007
/****************************/
ll n,a,b; 
int main()
{
	cin>>n>>a>>b;
	ll ans=0;
	ans+=n/(a+b)*a;
	if(n%(a+b)>=a)
	{
		ans+=a;
	}
	else
	{
		ans+=n%(a+b);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
    string S;
    bool before = true, after = true, total = true;
    cin >> S;
    int N = S.size();
    int a = (N - 1)/2, b = (N + 3)/2; //N=7, a=3, b=5
    for(int i = 0; i < a; ++i)
    {
        if(S.at(i) != S.at(N - 1 - i)) total = false;
    }
    //cout << "totoal = " << total << endl;
    for(int i = 0; i < a/2; ++i)
    {
        if(S.at(i) != S.at(a - 1 - i)) before = false;
        //cout << S.at(i) << S.at(a - 1 - i)<< endl;
        if(S.at(b - 1 + i) != S.at(N - 1 - i)) after = false;
    }
    //cout << "before = " << before << endl;
    //cout << "after = " << after << endl;
    if(before == true && after == true && total == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
multi2 = multi4 = 0
for i in map(int, input().split()):
    if i % 4 == 0:
        multi2 += 1
        multi4 += 1
    elif i % 2 == 0:
        multi2 += 1

res = 'No'
if multi4 >= n // 2 or multi2 == n:
    res = 'Yes'
elif multi4 >= (n - (multi2 - multi4)) / 2:
    res = 'Yes'
print(res)


Measured memory_bytes: 11096
# -*- coding: utf-8 -*-
A,B,C,D=[int(i) for i in input().split()]
ans=0
while True:
    C=C-B
    if C<=0:
        break
    A=A-D
    if A<=0 :
        break
if C<=0:
    print("Yes")
else:
    print("No")

    

Measured memory_bytes: 61760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n;
    cin >> n;
    int f[110][20] = {};
    int p[110][20] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 10; j++)
            cin >> f[i][j];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 11; j++)
            cin >> p[i][j];
    }
    int ans = INT_MIN;
    for (int i = 1; i < (1 << 10); i++)
    {
        int hoge = 0;
        for (int j = 0; j < n; j++)
        {
            int tmp = 0;
            for (int k = 0; k < 10; k++)
            {
                if (i & (1 << k) && f[j][k] == 1)
                    tmp++;
            }
            hoge += p[j][tmp];
        }
        ans = max(ans, hoge);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)
N=int(input())
x,y=0,0
for i in range(N):
  p=0
  T,A=map(int,input().split())
  if i==0:
    x,y=T,A
    continue
  if x<=T and y<=A:
    x,y=T,A
  elif x<=T and A<y:
    if y%A!=0:
      p=1
    x=T*(y//A+p)
    y=A*(y//A+p)
  elif T<x and y<=T:
    if x%T!=0:
      p=1
    y=A*(x//T+p)
    x=T*(x//T+p)
  else:
    if (x//T+1)<=(y//A+1):
      if y%A!=0:
        p=1
      x=T*(y//A+p)
      y=A*(y//A+p)
    else:
      if x%T!=0:
        p=1
      y=A*(x//T+p)
      x=T*(x//T+p)
print(x+y)

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

int N;
int x;

vector<int> U;
vector<int> V;

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

    cin >> N >> x;

    if (x == 1 || x == (2*N-1)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    if (N == 2 && x == 2) {
        cout << 3 << endl;
        cout << 2 << endl;
        cout << 1 << endl;
        return 0;
    }

    if (x > 2) {
        U.clear();
        V.clear();

        U.push_back(x-2);
        U.push_back(x);
        U.push_back(x+1);
        U.push_back(x-1);

        for (int i = 1; i <= (2*N-1); ++i) {
            if (x-2 <= i && i <= x+1) {
            } else {
                V.push_back(i);
            }
        }

        int j = 0;
        int k = 0;
        for (int i = 1; i <= (2*N-1); ++i) {
            if (N-1 <= i && i <= N+2) {
                cout << U[j] << endl;
                j++;
            } else {
                cout << V[k] << endl;
                k++;
            }
        }
    } else {
        U.clear();
        V.clear();

        U.push_back(x+2);
        U.push_back(x);
        U.push_back(x-1);
        U.push_back(x+1);

        for (int i = 1; i <= (2*N-1); ++i) {
            if (x-1 <= i && i <= x+2) {
            } else {
                V.push_back(i);
            }
        }

        int j = 0;
        int k = 0;
        for (int i = 1; i <= (2*N-1); ++i) {
            if (N-1 <= i && i <= N+2) {
                cout << U[j] << endl;
                j++;
            } else {
                cout << V[k] << endl;
                k++;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 2420
///"    "\\\

# include <bits/stdc++.h>

# define pb push_back

using namespace std;

int k , z = 0 , o , p = 0 ;

	
int main() {

	int k , x ;
	cin >> k >> x ;
	int t = max((x-k+1),-100000);

	int j = min((x +k-1),100000);

	for(int i = t ; i <= j ; i ++ ){
		cout << i << ' ' ;
	}

}

///"    "\\\

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

int main () {
 int n; cin >> n;
 vector<ll> a(n);
 ll sum=1;
 rep(i,n){
   cin >> a[i];
   if(a[i]==0){
     cout << 0 << endl;
     return 0;
   }
 }
 rep(i,n){
  if(a[i]<=1000000000000000000/sum){
    sum*=a[i];
  }
   else{
     cout << -1 <<endl;
    return 0;
     }
 }
 cout << sum << endl;
}


Measured memory_bytes: 4052
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 105
char s[N],sta[N],tmp[N]={'\0','k','e','y','e','n','c','e','\0'};int n;
bool check(char *s)
{
	for(int i=1;i<=7;i++)if(tmp[i]!=sta[i])return 0;
	return 1;
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);int now=0;
	for(int i=1;i<=7;i++)if(s[i]!=tmp[i]){now=i;break;}
	for(int i=now;i<=7;i++)if(s[n-7+i]!=tmp[i])return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;
 
int main(){
  long long N;
  long long K;
  cin >> N >> K;
  long long ans=K;
  for(int i=1;i<N;i++){
   ans*=K-1; 
  }
  cout << ans << endl;
  return 0;}

Measured memory_bytes: 256
A = int(input()) # 500 yen
B = int(input()) # 100 yen
C = int(input()) # 50  yen
X = int(input()) # sum
comb = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            total = 500*i + 100*j + 50*k
            if total == X:
                comb+=1
                
print(comb)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 205;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN][MAXN];
int n, dist[MAXN];
bool vis[MAXN], col[MAXN];
void bfs(int pos) {
	static int q[MAXN];
	int l = 0, r = 0; q[0] = pos;
	memset(dist, 0, sizeof(dist));
	dist[pos] = 1;
	while (l <= r) {
		int pos = q[l++];
		for (int i = 1; i <= n; i++)
			if (s[pos][i] == '1' && dist[i] == 0) {
				dist[i] = dist[pos] + 1;
				q[++r] = i;
			}
	}
}
void dfs(int pos) {
	vis[pos] = true;
	for (int i = 1; i <= n; i++)
		if (s[pos][i] == '1') {
			if (vis[i]) {
				if (col[i] == col[pos]) {
					puts("-1");
					exit(0);
				}
			} else {
				col[i] = !col[pos];
				dfs(i);
			}
		}
}
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		scanf("\n%s", s[i] + 1);
	dfs(1);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		bfs(i);
		for (int j = 1; j <= n; j++)
			chkmax(ans, dist[j]);
	}
	writeln(ans);
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s, t;
    int a,b,c,d,e, n, m, x; cin >> x;

    a = 1000*(x/500);
    x %= 500;
//    debug(x);
    a += 5*(x/5);

    cout <<  a << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	ArrayList<ArrayList<Integer>>g = new ArrayList<>();
	boolean used[];
	int n;
	int ans;
	public void run() {
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();
		int m=sc.nextInt();
		for(int i=0; i<n; i++) {
			g.add(new ArrayList<>());
		}
		used = new boolean[n];
		for(int i=0; i<m; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			a--;
			b--;
			g.get(a).add(b);
			g.get(b).add(a);
		}
		used[0]=true;
		dfs(0, 1);
		System.out.println(ans);
		sc.close();
	}

	private void dfs(int u, int cnt) {
		for(int i=0; i<g.get(u).size(); i++) {
			int v = g.get(u).get(i);
			if(! used[v]) {
				used[v]=true;
				dfs(v, cnt+1);
				used[v]=false;
			}
		}
		if(cnt == n) {
			ans++;
		}
	}
}


Measured memory_bytes: 37772
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{

    ll n,x,m;
    cin>>n>>x>>m;
    ll cnt;
    if(n%x)
        cnt=1+(n/x);
        else
            cnt=n/x;
    cout<<cnt*m<<endl;

return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
	map<char, int> dx,dy;
	dx['U']=0; dy['U']=-1;
	dx['D']=0; dy['D']=1;
	dx['L']=-1; dy['L']=0;
	dx['R']=1; dy['R']=0;

	while(1){
		int hp,hpmax;
		cin >> hp >> hpmax;
		if(hp == 0) break;

		int h,w;
		cin >> h >> w;
		vector<string> field(h);
		for(int i=0; i<h; i++){
			cin >> field[i];
		}
		int t;
		cin >> t;
		vector<int> damage(256, 0);
		for(int i=0; i<t; i++){
			char c;
			int d;
			cin >> c >> d;
			damage[c] = d;
		}
		int s;
		cin >> s;
		vector<int> damageseq;
		int x=0,y=0;
		for(int i=0; i<s; i++){
			char dir;
			int num;
			cin >> dir >> num;
			for(int j=0; j<num; j++){
				x+=dx[dir];
				y+=dy[dir];
				if(damage[field[y][x]] > 0){
					damageseq.push_back(damage[field[y][x]]);
				}
			}
		}
		int p;
		cin >> p;
		vector<int> portion(p);
		for(int i=0; i<p; i++){
			cin >> portion[i];
		}

		vector<vector<int> > dp(damageseq.size()+1, vector<int>(1<<p, 0));
		dp[0][0] = hp;
		for(int i=0; i<(int)damageseq.size(); i++){
			for(int j=0; j<(1<<p); j++){
				if(dp[i][j] <= 0) continue;
				dp[i+1][j] = max(dp[i+1][j], dp[i][j]-damageseq[i]);
				for(int k=0; k<p; k++){
					if(j>>k & 1) continue;
					int newhp = min(dp[i][j]+portion[k], hpmax);
					dp[i][j|(1<<k)] = max(dp[i][j|(1<<k)], newhp);
				}
			}
		}
		bool yes = false;
		for(int i=0; i<(1<<p); i++){
			if((dp.back())[i] > 0) yes = true;
		}
		if(yes){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 18856
import java.util.Scanner;
public class Main{

    int x,y;
 



    public void input(){
	Scanner scan = new Scanner(System.in);
	while(true){

	x = scan.nextInt();
        y = scan.nextInt();

	if(x == 0 && y == 0)break;
        output();
	}
	

    }
    public void output(){
     
	if(x < y){
	    System.out.println(x+" "+y);
      	}else{
	    System.out.println(y+" "+x);

		}



    }
    



    public static void main(String[] args){
	Main  p = new Main();
	p.input();
	//  	p.output();
    }
}
 

Measured memory_bytes: 34768
N, M = map(int, input().split())
C = [tuple(map(int, input().split())) for _ in range(N)]

res = 0

for i in range(8):
    D = [0 for _ in range(N)]
    for j in range(N):
        x, y, z = C[j]
        if (i >> 0) & 1:
            D[j] += x
        else:
            D[j] -= x
        if (i >> 1) & 1:
            D[j] += y
        else:
            D[j] -= y
        if (i >> 2) & 1:
            D[j] += z
        else:
            D[j] -= z
    D.sort(reverse=True)
    res = max(res, sum(D[:M]))

print(res)

Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	vector<ll> v(n);
	ll ans = 0;
	for( auto &i : v ) cin >> i;
	for( int l = 0; l <= n; ++l ){
		for( int r = 0; r <= n; ++r ){
			if( ( l == 0 && r == 0 ) || l+r > n || l+r > k ) break;
			ll sum = 0;
			priority_queue< ll, vector<ll>, greater<ll> > pq;
			for( int i = 0; i < l; ++i ){
				sum += v[i];
				if( v[i] < 0 ) pq.push(v[i]);
			}
			for( int i = 0; i < r; ++i ){
				sum += v[n-1-i];
				if( v[n-i-1] < 0 ) pq.push(v[n-1-i]);
			}
			ans = max(ans, sum);
			for( int i = 0; ( i < k-l-r && !pq.empty() ); ++i ){
				sum += (-1)*pq.top();
				pq.pop();
			}
			ans = max(ans, sum);
		}
	}
	/*
	if( k > n ){
		ll sum = accumulate( v.begin(), v.end(), 0ll );
		priority_queue< ll, vector<ll>, greater<ll> > pq;
		for( int i = 0; i < n; ++i ){
			if( v[i] < 0 ) pq.push(v[i]);
		}
		for( int i = 0; ( i < k-n && !pq.empty() ); ++i ){
			sum += (-1)*pq.top();
			pq.pop();
		}
		ans = max(ans, sum);
	}
	*/
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        String t = sc.nextLine();

        sc.close();
        String hikaku = t.substring(0,t.length()-1);
        if(s.equals(hikaku)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main() {
  int a,c;
  string b;
  cin>>a>>b>>c;
  char d=b.at(c-1);
  for(int i=0;i<a;i++){
    if(b.at(i)==d){
      cout<<d;
    }
    else{
      cout<<'*';
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 20, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long qpow(long long a, long long b)
{
    long long res0 = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  multMod(res0, a);
        multMod(a, a);
    }
    return res0;
}

long long fact[maxN], tcaf[maxN];

long long cf(int n, int k)
{
	bool static initd = false;
	if (!initd)
	{
		fact[0] = 1;
		FOR(i, 1, maxN)
			fact[i] = fact[i - 1] * i % mod;
		tcaf[maxN - 1] = qpow(fact[maxN - 1], mod - 2);
		for (int i=maxN-1; i>0; i--)
			tcaf[i - 1] = tcaf[i] * i % mod;
		initd = true;
	}
	if (k < 0 or k > n)
		return 0;
	long long res0 = fact[n];
	multMod(res0, tcaf[k]);
	multMod(res0, tcaf[n-k]);
	return res0;
}

long long f(int n, int d)
{
	return cf(n+1, d+1);
}

int x[maxN];
long long pref[maxN];

int main()
{
	int n;
	scanf ("%d", &n);
	cf(n, 0);
	
	FOR(i, 0, n)
		scanf ("%d", x+i);
	
	FOR(i, 1, n+1)
		pref[i] = (pref[i-1] + qpow(i, mod-2)) % mod;
	
	long long res = 0;
	FOR(i, 0, n-1)
		addMod(res, pref[i+1] * (x[i+1] - x[i]));
	
	multMod(res, fact[n-1]);
	printf("%lld\n", res);
	return 0;	
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAX=3234566667;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    queue<ll> que;
    for (int i=1;i<10;++i) que.emplace(i);
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    while(!que.empty()){
        ll now=que.front(),nxt=now%10; que.pop();
        pq.emplace(now);
        if (nxt!=0&&now*10+nxt-1<=MAX) que.emplace(now*10+nxt-1);
        if (now*10+nxt<=MAX) que.emplace(now*10+nxt);
        if (nxt!=9&&now*10+nxt+1<=MAX) que.emplace(now*10+nxt+1);
    }
    for (int i=0;i<K-1;++i) pq.pop();
    cout << pq.top() << '\n';
}

Measured memory_bytes: 1784
//#pragma GCC oplmize(2)
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e7+5;
const int mod=998244353;
const double pi=acos(-1.0);
const double eps = 1e-8;
char s[maxn];
int a[maxn],len;
ll dp[2][maxn];   //每个状态有两个选择，dp[0][i]表示支付x张10^i元货币，dp[1][i]表示支付一张10^(i+1)，找10-x张10^i元货币

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    scs(s);
    len=strlen(s+1);
    for(int i=1;i<=len;i++){
        a[i]=s[len-i+1]-'0';
    }
    dp[0][1]=a[1];
    dp[1][1]=10-a[1];
    for(int i=2;i<=len+1;i++){
        dp[0][i]=min(dp[0][i-1]+a[i],dp[1][i-1]+a[i]+1);
        dp[1][i]=min(dp[0][i-1]+10-a[i],dp[1][i-1]+10-(a[i]+1));
    }
    pr(min(dp[0][len+1],dp[1][len+1]));
    return 0;
}


// //#pragma GCC oplmize(2)    //贪心写法
// #include <bits/stdc++.h>
// #define ll long long
// #define sc(x) scanf("%lld",&x)
// #define scs(x) scanf("%s",x+1)
// #define pr(x) printf("%lld\n",x)
// #define prs(x) printf("%s\n",x)
// using namespace std;
// const int maxn=1e7+5;
// const int mod=998244353;
// const double pi=acos(-1.0);
// const double eps = 1e-8;
// char s[maxn];
// int a[maxn],len;
// ll sum;

// int main()
// {
//     ios::sync_with_stdio(false);
//     cin.tie(0);
//     scs(s);
//     len=strlen(s+1);
//     for(int i=1;i<=len;i++){
//         a[i]=s[len-i+1]-'0';
//     }
//     for(int i=1;i<=len+1;i++){
//         if(a[i]==10){
//             a[i]-=10;
//             a[i+1]++;
//         }
//         if(a[i]>5){
//             sum+=(10-a[i]);
//             a[i+1]++;
//         }
//         else if(a[i]<5){
//             sum+=a[i];
//         }
//         else{
//             sum+=5;
//             if(a[i+1]>=5){
//                 a[i+1]++;
//             }
//         }
//     }
//     pr(sum);
//     return 0;
// }

Measured memory_bytes: 24368
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   #ifndef ONLINE_JUDGE
      // freopen("input.txt", "r", stdin);
      // freopen("output.txt", "w", stdout);
   #endif
   int n;
   cin >> n;
   map<string,int> cnt;
   int mx = 0;
   string s;
   f(i,0,n){
      cin >> s;
      cnt[s]++;
      mx = max(mx,cnt[s]);
   }
   vector<string> ans;
   for(auto &e : cnt){
      if(e.S == mx){
         cout << e.F << '\n';
      }
   }
   return 0;
}

Measured memory_bytes: 23808
import java.util.*;

class Main {
    public static void main(String...args) {
        Scanner scan = new Scanner(System.in);
        int aryLen = scan.nextInt();
        int[] ary = new int[aryLen];
        int interCount = 1;
        int sortCount = 0;
        int maxInter = 0;
        

        for(int i = 0; i < aryLen; i++) {
            ary[i] = scan.nextInt();
        }
        
        int inter = 1;
        while(inter * 3 + 1 < aryLen ) {
            inter = inter * 3 + 1;
            interCount++;
        }

        maxInter = inter;

        for(; inter > 0 ; inter /= 3) {
            for(int j = inter; j < aryLen; j++) {
                int tmp = ary[j];
                int point = j;
                while(point - inter >= 0 && ary[point - inter] > tmp) {
                    ary[point] = ary[point - inter];
                    point -= inter;
                    sortCount++;    
                }
                ary[point] = tmp;
            }
            
        }
        System.out.println(interCount);
        for(; maxInter > 0; maxInter/=3) {
            System.out.print(maxInter);
            if(maxInter != 1) {
                System.out.print(" ");
            } else if(maxInter == 1) {
                System.out.println();
            }
        }
        System.out.println(sortCount);
        for(int k = 0; k < aryLen; k++) {
            System.out.println(ary[k]);
        }
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

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

	string a, b;
	cin >> a >> b;
	if ( a.size() > b.size() )
		std::cout << "GREATER" << std::endl;
	else if ( a.size() < b.size() )
		std::cout << "LESS" << std::endl;
	else if ( a > b )
		std::cout << "GREATER" << std::endl;
	else if ( a < b )
		std::cout << "LESS" << std::endl;
	else
		std::cout << "EQUAL" << std::endl;

	return 0;
}


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

int main() {
    ll N; cin >> N;
    vector<int> A(N), B(N);
    ll wa = 0;
    rep(i,N) {
        cin >> A.at(i);
        wa += A[i];
    }

    ll x1 = wa;
    for (int i = 1; i < N-1; i += 2) x1 -= 2 * A[i]; 
    cout << x1;
    rep(i, N-1) {
        cout << " ";
        int xn = 2 * A[i] - x1;
        cout << xn;
        x1 = xn;
    }
    cout << endl;
}


Measured memory_bytes: 4056
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<string>
#include<cstdio>
#include<stack>
#include<cmath>
#include<bitset>
#include<memory>
#include<memory.h>
#include<utility>
#include<map>
using namespace std;
#define FOR(i,m,n) for(i=m;i<n;i++)
#define CLR(a,b) memset(a,b,sizeof(a))
#define ROF(i,m,n) for(i=m;i>=n;i--)
#define BUG cout<<"debug"<<endl;
#define RT return
#define BK break
#define HEAP priority_queue
#define SP " "
#define rd(x) (rand()%(x))
#define lowf(a,b,c) lower_bound(a,b,c)
#define upf(a,b,c) upper_bound(a,b,c)
#define sh(a) cout<<a<<endl
typedef long long LL;
typedef vector<int> VI;
const int INF = 2147483647;
const int NEN = -INF - 1;
const LL LINF = 9223372036854775807;
bitset<10005> Map[12];
int ord[10];
int R, C,i,j,k,ans,sum,ANS;//C是高，R是宽
int main()
{
	int temp;
	while (cin >> C >> R)
	{
		CLR(ord, 0);
		if (C == 0 && R == 0)break;
		ans = 0;
		FOR(i, 0, C)
		{
			FOR(j, 0, R)
			{
				cin >> temp;
				Map[i][j] = temp;
			}
		}
		ANS = 0;
		FOR(j, 0, R)
		{
			sum = 0;
			FOR(i, 0, C)
			{
				sum += Map[i][j];
			}
			ANS += max(sum, C - sum);
		}
		ans = ANS;
		FOR(i, 0, C)
		{
			sort(ord, ord + C);
			ord[C - 1 - i] = 1;
			do
			{
				ANS = 0;
				FOR(j, 0, C)
				{
					if (ord[j] == 1)Map[j].flip();
				}
				FOR(j, 0, R)
				{
					sum = 0;
					FOR(k, 0, C)
					{
						sum += Map[k][j];
					}
					sum = max(sum, C - sum);
					ANS += sum;
				}
				ans = max(ans, ANS);
				FOR(j, 0, C)
				{
					if (ord[j] == 1)Map[j].flip();
				}
			} while (next_permutation(ord, ord + C));
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000
//bool cmp(P a,P b){ return a.second < b.second;}


	ll N,M,K,ans=0;
    string S;



int main(){
	std::ios_base::sync_with_stdio(false);
    cin>>S>>N;
    std::deque<char> Q;
    REP(i,S.size())Q.push_back(S[i]);
    bool rev=false;
    REP(i,N){
        int mode;
        cin>>mode;
        if(mode==1){
            if(rev)rev=false;
            else rev=true;
        }else{
            char sd;int as;
            cin>>as>>sd;
            if(rev){
                if(as==2)Q.push_front(sd);
                else Q.push_back(sd);
            }else{
                if(as==1)Q.push_front(sd);
                else Q.push_back(sd);
            }
        }

    }
    if(rev){
        std::for_each(Q.rbegin(), Q.rend(), [](char x) {
            std::cout << x ;
        });
    }else{
        std::for_each(Q.begin(), Q.end(), [](char x) {
            std::cout << x ;
        });
    }
	return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>

using namespace std;

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

    int a,b;
    // 引数の受け取り
    cin >> a >> b ;

    cout << (a * a - b)  << endl;

    // 出力
    return 0;
}



Measured memory_bytes: 256