akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const size_t MAX_H = 60;
const size_t MAX_W = 100001;

struct BinaryMatrix {
    BinaryMatrix(size_t H, size_t W) : H(H), W(W) {};
    inline bitset<MAX_W>& operator[](size_t i) {return mat[i];}
    size_t H, W;
    bitset<MAX_W> mat[MAX_H];
};

void gauss_jordan(BinaryMatrix &A, bool extended = false) {
    vector<bool> used(A.H, false);

    for(size_t col = 0; col < A.W; ++col) {
        if(extended && col + 1 == A.W) break;

        // select a pivot
        int pivot = -1;
        for(size_t row = 0; row < A.H; ++row) {
            if(used[row]) continue;
            if(A[row][col]) {
                pivot = row;
                break;
            }
        }
        if(pivot == -1) continue;

        // sweep
        for(size_t row = 0; row < A.H; ++row) {
            if(row != pivot && A[row][col]) {
                A[row] ^= A[pivot];
            }
        }
        used[pivot] = true;
    }
}

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

    long long res = 0;
    const int md = 59;
    vector<bool> used(md + 1);
    BinaryMatrix M(md + 1, N + 1);
    for(int d=md; d>=0; --d) {
        int cnt = 0;
        for(long long a : A) {
            if((a >> d) & 1) ++cnt;
        }

        if(cnt == 0) {
            used[d] = true;
        } else if(cnt & 1) {
            used[d] = true;
            res += (1LL << d);
        } else {
            for(int i=0; i<N; ++i) {
                if((A[i] >> d) & 1) M[md - d][i] = true;
            }
            M[md - d][N] = true;
        }
    }

    gauss_jordan(M, true);

    for(int d=md; d>=0; --d) {
        if(used[d]) continue;
        bool flag = false;
        for(int i=0; i<N; ++i) {
            if(M[md - d][i]) flag = true;
        }
        if(!M[md - d][N]) flag = true;

        if(flag) res += (1LL << (d + 1));
    }

    cout << res << endl;
}

Measured memory_bytes: 1792
import scala.math.abs

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val t, a = sc.nextInt()
  val h = Array.fill(n)(sc.nextInt())
  val temps = h.map(t - _ * 0.006)
  val diff = temps.map(temp => abs(a - temp))
  println(diff.indexOf(diff.min) + 1)
}

Measured memory_bytes: 56244
# -*- coding: utf-8 -*-


def main():
    h, w, a, b = map(int, input().split())
    ans = [[0 for _ in range(w)] for _ in range(h)]

    # See:
    # https://www.youtube.com/watch?v=RXYksUjlPD4
    # KeyInsight
    # 以下の形式で埋める
    # －－－－－
    # |000|1111|
    # |000|1111|
    # －－－－－
    # |111|0000|
    # －－－－－
    # 思いつくためには，最初の行・列が条件を満たす場合を考える
    # 今回，Noのケースはない
    for wi in range(a, w):
        for hi in range(b):
            ans[hi][wi] = 1

    for hi in range(b, h):
        for wi in range(a):
            ans[hi][wi] = 1

    for a in ans:
        print(''.join(map(str, a)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 12916
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
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;
  }
};

vi G[100100];
vi d(100100,-1);
int main() {
  int n, k;
  cin >> n >> k;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  mint ans = k;
  queue<int> q;
  d[0] = 1;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    //show(u);
    q.pop();
    int x;
    int m = sz(G[u]);
    if(u != 0)m--;
    if (d[u] == 1)
      x = k - 1;
    else
      x = k - 2;
    rep(i, m) {
      ans *= x;
      x--;
    }
    //show(ans.x);
    for(auto v:G[u]){
      if(d[v] != -1)continue;
      d[v] = d[u]+1;
      q.push(v);
    }
  }
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 9916
while True:
    n, x =map(int, input().split())
    p = 0
    if n==0 and x==0:
        break
    for a in range(1,n+1):
        for b in range(1,n+1):
            for c in range(1,n+1):
                if a+b+c==x and a<b<c:
                    p=p+1
    print(p)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

