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

int main() {
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(ll i=2;i<n;i++)
    {   dp[i]=INT_MAX;
        for(ll j=min(i,k);j>=1;j--)
       dp[i]=min(dp[i],abs(arr[i-j]-arr[i])+dp[i-j]);
       
       
    }
    
    cout<<dp[n-1];
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> p;
    rep(i,n){
        int a; cin>>a;
        p.push(a);
    }
    rep(i,m){
        int a=p.top();
        a/=2;
        p.pop();
        p.push(a);
    }
    ll ans=0;
    rep(i,n){
        ans+=p.top();
        p.pop();
    }
    cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define repr(i,a,b) for(int i=a; i<b; i++)

int main()  {
  int K,X;
  cin >> K >> X;
  int i;
  repr(i, X-K+1, X) {
    cout << i << " ";
  }
  repr(i, X, X+K) {
    cout << i;
    if(i != X+K-1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
int num[200005];
ll C(ll n,ll m)//n<m
{
    ll c[5];
    c[0]=1;
    for(int i=1;i<=n;i++)
    {
        c[i]=((c[i-1]*(m-i+1)))/i;
    }
    return c[n];
}
int main()
{
    int n,p;
    ll ans=0,m=0,maxn=0;
    memset(num,0,sizeof num);
    cin>>n>>p;
    cin>>s;
    if(p==2)
    {
        for(int i=0;i<n;i++)
        {
            if(!((s[i]-'0')&1))ans+=i+1;
        }
        cout<<ans<<endl;
    }
    else if(p==5)
    {
        for(int i=0;i<n;i++)
        {
            if(s[i]=='5'||s[i]=='0')ans+=i+1;
        }
        cout<<ans<<endl;
    }
    else
    {
        int ten=1;
        for(int i=n-1;i>=0;i--)
        {
            m=(m+(s[i]-'0')*ten)%p;
            ten=(ten*10)%p;
            //cout<<m<<endl;
            num[m]++;
            maxn=max(maxn,m);
        }
        //cout<<endl;
        for(int i=0;i<=maxn;i++){ans+=C(2,num[i]);}
        cout<<ans+num[0]<<endl;
        //cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1412
H = list(map(int, input().split()))
N = H[0]
K = H[1]
S = H[2]
ans=[]
if(10**5<S):
    for i in range(K):
        ans.append(int(S))
    for i in range(N-K):
        ans.append(1)
else:
    for i in range(K):
        ans.append(int(S))
    for i in range(N-K):
        ans.append(10**5)
for  item in ans:
    print(item,end=' ')


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

ll solve() {
    ll N, K, a;
    cin >> N >> K;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        A[i] = (a + K - 1) % K;
    }
    ll s = 0;
    map<ll, queue<ll>> m;
    ll ans = 0;
    m[0].push(-1);
    for ( int i = 0; i < N; i++ ) {
        s += A[i];
        s %= K;
        m[s].push(i);
        while ( !m[s].empty() &&  i - m[s].front() >= K ) m[s].pop();
        if ( !m[s].empty() ) {
            ans += m[s].size() - 1 ;
        }
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ll long long int
 
using namespace std;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int temp=(n+1)/2;
	cout<<fixed<<setprecision(10)<<temp/(double)n;
	return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    long long A,B,C,k,a,b,c,K=1e18;
    cin>>A>>B>>C>>k;
    if(k&1) cout<<B-A;
    else cout<<A-B;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<ll> dp(n + 2);
	dp[1] = 1;
	vector<bool> isBroken(n + 1);
	rep (i, m) {
	  int a;
	  cin >> a;
	  isBroken[a] = true;
	}
	FOR (i, 2, n + 2) {
	  if (isBroken[i - 1]) continue;
	  dp[i] += dp[i - 1] + dp[i - 2];
	  dp[i] %= MOD;
	}
	cout << dp[n + 1] << endl;
	
	return 0;
}



Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n,length,i;
  string s;
  char x;
    cin>>n>>s;
  length  = s.length();
  for(i=0;i<length;i++){
    s[i]+=n;
    if(s[i]>'Z')
      s[i]-=26;
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <numeric>
 
using namespace std;
 
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
        for(int i=0 ; i<n ;i++){
            cin>>p[i];
        }
    sort(p.begin(),p.end());
    int sum =0;
    for(int i =0;i<k;i++){
        sum+=p[i];    
    }
    cout<<sum;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	cout<<1-N<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int l,r;
  int sum = 0;
  int p = 0;
  for ( int i = 0 ; i < N; i++){
      cin >>l >> r;
      p = r - l + 1;
      sum += p;
    }
  
  cout << sum <<endl;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N){
    cin >> H[i];
  }

  int maxh = 0, ans=0;
  REP(i, N){
    if(maxh <= H[i]){
      ans++;
      maxh = H[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) {
    int n;
    while (cin >> n, n) {
        int sum[1000];
        int count = 0;
        sum[0] = 1;
        for (int i = 2; i < 1000; ++i) {
            sum[i-1] = i + sum[i-2]; 
        }
        for (int i = 1; i < 1000; ++i) {
            if (sum[i] == n) {
                count++;
                continue;
            }
            for (int j = 0; j < i - 1; ++j) {
                int tmp = sum[i] - sum[j];
                if (tmp == n || sum[i] == n) {
                    count++;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, int> m;
	rep(i, n){
		int in;
		cin >> in;
		m[in]++;
	}

	int ev = 0, od = 0;
	for(auto p : m){
		int ne = p.second % 2;
		if(ne == 1) od++;
		else ev++;
	}
	int ans = ev/2*2 + od;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int cnt[112345] = {};
int gen[112345] = {};
int dat[112345] = {};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num,mod;
    //cin >> num >> mod;
    scanf("%d%d",&num,&mod);

    for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		cnt[z%mod]++;
		dat[z]++;
	}
	for(int i=0;i<=100000;i++)
	{
		gen[i%mod]+=dat[i]/2;
	}

    int ret = 0;
    for(int i = 0; i+i <= mod; i++){
        if(i == 0 || i+i == mod){
            ret += cnt[i] / 2;
        }else{

			if(cnt[i]<cnt[mod-i])ret+=cnt[i]+min((cnt[mod-i]-cnt[i])/2,gen[mod-i]);
			else ret+=cnt[mod-i]+min((cnt[i]-cnt[mod-i])/2,gen[i]);

        }
    }
    printf("%d\n",ret);

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  string c;
  cin>>c;
  vector<int> d(b),e(b);
  rep(i,b)
    cin>>d[i]>>e[i];
 vector<int> f(a+1,0);
  rep(i,a){
    if(c[i]=='A'&&c[i+1]=='C')
  f[i+1]=f[i]+1;
    else
      f[i+1]=f[i];
  }
  rep(i,b){
  cout<<f[e[i]-1]-f[d[i]-1]<<endl;
  }
}

Measured memory_bytes: 3456
a,b=map(int,input().split())
c=list(map(int,input().split()))
ans=0
mod=10**9+7
for i in range(a):
  for j in range(a):
    if c[i]>c[j]:
      if i<j:
        ans+=(b*(b+1)//2)%mod
      else:
        ans+=(b*(b-1)//2)%mod
        
print(ans%mod)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a[MX], b[MX], c[MX];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    fi(0, n -1 ) cin >> b[i];
    int sum = 0;
    fi(0, n) {
    	if (i != 0)
    		a[i] = b[i - 1];
    	else
    		a[i] = b[i];
    	if (i != n - 1)
    		mine(a[i], b[i]);
    	sum += a[i];
    }
    cout << sum << '\n';
}

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

#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define MOD 1000000007
#define edl '\n'
#define IOFAST ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define loop(i,n) for(ll i =0; i<n; i++)

#define vi vector<int>
#define vvi vector<vector<int>>
#define vvpii vector<vector<pair<int, int>>>
#define vpii vector<pair<int, int>>

int main(){
    // ll T; 
    // cin>>T; 
    // loop(itr,T){
        
        
    // }
    string s; 
    cin>>s; 
    bool a=0, b=0, c=0; 
    a = (s[0]=='R');
    b = (s[1]=='R');
    c = (s[2]=='R');
    if (a&&b&&c) cout<<3; 
    else if ((a&&b&&!c) ||  (!a&&b&&c)) cout<<2;
    else if (a||b||c) cout<<1; 
    else cout<<0; 
}


Measured memory_bytes: 3624
n, m = [int(x) for x in input().split()]
k = [[int(x) for x in input().split()] for i in range(n)]

def foods(n, k):
    if n == 1:
        return len(k[0]) - 1

    init = k[0][1:]
    for i in range(n-1):

        next = k[i+1][1:]
        comb = []    

        for j in init[:]:
            if j in next:
                comb.append(j)
        init = comb[:]

    return len(comb)

print(foods(n, k))


Measured memory_bytes: 3064
N, K = map(int, input().split())
p = tuple(map(int, input().split()))

s = sum(p[:K])
mx = s
for i in range(N - K):
    j = i + K
    s += p[j] - p[i]
    if mx < s:
        mx = s

print((mx + K) / 2)


Measured memory_bytes: 71792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n;
	while(cin >> n && n) {
		map<string, int> p;
		int cnt[35];
		memset(cnt, 0, sizeof(cnt));

		string s[50];
		int m[50], d[50][50];
		rep(i, n) {
			cin >> s[i] >> m[i];

			rep(j, m[i]) {
				cin >> d[i][j];
				cnt[d[i][j]]++;
			}
		}

		rep(i, n) {
			rep(j, m[i]) {
				p[s[i]] += n - cnt[d[i][j]] + 1;
			}
		}

		int ans = INF;
		string res = "";
		rep(i, n) {
			if(ans > p[s[i]]) {
				ans = p[s[i]];
				res = s[i];
			} else if(ans == p[s[i]] && res > s[i]) {
				ans = p[s[i]];
				res = s[i];
			}
		}

		cout << ans << " " << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

ll h,w;
char table[1001][1001];
int dp[1001][1001] = {0};

void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

int main(){
    cin >> h >> w;

    rep(i,h){
        rep(j,w){
            cin >> table[i][j];
        }
    }

    dp[0][0] = 1;

    for(ll i=0; i<h; i++){
        for(ll j=0; j<w; j++){

            if (i+1 < h && table[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if (j+1 < w && table[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);

        }
    }

    dunk(dp[h-1][w-1]);
}


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

using namespace std;

typedef vector<int> VI;

bool dfs(const VI &balls, int idx, int l, int r) {
  if (idx >= 10) return true;
  int n = balls[idx];
  if (n > l && dfs(balls, idx+1, n, r)) return true;
  if (n > r && dfs(balls, idx+1, l, n)) return true;
  return false;
}

void solve() {
  VI balls;
  for (int i = 0; i < 10; i++) {
    int n;
    cin >> n;
    balls.push_back(n);
  }
  if (dfs(balls, 0, 0, 0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 3048
n = int(input())
ans = int(n/1.08)
if n<=ans*1.08<n+1 and n<=(ans+1)*1.08<n+1:
  print(ans)
elif n<=ans*1.08<n+1 and (n>=(ans+1)*1.08 or (ans+1)*1.08>n+1):
  print(ans)
elif (n>=ans*1.08 or ans*1.08>n+1) and n<=(ans+1)*1.08<n+1:
  print(ans+1)             
else:
  print(":(")

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

pub 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")
}

use std::cmp::{max, min};

fn main() {
    let x: i64 = read();
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {
	final static int MOD = 1000000007;
	
	public static void main(String[] args) {
		MyScanner in = new MyScanner();
		String s = in.nextLine();
		String t = in.nextLine();
		int count = 0;
		
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
		
		
	}
	
	static class MyScanner {
		static Scanner sc = new Scanner(System.in);
		
		String next() {
			return sc.next();
		}
		
		String nextLine() {
			return sc.nextLine();
		}
		
		int nextInt() {
			return Integer.parseInt(sc.next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextInt();
			}
			return array;
		}
		
		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextDouble();
			}
			return array;
		}
		
		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}
			return array;
		}
		
		String[] nextLineArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLine();
			}
			return array;
		}
		
		int[][] nextIntMatrix(int n, int m) {
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}
		
		double[][] nextDoubleMatrix(int n, int m) {
			double[][] matrix = new double[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextDouble();
				}
			}
			return matrix;
		}
		
		long[][] nextLongMatrix(int n, int m) {
			long[][] matrix = new long[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextLong();
				}
			}
			return matrix;
		}
	}
}

Measured memory_bytes: 25556
s = str(input())
t = str(input())
a = []
for i in list(s):
    a.append(i)
b = []
for j in list(t):
    b.append(j)
c = len(a)
d = len(b)
w = 1000
for k in range(c-d+1):
    e = a[k:k+d]
    f = 0
    for l in range(d):
        if e[l] != b[l]:
            f= f+1
    if w > f:
         w= f
print(w)

Measured memory_bytes: 67700
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int a;
int c=0;
cin>>a;
vector<int> b(a);
for(int i=0;i<a;i++)
cin>>b.at(i);
for(int i=0;i<a;i++){
for(int j=0;j<1000000000;j++){
	if(b.at(i)%2==0){
		b.at(i)/=2;
		c++;
	}
	else
		break;
}
}
cout<<c;
}


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

int main() {
  int N,i,cou=0;
  cin >> N ;
  vector<int> a(N),b(N);
  for(i=0;i<N;i++){
    cin >> a[i];
  }
  int j=0;
  while(!b[j]){
    b[j]=1;
    j=a[j]-1;
    cou++;
    if(j==1){
      b[1]=1;
      break;
    }
  }
  if(b[1])cout << cou << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long


long long gcd(long long x, long long y){
    if (x > y)
        return gcd(y, x);
    long long m = 1;
    while(m != 0){
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

long long lcm(long long x, long long y){
    return x * y / gcd(x, y);
}

int main(){
    lint n, m; cin >> n >> m;
    lint l, g;
    vector<int> A;
    rep(i, n){
        lint a; cin >> a; A.push_back(a);
        if(i == 0) l = a/2, g = a;
        else l = lcm(a/2, l), g = gcd(a, g);
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i, n){
        if((A[i] / g) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ((m/l)+1)/2 << endl;
}

Measured memory_bytes: 892
#include <cassert>
#include <climits>
#include <algorithm>
#include <iostream>
#include <vector>

class Item {
  public:
    int init_pos;
    int val;
    bool is_visited;
};

bool is_smaller(const Item& a, const Item& b)
{
  return a.val < b.val;
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<Item> item(n);
  int whole_min = INT_MAX;
  for (int i = 0; i < (int)item.size(); i++) {
    int val;
    std::cin >> val;
    item.at(i).init_pos = i;
    item.at(i).val = val;
    whole_min = std::min(whole_min, val);
  }
  std::stable_sort(item.begin(), item.end(), is_smaller);
  int total_cost = 0;
  for (int i = 0; i < (int)item.size(); i++) {
    if (item.at(i).is_visited) {
      continue;
    }
    item.at(i).is_visited = true;
    if (item.at(i).init_pos == i) { // swap operation is not needed
      continue;
    }
    // traverse the loop
    int loop_min = item.at(i).val;
    int total = item.at(i).val;
    int init = i;
    int head = item.at(i).init_pos;
    int cnt = 1;
    while (head != init) {
      item.at(head).is_visited = true;
      total += item.at(head).val;
      loop_min = std::min(loop_min, item.at(head).val);
      head = item.at(head).init_pos;
      cnt++;
    }
    total += std::min(loop_min * (cnt - 2), whole_min * cnt + whole_min + loop_min);
    total_cost += total;
  }
  std::cout << total_cost << std::endl;

  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,p[100010],was[100010],ac = 0,wa = 0;
	bool isAC[100010] = {};
	string s[100010];
	cin >> n >> m;
	for(int i = 0;i < m;i++) cin >> p[i] >> s[i];
	for(int i = 0;i < m;i++){
		if(s[i] == "WA"){
			was[p[i]]++;
		}else{
			if(!isAC[p[i]]){
				isAC[p[i]] = true;
				ac++;
				wa += was[p[i]];
			}
		}
	}
	cout << ac << " " << wa << endl;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
  ll h,n;
  cin >> h >> n;
  ll sum=0;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    sum+=a;
  }
  if(sum>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3488
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> a(N), dp(K + 1, -1);
	for (int i = 0; i < N; i++) cin >> a[i];
	dp[0] = 0;

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

		if (dp[i] != -1) continue;
		
		dp[i] = 0;
		for (int j = 0; j < N; j++) {
			if(i - a[j] >= 0) dp[i] |= (bool(dp[i - a[j]]) ^ 1);
		}

	}
	DMP(dp);

	if (dp[K]) cout << "First" << "\n";
	else cout << "Second" << "\n";

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<functional>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	int score[100];
	int win[100];
	int gameteam1[10000];
	int gameteam2[10000];
	int t1score[10000];
	int t2score[10000];
	pair<pair<int, int>,pair<int,int> > sorter[100];
	pair<int, int> answer[100];

	for (int a = 0; a < 100; a++)
	{
		score[a] = 0;
		win[a] = 0;
	}

	for (int a = 0; a < 10000; a++)
	{
		gameteam1[a] = 0;
		gameteam2[a] = 0;
		t1score[a] = 0;
		t2score[a] = 0;
	}

	cin >> n;

	for (int a = 0; a < n*(n - 1) / 2; a++)
	{
		cin >> gameteam1[a] >> gameteam2[a] >> t1score[a] >> t2score[a];
	}

	for (int a = 0; a < n*(n - 1) / 2; a++)
	{
		if (t1score[a] == t2score[a])
		{
			score[gameteam1[a]-1]++;
			score[gameteam2[a]-1]++;
		}
		else
		{
			if (t1score[a] > t2score[a])
			{
				score[gameteam1[a]-1] += 3;
				win[gameteam1[a]-1]++;
			}
			else if (t1score[a] < t2score[a])
			{
				score[gameteam2[a]-1] += 3;
				win[gameteam2[a]-1]++;
			}
		}
	}

	for (int a = 0; a < n; a++)
	{
		sorter[a] = make_pair(make_pair(score[a], win[a]),make_pair(10000,a));
	}

	sort(sorter, sorter + n,greater<pair<pair<int,int>,pair<int,int> > >());

	sorter[0].second.first = 1;

	for (int a = 1; a < n; a++)
	{
		if (sorter[a].first.first == sorter[a - 1].first.first)
		{
			sorter[a].second.first = sorter[a - 1].second.first;
		}
		else
		{
			sorter[a].second.first = a + 1;
		}
	}

	for (int a = 0; a < n; a++)
	{
		answer[a] = make_pair(sorter[a].second.second, sorter[a].second.first);
	}

	sort(answer, answer + n);

	for (int a = 0; a < n; a++)
	{
		cout << answer[a].second << endl;
	}

	return 0;
}

Measured memory_bytes: 1324
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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() {
    int n;
    cin >> n;
    vector<pii> X;
    rep(i, n){
        int m; cin >> m;
        X.push_back(pii(m, i));
    }
    sort(all(X));
    vector<bool> flag(n);
    rep(i, n){
        int s = X[i].second;
        if(i < n/2) flag[s] = 0;
        else flag[s] = 1;
    }
    rep(i, n){
        if(!flag[i]) cout << X[n/2].first << ln;
        else cout << X[n/2-1].first << ln;
    }
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b; 
  cin>>a>>b;
  vector<int> c(b);
  rep(i,b)
    cin>>c[i];
  sort(all(c));
  vector<int> d(b-1);
  rep(i,b-1)
    d[i]=abs(c[i+1]-c[i]);
  sort(all(d));
  reverse(all(d));
  int e=0;
  for(int i=a-1;i<b-1;i++)
    e+=d[i];
  cout<<e<<endl;
}

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

s = list(map(str, input()))
for w in range(1, len(s), 2):
    if 'R' in s[w]:
        print("No")
        exit()

for w in range(0, len(s), 2):
    if 'L' in s[w]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include<iostream>

using namespace std;
 
int main(){
	long long n,ans,p;

	cin >> n;
	p = 1;
	ans = 1000 * p - n;

	while(ans < 0){
		ans = 1000 * p - n;
		p++;
	}

	cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi p(n);
    rep(i,n) cin>>p[i];
    int ans=0;
    rep(i,n-1){
        if (p[i]==i+1){
            ans++;
            if (p[i+1]==i+2) i++;
        }
        if (i==n-2 && p[i+1]==i+2){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void)
{

    int N;
    cin >> N;
    vector<int> vec(N);

    for(int i = 0; i < N; i++) cin >> vec.at(i);

    

    int max = *(max_element(vec.begin(), vec.end()));
    int min = *(min_element(vec.begin(), vec.end()));

    cout << max - min << endl;

    return 0;
}

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

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			while (true) {
				String s = reader.readLine();
				String[] a = s.split(" ");
				
				int H = Integer.parseInt(a[0]);
				int W = Integer.parseInt(a[1]);
				
				if (H == 0 && W == 0) {
					break;
				}
				
				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 31524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

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

   ll ans;
   cin>>ans;

   rep(i,n-1){
      ll x;
      cin>>x;

      ans=lcm(ans,x);
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3632
use std::io::Read;
use std::ops::Sub;

fn order(p: &[i32], i: usize, m: u32, o: usize) -> usize {
    let n = p.len();
    if i == n {
        o
    } else {
        let usable_digits = n - m.count_ones() as usize;
        let digits_to_p = (0..p[i]).filter(|&j| (m >> j) & 1 == 0).count();
        order(
            p,
            i + 1,
            m | (1 << (p[i] - 1)),
            o * usable_digits + digits_to_p,
        )
    }
}

fn abs_sub<T: PartialOrd + Sub>(a: T, b: T) -> T::Output {
    if a >= b {
        a - b
    } else {
        b - a
    }
}

fn solve(_n: usize, p: &[i32], q: &[i32]) -> usize {
    abs_sub(order(p, 0, 0, 0), order(q, 0, 0, 0))
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let p = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<_>>();
    let q = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<_>>();
    let r = solve(n, &p, &q);
    println!("{}", r);
}


Measured memory_bytes: 2120
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if (s[s.size()-1]=='3')
  {
    cout<<"bon";
  }
  else if(s[s.size()-1]=='1' || s[s.size()-1]=='6' || s[s.size()-1]=='8' || s[s.size()-1]=='0')
  {
    cout<<"pon";
  }
  else{
    cout<<"hon";
  }
                                                                                                                                                                                                                                      
                                                                         
  
  return 0;
}

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;

void A();
void B();

int main()
{
	string s, str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string::iterator itr;
	int n, k, index;
	while (cin >> n, n) {
		int key[100];
		for (int i = 0; i < n; ++i)
			cin >> key[i];
		cin >> s;
		for (int i = 0; i < s.length(); ++i) {
			itr = find(str.begin(), str.end(), s[i]);
			index = itr - str.begin();
			s[i] = str[(index - key[i % n] + 52) % 52];
		}
		cout << s << endl;
	}
	return 0;
}

void A() {
	
}


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

using namespace std;

typedef long long ll;

const ll INF=1e13+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    int ans=0,N,z=0,o=0;
    string S;
    cin>>S;
    N=S.length();
    for(int i=0;i<N;i++){
        if(S[i]=='0')z++;
        else o++;
    }
    if(z<o){
        ans=z*2;
    }else{
        ans=o*2;
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#define lli long long int
using namespace std;

lli gcd(lli a, lli b) {
	return (a % b) ? gcd(b, a % b) : b;
}

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

int main() {
	lli a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;

	lli ans = (b - a) - (b / c + b / d - b / lcm(c, d)) + (a / c + a / d - a / lcm(c, d));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        int[][] S = new int[n][28];
        String ans = "";
        for(int i = 0;i < n;i++){
            String s = sc.next();
            for(int j = 0;j < s.length();j++){
                int id = s.charAt(j)-'a';
                S[i][id]++;
            }
        }
        for(int w = 0;w < 28;w++){
            int min = 100;
            for(int h = 0;h < n;h++){
                min = Math.min(min, S[h][w]);
            }
            for(int i = 0;i < min;i++)  ans = ans + (char)(w+'a');
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
ans_list = []

def sieve(N):
    global table,prime
    table = [True]*(N+1)
    table[0] = False
    table[1] = False
    prime = []
    for i in range(2,N+1):
        if table[i]:
            prime.append(i)
            for j in range(2*i,N+1,i):
                table[j] = False

sieve(123456*2)

while True:
    n = int(input())
    if n == 0:
        break
    ans = 0
    for p in prime:
        if n < p <= 2*n:
            ans += 1
    ans_list.append(ans)
    
for ans in ans_list:
    print(ans)


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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;;
  rep(i,n){
    if(i * i <= n){
      ans = max(ans,i*i);
    }
    else break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   ll n;
   cin>>n;
   int a[55][26];
   memset(a,0,sizeof(a));
   /*for(int i=0;i<n;i++)
   {
    for(int j=0;j<26;j++)
    {
      cout<<a[i][j];
    }
    cout<<endl;
   }*/
   
   for(int i=0;i<n;i++)
   {
     string s;
     cin>>s;
     for(int j=0;j<s.length();j++)
     {
      a[i][s[j]-'a']++;
     }
   }
  /*for(int i=0;i<n;i++)
   {
    for(int j=0;j<26;j++)
    {
      cerr<<a[i][j];
    }
    cerr<<endl;
   }*/
   /*for(int i=0;i<26;i++)
   {
    if(a[i]>=n)
    {
      int rep=a[i]/n;
      for(int p=0;p<rep;p++)
      {
          char temp='a'+i;
          cout<<temp;
    }
    }
   }*/

   for(int j=0;j<26;j++)
   {
    int temp=INT_MAX;
    for(int i=0;i<n;i++)
    {
      temp=min(temp,a[i][j]);
    }
    for(int p=0;p<temp;p++)
    {
      char cc='a'+j;
      cout<<cc;
    }
    //cerr<<endl;
   }
   cout<<endl;
   

}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define INF 100000001
using namespace std;
 
int N,M,L,K,A,H,T[101],map[101][101];
 
void floyd()
{
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
    map[i][j]=min(map[i][j],map[i][k]+map[k][j]);
      }
    }
  }
}
 
int main()
{
  int a,b,time;
  while(1){
    cin>>N>>M>>L>>K>>A>>H;
    if(N==0&&M==0&&L==0&&K==0&&A==0&&H==0)break;
    for(int i=0;i<N;i++){
      T[i]=0;
      for(int j=0;j<N;j++)map[i][j]=INF;
    }
    for(int i=0;i<L;i++){
      cin>>a;
      T[a]=1;
    }
    T[A]=1;T[H]=1;
    for(int i=0;i<K;i++){
      cin>>a>>b>>time;
      map[a][b]=time;
      map[b][a]=time;
    }
    floyd();
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
    if(map[i][j]>M || T[i]==0 || T[j]==0)map[i][j]=INF;
      }
    }
    floyd();
    if(map[A][H]>=INF)cout<<"Help!"<<endl;
    else if(map[A][H]<M)cout<<map[A][H]<<endl;
    else cout<<map[A][H]*2-M<<endl;
  }
  return 0;
}


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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

ll gcd(ll a, ll b);

ll sum(int n);

void go(){
   int a,p;cin>>a>>p;
   float fpie=(float)a*3/2;
   float spie=(float)p/2;
   int ans=fpie+spie;
   printf("%d",ans);
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

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

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using vpii = vector<pair<int, int>>;

int		main(void)
{
	int N;

	cin >> N;
	vpii J(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> J[i].first;
	}
	for (int i = 0; i < N; i++)
	{
		cin >> J[i].second;
	}
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		if (J[i].first > J[i].second)
			ans += J[i].first - J[i].second;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=100005*2,mod=1e9+7;
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
int n,m,hs;
int a[N],b[N];
vector <int> Ha;
int type[N];
int pre[N],suf[N];
vector <pair <int,int> > p;
int c[N];
void add(int x,int d){
	for (;x<=hs;x+=x&-x)
		Add(c[x],d);
}
int Ask(int x){
	int ans=1;
	for (;x;x-=x&-x)
		Add(ans,c[x]);
	return ans;
}
int res[N];
int main(){
	n=read(),m=read();
	For(i,1,n)
		a[i]=read(),Ha.pb(a[i]);
	For(i,1,m)
		b[i]=read(),Ha.pb(b[i]);
	Ha.pb(0);
	sort(Ha.begin(),Ha.end());
	Ha.resize(unique(Ha.begin(),Ha.end())-Ha.begin());
	hs=Ha.size()-1;
	For(i,1,n)
		type[lower_bound(Ha.begin(),Ha.end(),a[i])-Ha.begin()]=1;
	For(i,1,hs)
		pre[i]=type[i]?pre[i-1]:Ha[i];
	Fod(i,hs,1)
		suf[i]=type[i]?suf[i+1]:Ha[i];
	For(i,1,n){
		int A=lower_bound(Ha.begin(),Ha.end(),a[i])-Ha.begin();
		if (!pre[A]||!suf[A])
			continue;
		p.pb(mp(a[i]-pre[A],suf[A]-a[i]));
	}
	Ha.clear();
	for (auto i : p)
		Ha.pb(i.se);
	sort(Ha.begin(),Ha.end());
	Ha.resize(unique(Ha.begin(),Ha.end())-Ha.begin());
	hs=Ha.size();
	for (auto &i : p)
		i.se=lower_bound(Ha.begin(),Ha.end(),i.se)-Ha.begin()+1;
	sort(p.begin(),p.end());
	p.resize(unique(p.begin(),p.end())-p.begin());
	int ans=1;
	for (int i=0,j;i<(int)p.size();i=j+1){
		for (j=i;j+1<(int)p.size()&&p[j+1].fi==p[i].fi;j++);
		For(k,i,j)
			Add(ans,res[k]=Ask(p[k].se-1));
		For(k,i,j)
			add(p[k].se,res[k]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint r, d, x;
    cin>>r>>d>>x;
    REP(i, 10){
        x =  r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    map<int,int> mp;
    rep(i, n) {
        int x; cin >> x;
        mp[x]++;
    }
    cout << mp.size();
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int X,Y;
    scanf("%d %d",&X,&Y);
    int sum;
    int flag=0;

    for(int i=0;i<=X;i++){
        sum=i*2+(X-i)*4;
        if(sum==Y)
            flag=1;
    }

    if(flag==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  int n, m, q, ans = 0;
  cin >> n >> m >> q;
  vector<int> a(q), b(q), c(q), d(q);
  REP(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

  vector<vector<int>> V[11];
  for (int i = 1; i <= m; ++i) V[1].push_back({i});
  for (int i = 1; i <= n - 1; ++i) {
    for (auto& v : V[i]) {
      int lastNum = v.back();
      for (int pushNum = lastNum; pushNum <= m; ++pushNum) {
        vector<int> v2 = v;
        v2.push_back(pushNum);
        V[i + 1].push_back(v2);
      }
    }
  }
  for (auto& v : V[n]) {
    int sum = 0;
    for (int i = 0; i < q; ++i) {
      if (v[b[i] - 1] - v[a[i] - 1] == c[i]) sum += d[i];
    }
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 16112