akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
int n;
int a[maxx], b[maxx];

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) b[i] = a[i];
	sort(a + 1, a + n + 1);
	int l = a[n / 2], r = a[n / 2 + 1];
	for(int i = 1; i <= n; i++) {
		if(b[i] <= l) printf("%d\n", r);
		else if(b[i] >= r) printf("%d\n", l);
	}
}

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

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

using namespace std;

int main(){
	int x,a,b; cin>>x>>a>>b;
	if(b-a<=0) cout<<"delicious"<<endl;
	else if(b-a<=x) cout<<"safe"<<endl;
	else cout<<"dangerous"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
#define ll long long
#define INFTY 1 << 21

int main() {
  int N, cnt = 0;
  cin >> N;
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  for (int i = 0; i < N; i++) {
    if (p[i] != i + 1) {
      cnt++;
    }
  }

  if (cnt == 0 || cnt == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n;cin>>n;
	string s;cin>>s;
	if(n%2==1)
	{
		cout<<"No";
		return 0;
	}
	string a,b;
	ll len=s.length();
	for(ll i=0;i<len/2;i++)
	{
		if(s[i]!=s[i+len/2])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define forb(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	int base = 700;
	cin >> s;int sum = 0;
	int w = 100;
	for(char i : s){
		if(i == 'o') sum ++;
	}
	w *= sum;
	cout << base + w << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

mod = 1000000007

N, M = map(int, sys.stdin.readline().split())
A = set()
for _ in range(M):
    a = int(sys.stdin.readline())
    A.add(a)

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 0 if 1 in A else 1
for i in range(1, N):
    if i+1 in A:
        continue
    dp[i+1] = dp[i] + dp[i-1]
    dp[i+1] %= mod

# print(dp)
print(dp[N])

Measured memory_bytes: 17184
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int n, x, y, h, w;

  while(1) {
    cin >> n;
    if(!n) break;

    int ans = 0;
    REP(i, n) {
      cin >> x >> y >> h >> w;
      int sum = x+y+h;
      if(sum > 160 || w > 25) continue;
      else if(sum > 140 || w > 20) ans += 1600;
      else if(sum > 120 || w > 15) ans += 1400;
      else if(sum > 100 || w > 10) ans += 1200;
      else if(sum > 80 || w > 5) ans += 1000;
      else if(sum > 60 || w > 2) ans += 800;
      else ans += 600;
    }
    cout << ans << endl;
  }   
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int dfs(int now, int prev, int st, int ed, const vvi &g) {
  int res = 0;
  for(int i=0;i<SZ(g[now]);++i) {
    int nxt = g[now][i];
    if(nxt == prev) continue;
    if(nxt == st) {
      res += 0;
      continue;
    }
    if(nxt == ed) {
      res += 1;
      continue;
    }
    res += dfs(nxt, now, st, ed, g);
  }
  return res;
}

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

  int n, m; cin >> n >> m;
  vi d(n);
  vvi g(n);
  for(int i=0;i<m;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    d[a]++;
    d[b]++;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool ev = true;
  bool six = false;
  int four = 0;
  vi f;
  for(int i=0;i<n;++i) {
    ev &= (d[i] % 2 == 0);
    six |= d[i] >= 6;
    if(d[i] == 4) {
      four++;
      f.push_back(i);
    }
  }
  
  if(!ev) {
    cout << "No" << endl;
    return 0;
  } else if(six) {
    cout << "Yes" << endl;
    return 0;
  } else if(four <= 1) {
    cout << "No" << endl;
    return 0;
  } else if(four >= 3) {
    cout << "Yes" << endl;
    return 0;
  }

  int res = dfs(f[0], -1, f[0], f[1], g);
  
  cout << (res == 4 ? "No" : "Yes") << endl;


}


Measured memory_bytes: 8064
N, M = [int(x) for x in input().split()]
# N, M < 10 ** 5
# A < 10 ** 9
# B < 10 ** 5

AB = []
for i in range(N):
    AB.append(tuple(int(x) for x in input().split()))

rem = M
need = 0
for a, b in sorted(AB):
    if rem > b:
        need += a * b
        rem -= b
    else:
        need += a * rem
        break
print(need)



Measured memory_bytes: 17748
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	int n,m;
	cin >> n >> m;

	int a = n*(n - 1)/2;
	int b=  m* (m - 1) / 2;

	cout << a+b<< endl;
	return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


signed main(void)
{
	IOS;
	int n,m; cin>>n>>m;
	int req; cin>>req;
	vector<string> mat(n);
	for(int i = 0; i < n; i++) {
		cin>>mat[i];
	}
	int ans=0;
	for(int i = 0; i < (1<<n); i++) {
		for(int j = 0; j < (1<<m); j++) {
			vector<string> nmat = mat;
			int cnt=0;
			for(int bit = 0; bit < n; bit++) {
				if(__check(i,bit)) {
					for(int k = 0; k < m; k++)
						nmat[bit][k]='r';
				}
			}
			for(int bit = 0; bit < m; bit++) {
				if(__check(j,bit)) {
					for(int k = 0; k < n; k++)
						nmat[k][bit]='r';
				}
			}
			for(int r = 0; r < n; r++) {
				for(int c = 0; c < m; c++) {
					if(nmat[r][c] == '#')
						cnt++;
				}
			}
			if(cnt==req) {
				ans++;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		System.out.println((a * b > c * d)? a * b : c * d);
	}
}

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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	char ch;
	cin >> ch;
	if(ch >= 'A' && ch <= 'Z')
		cout << 'A';
	else
		cout << 'a';	

}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN=4000000;
const int MOD=1e9+7;
long long a[MAXN+10],pre[MAXN+10],n,k,f[2200][2200];
long long C(long long p,int x){
	return 1ll*(pre[p]*a[x])%MOD*a[p-x]%MOD;
}
long long pp(int x,int p){
	long long ans=1,m=x;
	while(p){
		if(p&1)(ans*=m)%=MOD;
		p>>=1;(m*=m)%=MOD;
	}
	return ans;
}
int main(){
//	freopen("1.out","w",stdout);
	scanf("%d%d",&n,&k);
    if(k==1){
        printf("1");
        return 0;
    }
	pre[0]=1;
	for(int i=1;i<=MAXN;i++)pre[i]=(1ll*i*pre[i-1])%MOD;
	a[MAXN]=pp(pre[MAXN],MOD-2);for(int i=MAXN-1;i>=0;i--)a[i]=a[i+1]*(i+1)%MOD;
	f[0][0]=1;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(i)f[i][j]=(f[i-1][j]+f[i][j])%MOD;
			if(j)f[i][j]=(f[i][j]+1ll*f[i][j-1]*C(n*k-i-(j-1)*(k-1)-1,k-2)%MOD)%MOD;
		}
	}
	long long ans=1ll*f[n][n]*pre[n]%MOD;
	printf("%d",ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

using coord_t = pair<ll, ll>;

template <typename T1, typename T2>
bool pair_second_lt(const pair<T1, T2> &p1, const pair<T1, T2> &p2) {
  return p1.second > p2.second;
}

ll solve(vector<ll> &h, vector<ll> &w) {
  vector<coord_t> coord_vec(h.size());
  unordered_map<ll, ll> h_map, w_map;
  for (size_t i = 0; i < h.size(); i++) {
    coord_vec[i] = coord_t{h[i], w[i]};

    h_map[h[i]]++;
    w_map[w[i]]++;
  }

  unordered_set<ll> h_max_keys, w_max_keys;
  ll h_max = 0, w_max = 0;
  for (auto &&p : h_map) {
    if (p.second > h_max) {
      h_max = p.second;
      h_max_keys = {p.first};
    } else if (p.second == h_max) {
      h_max_keys.emplace(p.first);
    }
  }
  for (auto &&p : w_map) {
    if (p.second > w_max) {
      w_max = p.second;
      w_max_keys = {p.first};
    } else if (p.second == w_max) {
      w_max_keys.emplace(p.first);
    }
  }

  if (h_max_keys.size() * w_max_keys.size() > h.size()) {
    return h_max + w_max;
  }

  set<coord_t> cand_coord;
  for (auto &&hk : h_max_keys) {
    for (auto &&wk : w_max_keys) {
      cand_coord.emplace(coord_t{hk, wk});
    }
  }

  bool is_all_coord_has_target = true;
  for (int i = coord_vec.size() - 1; i >= 0; i--) {
    coord_t c = coord_vec[i];
    if (cand_coord.count(c) == 1) {
      cand_coord.erase(c);
    }
    if (cand_coord.size() > i || cand_coord.empty()) {
      break;
    }
  }

  return h_max + w_max - (cand_coord.empty() ? 1 : 0);
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll H, W, M;
  cin >> H >> W >> M;

  std::vector<ll> h(M, 0), w(M, 0);
  for (size_t i = 0; i < M; i++) {
    cin >> h[i] >> w[i];
  }

  // main procedure
  ll ans = solve(h, w);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 66968
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String nums[] = line.split(" ");
        int A = Integer.parseInt(nums[0]);
        int B = Integer.parseInt(nums[1]);
        int C = Integer.parseInt(nums[2]);
        int amount = C - (A - B);
        if (amount < 0) {
          amount = 0;
        }
        System.out.println(amount);
    }
}

Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9) << flush;
//memset(a, 0, sizeof(a));
//--------------------------

int a[3];

int main()
{
	cin >> a[0]>> a[1] >> a[2];
	sort(a, a + 3);
	
	int ans = a[2] - a[1];
	a[1] += ans;
	a[0] += ans;

	if ((a[1] - a[0]) % 2) {
		a[1]++;
		ans += (1 + (a[1]-a[0])/2);
	}
	else {
		ans += ((a[1] - a[0]) / 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
LL dp[2005][2005][2];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    dp[n+1][0][0] = 1;
    for(int i=n;i>=2;i--){
        for(int j=n;j>=0;j--){
            dp[i][j][0] = (dp[i][j][0] + dp[i+1][j][0] + dp[i+1][j][1])%mod;
            dp[i][j+1][1] = (dp[i][j+1][1] + dp[i+1][j][0] + dp[i+1][j][1])%mod;
            dp[i][j][0] = (dp[i][j][0] + dp[i][j+1][0])%mod;
        }
    }
    int ans = (dp[2][n-k][0] + dp[2][n-k][1])%mod;
    for(int i=1;i<=n-k-1;i++) ans = ans*2%mod;
    printf("%d\n", ans);
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, b) for (int i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int,int>
#define scl(n) scanf("%d",&n);
#define pcl(n) printf("%d\n", n)
#define pcl1(n) printf("%lld ", n)
#define FastRead                  \
	ios_base::sync_with_stdio(0); \
	cin.tie(0)
bool comp(ppi a,ppi b)
{
	return a.first<b.first;
}

int main()
{
	int n,m,i=1,res=0;
	cin>>n>>m;
	ppi p;
	vector<ppi>v;
	while(n--)
	{
		scl(p.first);
		scl(p.second);
		if(p.second<=m) v.pb(p);
	}
	if(v.size()<1) 
	{
		cout<<"TLE\n";
		return 0;
	}
	else
	{
		sort(v.begin(),v.end(),comp);
		cout<<v[0].first<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N,M,R;
int p[1000],x[1000];
int saiki(int u){
	int i,j,sum=0;
	bool f=false;
	int xx[5001]={};
	xx[0]=1;
	for(i=0;i<N;i++)
		if(p[i]==u){
			f=true;
			int w=saiki(i);
			sum+=w;
			for(j=5000;j>=0;j--)
				if(xx[j]){
					xx[j]=0;
					if(j+x[i]<=5000)
						xx[j+x[i]]=1;
					if(j+w-x[i]<=5000)
						xx[j+w-x[i]]=1;
				}
		}
	if(!f)
		return x[u];
	f=false;
	for(i=x[u];i>=0;i--)
		if(xx[i]){
			f=true;
			break;
		}
	if(!f)
		throw 'a';
	return sum+x[u]-i;
}
signed main(){
	int i,j;
	p[0]=-1;
	cin>>N;
	for(i=1;i<N;i++){
		cin>>p[i];
		p[i]--;
	}
	for(i=0;i<N;i++)
		cin>>x[i];
	try{
		saiki(0);
	}
	catch(...){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	cout<<"POSSIBLE"<<endl;
}

Measured memory_bytes: 17024
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u32,
        k: u32,
        s: u32,
    }

    if n == 1 {
        if k == 0 {
            if s == 10u32.pow(9) {
                println!("1");
            } else {
                println!("{}", s + 1);
            }
        } else {
            println!("{}", s);
        }
        return;
    }

    for i in 0..n {
        if i < k {
            print!("{}", s);
        } else {
            if s == 10u32.pow(9) {
                print!("1");
            } else {
                print!("{}", s + 1);
            }
        }

        if i != n - 1 {
            print!(" ");
        } else {
            println!("");
        }
    }
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if((sum+4*M-1)/(4*M)<=a[i]) cnt++;
    }
    
    if(M<=cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())    # 宿泊数
K = int(input())    # 単価が切り替わる泊数
X = int(input())    # 単価a
Y = int(input())    # 単価b


if N <= K:
    a = N * X
else:
    a = K * X + Y * (N - K)

print(a)

Measured memory_bytes: 9028
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, T := sc.nextInt(), sc.nextInt()
	min := int(1e+9)
	for i := 0; i < N; i++ {
		c, t := sc.nextInt(), sc.nextInt()
		if t <= T && c < min {
			min = c
		}
	}
	if min == int(1e+9) {
		fmt.Fprintln(wtr, "TLE")
	} else {
		fmt.Fprintln(wtr, min)
	}
	wtr.Flush()
}


Measured memory_bytes: 640
g,r=map(int,input().split())
A=["."*(r+2)]
for i in range(g):
  w="."+input()+"."
  A.append(w)
A.append("."*(r+2))

for i in range(1,g+1):
  for j in range(1,r+1):
    if A[i][j]==".":
      B=[]
      for m in [i-1,i,i+1]:
        for k in [j-1,j,j+1]:
          B.append(A[m][k])
     
      A[i]=A[i][1:r+1:].replace(".",str(B.count("#")),1)
      A[i]="."+A[i]+"."
for i in range(1,g+1):
  print(A[i][1:r+1:])


    


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

public class Main {

	public static void main(String[] args)
	{
		int k; String c;
		String str = "";
		try {str = new BufferedReader(new InputStreamReader(System.in)).readLine();}
		catch (IOException e) {e.printStackTrace();}

		String result = "";
		for(int i=0;i<str.length()/2;i++)
		{
			k =  Integer.parseInt(str.substring(2*i, 2*i+1));
			c = str.substring(2*i+1, 2*(i+1));

			result += translator(k, c);
		}
		System.out.println(result);
	}

	private static String translator(int k, String c)
	{
		String result = "";
		int[] nums = {0,1,2,3,4,5,6,7,8,9};
		String[] cons = {"w","","k","s","t","n","h","m","y","r"};

		String[] dir = {"T","L","U","R","D"};
		String[] vowel = {"a","i","u","e","o"};

		if(k==0&&c.equals("U"))
		{result += "nn";}
		else
		{
			for(int i=0;i<nums.length;i++)
			{if(nums[i]==k) {result += cons[i];}}

			for(int i=0;i<dir.length;i++)
			{if(c.equals(dir[i])) {result +=vowel[i];}}
		}

		return result;
	}
}

Measured memory_bytes: 26956
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(void) {}
  Edge(int src, int dst) : src(src), dst(dst) {}
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void edges_to_graph(Graph &graph, const Edges &edges, const int vertices, const bool directed = true) {
  graph.clear(), graph.resize(vertices);
  for (const auto &e : edges) graph[e.src].emplace_back(e);
  if (!directed) for (const auto &e : edges) graph[e.dst].emplace_back(Edge(e.dst, e.src, e.weight));
}

void dfs(Graph &g, int v, int p, int prev_col, map<pair<int, int>, int> &cmap) {
  int col = 0;
  for (const auto &e : g[v]) {
    if (e.dst == p) continue;
    ++col;
    if (col == prev_col) ++col;
    cmap[{ v, e.dst }] = cmap[{ e.dst, v }] = col;
    dfs(g, e.dst, v, col, cmap);
  }
}

void bfs(Graph &g, map<pair<int, int>, int> &cmap) {
  queue<tuple<int, int, int>> que;
  que.push(make_tuple(0, -1, 0));
  while (!que.empty()) {
    int v = get<0>(que.front()), p = get<1>(que.front()), pc = get<2>(que.front());
    que.pop();
    int col = 1;
    for (const auto &e : g[v]) {
      if (e.dst == p) continue;
      if (col == pc) ++col;
      cmap[{ v, e.dst }] = cmap[{ e.dst, v }] = col;
      que.push(make_tuple(e.dst, v, col));
      ++col;
    }
  }
}

Graph graph;
int main(void) {
  int n;
  cin >> n;
  Edges edges(n - 1);
  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    edges[i] = {--a, --b, 0};
  }
  edges_to_graph(graph, edges, n, false);
  int maxi = 0;
  rep (i, n) maxi = max(maxi, (int)graph[i].size());
  // cv.assign(n, vector<int>(n));
  map<pair<int, int>, int> cmap;
  dfs(graph, 0, -1, 0, cmap);
  // bfs(graph, cmap);
  cout << maxi << "\n";
  rep (i, n - 1) cout << cmap[{ edges[i].src, edges[i].dst }] << "\n";
  return 0;
}

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

using namespace std ;

int n ;
long long ans ;
long long base = 1ll ;

double s(long long x){
    int ret = 0 ; long long y = x ;
    while (x) ret += (x % 10ll), x /= 10ll ;
    return (1.0 * y) / (1.0 * ret) ;
}
int main(){
    cin >> n ;
    while (n --){
        while (1){
            if (s(ans + base) > s(ans + base * 10ll))
                base *= 10ll ; else break ;
        }
        ans += base ;
        printf("%lld\n", ans) ;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin>>P[i];
  }
  vector<int>Q(N);
  for(int i=0;i<N;i++){
    cin>>Q[i];
  }
  vector<int>num(N);
  for(int i=0;i<N;i++){
    num[i]=i+1;
  }
  int cnt=0;
  int a=0,b=0;
  do{
    if(num==P){a=cnt;}
    if(num==Q){b=cnt;}
    cnt++;
  }while(next_permutation(num.begin(),num.end()));
  cout<<abs(a-b)<<endl;
  return 0;  
}

Measured memory_bytes: 3580
n, k = map(int, input().split())
aa = list(map(int, input().split()))
ff = list(map(int, input().split()))

a = sorted(aa, reverse=True)
f = sorted(ff)

def C(x):
    ret = 0
    for i in range(n):
        ret += max(0, a[i] - x // f[i])
    return ret

lb = -1
ub = 10 ** 12 + 1
while (ub - lb) > 1:
    mid = (ub + lb) // 2

    if C(mid) > k:
        lb = mid
    else:
        ub = mid
print(ub)


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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;


int main()
{
	ios_base::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	if(k%2==0) cout << a-b << endl;
	else cout << b-a << endl;
		
	
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = 0;
  if (abs(a-c)<=d) {
    cout << "Yes" << endl;
    x++;
  }
  else {
    if (abs(a-b)<=d && abs(b-c) <=d){
      cout << "Yes" << endl;
      x++;
    }
  }
  if(x==0) {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3568
char*s,T['   '],*r=T;U[1<<27];i;k;main(n){for(;gets(r+1);k=0)for(--n;*++r&=31;)U[r-T]=k|=!!n<<*r;for(;s>T||(s=r,i++-2);k=U[k]=U[k+=*s+2<<21]?:*s?s-T:0)n+=__builtin_popcount(U[--s-T]&(U[k+'   ']^=!s[-1]<<*s));printf("%d",n);}

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

#define ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair


int main() {
   string s;
   cin>>s;
  long long int c=0;
   for(int i=0;i<s.length();i++){
       c+=s[i]-'0';
   }
 //  cout<<c<<endl;
   if(c%9!=0){
       cout<<"No\n";
   }else{
       cout<<"Yes\n";
   }
}


Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int f(char c)
{
	return c - '0';
}

int main()
{

	LLI a;
	string s;
	cin >> a >> s;


	LLI b = (int)(f(s[0]) * 100 + f(s[2]) * 10 + f(s[3]));

	cout << (a * b) / 100;


	return 0;
}


Measured memory_bytes: 3592
N=int(input())
S=input()

i=0
ans=[]
while i<N:
    A=set(S[:i])
    B=set(S[i:])
    j=0
    count=0
    while j<len(A):
        count+=1*(list(A)[j]in B)
        j+=1
    ans.append(count)
    i+=1

print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pair<long long, long long> > v;
 v.push_back(make_pair(-1,-1));
    for(int i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        
    }
    vector<vector <long long  >> dp(n+1,vector<long long>(w+1));
    for(int i=1;i <=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
dp[i][j]=dp[i-1][j];
          if(j>=v[i].first) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second); 
        }
    }
   long long ans=0;
     for(int j=0;j<=w;j++){ans=max(ans,dp[n][j]);}
     cout<<ans;
    
return 0;
}


Measured memory_bytes: 80256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String ts, hs;
    int n, tm, hm, tsum, hsum;
    char[] tc, hc;
    int i, j;

    n = sc.nextInt();
    tsum = 0;
    hsum = 0;

    for(i = 0;i < n;i++){
      ts = sc.next();
      hs = sc.next();
      if(ts.equals(hs)){
        tsum++;
        hsum++;
      }else{
        tm = ts.length();
        hm = hs.length();
        tc = new char[tm];
        hc = new char[hm];
        for(j = 0;j < tm;j++){
          tc[j] = ts.charAt(j);
        }
        for(j = 0;j < hm;j++){
          hc[j] = hs.charAt(j);
        }

        if(tm >= hm){
          for(j = 0;j < hm;j++){
            if(tc[j] > hc[j]){
              tsum += 3;
              break;
            }else if(hc[j] > tc[j]){
              hsum += 3;
              break;
            }
            if(j + 1 == hm){
              tsum += 3;
            }
          }
        }else{
          for(j = 0;j < tm;j++){
            if(tc[j] > hc[j]){
              tsum += 3;
              break;
            }else if(hc[j] > tc[j]){
              hsum += 3;
              break;
            }
            if(j + 1 == tm){
              hsum += 3;
            }
          }
        }
      }
    }

    System.out.println(tsum + " " + hsum);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 20988
import java.util.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		final long STACK=8*1024*1024;
		new Thread(null, new AOJ0180(), "RUN!", STACK).start();
	}
	
	class AOJ0180 implements Runnable{
		AOJ0180(){}
		@Override public void run(){
			while(sc.hasNext()){
				int N=sc.nextInt(),E=sc.nextInt();
				if((N|E)==0)	break;
				solve(N,E);
			}
		}
		void solve(int N,int E){
			int[][] g=new int[N][N];
			for(int i=0; i<N; i++)for(int j=0; j<N; j++)g[i][j]=1<<29;
			for(int i=0; i<E; i++){
				int u=sc.nextInt(),v=sc.nextInt(),c=sc.nextInt();
				g[u][v]=c;
				g[v][u]=c;
			}
			//System.out.println(prim(g,N));
			System.out.println(new kruskal(g,N).solve());
		}
		
		class kruskal{
			ArrayList<Edge> es;
			int E,N;
			final int INF=1<<29;
			kruskal(int[][] g,int N){
				this.N=N;
				es=new ArrayList<kruskal.Edge>();
				for(int i=0; i<N; i++){
					for(int j=0; j<N; j++){
						if(-1*INF<g[i][j] && g[i][j]<INF)	es.add(new Edge(i,j,g[i][j]));
					}
				}
				this.E=es.size();
			}
			int solve(){
				Collections.sort(es);
				UnionFind uf=new UnionFind(N);
				int ret=0;
				for(int i=0; i<E; i++){
					Edge e=es.get(i);
					if(!uf.isSame(e.u, e.v)){
						uf.unite(e.u, e.v);
						ret+=e.cost;
					}
				}
				return ret;
			}
			class Edge implements Comparable<Edge>{
				int u,v,cost;
				Edge(int u,int v,int cost){
					this.u=u;	this.v=v;	this.cost=cost;
				}
				@Override public int compareTo(Edge e){
					return this.cost-e.cost;
				}
			}
		}
		
		class UnionFind{
			int[] par,rank;
			UnionFind(int n){
				par=new int[n];
				rank=new int[n];
				for(int i=0; i<n; i++){
					par[i]=i;
					rank[i]=0;
				}
			}
			
			// 木の根を求める
			int find(int x){
				if(par[x]==x)	return x;
				else			return par[x]=find(par[x]);
			}
			
			// xとyの属する集合を併合
			void unite(int x,int y){
				x=find(x);
				y=find(y);
				if(x==y)	return;
				
				if(rank[x]<rank[y]){
					par[x]=y;
				}else{
					par[y]=x;
					if(rank[x]==rank[y])	++rank[x];
				}
			}
			
			// xとyが同じ集合に属するか否か
			boolean isSame(int x,int y){
				return find(x)==find(y);
			}
		}
		
		int prim(int[][] g,int N){
			final int INF=1<<29;
			int[] mincost=new int[N];
			boolean[] used=new boolean[N];
			for(int i=0; i<N; i++)	mincost[i]=INF;
			
			mincost[0]=0;
			int ret=0;
			
			while(true){
				int v=-1;
				for(int u=0; u<N; u++){
					if(!used[u] && (v==-1 || mincost[u] < mincost[v]))	v=u;
				}
				if(v < 0)	break;
				used[v]=true;
				ret+=mincost[v];
				
				for(int u=0; u<N; u++)	mincost[u]=min(mincost[u], g[v][u]);
			}
			return ret;
		}
	}
}

Measured memory_bytes: 13000
#include<stdio.h>
#include<math.h>
int main(void){
    int N, K;
    scanf("%d %d", &N, &K);
    double p = 0;
    for(int i = 1; i <= N; i++){
        int  sum = i;
        double j = 1;
        while(1){
            // printf("sum : %d, j : %.4f ", sum, j);
            if(sum >= K) {break;}
            sum *= 2; j = j / 2;
        }
        // printf("%.4f", j/(double)i);
        // printf("\nsum : %d, j : %.4f ", sum, j);

        if(j == 1) p = p + (1/(double)N);
        else p = p + j/(double)N;
        // printf("  *p : %.4f\n",p);
    }

    printf("%.12f\n", p);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
int main(){
	double x, y, z, w;
	scanf("%lf%lf%lf%lf", &x, &y, &z, &w);
	printf("%.8f", sqrt((x-z)*(x-z)+(y-w)*(y-w)));
	return 0;
}


Measured memory_bytes: 2760
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	LL ans = 1;
	for (int i = n; i > 0; i--)ans *= i;
	cout << ans << endl;
}

Measured memory_bytes: 3092
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.DEBUG)
logging.disable(logging.CRITICAL)

def main():
    N, M = list(map(int, input().split()))
    dp = [[] for _ in range(N+2)]
    dp[0] = 0
    dp[1] = 1

    for _ in range(M):
        a = int(input())
        dp[a+1] = 0

    for i in range(2, N+2):
        if dp[i] == 0:
            continue
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % (10 ** 9 + 7)

    logging.debug("{}".format(dp))
    return dp[N+1]

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 86172
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s;
		cin >> s;
		ll len = 0 , ans = 0, n = s.length();
		per(i, n - 1, 0)
		{
			if (s[i] == 'W')
				len++;
			else
				ans += len;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3780
ls = "abcdefghijklmnopqrstuvwxyz"
n = int(input())
rr = [[0 for _ in range(26)]for i in range(n)]
for i in range(n):
    s = list(input())
    for j in range(len(s)):
        rr[i][ls.index(s[j])] += 1
for i in range(26):
    for j in range(min(list(map(lambda x:x[i] ,rr)))):
        print(ls[i],end="")
print()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    double d = scanner.nextInt();
    double t = scanner.nextInt();
    double s = scanner.nextInt();
    if((d/s)>t){
     System.out.print("No");    
    }else{
     System.out.print("Yes");    
    }
    
    
  }
}



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

using namespace std;
using ll = long long;
using ld = long double;

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

    if (s.length() == 1) {
        cout << -1 << " " << -1 << endl;
        return 0;
    }
    if (s.length() == 2) {
        if (s[0] == s[1]) {
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }

    for (int i = 0; i < s.length() - 2; ++i) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;


    return 0;
}

Measured memory_bytes: 512
s=(input())

S=list(s)
a=0

if S[0]==S[1] and S[2]!=S[0]:
    if S[2]==S[3]:
        a=1

elif S[0]==S[2] and S[2]!=S[1]:
    if S[1]==S[3]:
        a=1

elif S[0]==S[3] and S[2]!=S[0]:
    if S[1]==S[2]:
        a=1

else:
    a=0

if a==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(list[K - 1])


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int Atoi(char c) { return c - '0'; }

int main() {
  char buf[8] = {0};
  cin >> buf;
  const int A = Atoi(buf[0]);
  const int B = Atoi(buf[1]);
  const int C = Atoi(buf[2]);
  const int D = Atoi(buf[3]);

  char ops[3] = {0};
  for (int i = 0; i <= 1; ++i) {
    ops[0] = i == 0 ? '+' : '-';
    const int a = i == 0 ? A + B : A - B;
    for (int j = 0; j <= 1; ++j) {
      const int b = j == 0 ? a + C : a - C;
      ops[1] = j == 0 ? '+' : '-';
      for (int k = 0; k <= 1; ++k) {
        ops[2] = k == 0 ? '+' : '-';
        const int c = k == 0 ? b + D : b - D;
        if (c == 7) {
          cout << A << ops[0] << B << ops[1] << C << ops[2]
               << D << "=7" << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    Q = int(input())
    query = [list(input().split()) for _ in range(Q)]
    # print(S)
    # print(Q)
    # print(query)
    mode = True
    forward = []
    back = []
    for qs in query:
        if qs[0] == "1":
            mode = not mode
            continue
        
        if mode:
            if qs[1] == "1": # 前方
                forward.append(qs[2])
            else:
                back.append(qs[2])
        else:
            if qs[1] == "2": # 前方
                forward.append(qs[2])
            else:
                back.append(qs[2])

    ans = "".join(reversed(forward)) + S + "".join(back)
    if mode:
        print(ans)
    else:
        print(ans[::-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 33156
#include <iostream>
#include <queue>
#include <list>

const int MAXN = 100100;
using namespace std;

int n;
int d[MAXN][2];
list <int> adj[MAXN];

void bfs()
{
	queue <int> Q;
	Q.push(1);
	
	while(!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		
		for(const int &v : adj[u])
		{
			if(d[v][0] == 0 && v != 1)
			{
				d[v][0] = d[u][0] +1;
				Q.push(v);
			}
		}
	}
	
	Q.push(n);
	
	while(!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		
		for(const int &v : adj[u])
		{
			if(d[v][1] == 0 && v != n)
			{
				d[v][1] = d[u][1] +1;
				Q.push(v);
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	for(int i = 1; i < n; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	bfs();
	
	int score1 = 0, score2 = 0;
	
	for(int i = 2; i < n; i++)
	{
		if(d[i][0] > d[i][1])
			score2++;
		
		else
			score1++;
	}
	
	if(score1 > score2)
		cout << "Fennec" << endl;
	
	else
		cout << "Snuke" << endl;
		
	return 0;
}

Measured memory_bytes: 8832
#codeing : utf-8
def my_debt (a , n)
  puts  "#{a.to_i}" if ( n <= 0)
  b = (a*0.05) 
  c =( b  % 1000)
  b += 1000 if( c > 0)
  b -= c
  a += b
  return my_debt(a,n-1)   if(n > 0)
end
a = 100000
n = gets.to_i
my_debt(a,n)



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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto & p : mp){
    int s  = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
}

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

typedef long long ll;
const int N = 100010;
struct Node {
	ll x, y, mx;
} w[N];

inline bool cmp(Node a, Node b)
{
	return a.mx > b.mx;
}

int main()
{
	register ll n;
	scanf("%lld", &n);
	register ll sum = 0;
	for (register ll i = 1; i <= n; ++i) {
		scanf("%lld %lld", &w[i].x, &w[i].y);
		sum += w[i].x;
		w[i].mx = max(w[i].x, w[i].y);
	}
	sort(w + 1, w + n + 1, cmp);
	register ll cnt = 0;
	register ll now = 0;
	while (cnt <= n) {
		now += w[++cnt].mx;
		if (now >= sum) break;
	}
	register ll ansx = 1, ansy = 1;
	for (register ll i = 1; i <= n; ++i) {
		register ll tmp = sum - now + w[min(i, cnt)].mx;
		if (tmp <= w[i].y && tmp * ansy < ansx * w[i].y) ansx = tmp, ansy = w[i].y;
	}
	ansx = ansy - ansx + ansy * (n - cnt);
	ansy *= n;
	register ll gcd = __gcd(ansx, ansy);
	ansx /= gcd, ansy /= gcd;
	printf("%lld %lld\n", ansx, ansy);
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;const int N=1e5+10;
int a[N];int npos[N];int ppos[N];int k;int n;int res=0x3f3f3f3f;int tp1;int tp2;
int main()
{
	scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)if(a[i]>0)ppos[++tp1]=a[i];
	for(int i=n;i>=1;i--)if(a[i]<0)npos[++tp2]=-a[i];
	if(tp1+tp2<n)k--;if(k==0){printf("0");return 0;}
	for(int i=0;i<=tp1;i++)if(0<=k-i&&k-i<=tp2)res=min(res,2*ppos[i]+npos[k-i]);
	for(int i=0;i<=tp2;i++)if(0<=k-i&&k-i<=tp1)res=min(res,2*npos[i]+ppos[k-i]);
	printf("%d",res);return 0;
}


Measured memory_bytes: 896
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


n, m = map(int, input().split())

uf = DSU(n)

for _ in range(m):
    a, b = map(int, input().split())
    uf.merge(a - 1, b - 1)

ans = 0

for i in range(n):
    ans = max(ans, uf.size(i))

print(ans)


Measured memory_bytes: 15796
#include<stdio.h>
#define NILL -1

typedef struct
{
  int parent;
  int l;
  int r;
  //int id;
}T;

T tree[30];

void PreOrder(int i)
{
  if(i == NILL) return;
  printf(" %d",i);
  //if(i == NILL) return;
  PreOrder(tree[i].l);
  PreOrder(tree[i].r);
}

void InOrder(int i)
{
  if(i == NILL) return;
  InOrder(tree[i].l);
  printf(" %d",i);
  InOrder(tree[i].r);
}

void PostOrder(int i)
{
  if(i == NILL) return;
  PostOrder(tree[i].l);
  PostOrder(tree[i].r);
  printf(" %d",i);
}

int main()
{
  int i;//節点番号
  int n;
  int root = 0;

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

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

  printf("Preorder\n");
  PreOrder(root);
  printf("\n");
  
  printf("Inorder\n");
  InOrder(root);
  printf("\n");

  printf("Postorder\n");
  PostOrder(root);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2048
n, d, a = map(int, input().split())

monsters = []
for i in range(n):
    x, h = map(int, input().split())
    monsters.append((x,h))

monsters.sort()

def problem_a(h):
    if h <= 0:return 0
    ans = h // a
    if h % a != 0:
        ans += 1
    return ans

cnt_sum = 0
cnt = [0] * n
l = 0
for i in range(n):
    while monsters[l][0] + 2*d < monsters[i][0]:
        cnt_sum -= cnt[l]
        l += 1
        
    already = cnt_sum * a
    cnt[i] = problem_a(monsters[i][1] - already)
    cnt_sum += cnt[i]

print(sum(cnt))

Measured memory_bytes: 70744