vector<int> p;
int cnt[1003];
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	for (int i = 2; i <= n; ++i) {
		bool flag = false;
		int c = i;
		for (int j = 0; j < (int)p.size(); ++j) {
			while (c > 1 && c % p[j] == 0) {
				flag = true;
				++cnt[p[j]];
				c /= p[j];
			}
		}
		if (!flag) {
			p.push_back(i);
			++cnt[i];
		}
	}
	ll ans = 1;
	for (int i = 0; i < (int)p.size(); ++i) {
		ans *= cnt[p[i]] + 1;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
require 'set'

class UnionFind
	def initialize
		@obj_to_node = {}
	end

	def add(obj)
		@obj_to_node[obj] ||= Node.new(obj)
	end

	def size(x = nil)
		x ? @obj_to_node[x].root.size : @obj_to_node.size
	end

	class Node
		def initialize(obj)
			@obj = obj
			@parent = self
			@size = 1
			@rank = 0
		end

		def root
			return self if @parent == self
			@parent = @parent.root
		end

		attr_accessor :parent, :size, :rank
	end

	def union(x, y)
		u = (@obj_to_node[x] ||= Node.new(x)).root
		v = (@obj_to_node[y] ||= Node.new(y)).root
		return if u == v
		if u.rank > v.rank
			v.parent = u
			u.size += v.size
		elsif v.rank > u.rank
			u.parent = v
			v.size += u.size
		else
			u.parent = v
			v.rank += 1
			v.size += u.size
		end
	end

	def same?(x, y)
		return false unless u = @obj_to_node[x]
		return false unless v = @obj_to_node[y]
		u.root == v.root
	end

    def groups
        @obj_to_node.keys.group_by {|x| @obj_to_node[x].root}.values
    end
end

n = gets.to_i
contribute = [0] + gets.split.map(&:to_i)
uf = UnionFind.new
(1..n).each {|i| uf.add(i)}

g = {}
g_inv = {}
(1..n).map {|i| g[i] = Set.new; g_inv[i] = Set.new}

m = gets.to_i
neighbour = (0..n).map { Set.new }
m.times do
    u, v = gets.split.map(&:to_i)
    g[v] << u if contribute[u] <= contribute[v]
    g[u] << v if contribute[u] >= contribute[v]
    g_inv[v] << u if contribute[u] >= contribute[v]
    g_inv[u] << v if contribute[u] <= contribute[v]
    neighbour[u] << v
    neighbour[v] << u
    uf.union(u, v) if contribute[u] == contribute[v]

end

(1..n).each do |c|
    neighbour[c].sort_by{|v| contribute[v]}.each_cons(2) do |u, v|
        if contribute[u] == contribute[v]
            g[v] << u
            g[u] << v
            g_inv[v] << u
            g_inv[u] << v
            uf.union(u, v)
        else
            g[v] << u
            g_inv[u] << v
        end
    end
end

scc_size = Hash.new(1)

#g.strongly_connected_components.each do |scc|
uf.groups.each do |scc|
    next if scc.size == 1
    rep = scc[0]
    scc_size[rep] = scc.size

    scc[1..-1].each do |u|
        g[rep] += g[u]
        g[rep].delete(rep)
        g_inv[rep] += g_inv[u]
        g_inv[rep].delete(rep)

        g_inv[u].each do |v|
            g[v].delete(u)
            g[v] << rep if v != rep
        end

        g[u].each do |v|
            g_inv[v].delete(u)
            g_inv[v] << rep if v != rep
        end

        g.delete(u)
        g_inv.delete(u)
    end
end

salary = {}
out_deg = {}
queue = []
g.each do |u, s|
    queue << u if s.empty?
    out_deg[u] = s.size
end

until queue.empty?
    u = queue.shift
    salary[u] = (g[u].map {|v| salary[v]}.max || 0) + 1
    g_inv[u].each do |v|
        out_deg[v] -= 1
        queue << v if out_deg[v] == 0
    end
end

p g.keys.map {|v| salary[v] * scc_size[v]}.inject(:+)

Measured memory_bytes: 279392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	vector<string> s(h);
	for (int i = 0; i < h; i++) cin >> s[i];

	vector<int> di = { -1,0,1,0 };
	vector<int> dj = { 0,-1,0,1 };
	const int INF = 1e9;
	vector<vector<int>> dist(h, vector<int>(w, INF));
	deque<pair<int, int>> q;
	ch--; cw--; dh--; dw--;
	dist[ch][cw] = 0;
	q.push_back(make_pair(ch, cw));
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		int d = dist[i][j];
		q.pop_front();
		for (int v = 0; v < 4; v++) {
			int ni = i + di[v];
			int nj = j + dj[v];
			if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
			if (s[ni][nj] == '#') continue;
			if (dist[ni][nj] <= d) continue;
			dist[ni][nj] = d;
			q.push_front(make_pair(ni, nj));
		}

		for (int vi = -2; vi <= 2; vi++) {
			for (int vj = -2; vj <= 2; vj++) {
				int ni = i + vi;
				int nj = j + vj;
				if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
				if (s[ni][nj] == '#') continue;
				if (dist[ni][nj] <= d + 1) continue;
				dist[ni][nj] = d + 1;
				q.push_back(make_pair(ni, nj));
			}
		}
	}
	if (dist[dh][dw] == INF) cout << -1 << endl;
	else cout << dist[dh][dw] << endl;
}


