akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << b + min(a + b + 1, c) << '\n';
  return 0;
}


Measured memory_bytes: 256
# Manhattan Distance
distance = (
    (),
    (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
    (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
    (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
    (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
    (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
    (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
    (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
    (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
    (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
    (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
    (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
    (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
    (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
    (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
    (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1)
)

def get_distance(board):
    sd = 0
    for i in range(16):
        p = board[i]
        if p == 0:
            continue
        sd += distance[p][i]
    return sd

adjacent = (
    (1, 4),         # 0
    (0, 2, 5),      # 1
    (1, 3, 6),      # 2
    (2, 7),         # 3
    (0, 5, 8),      # 4
    (1, 4, 6, 9),   # 5
    (2, 5, 7, 10),  # 6
    (3, 6, 11),     # 7
    (4, 9, 12),     # 8
    (5, 8, 10, 13), # 9
    (6, 9, 11, 14), # 10
    (7, 10, 15),    # 11
    (8, 13),        # 12
    (9, 12, 14),    # 13
    (10, 13, 15),   # 14
    (11, 14)        # 15
)

GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]

import sys
import heapq

# A* algorithm
def solve():
    board = list(map(int, sys.stdin.read().split()))
    h_cost = get_distance(board)
    state = [h_cost, board]
    
    q = [state] # priority queue
    d = {tuple(board): True}
    
    while q:
        state1 = heapq.heappop(q)
        h_cost, board = state1
        if board == GOAL:
            return h_cost
        space = board.index(0)
        for i in adjacent[space]:
            p = board[i]
            new_board = board[:]
            new_board[space], new_board[i] = p, 0
            new_h_cost = h_cost + 1 - distance[p][i] + distance[p][space]

            key = tuple(new_board)
            if key not in d and new_h_cost <= 45:
                new_state = [new_h_cost, new_board]
                heapq.heappush(q, new_state)
                d[key] = True

print(solve())

Measured memory_bytes: 443800
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll n, m;
	
	cin >> n >> m;
	/*
	int x_[3] = {-1,0,1};
	int y_[3] = {-1,0,1};

	rep(i, n)
	{
		rep(j, m)
		{

		}
	}
	rep(i, 3)
	{

	}
	*/
	if (n > m)
	{
		n = n ^ m;
		m = n ^ m;
		n = n ^ m;
	}

	if (n == 1)
	{
		if (m == 1)
		{
			cout << 1 << endl;
		}
		else if (m >= 2)
		{
			cout << m - 2 << endl;
		}
		
	}
	else
	{
		if (n == 2)
		{
			cout << 0 << endl;
		}
		else
		{
			cout << (n-2) * (m-2) << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <map>
#include <cstring>
using namespace std;

struct node {
    int id;
    int acc_dis;

    bool operator < (const node &rhs) const {
        return acc_dis > rhs.acc_dis;
    }
};

int N, M, R;
int res = 0x3f3f3f3f;
vector<int> need_to_visit;
vector<vector<pair<int, int> > > all_roads;
int min_dis[1005];


map<pair<int, int>, int> dis_cache;

int dij(int from, int to) {
    priority_queue<node> search_queue;

    auto cached = dis_cache.find(pair<int, int>(from, to));
    if (cached != dis_cache.end()) {
        return cached->second;
    }

    memset(min_dis, 0, sizeof(min_dis));

    search_queue.push( node{from, 0} );
    while(!search_queue.empty()) {
        node now_min = search_queue.top();
        search_queue.pop();

        if (min_dis[now_min.id]) {
            continue;
        }

        if (now_min.id == to) {
            dis_cache[ make_pair(from, to) ] = now_min.acc_dis;
            return now_min.acc_dis;
        }

        min_dis[now_min.id] = now_min.acc_dis;

        for(auto &neigh :all_roads[now_min.id]) {
            if (!min_dis[neigh.first]) {
                search_queue.push( node{neigh.first, now_min.acc_dis + neigh.second});
            }
        }
    }
    
    dis_cache[ make_pair(from, to) ] = min_dis[to];
    return min_dis[to];
}

void print_all(const vector<int> &a_path) {
    
    for(auto &i : a_path) {
        cout << i << " ";
    }
    
    cout << endl;
}
 
void get_path_min(const vector<int> &a_path) {
    
    int min_cost = 0;
    for(int i = 0; i < (int)a_path.size()-1; i++) {
        min_cost += dij(a_path[i], a_path[i+1]);
    }
    
    if (min_cost < res) {
        res = min_cost;
    }
    
}

vector<int> possible_path;
vector<bool> used;

void all_permu(int cnt) {

    if (!cnt) {
        get_path_min(possible_path);
        return;
    }


    for(int i = 0; i < R; i++) {
        if (!used[i]) {
            used[i] = true;
            possible_path.push_back(need_to_visit[i]);
            all_permu(cnt - 1);
            used[i] = false;
            possible_path.pop_back();
        }
    }
}

int main() {

    cin >> N >> M >> R;

    used.resize(N);

    for(int i = 0; i <= N; i++) {
        all_roads.push_back( vector<pair<int, int> >() );
    }
    
    int v_id;
    for(int i = 0; i < R; i++) {
        cin >> v_id;
        need_to_visit.push_back(v_id);
    }

    int a, b, cost;
    for(int i = 0; i < M; i++) {
        cin >> a >> b >> cost;
        all_roads[a].push_back( make_pair(b, cost) );
        all_roads[b].push_back( make_pair(a, cost) );
    }

    // print_all(need_to_visit);

    all_permu(R);

    cout << res << endl;

    return 0;
    
}


Measured memory_bytes: 1164
//O(NlogN)
#include<stdio.h>

int a[10000010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)for(int j=i;j<=n;j+=i)a[j]++;
	long long ans=0;
	for(int i=1;i<=n;i++)ans+=(long long)a[i]*i;
	printf("%lld\n",ans);
}


Measured memory_bytes: 40736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

bool dp[2][60000];

bool check(int pos, vector<int> vec){
    memset(dp, 0, sizeof(dp));
    dp[0][30000] = true;//原点
    for(int i = 0; i < vec.size(); ++i){
        for(int j = 0; j < 60000; ++j){
            if(dp[i%2][j] == 0) continue;
            if(j - vec[i] >= 0)     dp[(i+1)%2][j - vec[i]] |= dp[i%2][j];
            if(j + vec[i] < 60000)  dp[(i+1)%2][j + vec[i]] |= dp[i%2][j];
        }
        for(int j = 0; j < 60000; j++){
            dp[i%2][j] = false;
        }
    }
    return dp[vec.size() % 2][pos + 30000];
}

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;
    /*
    {
        //一回もTがないとき->のみ
        int cntT = 0;
        int cntF = 0;
        for(auto c : s) {
            if(c == 'T') cntT++;
            else cntF++;
        }
        if(cntT == 0){
            if(x == cntF && y == 0) cout << "Yes" << endl;
            else cout << "No" << endl;
            return 0;
        }
    }
    */
    vector<int> vecx, vecy;
    int id = 0;
    int cnt = 0;
    s += 'T';
    bool goright = true;
    int offset = 0;
    for(auto c : s){
        if(c == 'F') cnt++;
        else {
            if(id%2==0){
                if(goright){
                    goright = false;
                    offset = cnt;
                    id++;
                    cnt = 0;
                    vecx.push_back(0);
                }else{
                    vecx.push_back(cnt);
                    id++;
                    cnt = 0;
                }
            }else{
                vecy.push_back(cnt);
                id++;
                cnt = 0;
            }
        }
    }
    /*
    for(auto elem : vecx) cout << elem;
    cout << endl;
    for(auto elem : vecy) cout << elem;
    cout << endl;
    cout << vecx.size() << endl;
    cout << vecy.size() << endl;
    */
    if(check(x-offset,vecx) && check(y, vecy)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int Max_N=6,Max_C=50;
int n,c,a[Max_N+5]={},b[Max_N+5]={},vis[Max_N+5]={};
long long ans=0,tot=0,f[Max_N+5][Max_C+10][1<<Max_N]={};
inline void dfs(int x){
	if(x>n){
		memset(f,0,sizeof(f));
		f[0][a[n+1]][0]=1;
		for(int k=0;k<c;k++)
		 for(int J=1;J<=n;J++)
		  for(int I=0;I<=n;I++)
		   for(int i=0;i<1<<n;i++)
		    if((((1<<I-1)&i)||I==0)&&!((1<<J-1)&i))
		     for(int j=k;j<=c;j++){
		     	if((j==k&&I<J)||!f[I][j][i]) continue;
				int pos=0;
				if(j!=k+a[b[J]]) pos=j<k+a[b[J]]?J:I;
				else pos=I<J?J:I;	
				f[pos][min(max(j,k+a[b[J]]),c)][i|(1<<J-1)]+=f[I][j][i];
			 }
		for(int i=1;i<=n+1;i++) ans+=f[i][c][(1<<n)-1];
		return;
	}
	for(int i=1;i<=n;i++)
	 if(!vis[i]){
		vis[b[x]=i]=1;
		dfs(x+1);
		vis[i]=0;
	}
}
int main(){
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1); --n; a[0]=a[n+1];
	dfs(1); tot=1;
	for(int i=1;i<=n;i++) tot=tot*c*i;
	printf("%.12lf\n",ans*1.0/tot);
	return 0;
}

Measured memory_bytes: 4100
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, S, E) for (int(X) = (S); (X) < (E); ++(X))
#define rrep(X, S, E) for (int(X) = (E)-1; (X) >= (S); --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 9 * 1e15;
const ll MOD = 1e9 + 7;

// O(|V||E|)
class Graph {
private:
  ll V; // 0index
  vector<pair<ll, pll>> edges;
  vector<bool> hasNegativeCycles;
  vector<ll> dist;

public:
  Graph(ll V);
  void addEdge(ll u, ll v, ll w);
  void bellmanFord(ll src);
  ll getDistance(ll n);
  bool hasNegativeCycle(ll n);
};
Graph::Graph(ll V) {
  this->V = V;
  this->dist = vector<ll>(this->V, INF);
  this->hasNegativeCycles = vector<bool>(this->V, false);
}
void Graph::addEdge(ll u, ll v, ll w) { edges.push_back({w, {u, v}}); }
void Graph::bellmanFord(ll src) {
  this->dist[src] = 0;
  vector<pair<ll, pair<ll, ll>>>::iterator it;

  for (ll i = 0; i < this->V - 1; i++) {
    for (it = edges.begin(); it != edges.end(); ++it) {
      ll u = it->second.first;
      ll v = it->second.second;
      ll w = it->first;
      if (this->dist[u] + w < this->dist[v]) {
        this->dist[v] = this->dist[u] + w;
      }
    }
  }

  for (it = edges.begin(); it != edges.end(); ++it) {
    ll u = it->second.first;
    ll v = it->second.second;
    ll w = it->first;
    if (this->dist[u] + w < this->dist[v]) {
      this->hasNegativeCycles[v] = true;
    }
    if (this->hasNegativeCycles[u] == true) {
      this->hasNegativeCycles[v] = true;
    }
  }
}
ll Graph::getDistance(ll n) { return this->dist[n]; }
bool Graph::hasNegativeCycle(ll n) { return this->hasNegativeCycles[n]; }

void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  Graph g(N);
  rep(m, 0, M) { g.addEdge(a[m] - 1, b[m] - 1, -c[m]); }
  g.bellmanFord(0);

  if (!g.hasNegativeCycle(N - 1)) {
    print(-g.getDistance(N - 1));
  } else {
    print("inf");
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, M, std::move(a), std::move(b), std::move(c));
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[11],b[101];
int main()
{
	int i,j,n,k,s=0,lena,lenb;
	bool yes;
	cin>>a;
	lena=strlen(a);
	cin>>n;
	for(k=1;k<=n;k++)
	{
		cin>>b;
		lenb=strlen(b);
		yes=false;
		for(i=0;i<lenb;i++)
		{
			if(b[i]==a[0])
			{
				for(j=0;j<lena;j++)
				{
					if(i+j>=lenb)
					{
						if(b[i+j-lenb]==a[j])yes=true;
					    else yes=false;
					}
					else
					{
						if(b[i+j]==a[j])yes=true;
					    else yes=false;
					}
					if(yes==false)break;
				}
			}
			if(yes==true)break;
		}
		if(yes==true)s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main(){
	long long a,b,k;
	cin >> a >> b >> k;
	long long j=k-a;
	a=max(a-k,0ll);
	if(a!=0){
		cout<<a<<" "<<b<<endl;
		return 0;
	}
	b=max(b-j,0ll);
	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int a,b;
  int c=0;
  cin>>a;
  for(int i=0;i<=9;i++){
      for(int j=0;j<=9;j++){
          b=i*j;
          if(a == b){
              c=1;
              break;
          }
      }
  }
  if(c == 1){
      cout<<"Yes";
  }
  else{
      cout<<"No";
  }
  	return 0;
}

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

#define repfrom(i, from, n) for (ll i = (from); i < (n); i++)
#define rep(i, n) repfrom(i, 0, n)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;
using uc = unsigned char;
constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

ll gcd(ll n, ll x) {
    return x ? gcd(x, n % x) : n;
}

ll solve(ll n) {
    return 3 * (n - 1);
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, X;
    cin >> N >> X;
    
    ll d = gcd(N, X);
    cout << d * solve(N / d) << endl;
    
    return 0;
}


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

int main() {

	int a, b, x; cin >> a >> b >> x;
	int V = a * a * b;	
	double ans;
	if (V < 2 * x) {
		double tmp = (double)2 * (a * a * b - x) / (a * a * a);
		tmp = atan(tmp);
		ans = tmp * 180 / M_PI;
	}
	else { // 2 * x <= V 
		double tmp = (double)(a * b * b) / (2 * x);
		tmp = atan(tmp);
		ans = tmp * 180 / M_PI;
	}

	double Sx = (double)x / a;
	cout << fixed << setprecision(11) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define uy q.front()
#define SIZE (ll)(1e6)
#define mod (ll)(1e9+7)
using namespace std;
typedef long long  ll;
int main(){
int n;cin>>n;
int ar[n];
for(int i=0;i<n;i++) cin>>ar[i];
  int dp[n];
for(int i=0;i<n;i++) dp[i]=mod;
  dp[0]=0;dp[1]=abs(ar[0]-ar[1]);
for(int i=2;i<n;i++){
  for(int j=0;j<2;j++){
    dp[i]=min((dp[i-j-1]+abs(ar[i-j-1]-ar[i])),dp[i]);
  }
}
cout<<dp[n-1]<<endl;return 0;}



Measured memory_bytes: 1024
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

list = [7, 5, 3]

flg = 0
for i in range (len(list)):
    if a == list[i]:
        flg = 1

if flg == 0:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

char s[100000+5];

int main()
{
	scanf("%s",s+1);int len=strlen(s+1);
	if(s[1]==s[len] && len%2==1) puts("Second");
	else if(s[1]==s[len] && len%2==0)  puts("First");
	else if(s[1]!=s[len] && len%2==1) puts("First");
	else if(s[1]!=s[len] && len%2==0)puts("Second");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

// oooo
// 1-> o
// 2-> x

// ooo
// ooo
// ooo
// 3 -> o
// 5 -> o
// 8 -> x

int main(){
  ll N,M; cin>>N>>M;
  if(N>M){swap(N,M);}
  ll r;
  if(N==1){
    if(M==1){
      r = 1;
    }else{
      r = M-2;
    }
  }else{
    r = (N-2)*(M-2);
  }
  cout << r;
}

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

using namespace std;

void fast()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
}
const int mxA = 1e7;
int freq [mxA+1] ;
int pref [mxA+1];

int main()
{
    fast();
    int a ,b;
    cin >> a>>b;
    if ((a*b*1%2!=0)||(a*b*2%2!=0)||(a*b*3%2!=0)){
        cout << "Yes" ;
    }else {
        cout << "No" ;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	scanf("%d", &N);
	if ((N / 10 == 9) || ((N - (N / 10) * 10))==9) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}


	return 0;

}

Measured memory_bytes: 128
# include <stdio.h>
int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %lf\n",d,r,f);









    return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int min(int a,int b){
   if (a > b) {
      return b;
   }
   else {
      return a;
   }
}

int main(void){
   int n;
   char s[50][50] = {""};
   scanf("%d", &n);
   for (int i = 0; i < n; i++) {
      scanf("%s", s[i]);
   }
   for (int k = 0; k < 26; k++) {
      char character = 'a' + k;
      int minimum = 100000;
      for (int i = 0; i < n; i++) {
         int cnt = 0;
         for (int j = 0; j < 50; j++) {
            if (character - s[i][j]  == 0) {
               cnt++;
            }
         }
         minimum = min(minimum,cnt);
      }
      for (int i = 0; i < minimum; i++) {
         printf("%c",'a'+k);
      }
   }
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	char S[300000],T[300000];
	int k,n=0;
		scanf("%s",S);
		scanf("%s",T);
	for (k = 0;S[k] != '\0';k++);
	for(int i=0;i<k;i++){
		if(S[i]!=T[i]){
			n+=1;
		}
	}
	printf("%d\n",n);
	
	return 0;
}

Measured memory_bytes: 2128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int d[2005];
V<int> v[2005];
P<int,int> p[2005];
void dfs(int x){
	for(auto u:v[x])if(d[u]==-1){
		d[u]=d[x]+1;
		dfs(u);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k; 
	cin>>n>>k;
	rep(i,1,n){
		cin>>p[i].F>>p[i].S;
	}
	int mini=1e9;
	if(k&1){
		k/=2;
		rep(i,1,n){
			FOR(j,1,n)v[j].clear();
			rep(j,1,n)if(i!=j){
				v[p[j].S].PB(p[j].F);
				v[p[j].F].PB(p[j].S);
			}
			FILL(d,-1);
			d[p[i].F]=0;
			d[p[i].S]=0; 
			dfs(p[i].F);dfs(p[i].S);
			int ans=0;
			FOR(j,1,n)ans+=d[j]>k;
			gmin(mini,ans);
		}
	}else{
		rep(i,1,n){
			v[p[i].F].PB(p[i].S);
			v[p[i].S].PB(p[i].F);
		}
		k/=2;
		FOR(i,1,n){
			FILL(d,-1);
			d[i]=0;
			dfs(i);
			int ans=0;
			FOR(j,1,n)ans+=d[j]>k;
			gmin(mini,ans);
		}
	}
	cout<<mini<<'\n'; 
	RE 0;
}




Measured memory_bytes: 384
from operator import itemgetter
from itertools import accumulate


n,k = map(int, input().split())
sushi = [list(map(int, input().split())) for i in range(n)]

sushi.sort(key=itemgetter(1))
sushi.reverse()


# 各ネタ最大美味しさの寿司
a = []

# それ以外の寿司
b = []

# aにすでに入っているネタ = 1
in_a = [0]*(n+1)

for i in range(n):
    t,d = sushi[i]
    if in_a[t]==0:
        in_a[t]=1
        a.append(d)
    else:
        b.append(d)

ans = 0

a = list(accumulate([0]+a))
b = list(accumulate([0]+b))


for i in range(len(a)):
    if i<=k:
        if 0<=k-i<len(b):
            ans = max(a[i]+b[k-i]+i**2,ans)
print(ans)

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

ll sll(string s) {
	ll ret = 0;
	REP(i, s.size()) {
		ret *= 10;
		ret += s[i] - '0';
	}
	return ret;
}
ll dist(string s, string t) {
	return abs(sll(s) - sll(t));
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	string ans;
	ll cmax = -INF;
	REP(i, 1 << 10) {
		int cnt = 0;
		REP(j, 10)if (i&(1 << j))cnt++;
		if (cnt != n)continue;
		string t;
		REP(j, 10) {
			if (i&(1 << j))t += char('0' + j);
		}
		sort(ALL(t));
		do {
			ll a = min(dist(s, t),ll(pow(10,n))-dist(s,t));
			if (a > cmax||(a==cmax&&sll(ans)>sll(t))) {
				cmax = a;
				ans = t;
			}
		} while (next_permutation(ALL(t)));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3356
#include <iostream>
#include <string>

using namespace std;

struct ticket{
	string str;
	int cost;
	int length;
};

int main()
{
	int n, m;
	ticket tic[101];
	string s;
	
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> s >> tic[i].cost;
			for(int j = 0; j < 8; j++){
				if(s[j] != '*'){
					tic[i].str = s.substr(j);
					tic[i].length = j;
					break;
				}
			}
		}
		int c = 0;
		for(int i = 0; i < m; i++){
			cin >> s;
			for(int j = 0; j < n; j++){
				if(s.substr(tic[j].length) == tic[j].str){
					c += tic[j].cost;
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 928
#include<bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
  
int main()
{
  	long double a, b, h, m, d, ans;
  	cin >> a >> b >> h >> m;

    long double small = 6*m;
  	long double big = 30*h + 0.5*m;
  	long double angle = min(360-abs(big-small), abs(big-small));
  	long double cos_c = cos(angle/180.0*pi);
    long double c = sqrt(a*a + b*b - 2*a*b*cos_c);
    cout << setprecision(20) << fixed << c <<endl;
}
  


Measured memory_bytes: 4100
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL long long
const int N = 50005;
LL x,y;
LL gcd(LL a, LL b){
    return (b==0?a:gcd(b,a%b));
}
void init(){
}
void solve(){
}
int main(){
    while(cin>>x>>y){
        LL g = gcd(x,y);
        cout<<g<<" "<<x/g*y<<endl;
    }
    return 0;
}

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

int main() {
    lint n, k;
    cin >> n >> k;

    vector<lint> a(n);
    for(auto& e : a)  cin >> e;
    sort(begin(a), end(a));

    vector<lint> f(n);
    for(auto& e : f)  cin >> e;
    sort(begin(f), end(f));
    reverse(begin(f), end(f));

    vector<tuple<lint, lint, lint>> mul(n);
    for(lint i=0; i<n; i++) {
        mul[i] = make_tuple(a[i]*f[i], a[i], f[i]);
    }
    sort(begin(mul), end(mul));

    lint ok = 1e13;
    lint ng = -1;
    // k 回以内に最大値を x にできるか
    auto check = [&](lint x) {
        lint sum = 0;
        for(auto e : mul) {
            lint m, a, f;
            tie(m, a, f) = e;
            if(m > x)  sum += ceil((double)(m - x) / f);
        }
        return sum <= k;
    };

    while(abs(ok - ng) > 1) {
        lint mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    cout << ok << endl;
}

Measured memory_bytes: 8064
#import math

A, B = map(int, input().split(" "))

#if A >= B: # B-A <=0 
#    print(1)
#else:
#    out = math.ceil((B-A) / (A-1)) + 1
#    print(out)

out = 1
count = 0
while out < B:
    out += (A-1)
    count += 1

print(count)

Measured memory_bytes: 2940
var s,s1:string;
    i,len:longint;
begin
 readln(s);
 len:=length(s);
 for i:=1 to len do
 case s[i] of
  'b':s1:='d'+s1;
  'd':s1:='b'+s1;
  'p':s1:='q'+s1;
  'q':s1:='p'+s1;
 end;
 if (s=s1) then writeln('Yes') else writeln('No');
end.

Measured memory_bytes: 384
<?php
$stdin = trim(fgets(STDIN));

$fh = floor($stdin / 3600);
$m = ($stdin - $fh*3600) / 60;
$fm = floor($m);
$fs = floor(($stdin - $fh*3600 - $fm*60));

$time = "$fh:$fm:$fs";
echo $time;
?>

Measured memory_bytes: 6536
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
e=0
d = sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        e += c[a[i]-1]
    else:
        e += 0
print(e + d)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  double a,b,x;
  cin>>a>>b>>x;
  double c = (a*a*b)/2.0;
  double ans;
  if(x<=c){
    ans = atan((a*b*b/(2.0*x)));
    ans /= PI;
    ans *= 180.0;
  }else{
    ans = atan(2*(a*a*b-x)/(a*a*a));
    ans /= PI;
    ans *= 180.0;
  }
  cout << fixed << setprecision(8) << ans << endl;
  
  return 0;
}


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

#define N 300011
int n, ans = N;
int cntE[N]; // 面朝E的人数
char ch[N];
inline int changeCnt(int x)
{
    // (x-1) - a[x-1]表示前x-1中，朝W的人数，也就是需要转身的人数
    // a[n] - a[x]表示从x+1到n的人中，朝E的人数，也就是需要转身的人数
    return (x-1) - cntE[x-1] + cntE[n] - cntE[x];
}

int main()
{
    scanf("%d", &n);
    scanf("%s", ch + 1);
    for(int i = 1; i <= n; i++)
    {
        cntE[i] = cntE[i - 1] + (ch[i] == 'E');
    }

    for(int i = 1; i <= n; i++)
    {
        ans = min(ans, changeCnt(i));
    }

    printf("%d\n", ans);
    return 0;
 }


Measured memory_bytes: 1664
N = input()
N = N[::-1]

c = 0
otsuri = 0
mai = 0
for i in range(len(N)):
    if int(N[i]) + c == 5 and i < len(N) - 1:
        if int(N[i+1]) >= 5:
            otsuri += 5
            c = 1
        else:
            mai += int(N[i]) + c
            c = 0
    elif int(N[i]) + c > 5:
        otsuri += 10 - int(N[i]) - c
        c = 1
    else:
        mai += int(N[i]) + c
        c = 0

print(otsuri + mai + c)

Measured memory_bytes: 58352
S=list(map(str,input()))
T=list(map(str,input()))

#print(S)
#print(T)

s=len(S)
t=len(T)
m=1001;e=0
for i in range(s-t+1):
  #print(s,t,i)
  for j in range(t):
    if S[i+j]!=T[j]:
      e=e+1
  if e<m:
    m=e
  e=0
print(m)

Measured memory_bytes: 9136
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve()
{
    int H, N; cin >> H >> N;

    vector<int> dp(H+1, INTINF);
    // i 減らすのにかかる最小コスト
    dp[0] = 0;

    REP0(i, N)
    {
        int a, b; cin >> a >> b;
        
        REP0(j, H)
        {
            int next_j = min(j + a, H);
            dp[next_j] = min(dp[next_j], dp[j] + b);
        }
    }
    cout << dp[H] << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import random
import collections

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(k,lst):  # fix inputs here
    console("----- solving ------")

    arr = [0 for _ in lst]
    for _ in range(min(k,50)):
        uppp = [0 for _ in range(len(lst)+1)]
        down = [0 for _ in range(len(lst)+1)]
        for i,x in enumerate(lst):
            uppp[max(0,i - x)] += 1
            down[min(len(lst),i + x + 1)] += 1
        # console("ud")
        # console(uppp)
        # console(down)
        cur = 0
        for i,x in enumerate(arr):
            cur += uppp[i]
            cur -= down[i]
            arr[i] = cur
        # console("ar")
        # console(arr)
        # console()
        lst = arr

    return " ".join([str(x) for x in lst])


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return


# for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
    # k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
_,k = list(map(int,input().split()))
lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

res = solve(k,lst)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)


Measured memory_bytes: 189640
#include<cstdio>

int main() {
  //入力
  int a,b,c;
  std::scanf("%d%d%d",&a,&b,&c);
  
  if(a < b && b < c) {
    std::printf("Yes\n");
  }
  else {
    std::printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2680
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    int count = 0;
    if (N.charAt(0) == '2')
      count++;
    if (N.charAt(1) == '2')
      count++;
    if (N.charAt(2) == '2')
      count++;
    if (N.charAt(3) == '2')
      count++;
    System.out.println(count);
  }
}

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

int main(){
    int N,A=0,B=0,Backup;
    cin >> N;

    Backup = N;
    while(Backup != 0){
        A += (Backup%10);
        Backup = Backup/10;
    }

    if(N % A == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 1000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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



int main() {

  int n, k, h, c = 0;
  cin >> n >> k;
  rep(i, n) {
    cin >> h;
    if(h>=k) ++c;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 384
/**
 *	@file: C.cpp
 *	@author: Huy Le
 *	@created: 08-03-2020 08:24:59
**/


#include<bits/stdc++.h>
using namespace std;

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void update(int ind, int value) {
	++ind;
	for(; ind <= n; ind += ind&-ind)
		BIT[ind] += value;
}

int query(int ind) {
	++ind;
	int sum  = 0;
	for(; ind > 0; ind -= ind&-ind)
		sum += BIT[ind];
	return sum;
}

void solve() {
	read(n,m);
	c = vector<int>(n);
	q = vector<vector<pair<int,int>>>(n);
	BIT = vector<int>(n + 1);
	read(c);
	for(int i = 0; i < m; ++i) {
		int x,y;
		read(x,y);
		--x;
		--y;
		q[y].push_back({x, i});
	}
	ans = vector<int>(m);
	cnt = vector<int>(n + 1, -1);
	map<int,int> mp;
	for(int i = 0; i < n; ++i) {
		if(cnt[c[i]] != -1)
			update(cnt[c[i]], -1);
		update(i, 1);
		for(auto a : q[i]) {
			ans[a.second] = query(i) - query(a.first - 1);
		}
		cnt[c[i]] = i;
	}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


Measured memory_bytes: 42476
n = int(input())
listT = list(map(int, input().split()))
sumT =0
index3 =0
while index3 < len(listT):
    sumT+=listT[index3]
    index3+=1
m = int(input())
listForL = []
index=0
while index < m:
    pXList = list(map(int, input().split()))
    listForL.append(pXList)
    index+=1

listForA = []
index2 =0
while index2 < len(listForL):
    sum = sumT - listT[listForL[index2][0]-1] + listForL[index2][1]
    listForA.append(sum)
    index2+=1

for ans in listForA:
    print(ans)

Measured memory_bytes: 3064
from collections import deque
n,m = map(int,input().split())
V = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    V[a].append([b,i])
    V[b].append([a,i])
ans = 0
for i in range(m):
    q = deque([])
    reach = [0] + [-1]*n
    q.append(1)
    reach[1] = 0
    while q:
        x = q.popleft()
        for X,j in V[x]:
            if j == i:
                pass
            else:
                if reach[X] == -1:
                    q.append(X)
                    reach[X] = 0
    if -1 in reach:
        ans += 1
print(ans)

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

int main() {
  int a,b;
  cin >> a >> b;
  for(int i=0;i<b+2;i++){
    cout<<"#";

  }
  cout << endl;
  vector<string> H(a);

for(int i=0;i<a;i++){
  cin >> H[i];
}
for(int i=0;i<a;i++){
  cout << "#"<< H[i]<<"#"<<endl;

}
  for(int i=0;i<b+2;i++){
    cout<<"#";

  }
  cout<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int v[1100000];

int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           map<int,int> a;
           rep(i,0,n){
             int k;
             cin>>k;
               a[k]++;
           }
           //sort(all(a));
           int ans=0;
          for(auto f:a){
            
            int b=f.first;
             if(v[b])continue;
             int c=b;
             if(f.second==1)ans++;
             while(b<1100000){
               v[b]=1;
               b+=c;
               
             }
             
           }
           cout<<ans<<endl;
           
}

Measured memory_bytes: 17144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    rep(i,n){
        cin>>a[i];
    }
    ll s=0;
    ll m=a[0];
    for(int i=1;i<n;i++){
        if(m>a[i]){
            s+=m-a[i];
            a[i]=m;
            
        }else{
            m=a[i];
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


int main(){
  ll N,M; cin>>N>>M;
  ll r = 0;
  if(M/2<=N){
    r = M/2;
  }else{
    r = N;
    M -= N*2;
    r += (M/4);
  }
  cout << r;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
    bool comp(const pii& a, const pii& b) {
        int t1 = a.fr * a.fr + a.sc * a.sc;
        int t2 = b.fr * b.fr + b.sc * b.sc;
        return (t1 != t2) ? t1 < t2 : a.fr < b.fr;
    }
}

signed main() {
    int h, w;
    vector<pii> v;
    repq(i,1,150) repq(j,i+1,150) {
        v.pb(pii(i,j));
    }
    sort(v.begin(), v.end(), comp);
    while(cin >> h >> w, h || w) {
        int k = 0;
        rep(i,0,v.size())  {
            if(v[i].fr == h && v[i].sc == w) {
                k = i;
                break;
            }
        }
        printf("%lld %lld\n", v[k+1].fr, v[k+1].sc);
    }
    return 0;
}

Measured memory_bytes: 3320
N, Q = map(int, input().split())
S = input()


cum_sum = [0] * N
count_AC = [0] * N

for i in range(N-1):
    if (S[i] + S[i+1]) == "AC":

        count_AC[i+1] = 2
        cum_sum[i+1] = 2
    cum_sum[i+1] = cum_sum[i] + cum_sum[i+1]


for _ in range(Q):
    l,r = map(int, input().split())
    l = l - 1
    r = r - 1
    print((cum_sum[r]//2)-(cum_sum[l]//2))   

Measured memory_bytes: 13820
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
vector<int> a;
int N,S,W,Q;
void make(){
	int g=S,i=0;
	for(a.clear();i<N;g=(g>>1)^((g&1)?W:0),i++)a.push_back((g/7)%10);
}
int hard(){
	int answer = 0;
	map<int,int> freq;
	freq[0] = 1;
	int base = 1, sum = 0;
	for(int i=a.size()-1; i>=0; i--){
		sum  = (a[i]*base + sum) % Q;
		base = (base*10) % Q;
		if(a[i])answer += freq[sum];
		freq[sum] ++;
	}
	return answer;
}
int easy(){
	int answer = 0;
	int nonZero = 0;
	for(int i=0; i<a.size(); i++){
		nonZero += (a[i]!=0 ? 1 : 0);
		answer  += (a[i]%Q==0 ? nonZero : 0);
	}
	return answer;
}
main(){
	for(;scanf("%d%d%d%d",&N,&S,&W,&Q),Q;printf("%d\n",(Q==2||Q==5)?easy():hard()))make();
}

Measured memory_bytes: 4028
#include <stdio.h>

int main(void) {
    int max, min;
    int n, s[128];
    int i;
    int temp;
    
    do {
        scanf("%d", &n);
        if(!n)
            break;
        
        max = 0;
        min = 1000;
        temp = 0;
        
        for(i = 0; i < n; i++) {
            scanf("%d", &s[i]);
            if(s[i] > max)
                max = s[i];
            if(min > s[i])
                min = s[i];
            
            temp += s[i];
        }
        
        printf("%d\n", (temp - max - min) / (n - 2));
    } while(1);
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int H, W;
  cin >> H >> W;
  vector<string> v(H);
  rep(i, 0, H) { cin >> v[i]; }
  auto inrange = [&](int x, int y) {
    return 0 <= x and x < H and 0 <= y and y < W;
  };
  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  bool ans = true;

  rep(i, 0, H) rep(j, 0, W) {
    if (v[i][j] == '.')
      continue;

    bool f = false;
    rep(k, 0, 4) {
      int a = i + dx[k], b = j + dy[k];
      if (inrange(a, b)) {
        dump(inrange(a, b), a, b);
        f |= (v[a][b] == '#');
      }
    }

    ans &= f;
  }

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, t = i_map()
    num_list = i_row_list(n)

    min_cost = INF

    for cost, time in num_list:
        if time > t:
            continue
        min_cost = min(min_cost, cost)

    print(min_cost if min_cost != INF else 'TLE')

if __name__ == '__main__':
    main()


Measured memory_bytes: 59244