akhauriyash/Code-Regression huggingface dataset:
/**

    WARNING
          This Code Sucks
                        Just Like My Life :(

                                            **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define sz(s) (int)(s.size())

using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5;
const  double EPS = 1e-14;
const int MOD = 1e9+7;
/*
ll GCD(ll a,ll b){return (a)?GCD(b%a,a):b;}
ll LCM(ll a, ll b){return a*b/GCD(a,b);}
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//freopen("in.txt", "r", stdin);
#endif
    int n;
    cin>>n;
    int b[n+5],a[n+5];
    ll sum=0;
    for(int i=1; i<n; i++){
        cin>>b[i];
        a[i]=b[i];
    }
     a[0]=b[1];
    for(int i=1;i<n;i++)
        if(a[i-1]>a[i])
          a[i-1]=a[i];
    for(int i=0;i<n;i++)
        sum+=a[i];
    cout<<sum;
}



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

int main()
{
    ll n,m,sum=0,x;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        sum+=x;
    }
    if(n<sum)
        cout<<-1<<endl;
    else
        cout<<n-sum<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int k;
   cin>>k;
   string s;
   cin>>s;

   rep(i, s.size()) s[i]=(s[i]-'A'+k)%26+'A';
   cout<<s<<endl;
   return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=2000000;
const int inf=1e9;
const ll mod=1000000007;
const double eps=0.0000000001;

int main()
{
    FasterIO;

    ll a, b, c;
    cin>>a>>b>>c;
    c-=(a+b);
    if(c<=0)
    {
        cout<<"No"<<endl; return 0;
    }
    c*=c;
    a=a*b*4LL;
    if(a<c) cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
	  
	int n;
	string s;
	cin>>n;
	cin>>s;
	int res=1;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
		{
			res++;
		}
	}
	cout<<res;
}


Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
using namespace std;

typedef complex<double> P;
typedef vector<P> L;

static const double PI = 4.0 * atan(1.0);
static const double EPS = 1e-9;

int n;
P o[52];
double r[52][2];

vector< L > getSessen(double x1 , double y1 , double r1, double x2 , double y2 , double r2){
  vector< L > lines;
  double dist = abs(P(x1 , y1) - P(x2 , y2));
  double dr = r1 - r2;

  if(abs(dr) <= dist){
    double a = atan2(y2-y1 , x2-x1);
    double t = acos(dr / dist);
    P p1[2] , p2[2];

    p1[0] = P(x1 + r1 * cos(a+t) , y1 + r1 * sin(a+t));
    p1[1] = P(x1 + r1 * cos(a-t) , y1 + r1 * sin(a-t));

    p2[0] = P(x2 + r2 * cos(a+t) , y2 + r2 * sin(a+t));
    p2[1] = P(x2 + r2 * cos(a-t) , y2 + r2 * sin(a-t));

    for(int i = 0 ; i < 2 ; i++){
      L l;
      l.push_back(p1[i]);
      l.push_back(p2[i]);
      lines.push_back(l);
    }

    dr = r1+r2;
    if(dr < dist){
      t = acos(dr / dist);

      p2[0] = P(x2 + r2 * cos(a+t+PI) , y2 + r2 * sin(a+t+PI));
      p2[1] = P(x2 + r2 * cos(a-t+PI) , y2 + r2 * sin(a-t+PI));

      for(int i = 0 ; i < 2 ; i++){
        L l;
        l.push_back(p1[i]);
        l.push_back(p2[i]);
        lines.push_back(l);
      }
    }

    else if(abs(dr- dist) < EPS){
      p1[0] = P(x1 + r1 * cos(a) , y1 + r1 * sin(a));
      p2[0] = P(x2 + r2 * cos(a+PI) , y2 + r2 * sin(a+PI));
 
      L l;
      l.push_back(p1[0]);
      l.push_back(p2[0]);
      lines.push_back(l);
    }
  }

  return lines;
}

double dot(const P &a, const P &b){
  return real(conj(a) * b);
}

P projection(const L &l, const P &p){
  double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
  return l[0] + t * (l[0] - l[1]);
}

double distLP(const L &l, const P &p){
  return abs(p - projection(l, p));
}

int solve(L l){
  int res = 0;

  for(int i = 0; i < n; i++){
    double dist = distLP(l, o[i]);
    if(dist - r[i][0] >= -EPS && r[i][1] - dist >= -EPS){
      res++;
    }
  }

  return res;
}

int main(){
  while(cin >> n, n){
    for(int i = 0; i < n; i++){
      cin >> o[i].real() >> o[i].imag() >> r[i][0] >> r[i][1];
      r[i][1] += r[i][0];
    }

    int ans = 1;

    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        for(int r1 = 0; r1 < 2; r1++){
          for(int r2 = 0; r2 < 2; r2++){
            vector<L> v = getSessen(o[i].real(), o[i].imag(), r[i][r1],
                                    o[j].real(), o[j].imag(), r[j][r2]);
            for(int k = 0; k < v.size(); k++){
              ans = max(ans, solve(v[k]));
            }
          }
        }
      }
    }

    cout << ans << endl;
  }
}

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


int main(){
	char n1, n2, n3;
	cin >> n1 >> n2 >> n3;
	int a = n1 - '0';
	int b = n2 - '0';
	int c = n3 - '0';
	if (a == 1)
	{cout << "9";}
	else
	{cout << "1";}
	if (b == 1)
	{cout << "9";}
	else
	{cout << "1";}
	if (c == 1)
	{cout << "9";}
	else
	{cout << "1";}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<29;

int dp[310][310];

int main(){
  int n,m,r; cin >> n >> m >> r;
  vector<int> v(r);
  rep(i,r){
    int a; cin >> a; a--; v[i]=a;
  }
  rep(i,n)rep(j,n) dp[i][j]=inf;
  rep(i,n) dp[i][i]=0;
  rep(i,m){
    int a,b,t; cin >> a >> b >> t; a--; b--;
    dp[a][b]=t;
    dp[b][a]=t;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
  sort(all(v));
  ll ans=inf;
  do{
    ll sum=0;
    rep(i,r-1) sum+=dp[v[i]][v[i+1]];
    chmin(ans,sum);
  }while(next_permutation(all(v)));
  cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    #ifdef FILIP_KADAK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n<k)
        cout << n*x;
    else 
        cout << k*x+(n-k)*y;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s; int k;
  cin>>s>>k;
  int n=s.size();
  string ans;
  for(int i=0; i<n; i++){
    int t=s[i]-'a';
    if(s[i]=='a'){
      ans+='a';
      continue;
    }
    if(k>=26-t){
      ans+='a';
      k-=(26-t);
    }else{
      ans+=s[i];
    }
  }
  k%=26;
  ans[n-1]+=k;
  cout<<ans<<endl;
	return 0;
}

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

int main() {
  long long a = 2, b = 1;
  int N;
  cin >> N;
  
  if (N == 0) {
    cout << 2 << endl;
  } else if (N == 1) {
    cout << 1 << endl;
  } else {
    for (int i = 2; i <= N; i++) {
      b += a;
      a = b-a;
    }
    cout << b << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans = 0;
        long q = 2;
        int e = 1;
        long div;

        if(N == 1){
            System.out.println(0);
            return;
        }

        while(true){
            div = (long) Math.pow(q, e);
            if(N % div == 0){
                N /= div;
                ans++;
                e++;
                continue;
            }
            while(N % q == 0){
                N /= q;
            }
            q++;
            e = 1;
            if(q * q > N) break;
        }

        if(N != 1){
            ans++;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35744
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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,k;
    cin >> n>> k;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    int res = 0;
    int right = 0;
    while(true) {
        if(res==0){
            res++;
            right += k;
        } else {
            res++;
            right += k-1;
        }
        if(right>=n) break;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll x; cin >> x;
	int ans = 0;
	ll cnt = 100;
	while (cnt < x) {
		++ans;
		cnt += cnt / 100;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3640
#include <cassert>
#include <cstdlib>
#include <iostream>
using namespace std;

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

	int result;
	cin >> result;

	for(char c; cin >> c, c != '=';) {
		int value;
		cin >> value;

		switch(c) {
		case '+': result += value; break;
		case '-': result -= value; break;
		case '*': result *= value; break;
		case '/': result /= value; break;
		default:
			assert(false);
		}
	}

	cout << result << endl;

	return EXIT_SUCCESS;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {

    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii,
       std.typecons;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  
  int a, b;
  a = cin.next!int;
  b = cin.next!int;
  int cnt;
  for (int i = a; i < b + 1; ++i) {
    dchar[] s = i.to!(dchar[]);
    dchar[] t;
    foreach_reverse (c; s) {
      t ~= c;
    }
    if (s == t) cnt++;
  }
  writeln(cnt);
}


Measured memory_bytes: 1276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#define ll long long

using namespace std;

const int M = 1000000007;

int n, m, x, y, z, b, w;
vector <int> v, p;
int dp[1010][5010];

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> m;
	w = (1<<n);
	v.push_back(0); p.push_back(0);
	
	for (int i = 1; i < w; i++) dp[0][i] = M;
	
	for (int i = 0; i < m; i++){
		cin >> x >> y;
		z = 0;
		for (int j = 0; j < y; j++){
			cin >> b; b--;
			z |= (1<<b);
		}
		p.push_back(x);
		v.push_back(z);
	}
	
	for (int i = 1; i <= m; i++){
		for (int j = 0; j < w; j++){
			dp[i][j] = min(dp[i-1][j], dp[i-1][(j^v[i])&j]+p[i]);
		}
	}
	
	/*for (int i = 1; i <= m; i++){
		for (int j = 0; j < w; j++){
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
	
	if (dp[m][w-1] == M) cout << -1;
	else cout << dp[m][w-1];
	
return 0;
}




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

int main()
{
    double s;
    cin>>s;
    double length = s / 3;
    s -= length;
    double breadth = s / 2;
    double height = s - breadth;
    double volume =  length * breadth * height;
    cout <<fixed<<setprecision(12)<<volume << endl;
    return 0;
}


Measured memory_bytes: 256
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7

# n = int(input())
# a = list(map(int, input().split()))
n = int(input())


if n > 81:
    print('No')
    exit()

else:
    for i in range(1,10):
        if n % i == 0 and 1<= (n // i) <=9:
            print('Yes')
            exit()

print('No')


Measured memory_bytes: 38384
N = int(input())

ab = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N)]

for ai, bi in ab:
    graph[ai - 1].append(bi - 1)
    graph[bi - 1].append(ai - 1)

from collections import deque

ans = []
col_max = 1
q = deque([(0, -1, 0)])
while len(q) > 0:
    col = 1
    src, prev, col_prev = q.popleft()
    # print("#", src)
    for dst in graph[src]:
        if dst == prev: continue
        #
        if col == col_prev: col += 1
        # print("##", dst)
        # ans[src][dst] = col
        ans.append((dst, src, col))
        q.append((dst, src, col))
        col_max = max(col, col_max)
        col += 1
        
ans.sort(key=lambda x: x[0] * N + x[1])
        
print(col_max)
for ai, bi in ab:
    l = 0
    r = N - 2
    # print("#", ai, bi)
    while l < r:
        m = l + (r - l + 1) // 2
        tmp = ans[m][0] * N + ans[m][1]
        # print("#", (l, r), m, tmp)
        if tmp <= (bi - 1) * N + (ai - 1):
            l = m
        else:
            r = m - 1
    #
    # print("#", l, ans)
    print(ans[l][2])

Measured memory_bytes: 100568
A, B, C, X, Y = map(int,input().split())
import math
price_min = -1
for ab in [0, 2*X, 2*Y]:
    X_need = X - 0.5*ab
    Y_need = Y - 0.5*ab
    if X_need < 0:
        X_need = 0
    if Y_need < 0:
        Y_need = 0
    price = ab * C + A * math.ceil(X_need) + B * math.ceil(Y_need)
    if price_min == -1:
        price_min = price
    else:
        price_min = min(price, price_min)
print(price_min)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

typedef pair<int, int> P;

#define MAX_H 100
#define MAX_W 100

int H, W;
char farm[ MAX_H ][ MAX_W + 1 ];
const int dx[ 4 ] = { 1, 0, -1, 0 }, dy[ 4 ] = { 0, 1, 0, -1 };

void DFS( int x, int y ) {
	char ch = farm[ y ][ x ];
	farm[ y ][ x ] = '.';
	for( int i = 0; i < 4; ++i ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];
		if( 0 <= nx && nx < W && 0 <= ny && ny < H && farm[ ny ][ nx ] == ch ) { DFS( nx, ny ); }
	}
}

int main()
{
	while( scanf( "%d %d", &H, &W ), H || W ) {
		for( int y = 0; y < H; ++y ) { scanf( "%s", farm[ y ] ); }

		int ans = 0;
		for( int y = 0; y < H; ++y ) {
			for( int x = 0; x < W; ++x ) {
				if( farm[ y ][ x ] != '.' ) {
					DFS( x, y );
					++ans;
				}
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int keta(int N)
{
	if(N <= 9) return 1;
	else if(N <= 99) return 2;
	else if(N <= 999) return 3;
}

int ketame(int N,int nketame)
{
	if(nketame == keta(N)) return (N % 10);
	else if(nketame == keta(N)-1) return (int)((N % 100)/10);
	else if(nketame == keta(N)-2)
	return (int)((N % 1000)/100);
}
bool isiOK(int i,int N,int M,int s[],int c[])
{
	bool solution = true;
	if(keta(i) != N) solution = false;
	int j;
	for(j = 1;j <= M;j++)
	{
		if(ketame(i,s[j]) != c[j]) solution = false;
	}
	return solution;
}
int main()
{
	long long N , M;
	cin >> N >> M;
	int i;
	int s[M],c[M];
	for(i = 1;i <= M;i++)
	{
		cin >> s[i] >> c[i];
	}
	for(i = 0;i < 1000;i++)
	{
		if(isiOK(i,N,M,s,c)) 
		{
			cout << i;
			break;
		}
		if(i == 999)
		{
			cout << "-1" << endl;
		}
	}
}
		


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

constexpr int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }

const int mod = TEN(9) + 7;

bool used[200010];

struct UF {
	vi data;
	void init(int n)
	{
		data.resize(n);
		fill(all(data), -1);
	}
	int root(int x)
	{
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	void unite(int x, int y)
	{
		x = root(x);
		y = root(y);
		if (x == y) return;
		if (size(x) < size(y)) swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}
	bool same(int x, int y)
	{
		return root(x) == root(y);
	}
	int size(int x)
	{
		x = root(x);
		return -data[x];
	}
	bool is_root(int x)
	{
		return x == root(x);
	}
};

UF uf;
int N, M;
int p[100010];

signed main()
{
	cin >> N >> M;
	uf.init(N);
	rep(i, N) cin >> p[i], --p[i];

	rep(i, M) {
		int x, y; cin >> x >> y; --x, --y;
		uf.unite(p[x], p[y]);
	}

	int ans = 0;

	rep(i, N) {
		if (uf.same(i, p[i]) or p[i] == i) ans++;
	}

	cout << ans << endl;
}




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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    long long int n,m,ans=0;
    cin>>n>>m;
    if(n==1 && m==1)
    {
        cout<<"0";
    }
    else
    {
        if(n>=2)
        {
            long long tm= n*(n-1);
            tm/=2;
            ans+=tm;
        }
        if(m>=2)
        {
            long long int tm= m*(m-1);
            tm/=2;
            ans+=tm;
        }
        cout<<ans;
    }
}


Measured memory_bytes: 3568
N,K = [int(hoge) for hoge in input().split()]
P = [int(hoge)-1 for hoge in input().split()]#0-indexed
C = [int(hoge) for hoge in input().split()]
LoopSum = []
ans = 0
LoopIndex = [-1 for i in range(N)]
Loops = []
num = 0
for start in range(N):
    if -1 == LoopIndex[start]:
        LpSm = C[start]
        LoopIndex[start] = num
        route = [start]
        cur = P[start]
        while cur != start:
            LoopIndex[cur] = num
            route.append(cur)
            cur = P[cur]
            LpSm += C[cur]
        Loops.append(route)
        LoopSum.append(LpSm)
        num += 1
DekiSumAmari = [(K//len(L),sum([C[j] for j in L]),K%len(L)) for L in Loops]
for s in range(N):
    Looplen =len(Loops[LoopIndex[s]])
    score = 0
    D,S,A = DekiSumAmari[LoopIndex[s]]
    if S<=0:#一周もしないほうがいい
        A = min(K,Looplen)
    else:
        if A==0:
            D -= 1
            A = Looplen
        score += D*S
    curpos = s
    curplus = 0
    maxplus = 0
    for i in range(min(K,Looplen)):
        if i == A:
            curplus -= S
        curplus += C[curpos]
        curpos = P[curpos]
        maxplus = max(maxplus,curplus)
    score += maxplus
    ans = max(ans,score)
if ans == 0:
    ans = max(C)
print(ans)

Measured memory_bytes: 69340
n = int(input())
temp = list(map(int, input().split()))
t = temp[0]
a = temp[1]
highs = list(map(int, input().split()))

answer = 0
close = -1
for i in range(n):
    high = highs[i]
    c = abs(a - (t - high * 0.006))
    if close < 0 or c < close:
        close = c
        answer = i
print(answer + 1)

Measured memory_bytes: 3064
def main():
    n, k = map(int, input().split())
    P = [int(x) for x in input().split()]
    p_e = list()
    exp = 0
    p_e.append(exp)
    for p in P:
        exp += (1+p)/2
        p_e.append(exp)
    maxv = p_e[k] - p_e[0]
    for i in range(1, n-k+1):
        p_sum = p_e[k+i] - p_e[i]
        maxv = max(maxv, p_sum)
    print(maxv)

if __name__ == '__main__':
    main()
    

Measured memory_bytes: 31980
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (int)(b); i < _b; ++i)
#define fr(i, a, b) for (int i = (a), _b = (int)(b); i <= _b; ++i)

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const int N = 1000000 + 15;
const int M = 55;
const int multipleTest = 0;

int cnt[N];
int n;

void solve() {
    cin >> n;
    rep(i, 0, n ) {
        int u; scanf("%d", &u);
        cnt[u]++;
    }
    
    int res = 0;
    rep(j, 0, N) {
        int cur = cnt[j];
        if (j > 0) cur += cnt[j - 1];
        if (j + 1 < N) cur += cnt[j + 1];
        res = max(res, cur);
    }
    cout << res;
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


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

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

  while (true) {
    c -= b;

    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }

    a -= d;

    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	ll N, A, B;
	
	void ans() {
		cin >> N >> A >> B;
		ll res;
		if (A > B || (N == 1 && A < B)) res = 0;
		else if (A == B) res = 1;
		else res = (B - A)*(N - 2) + 1;
		cout << res << "\n";
	}

};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	question q;
	q.ans();
	
	return 0;
}



Measured memory_bytes: 256
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    a,b,c = map(int, input().split())
    k = int(input())
    flag = False
    if a < b < c:
        print("Yes")
        sys.exit()

    for i in range(k):
        if a < b < c:
            c *= 2
        if a >= b:
            if b >= c:
                c *= 2
            else:
                b *= 2
        else:
            if b >= c:
                c *= 2
            else:
                b *= 2

    if a < b < c:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
	main()


Measured memory_bytes: 9588
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main()
{


 int k,i;
 cin>>k;
 string s;
 cin>>s;
 int n=s.size();
 if(n<=k)
 {
   cout<<s;
 }
  else
  {
    string s1;
    for(i=0;i<k;i++)
    {
        s1+=s[i];
    }
    s1+="...";
    cout<<s1;
  }

}





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

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

fn main() {
    let a:u64 = read();
    let b:u64 = read();
    println!("{}", a / gcd(a, b) *  b);
}

fn gcd(a:u64, b:u64) -> u64 {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//誤差を考慮して足し算
double add(double a,double b){
	if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{//2次元ベクトル
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	double dot(P p){//内積
		return add(x*p.x,y*p.y);
	}
	double det(P p){//外積
		return add(x*p.y,-y*p.x);
	}
	bool equal(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y) < EPS*EPS;
	}
};
//線分p1-p2上に点qがあるか判定
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
//直線p1-p2と直線q1-q2の交点
P intersection(P p1,P p2,P q1,P q2){
	return p1+(p2-p1)*( (q2-q1).det(q1-p1)/(q2-q1).det(p2-p1) );
}

int main(){
	int n,ans;
	P p[100],q[100];
	vector<P> cross;//交点
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			double a,b,c,d;
			cin>>a>>b>>c>>d;
			p[i]=P(a,b);
			q[i]=P(c,d);
		}
		ans=1;
		for(int i=0;i<n;i++){
			cross.clear();
			for(int j=0;j<i;j++){
				if(p[i].equal(p[j]) || p[i].equal(q[j]) || q[i].equal(p[j]) || q[i].equal(q[j]) )continue;
				if( (q[i]-p[i]).det(q[j]-p[j])==0 )continue;//平行
				P a=intersection(p[i],q[i],p[j],q[j]);
				//if(on_seg(p[i],q[i],a) || on_seg(p[j],q[j],a)){
				if ( -100 <= a.x && a.x <= 100  && -100 <= a.y && a.y <= 100){
					int k;
					for(k=0;k<cross.size();k++){
						if(cross[k].equal(a))break;
					}
					if(k==cross.size()){//新しい交点
						cross.push_back(a);
					}
				}
			}
			ans += cross.size() + 1;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>

using namespace std;

void solve()
{
	string s;
	int count[26] = { 0 };
	while (getline(cin, s))
	{
		for (int i = 0; i < s.size(); ++i)
		{
			char c = tolower(s[i]);
			count[c - 'a']++;
		}
	}
	for (int i = 0; i < 26; ++i)
	{
		cout << char(i + 'a') << " : " << count[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1176
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

A, B = map(int, input().split())
X = gcd(A, B)
primes = []
while X % 2 == 0:
    primes.append(2)
    X //= 2
f = 3
while f * f <= X:
    if X % f == 0:
        primes.append(f)
        X //= f
    else:
        f += 2
if X != 1:
    primes.append(X)
print(len(set(primes))+1)


Measured memory_bytes: 39024
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy
n,k = L()
l = [1]*n
for i in range(k):
    d = N()
    a = L()
    for j in a:
        l[j-1] = 0
print(l.count(1))

Measured memory_bytes: 9116
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)

char s[1000000];
int main() {
	int k; scanf("%s%d", s, &k);
	int len = strlen(s);
	rep(i, len) {
		if (s[i] != 'a'&&s[i] + k > 'z') {
			k = k + s[i] - 'z' - 1;
			s[i] = 'a';
		}
	}
	if (k)s[strlen(s) - 1] = (s[strlen(s) - 1] + k - 'a') % 26 + 'a';
	printf("%s\n", s);
}

Measured memory_bytes: 384
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val H, W = sc.nextInt()
    val C = Array.fill(10, 10)(sc.nextInt())
    val A = Array.fill(H, W)(sc.nextInt())

    // つまり, どの数字をどの順番で変えてもいいし, 同じ数字に変えてもいい
    // ある数字は, 必ず同じ順番で数字を変化させ, 最終的に数字を1にする
    // ある数字を1に変える最小魔力は ある数字u からある数字vへの変換の最小コストを求める
    // 全点対最短経路問題に帰着でき, Cはそのまま数字から数字への接続を表す無向グラフを表現している
    // V = 10程度なので, O(V^3)のワーシャルフロイドで解くことができる
    val d = floydWarshall(10, C)
    val minCost = (for {
      i <- 0 until H
      j <- 0 until W
      if A(i)(j) != -1
    } yield d(A(i)(j))(1)).sum

    println(minCost)
  }

  def floydWarshall(V: Int, G: Array[Array[Int]]): Array[Array[Int]] = {
    for {
      k <- 0 until V
      u <- 0 until V
      v <- 0 until V
    } G(u)(v) = G(u)(v) min (G(u)(k) + G(k)(v))
    G
  }

}


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

int n,m,a[305][305],b[305],ans;

void work()
{
	scanf("%d %d",&n,&m),ans=n;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			scanf("%d",&a[i][j]);
	for (int _=m,x; _; )
		{
			for (int i=1; i<=m; i++)  if (b[i]!=-1)  b[i]=0;
			for (int i=1; i<=n; i++)
				for (int j=1; j<=m; j++)
					if (b[a[i][j]]!=-1)
						{b[a[i][j]]++;  break;}
			x=0;
			for (int i=1; i<=m; i++)  if (b[i]!=-1)  x=max(x,b[i]);
			ans=min(ans,x);
			for (int i=1; i<=m; i++)  if (b[i]==x)  b[i]=-1,_--;
		}
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

int k =VMAX;
for ( i= 0; i < n;i++){
	scanf("%d",&A[i]);
}
for ( i =0; i <= k;i++){
	C[i] = 0;
}
for ( j = 0; j< n; j++){
	C[A[j]]++;
}
for ( i = 0; i <  k ; i++){
C[i+1]+= C[i];
}
for ( j = n-1 ; j >= 0; j--){
	B[C[A[j]]] = A[j];
	C[A[j]]--;
}
for ( i = 1;i <= n;i++){
printf("%d" ,B[i]);
if ( i != n){ printf(" ");}
}
printf("\n");
  return 0;
}

  /* your code 
  1 CountingSort(A, B, k)
2     for i = 0 to k
3         C[i] = 0
4
5     /* C[i] に i の出現数を記録する 
6     for j = 1 to n
7         C[A[j]]++
8
9     /* C[i] に i 以下の数の出現数を記録する
10    for i = 1 to k
11        C[i] = C[i] + C[i-1]
12
13    for j = n downto 1
14        B[C[A[j]]] = A[j]
15        C[A[j]]--*/