Measured memory_bytes: 9512
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

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

	if (A[K-1] == 'A')
		A[K-1] = 'a';
	if (A[K-1] == 'B')
		A[K-1] = 'b';
	if(A[K - 1] == 'C')
		A[K-1] = 'c';
	for (int i = 0; i < N; i++)
		cout << A[i];

	return 0;
}

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

char chess(int h , int w){
    if((h+w)%2==0) {
        return '#';
    }
return '.';
}

int main()
{
    int H, W;
    while(true){
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }
    for(int i = 0; i<H; i++){
        for(int j = 0; j <W; j++){
            cout << chess(i,j);
        }
    cout << endl;
           }
        cout << endl;
    }
    }


Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < y->key){
      x = y->left;
    } else {
      x = y->right;
    }
  }

  z->parent = y;
  if(y == NIL){
    root = z;
  } else {
    if(z->key < y->key){
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    cin >> com;
    if(com[0] == 'f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(com == "insert"){
      scanf("%d", &x);
      insert(x);
    } else if(com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 20004
n,p = (int(num) for num in input().split())
s = input()
s = s[::-1]

if p != 2 and p != 5:
    dec = [1] * n
    for i in range(1,n):
        dec[i] = (dec[i - 1] * 10) % p
    s_mod = [0] * n
    for i in range(n):
        s_mod[i] = (int(s[i]) * dec[i]) % p

    #print(dec)
    #print(s_mod)

    cumsum = [0] * (n + 1)
    cnt = [1] + [0] * (p - 1)
    for i in range(n):
        cumsum[i + 1] = (cumsum[i] +  s_mod[i]) % p
        cnt[cumsum[i + 1]] += 1
    #print(cumsum)
    #print(cnt)

    ans = 0
    for i in range(p):
        ans += (cnt[i] * (cnt[i] - 1)) // 2
    print(ans)
elif p == 2:
    ans = 0
    for i in range(n):
        if int(s[i]) % 2 == 0:
            ans += n - i
    print(ans)
elif p == 5:
    ans = 0
    for i in range(n):
        if int(s[i]) % 5 == 0:
            ans += n - i
    print(ans)

Measured memory_bytes: 25940
s = gets.chomp
q = gets.to_i

HEAD = 0
TAIL = 1

dir = TAIL
head = []
tail = []

q.times do
  line = gets.chomp
  if line[0] == "1"
    dir = 1 - dir
  else
    a,b,c = line.split   
    b = b.to_i - 1
    if b ^ dir == 0
      tail << c
    else
      head << c
    end
  end
end

if dir == TAIL
  puts head.reverse.join + s + tail.join
else
  puts tail.reverse.join + s.reverse + head.join
end




Measured memory_bytes: 20604
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,k;
    cin >> n >> k;
    k *= n;
    vector<int> a(n);
    map<int,vector<int>> mp;
    rep(i,n){
        cin >> a[i];
        mp[a[i]].emplace_back(i);
    }
    vector<ll> w(n);
    for(auto m: mp){
        vector<int> vec = m.second;
        int s = vec.size();
        vec.emplace_back(vec[0]+n);
        for(int i=0; i<s; i++){
            int v = vec[i];
            w[v] = vec[i+1] - vec[i] + 1;
        }
    }
    vector<vector<ll>> nx = {w};
    int L = 60;
    for(int _=0; _<L; _++){
        vector<ll> x = nx.back();
        vector<ll> y(n);
        for(int i=0; i<n; i++){
            y[i] = min(k+1,x[i] + x[(i+x[i])%n]);
        }
        nx.emplace_back(y);
    }
    ll cur = 0;
    for(int i=L-1; i>=0; i--){
        if(cur + nx[i][cur%n] <= k){
            cur += nx[i][cur%n];
        }
    }
    if(cur == k) return 0;
    vector<int> ans;
    set<int> has;
    for(int i=cur%n; i<n; i++){
        if(has.count(a[i])){
            while(1){
                int v = ans.back();
                ans.pop_back();
                has.erase(v);
                if(v == a[i]) break;
            }
        }else{
            has.insert(a[i]);
            ans.emplace_back(a[i]);
        }     
    }
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " \n"[i+1 == ans.size()];
    }
    return 0;
}

Measured memory_bytes: 131172
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  ll right = c - a - b;
  if (right < 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << ( (4LL * a * b < right * right) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MIN INT_MIN
#define MAX INT_MAX
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define E "\n"
#define frep(i,j,k,inc) for(int i=j;i<k;i+=inc)
#define rrep(i,j,k,dec) for(int i=j;i>k;i-=dec)
#define arep(elm,obj) for(auto elm:obj)
#define all(x) x.begin(),x.end()
#define revT greater<int>()
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int>pii;
const ll mod=1000000007;
void solve();
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    int t;
//    cin>>t;
//    while(t--)
    	solve();

    return 0; 
}

int mima(vi vec,int f){
	int mi=vec[0],ma=vec[0];
	frep(i,1,vec.size(),1){
		mi=min(mi,vec[i]);
		ma=max(ma,vec[i]);
	}
	if(f){return ma;}
	else{return mi;}
}


void solve(){
	int n;
	cin>>n;
	int arr[4];
	memset(arr,0,sizeof(arr));
	frep(i,0,n,1){
		string s;
		cin>>s;
		if(s=="AC"){arr[0]++;}
		if(s=="WA"){arr[1]++;}
		if(s=="TLE"){arr[2]++;}
		if(s=="RE"){arr[3]++;}
	}
	cout<<"AC x "<<arr[0]<<E;
	cout<<"WA x "<<arr[1]<<E;
	cout<<"TLE x "<<arr[2]<<E;
	cout<<"RE x "<<arr[3]<<E;
}

Measured memory_bytes: 3604
import java.util.Scanner

object Main {
  def gcd(a: Long, b: Long): Long = if (a < b) (gcd(b, a)) else if (b == 0) (a) else (gcd(b, a % b))

  def solve(sc: => Scanner, N: Int): Long = {
    if (N == 0) (1) else {
      val X = sc.nextLong
      val Y = solve(sc, N - 1)
      X / gcd(X, Y) * Y
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    println(solve(sc, sc.nextInt))
  }
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

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

template <class T>
T ext_gcd(T a, T b, T& x, T& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    auto d = ext_gcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

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

signed main() {
    int a, b;
    cin >> a >> b;
    int x, y;
    ext_gcd(a, b, x, y);
    cout << x << " " << y << "\n";
}



Measured memory_bytes: 3216
a=int(input())
b=int(input())
c=int(input())
d=c*3-a-b
g=c*2-d
h=c*2-b
i=c*2-a
e=c*3-a-g
f=c*3-d-i
print(a,b,d)
print(e,c,f)
print(g,h,i)

Measured memory_bytes: 61900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>x(N);
    vector<ll>y(N);
    vector<ll>h(N);
    ll hmin=INF;
    ll hmax =0;
    rep(i,N){
        cin>>x[i]>>y[i]>>h[i];
        chmin(hmin,h[i]);
        chmax(hmax,h[i]);
    }

    rep(i,101){
        rep(j,101){
            rep3(nh,hmax,hmin+205){
                rep(k,N){
                    if(h[k] != max(nh-abs(i-x[k])-abs(j-y[k]),ll(0))){
                        break;
                    }
                    if(k==N-1){
                        cout<<i<<" "<<j<<" "<<nh<<endl;
                    }
                }
            }
        }
    }



    return 0;
    

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	cin>>a>>b;
	for (int i=1; i<=1000; i++){
		int x = i * 0.08;
		int y = i * 0.1;
		if (x == a && y == b){
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
}

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

int main() {
	int64_t n, m, l;
	cin >> n >> m >> l;
	vector<vector<int64_t>> a(n, vector<int64_t>(m));
	rep(i, n)
	{
		rep(j, m)
			cin >> a.at(i).at(j);
	}
	vector<vector<int64_t>> b(m, vector<int64_t>(l));
	rep(i, m)
	{
		rep(j, l)
			cin >> b.at(i).at(j);
	}
	rep(i, n)
	{
		rep(j, l)
		{
			int64_t sum;
			sum = 0;
			rep(k, m)
				sum += a.at(i).at(k) * b.at(k).at(j);
			if(j)
				cout << ' ';
			cout << sum;
		}
		cout << endl;
	}
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define ll long long
using namespace std;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  vector<ll> d(n);
  rep(i,n-1) d[i] = x[i+1]-x[i];
  ll ans = 0;
  rep(i,n-1){
    ans += min(d[i]*a,b);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![(0, 0); n];
    for i in 0..n {
        seq[i].0 = read::<usize>();
        seq[i].1 = i;
    }
    seq.sort();
    for i in 0..n {
        if i != 0 {
            print!(" ");
        }
        print!("{}", seq[i].1 + 1);
    }
}


Measured memory_bytes: 4080
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String o = sc.nextLine();
		String e = sc.nextLine();
		String result = "";
		for(int i = 0; i < e.length(); i++){
			result += o.charAt(i);
			result += e.charAt(i);
		}
		if(o.length() > e.length())
			result += o.charAt(o.length() - 1);
		
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 21844
A,B = map(int,input().split())
divA = []
divB = []

for i in range(2,int(A**0.5)+2):
    if A % i == 0:
        divA.append(i)
    while(A % i == 0):
        A = A//i
if A != 1:
    divA.append(A)

for i in range(2,int(B**0.5)+2):
    if B % i == 0:
        divB.append(i)
    while(B % i == 0):
        B = B//i
if B != 1:
    divB.append(B)

print(len(set(divA)&set(divB))+1)

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

int N;
vector<int> A;
int table[] = {5, 7, 5, 7, 7};

int solve(){
    for(int i=0; i<N; i++){
        bool ok = true;
        int cur = i;
        for(int j=0; j<5; j++){
            int s = 0;
            while(cur<N && s<table[j]){
                s += A[cur++];
            }
            if(table[j] != s){
                ok = false;
                break;
            }
        }
        if(ok)
            return i+1;
    }
    return -1;
}

int main(){
    while(cin >> N, N){
        A.clear();
        for(int i=0; i<N; i++){
            string s; cin >> s;
            A.push_back(s.size());
        }
        cout << solve() << endl;
    }
    return 0;
}

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

template<int um> class UF { // from kmjp
public:
	vector<int> par;
	UF() { par = vector<int>(um, 0); rep(i, 0, um) par[i] = i; }
	int operator[](int x) { return par[x] == x ? x : par[x] = operator[](par[x]); }
	void operator()(int x, int y)
	{
		x = operator[](x); y = operator[](y);
		if (x != y) par[x] = y;
	}
};
//-----------------------------------------------------------------
int N, W, H;
int X[40101], Y[40101];
UF<40101> uf;
//-----------------------------------------------------------------
int main() {
	cin >> N >> W >> H;
	rep(i, 0, N) cin >> X[i] >> Y[i];

	rep(i, 0, N) rep(j, i + 1, N) if (X[i] == X[j] || Y[i] == Y[j]) uf(i, j);

	bool isWall = false;
	rep(i, 0, N) if ((X[i] == 1 || X[i] == W) || (Y[i] == 1 || Y[i] == H)) isWall = true;

	int ans = 0;
	rep(i, 0, N) if (uf[i] == i) ans++;

	if (ans == 1)
		ans = N - 1;
	else {
		if (isWall) ans--;
		ans += N - 1;
	}	

	cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>p(N);
  vector<int>q(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> 	q.at(i);
  }
  vector<int>order(N);
  for(int i=0;i<N;i++){
    order.at(i)=i+1;
  }
  int p_ans,q_ans;
  int count=1;
  do{
    bool p_if=true;
    bool q_if=true;
    for(int i=0;i<N;i++){
      if(p.at(i)!=order.at(i)) p_if=false;
      if(q.at(i)!=order.at(i)) q_if=false;
    }
    if(p_if) p_ans=count;
    if(q_if) q_ans=count;
    count++;
  }while(next_permutation(order.begin(),order.end()));
  cout << abs(p_ans-q_ans) << endl;
}


Measured memory_bytes: 3600
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String [] line = sc.nextLine().split(",");
            int [] length = new int[10];
            int totalLength = 0;
            for(int i = 0; i < 10; i++) {
                length[i] = Integer.parseInt(line[i]);
                totalLength += length[i];
            }

            int v1 = Integer.parseInt(line[10]);
            int v2 = Integer.parseInt(line[11]);

            double meet = totalLength * 1.0 * v1 / (v1 + v2);

            for(int i = 0; i < 10; i++) {
                if (meet <= length[i]) {
                    System.out.println(i + 1);
                    break;
                } else {
                    meet -= length[i];
                }
            }
        }

    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<stdlib.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(1)
  {
    c-=b;
    if(c<=0)
    {
      printf("Yes\n");
      break;
    }a-=d;
    if(a<=0)
    {
      printf("No\n");
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
typedef long long LL;
int num[maxn];
double E[maxn];
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 1;i<=n;++i)
    {
        scanf("%d",&num[i]);
        E[i] = (1+num[i])/2.0+E[i-1];
    }
      double sum = 0;
    //sort(num,num+n,greater<int>());
    for(int i = 1,j = k;j<=n;++i,++j)
    {

        sum = max(sum,E[j]-E[i-1]);
    }
    cout << fixed <<setprecision(9) <<sum << endl;
    return 0;
}


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

int main()
{
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	if (abs(x - a) < abs(x - b)) printf("A\n");
	else printf("B\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

int n;
int pre[maxn],suf[maxn];
int A[maxn];

int main() {
	cin >> n;
	for (int i =0;i<n;i++) cin >> A[i];
	pre[0] = A[0];
	for (int i =1;i<n;i++) pre[i] = __gcd(pre[i-1],A[i]);
	suf[n-1] = A[n-1];
	for (int i =n-2;i>=0;i--) suf[i] = __gcd(suf[i+1],A[i]);
	
	int ans = 0;
	for (int i =0;i<n;i++) {
		if (i == 0) ans = max(ans,suf[i+1]);
		else if (i == n-1) ans = max(ans,pre[i-1]);
		else ans = max(ans, __gcd(pre[i-1],suf[i+1]));
	}
	cout << ans;
}
	


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,q,tx,ty,ans,px[2<<17],py[2<<17];
signed main(){
	cin>>n>>q;tx=ty=n;ans=(n-2)*(n-2);
	while(q--){
		int t,x;
		cin>>t>>x;
		if(t==1){
			if(x<tx){
				ans-=ty-2;
				while(tx>x)px[tx--]=ty-2;
			}else ans-=px[x];
		}else{
			if(x<ty){
				ans-=tx-2;
				while(ty>x)py[ty--]=tx-2;
			}else ans-=py[x];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,q,a[maxn][maxn],sum[maxn][maxn];
int main(){
	cin >> n >> m >> q;
	for(int i=1;i<=m;i++){
		int l,r;
		cin >> l >> r;
		a[l][r]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[i][j] = sum[i][j-1] + a[i][j];
		}
	}
	for(int i=1;i<=q;i++){
		int p1,q1;
		cin >> p1 >> q1;
		int ans = 0;
		for(int i=p1;i<=q1;i++){
			ans += sum[i][q1];
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	char input[7],ac[] = "AC";
	scanf("%s",input);
	if(strstr(input,ac) != NULL)	puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

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

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	int n;
	cin>>n;
	unsigned long long s;
	for(int i=40000;i>=1;i--){
		s=i*i;
		if(s<=n)cout<<s<<endl;
		else continue;
		return 0;
	}
}

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

const int INF = 1001001001;

const int mod = 1000000007;

struct mint{
  ll x;
  mint(ll x = 0):x((x % mod + mod) % mod){};
  mint pow(ll y) const {
    mint res(1);
    mint a(x);
    while(y>0){
      if(y&1) res *= a;
      a *= a;
      y >>= 1;
    }
    return res;
  }
  mint inv() const{ return pow(mod-2); }
  mint& operator+= (const mint a) noexcept {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-= (const mint a) noexcept {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*= (const mint a) noexcept {
    (x *= a.x) %= mod;
    return *this;
  }
  mint& operator/= (const mint a) noexcept {
    return (*this) *= a.inv();
  }
  mint operator+ (const mint a) const noexcept {
    mint res(*this);
    return res += a;
  }
  mint operator- (const mint a) const noexcept {
    mint res(*this);
    return res -= a;
  }
  mint operator* (const mint a) const noexcept {
    mint res(*this);
    return res *= a;
  }
  mint operator/ (const mint a) const noexcept{
    mint res(*this);
    return res /= a;
  }
};

ostream& operator<<(ostream& stream, const mint& n){
  stream << n.x;
  return stream;
};

struct comb{
  vector<mint> fact, ifact;
  comb(int n): fact(n+1), ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const noexcept{
    if(k < 0 || n < k) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  mint ans;
  REP(i, 60){
    ll x = 0;
    REP(j, n) if(a[j]>>i & 1) x++;
    mint now = x*(n-x);
    now *= mint(2).pow(i);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	ll r,d,x,i;
	cin>>r>>d>>x;
	for(i=1;i<11;i++)
	{
	    x= r*x-d;
	    cout<<x<<endl;
	}
    return 0;
}























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[20];
int main()
{
	scanf("%s", s);
	if (s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I')printf("Yes\n");
	else printf("No\n");
}

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

long long N, LL, A[100009], B[100009], C[100009], id[100009]; vector<pair<long long, long long>>X;
long long P1[100009], P2[100009], Q1[100009], Q2[100009];

long long sum(long long pos, long long XX) {
	if (pos < XX) return P1[pos];
	return P2[pos] - X[XX - 1].first;
}
long long query(long long pos, long long XX) {
	if (pos < XX) return Q1[pos];
	return min(Q1[XX - 1], Q2[pos] - X[XX - 1].first);
}

int main() {
	cin >> N >> LL;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i]; id[i] = (1 << 30);
		if (A[i] - B[i] >= 1) X.push_back(make_pair(A[i] - B[i], i));
	}
	for (int i = 1; i <= N; i++) { cin >> C[i]; C[i] += C[i - 1]; }

	sort(X.begin(), X.end(), greater<pair<long long, long long>>());

	for (int i = 0; i < X.size(); i++) {
		id[X[i].second] = i + 1; P1[i + 1] = X[i].first; P2[i] = X[i].first;
		P1[i + 1] += P1[i]; if (i >= 1) P2[i] += P2[i - 1];
		Q1[i + 1] = P1[i + 1]; Q2[i] = P2[i];
	}
	for (int i = 1; i <= N; i++) { Q1[i] -= C[i]; Q2[i] -= C[i]; }
	Q1[0] = (1LL << 32); Q2[0] = (1LL << 32);
	for (int i = 1; i <= N; i++) { Q1[i] = min(Q1[i], Q1[i - 1]); Q2[i] = min(Q2[i], Q2[i - 1]); }

	long long ans = (1 << 30);

	for (int i = 1; i <= N; i++) {
		long long L = 0, R = X.size(), M, maxn = (1 << 30); if (id[i] == (1 << 30)) R++; R = min(R, N);
		for (int j = 0; j < 30; j++) {
			M = (L + R) / 2;
			long long ti = sum(M, id[i]);
			if (ti >= LL - A[i]) { R = M; maxn = min(maxn, M); }
			else { L = M; }
		}
		long long L2 = 0, R2 = X.size(), M2, maxn2 = -1; if (id[i] == (1 << 30)) R2++; R2 = min(R2, N);
		for (int j = 0; j < 30; j++) {
			M2 = (L2 + R2) / 2;
			long long rmq = query(M2, id[i]);
			if (rmq > 0) { maxn2 = max(maxn2, M2); L2 = M2; }
			else { R2 = M2; }
		}
		if (maxn2 < maxn) continue;
		ans = min(ans, maxn + 1);
	}
	if (ans == (1 << 30)) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;

    cin>>n;
    map<string,ll>mp;

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

    	string s;
    	cin>>s;
    	mp[s]++;
    }
    set<pair<ll, string> >st;

    map<string, ll>::iterator it;
    for(it = mp.begin(); it != mp.end(); it++){

    	st.insert(make_pair(-(it->second), (it->first)));
    }
    set<pair<ll, string> >::iterator it1;
    int val = 0;

    for(it1=st.begin(); it1!= st.end();it1++){
    	if(val == 0){
    		cout<<(it1->second)<<"\n";
    		val = it1->first;
    	}else if(it1->first == val){
    		cout<<(it1->second)<<"\n";
    	}
    }

    return 0;
}

Measured memory_bytes: 36480
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int n=s.length();
    int res=0;
    for(int i=0;i<n;i++){
        if(i==0){
            res+=1;
            if(s[i]=='0')s[i]='1';
            else s[i]='0';
        }
        if(s[i]==s[i-1]){
            res++;
            if(s[i-1]=='1')s[i]='0';
            else s[i]='1';
        }
    }
    cout<<n-res<<endl;
    return 0;
    }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

  int n;
  int count = 0;
  cin >> n;
  string s;
  cin >> s;

if(n == 1 || n == 0 || n % 2 != 0){
  cout << "No" << endl;
  return 0;
}
  rep(i, n / 2){
    if(s[i] == s[n/2 + i])count++;
  }
  if(count == n / 2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}




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

using namespace std;
int main(void){
    int n,tmp;
    cin>>n;
    vector<int> A(n),B(n),C(n-1);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>C[i];
    }
    int ans=B[A[0]-1];
    for(int i=1;i<n;i++){
        ans+=B[A[i]-1];
        if(A[i-1]+1==A[i]){
            ans+=C[A[i-1]-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int a[maxn];

int n, c, k;

int read() {
  if (scanf("%d%d%d", &n, &c, &k) < 3) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  return 1;
}

void solve() {
  int res = 0;

  sort(a, a + n);
  for (int i = 0; i < n;) {
    int i0 = i;
    for (; i - i0 < c && i < n && a[i] - a[i0] <= k; ++i) ;
    ++res;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 764
def main():
    import sys
    from collections import defaultdict

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    n = len(s)
    k = int(input())
    for i in range(n):
        tmp = (ord('a')-ord(s[i]))%26
        if tmp > k:
            continue
        k -= tmp
        s = s[:i]+'a'+s[i+1:]
    s = s[:-1]+chr((ord(s[-1])+k%26-ord('a'))%26+ord('a'))
    print(s)

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 10512
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1234567891
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

const int TTL = 1;

int a, b;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> a >> b;
	if (b < 0)
	{
		if (a % 2 == b % 2)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
	}
	else if (a>0)
		cout << "Positive" << endl;
	else
		cout << "Zero" << endl;

	cin.get(); cin.get();
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  int ans = 1;
  for(ll i=0LL; i<k; i++){
    if((s[i]-'0'!=1)){
      ans = s[i]-'0';
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

#pragma endregion 

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

	int n, x;
	cin >> n >> x;
	vi a(n);
	f_vI(a, n);
	LL ans = 0;
	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}
	f(i, 0, n - 1) {
		if (a[i] + a[i + 1] > x) {
			ans += a[i + 1] - (x - a[i]);
			a[i + 1] = x - a[i];
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	string N;
	cin >> N;
	int rem = 0;
	for (int i = 0; i < N.length(); i++) {
		rem += (N[i] - '0');
		rem = rem % 9;
	}
	if (rem == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 3712