Measured memory_bytes: 9592
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int n, k;
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    ll lo = 0, hi = 0;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        lo += i;
        hi += n - i;
        if (i + 1 >= k) {
            ans += hi - lo + 1;
            ans %= MOD;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3148
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int c;
	if(b >= 0 && b <= 9)	c = b + a * 10;
	else if(b == 100)	c = b + a * 1000;
	else c = b + a * 100;
	if((int)sqrt(c) == sqrt(c))	puts("Yes");
	else puts("No");
	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    
    int n;
    cin >> n;
    vector<int> p(n, 0);
    for (int i = 0; i < n; i++) cin >> p[i];
    
    int sum = 0;
    for (int i = 0; i < n; i++) sum += p[i];
    sum -= *max_element(p.begin(), p.end()) / 2;
    
    cout << sum << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int n; cin >> n;
    ll ans = 0;
    repr(i,1,n){
        int d;
        if(n%i == 0) d = n/i-1;
        else d = n/i;
        ans += d;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3648
#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>;

const ll INF = 1e18;

int main() {
    ll n;
    cin >> n;
    
    ll ans = INF;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ll sum = i + n/i - 2;
            ans = min(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long int;
 
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;
 
template<typename T>
void print1d(vector<T> a){
    for (auto x:a){
        cout << x << " ";
    }
    cout << endl;
}
 
template<typename T>
void print2d(vector<vector<T>> a){
	for (auto v:a){
		for (auto x:v){
			cout << x << " ";
		}
		cout << endl;
	}
}

template<typename T>
void print(T a){
	for (auto x:a){
		cout << x << " ";
	}
	cout << endl;
}


int main()
{
	int n;
	cin >> n;
	map<char, int> res;
	rep(i,n){
		map<char, int> temp;
		string s;
		cin >> s;
		rep(j,s.size()){
			temp[s[j]]++;
		}
		if (i == 0){
			res = temp;
		}else {
			for (char c = 'a'; c <= 'z'; c++)
			{
				res[c] = min(res[c], temp[c]);
			}
		}

		
	}
	string ans = "";
	for (char c = 'a'; c <= 'z';c++){
		ans += string(res[c], c);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
//const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

vector<ll> dx = { 0, 1, 0, -1, 1, -1, 1, -1, 0};
vector<ll> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0};

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

ll x;

void solve() {
	cin >> x;
	for (ll i = 1; i * i <= x; i++) {
		if (x % i != 0) continue;
		for (ll j = -400; j < 400; j++) {
			ll an = pow_long(j, 5) - pow_long(j - i, 5);
			if (an == x) {
				cout << j << ' ' << j - i << endl;
				return;
			}
			an = pow_long(j, 5) - pow_long(j - x / i, 5);
			if (an == x) {
				cout << j << ' ' << j - x / i << endl;
				return;
			}
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 3656
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
  long h,w,num[10]={},a,b;
  int n,cnt=0;
  vector<pair<long,long>> p;
  scanf("%ld %ld %d",&h,&w,&n);
  for(int i=0;i<n;i++){
    scanf("%ld %ld",&a,&b);
    for(long j=max((long)1,a-2);j<=min(a,h-2);j++)
      for(long k=max((long)1,b-2);k<=min(b,w-2);k++)
        p.push_back(make_pair(j,k));
  }
  a=b=0;
  sort(p.begin(),p.end());
  p.push_back(make_pair(h+1,w+1));
  for(int i=0;i<p.size();i++){
    if(a==p[i].first&&b==p[i].second)
      cnt++;
    else{
      num[cnt]++;
      cnt=1;
      a=p[i].first;
      b=p[i].second;
    }
  }
  num[0]=(h-2)*(w-2);
  for(int i=1;i<=9;i++)
    num[0]-=num[i];
  for(int i=0;i<10;i++)
    printf("%ld\n",num[i]);
}


Measured memory_bytes: 18664
#include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define all(x) (x).begin(), (x).end()
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int MOD = 1e9 + 7;
int n, f[2000010], m;
int main()
{
    n = read();
    f[n] = n;
    m = n - 1;
   	for(int i = n - 1; i; i --)
    {
    	f[i] = 1LL * (n - 1) * (n - 1) % MOD;
    	(f[i] += f[i + 1]) %= MOD;
    	(f[i] += m) %= MOD;
    	m += (i + 2 > n ? 1 : f[i + 2]) - 1;
    	m %= MOD;
    }
    printf("%d\n", f[1]);
    return 0;
}


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

int main()
{
    int n, a[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    int b[100010] = {};
    for (int i = 0; i < n; i++) {
        b[a[i]]++, b[a[i] - 1]++, b[a[i] + 1]++;
    }

    int ans = 0;
    for (int i = 0; i < 100010; i++) {
        ans = max(ans, b[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<algorithm>
#define max(x,y) x>y?x:y
#define min(x,y) x<y?x:y
using namespace std;
const int maxn=1e5+10;
const int maxm=6*1e5+10;
const int gg=0x7FFFFFFF;
int a,b,c;
int main()
{
    int p[4];
    scanf("%d%d%d",&p[0],&p[1],&p[2]);
    

        sort(p,p+3);
        a=p[0]; b=p[1]; c=p[2];
        //cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
        int ans=0;
        ans=c-b;
        int t=0;
        if((b-a)%2==1)
        {
            ans+=(b-a+1)/2+1;
        }
        else
        {
            ans+=(b-a)/2;
        }
        printf("%d\n",ans );
    
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int A, B;
	scanf("%d%d", &A, &B);

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		printf("Possible");
	}
	else {
		printf("Impossible");
	}




}

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

int Standard_Input(int* a,int* b,int* c,int* d)
{
    int x,r;
    r=scanf("%d",&x);
    while(x>=10000||x<0)
    {
        r=scanf("%d",&x);
    }
    *d=x%10;x/=10;
    *c=x%10;x/=10;
    *b=x%10;x/=10;
    *a=x%10;
    return r;
}

int main()
{
    int a,b,c,d;
    while(Standard_Input(&a,&b,&c,&d)==1)
    {
        if(a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
        else if(a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
        else if(a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
        else if(a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
        else if(a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
        else if(a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
        else if(a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
        else if(a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
        else continue;
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i, &st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	int j= pop(&st1);
    	sum+=i-j;
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	pop(&st2_j);
      	a+=pop(&st2_a);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j,&st2_j);
    	push(a,&st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
	for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]); 
  printf("\n");
	
  return 0;
}


Measured memory_bytes: 2144