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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);


int main() {
	cin.sync_with_stdio(false);
	ll init[5] = {};
	int N;
	cin >> N;
	string s = { 'M','A','R','C','H' };
	rep(i, N) {
		string S;
		cin >> S;
		rep(j, 5)if (S[0] == s[j])init[j]++;
	}
	vector<ll>p;
	rep(i, 5)p.push_back(i);
	ll cnt = 0;
	int x = 0;
	do {
		cnt += init[p[0]] * init[p[1]] * init[p[2]];
	} while (next_permutation(p.begin(), p.end()));
	cout << cnt/12 << endl;


	return 0;
}


Measured memory_bytes: 256
(let* ((n (read))
    (dn (make-array n)))

    (loop for i below n do
        (setf (aref dn i) (read))    
    )
    (setf dn (sort dn #'<))
    (if (equal (aref dn (- (/ n 2) 1)) (aref dn (/ n 2)))
        (princ "0")
        (princ (- (aref dn (/ n 2)) (aref dn (- (/ n 2) 1))))
    )
)

Measured memory_bytes: 77008
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;

int main(){
  string s;
  int count = 0;
  cin >> s;
  int x = s.size();
  rep(i,x/2){
    if(s[i] != s[x-1-i])count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
const NMAX=1000010;
type  ary=array[1..NMAX]of int64;
var n,i,j,k,ans  :int64;
    d  :ary;
    
procedure sort(p,q :int64; var a :ary);
  var i, j, k, w :int64;
begin i := p; j := q; k:=a[(p+q) div 2];
  repeat
    while a[i] < k do i := i+1;
    while k < a[j] do j := j-1;
    if i <= j then begin
      w := a[i]; a[i] := a[j]; a[j] := w;
      i := i+1;  j := j-1
    end
  until i > j;
  if p < j then sort(p,j,a);
  if i < q then sort(i,q,a)
end;

begin
  readln(n);
  for i:=1 to n do read(d[i]);
  sort(1,n,d);
  j:=d[(n div 2)+1];
  writeln(j-d[n div 2]);
end.

Measured memory_bytes: 896
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
#define INF 2000000000
#define fi first
#define sec second
const int SIZE = 1<<17;
int N,R,L;
struct segtree
{
	P seg[SIZE*2];
	void init()
	{
		for(int i=0;i<N;i++)
		{
			seg[i+SIZE-1].fi=0;
			seg[i+SIZE-1].sec=-i;
		}
	}
	void build()
	{
		for(int i=SIZE-2;i>=0;i--)seg[i]=max(seg[i*2+1],seg[i*2+2]);
	}
	void update(int k,int x)
	{
		k+=SIZE-1;
		seg[k].fi+=x;
		while(k>0)
		{
			k=(k-1)/2;
			seg[k]=max(seg[k*2+1],seg[k*2+2]);
		}
	}
	P query(int a,int b,int k,int l,int r)
	{
		if(r<=a||b<=l)return P(-INF,INF);
		else if(a<=l&&r<=b)return seg[k];
		else return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
	}
	P query()
	{
		return query(0,N,0,0,SIZE);
	}
};
segtree seg;
int total[100100];
int d[1000100],t[1000100],x[1000100];
int main()
{
	scanf("%d %d %d",&N,&R,&L);
	for(int i=0;i<R;i++)
	{
		scanf("%d %d %d",&d[i],&t[i],&x[i]);
		d[i]--;
	}
	t[R]=L;
	seg.init();
	seg.build();
	total[-((seg.query()).sec)]+=t[0];
	for(int i=0;i<R;i++)
	{
		seg.update(d[i],x[i]);
		total[-((seg.query()).sec)]+=t[i+1]-t[i];
	}
	int ansv=-1,ans;
	for(int i=0;i<N;i++)if(ansv<total[i])
	{
		ansv=total[i];
		ans=i;
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 15188
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
class uft{
public:
  int par[100010];//親
  int rank[100010];//木の深さ
  ll size[100010];
  uft(int N);//コンストラクタ
  int find(int x);
  void unite(int x,int y);
  bool same(int x,int y);
  ll usize(int x);
};
uft::uft(int N){//コンストラクタ
  for(int i=0;i<N;i++){
    par[i]=i;
    rank[i]=0;
    size[i]=1;
  }
}
int uft::find(int x){//xの根を返す
  if(par[x]==x) return x;//根の親は自分自身
  else return par[x]=find(par[x]);//再起で親を辿る
}
void uft::unite(int x,int y){//x,yを併合
  x=find(x);
  y=find(y);
  if(x==y) return ;//根が同じなら併合する必要なし

  if(rank[x]<rank[y]){//木の深い方に浅い方をつける
    par[x]=y;
    size[y]+=size[x];
  }
  else{
    par[y]=x;
    size[x]+=size[y];
    if(rank[x]==rank[y]) rank[x]++;//同じ深さなら深さを増やす
  }
  
}
bool uft::same(int x,int y){//x,yが同じグループにいるかどうかを返す
  return find(x)==find(y);//根が同じかどうかを判断する
}
ll uft::usize(int x){
  return size[find(x)];
}
int n,m;
int a[100010],b[100010];
int main(){
  scan(n);scan(m);
  rep(i,m){
    scan(a[i]);scan(b[i]);
  }
  uft uf(n);
  ll res[100010];
  rep(i,m){
    if(!uf.same(a[m-1-i],b[m-1-i])){
      res[m-1-i]=uf.usize(a[m-1-i])*uf.usize(b[m-1-i]);
      uf.unite(a[m-1-i],b[m-1-i]);
    }
    else res[m-1-i]=0;
  }
  ll ans=0;
  rep(i,m){
    ans+=res[i];
    prin(ans);
  }

  

  return 0;
}


Measured memory_bytes: 4480
# https://atcoder.jp/contests/abc103/tasks/abc103_b


S = gets.chomp
T = gets.chomp

cond = false
s = S
s.size.times do
  if s == T
    cond = true
    break
  end
  s = s[-1] + s[0..-2]
end

puts cond ? 'Yes' : 'No'


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = 0;
		int b = 0;
				for (int i = 0; i < 4; i++) {
					a += sc.nextInt();
				}
				for (int i = 0; i < 4; i++) {
					b += sc.nextInt();
				}
		System.out.println(Math.max(a, b));
		sc.close();
	}
}


Measured memory_bytes: 26352
integer N
integer(8),allocatable,dimension(:)::A
integer(8) Yotei
read*,N
allocate(A(0:N+1))
A(0)=0
read*,A(1:N)
A(N+1)=0
do i=1,N+1
  Yotei=Yotei+abs(A(i)-A(i-1))
end do
do i=1,N
  print"(i0)",Yotei-(abs(A(i)-A(i-1))+abs(A(i+1)-A(i)))+abs(A(i-1)-A(i+1))
end do
end

Measured memory_bytes: 2560
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	if (a.back() == b.front() && b.back() == c.front())
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}
	

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

int main(){
  vector<string> s(3);
  rep(i,3) cin >>s[i];
  int ans = 0;
  while(true){
    string t = s[ans];
    if(t.empty()){
      cout << char(ans+'A') << endl;
      return 0;
    }
    s[ans] = t.substr(1,t.size()-1);
    ans = t[0]-'a';
  }
  return 0;
}

Measured memory_bytes: 3620
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <ctype.h>>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
string s;
int n,d,mn,dp[10004][102];
int main()
{
	cin >> s >> d;
	n = s.length();
	for (int i = 0; i < n; i++)
	{
		if(i)
			for (int k = 0; k <= 9; k++)
				for (int j = 0; j < d; j++)
				{
					dp[i][(j + k) % d] += dp[i-1][j];
					dp[i][(j + k) % d] %= mod;
				}
		for (int k = 0; k < s[i] - '0'; k++)
		{
			dp[i][(mn + k) % d]++;
			dp[i][(mn + k) % d] %= mod;
		}
		mn = (mn + s[i] - '0') % d;
	}
	cout << (mod+dp[n - 1][0] + (mn == 0)-1)%mod << endl;
	return 0;
}

/*



*/

Measured memory_bytes: 4224
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	int  n;
	long double ave;    //??????
	long double sum1=0;  //????¨????
	long double sum2=0;
	int s[1000]={0};     //??????
	long double a;   //?????£
	
	while(1){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
			cin>>s[i];
			sum1+=s[i];
		}
		ave=sum1/n;
		for(int i=0;i<n;i++)
			sum2+=(s[i]-ave)*(s[i]-ave);
		
		a=sum2/n;
		cout<<fixed<<setprecision(6)<<sqrt(a)<<endl;
		sum1=0;
		sum2=0;
		ave=0;
	}
}
	
	
	

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long check1 = max(a*c,a*d), check2 = max(b*c,b*d);
  long long ans = max(check1,check2);
  cout << ans << endl;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

long long  n, a, b, c, d, e, ans;

int main() {
	INIT
	cin >> n;
	vector<long long > A(5);
	for (int i = 0; i < 5; ++i) {
		cin >> A[i];
	}
	long long Min = *min_element(A.	begin(), A.end());
	ans = (Min + n - 1) / Min + 4;
	cout << ans;
	return 0;
}

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

int main()
{
    int a,b,x;
    cin >> a >> b;
    x=(a+b)/2;
    if((a+b)%2==0){
        cout << x <<endl;
    }else{
        cout << x+1 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

map<ll, ll> ma;

void PrimeFactorization(ll n){
    Rep(i, 2, sqrt(n)){
        while(n%i == 0){
            ma[i]++;
            n /= i;
        }
        if(n == 1) break;
    }
    if(n != 1) ma[n]++;
    
}

int main() {
    ll n; cin >> n;
    Rep(i, 1, n){
        PrimeFactorization(i);
    }
    ll ans = 1;
    for(auto it : ma){
        ans *= (it.se+1)%MOD;
        ans %= MOD;
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 256
a,b,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
li = []
val = []
c = sorted(A)
d = sorted(B)
minv = c[0]+d[0]
for i in range(m):
    x,y,c = map(int,input().split())
    li.append([x,y,c])
    val.append(A[x-1]+B[y-1]-c)
ans = min(min(val),minv)
print(ans)

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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){
	ll x,y;
	cin >> x >> y;
	if(y%2==0 and 2*x<=y and 4*x>=y)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

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

  int a, b;
  cin >> a >> b;
  cout << 6 - a - b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main()
{
    int v, e;
    cin >> v >> e;

    vector<vector<int>> dis(v, vector<int>(v, 1e9));
    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        dis[s][t] = d;
    }

    vector<vector<int>> dp((1 << v), vector<int>(v, 1e9));

    rep(i, v) dp[0][0] = 0;
    rep(s, 1 << v) {
        rep(now, v) {
            rep(to, v) {
                if ((s >> to) & 1 || dis[now][to] == 1e9) continue;
                chmin(dp[s|(1 << to)][to], dp[s][now] + dis[now][to]);
            }
        }
    }

    int ans = dp[(1 << v) - 1][0];
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 6312
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007



int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flag = 0;
    while(a > 0 && c > 0) {
        if(flag == 0) {
            c -= b;
            flag = 1;
        }
        else {
            a -= d;
            flag = 0;
        }
    }
    if (a <= 0) cout<<"No";
    else cout<<"Yes";
}


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

int main() {
  int N, foo, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> foo;
    if ((foo & 1) == 0) {
      foo >>= 1;
      ans++;
      while ((foo & 1) == 0) {
        foo >>= 1;
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n,m,h,w;
int main()
{
    scanf("%d%d%d%d",&n,&m,&h,&w);
    if(n%h==0&&m%w==0)
    {
        puts("No");return 0;
    }
    puts("Yes");
    int inf=5000;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(i%h==1&&j%w==1)printf("%d ",inf-1);
            else if(h==1&&j%w==1)printf("%d ",inf-1);
            else if(i%h==1&&w==1)printf("%d ",inf-1);
            else if(i%h==0&&j%w==0)printf("%d ",-inf);
            else printf("0 ");
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
 
  d=a/b;
  r=a%b;
  f=(double)a/b;
 
  printf("%d %d %f\n",d,r,f);
 
  return 0;
 
}


Measured memory_bytes: 2104
/*
      author  : nishi5451
      created : 15.08.2020 12:16:59
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    int now = a;
    int count = 1;
    while(now < b){
        count++;
        now += a-1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;
	int ans;
	if (op == '+')
	{
		ans = a + b;
	}else{
		ans = a - b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;
map<ll,ll> ma;
void yakusu(ll n){
	ll p=n;
	FOR(i,2,sqrt(n)+1){
		while(p%i==0){
			ma[i]++;
			p/=i;
		}
	}
	if(p!=1)ma[p]++;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	FOR(i,2,N+1){
		yakusu(i);
	}
	ll ans = 1;
	for(auto x:ma){
		ans *= x.second+1;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    double res = 0;
    for (int i = 0;i < n;i++){
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY"){
            res += x;
        }
        else if (s == "BTC"){
            res += x * 380000;
        }
    }
    cout  << setprecision(8) << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define d_flag 0
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)<(b)?(b):(a))
#define abs(a) max((a),-(a))

int main(){
  int n;
  scanf("%d",&n);
  int i,dp_a[n],dp_b[n],dp_c[n],a,b,c;
  
  scanf("%d%d%d",&dp_a[0],&dp_b[0],&dp_c[0]);
  if(d_flag) printf("Day %d: %d,%d,%d\n",0,dp_a[0],dp_b[0],dp_c[0]);
  for(i=1;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    dp_a[i]=a+max(dp_b[i-1],dp_c[i-1]);
    dp_b[i]=b+max(dp_c[i-1],dp_a[i-1]);
    dp_c[i]=c+max(dp_a[i-1],dp_b[i-1]);
  if(d_flag) printf("Day %d: %d,%d,%d\n",i,dp_a[i],dp_b[i],dp_c[i]);
  }



  int ans=max(dp_a[n-1],dp_b[n-1]);
  printf("%d",max(ans,dp_c[n-1]));
}


Measured memory_bytes: 1280
from collections import*
n,x,y=map(int,input().split())
e=[[]for _ in range(n)]
for i in range(n-1):
    e[i]+=i+1,
    e[i+1]+=i,
e[x-1]+=y-1,
e[y-1]+=x-1,
a=[0]*n
for s in range(n):
    d=[-1]*n
    d[s]=0
    q=deque([s])
    while q:
        v=q.popleft()
        for w in e[v]:
            if d[w]<0:
                d[w]=d[v]+1
                q+=w,
    for i in d:a[i]+=1
print(*[i//2for i in a[1:]])

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

using namespace std;

int N;
string S;

int main() {
  cin >> N >> S;
  
  int ans = 0;
  for(int i = 1; i < N; i++){
    string s1 = S.substr(0, i);
    string s2 = S.substr(i, N-i);
    int ctn = 0;
    for(int j = 0; j < 26; j++){
      bool flag1 = false;
      bool flag2 = false;
      for(int k = 0; k < s1.length(); k++){
        if(s1[k] - 'a' == j) flag1 = true;
      }
      for(int k = 0; k < s2.length(); k++){
        if(s2[k] - 'a' == j) flag2 = true;
      }
      if(flag1 && flag2) ctn++;
    }
    if(ctn > ans) ans = ctn;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 5e5;
ll fac[MAX_N+1], ifac[MAX_N+1], inv[MAX_N+1];

//mpow(x,n)で(x^n)をO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n & 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n >>= 1;
    }
    return res;
}

//setcomb()でfac,ifac,invを全て計算
void setcomb(){
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
}

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

int main(){
    setcomb();
    int B, W;
    cin >> B >> W;
    // e[i] := 2^i, ie[i]:=2^(-i)
    ll e[B+W+1], ie[B+W+1];
    e[0] = 1, ie[0] = 1;
    rep(i, B+W){
        e[i+1] = (e[i]*2)%MOD;
        ie[i+1] = (ie[i]*inv[2])%MOD;
    }
    //b[i](w[i]):=玉を適当にi個並べたときに黒玉(白玉)がB個以上存在するような並べ方の総数
    ll b[B+W], w[B+W];
    b[0] = 0, w[0] = 0;
    rep2(i, 1, B+W-1){
        if(i >= B) b[i] = (2*b[i-1]+comb(i-1, B-1))%MOD;
        else b[i] = 0;
        if(i >= W) w[i] = (2*w[i-1]+comb(i-1, W-1))%MOD;
        else w[i] = 0;
    }
    rep(i, B+W){
        //i個決めた状態で次が黒(白)であることが決まってる場合
        ll tmpB = (w[i]*ie[i])%MOD, tmpW = (b[i]*ie[i])%MOD;
        ll ans = (tmpB+(1+2*MOD-tmpB-tmpW)*inv[2])%MOD;
        cout << ans << endl;
    }
}

Measured memory_bytes: 20224
#include <bits/stdc++.h>
#define N 100010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 0; i <= n; ++i)
#define forr(i, x, n) for(int i = x; i <= n; ++i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
  
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
  
using namespace std;



int main() {
    barnarnar
	int n;
	cin >> n;
	string a, b;
	cin >> a >> b;
	forn(i, n)
	{
		cout << a[i] << b[i];
	}
    return 0;
}















Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
int n;
char b[3][2][2][3];

int progress(char s[][2][3]){
	int flag=1;
	while(flag){
		rep(i,0,20)rep(j,0,2)rep(k,0,2)if(s[i][j][k]=='*'&&(i==0||s[i-1][j][k]=='#'))flag=0;
		if(flag)rep(i,0,20)rep(j,0,2)rep(k,0,2)if(s[i][j][k]=='*'){s[i-1][j][k]=s[i][j][k];s[i][j][k]='.';}
	}
	rep(i,0,20)rep(j,0,2)rep(k,0,2)if(s[i][j][k]=='*')s[i][j][k]='#';
	int ans=0;
	rep(i,0,20)if(s[i][0][0]=='#'&&s[i][0][1]=='#'&&s[i][1][0]=='#'&&s[i][1][1]=='#'){
		ans++;
		rep(ii,i+1,20)rep(j,0,2)rep(k,0,2){s[ii-1][j][k]=s[ii][j][k];s[ii][j][k]='.';}
		i--;
	}
	return ans;
}

int f(char [][2][3],int);
int calc(char ss[][2][3],int c){
	char sss[20][2][3]={};
	rep(i,0,20)rep(j,0,2)rep(k,0,2)sss[i][j][k]=ss[i][j][k];
	rep(i,0,2)rep(j,0,2)rep(k,0,2)sss[18+i][j][k]=b[c][i][j][k]=='#'?'*':'.';
	int temp=progress(sss);
	return temp+f(sss,c+1);
}

int f(char ss[][2][3],int c){
	if(c==n)return 0;	
	int ans=0,ret;

	ret=calc(ss,c);
	ans=max(ans,ret);
	
	int flag=0;
	if((b[c][0][0][0]=='.'&&b[c][0][0][1]=='.'&&b[c][1][0][0]=='.'&&b[c][1][0][1]=='.')
	   ||(b[c][0][1][0]=='.'&&b[c][0][1][1]=='.'&&b[c][1][1][0]=='.'&&b[c][1][1][1]=='.')){
		flag++;
		rep(i,0,2)rep(k,0,2){char t=b[c][i][0][k];b[c][i][0][k]=b[c][i][1][k];b[c][i][1][k]=t;}
		ret=calc(ss,c);
		ans=max(ans,ret);
	}

	if((b[c][0][0][0]=='.'&&b[c][0][1][0]=='.'&&b[c][1][0][0]=='.'&&b[c][1][1][0]=='.')
	   ||(b[c][0][0][1]=='.'&&b[c][0][1][1]=='.'&&b[c][1][0][1]=='.'&&b[c][1][1][1]=='.')){
		flag++;
		rep(i,0,2)rep(j,0,2){char t=b[c][i][j][0];b[c][i][j][0]=b[c][i][j][1];b[c][i][j][1]=t;}
		ret=calc(ss,c);
		ans=max(ans,ret);
	}
	if(flag==2){
		rep(i,0,2)rep(k,0,2){char t=b[c][i][0][k];b[c][i][0][k]=b[c][i][1][k];b[c][i][1][k]=t;}
		ret=calc(ss,c);
		ans=max(ans,ret);
	}
	
	return ans;
}

int main(){
	int h;
	while(scanf("%d%d",&h,&n),n){
		char s[20][2][3];
		rep(i,0,20)rep(j,0,2)rep(k,0,2)s[i][j][k]='.';
		rep(i,0,h)rep(j,0,2)scanf("%s",s[i][j]);
		rep(nn,0,n)rep(i,0,2)rep(j,0,2)scanf("%s",b[nn][i][j]);
		printf("%d\n",f(s,0));
	}
}


Measured memory_bytes: 2032
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>>pass(N + 1,vector<int>(1,0));
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        pass[a].push_back(b);
    }

    for (int i = 0; i < pass[1].size(); i++) {
        if (pass[pass[1][i]].back()==N) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 11776
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int k, x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; ++i) {
		cout << i << ' ';
	}
	cout << '\n';
 	return 0;
}


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

int main(){
	int t;
	
	cin >> t;
	for(int i=0 ; i < t ; i++ ){
		int m[50][50] = {0};
		int gx,gy,p,x1,y1,x2,y2;
		
		cin >> gx >> gy;
		cin >> p;
		for(int j=0 ; j < p ; j++ ){
			cin >> x1 >> y1 >> x2 >> y2;

			if( x1 == x2 ){
				if( y1 > y2 ) swap( y1 , y2 );
				
				for(int y_ = y1*2+1 ; y_ < y2*2+1 ; y_ += 2 ){
					m[y_][x1*2] = 1;
				}
			}else if( y1 == y2 ){
				if( x1 > x2 ) swap( x1 , x2 );
				
				for(int x_ = x1*2+1 ; x_ < x2*2+1 ; x_ += 2 ){
					m[y1*2][x_] = 1;
				}
			}
		}
		m[0][0] = 1;
		
		for(int y=0 ; y <= gy ; y++ ){
			for(int x=0 ; x <= gx ; x++ ){
				if( y != 0 && m[2*y-1][2*x] == 0 ) m[2*y][2*x] += m[2*y-2][2*x];
				if( x != 0 && m[2*y][2*x-1] == 0 ) m[2*y][2*x] += m[2*y][2*x-2];
			}
		}
		if( m[gy*2][gx*2] == 0 ){
			cout << "Miserable Hokusai!" << endl;
		}else{
			cout << m[gy*2][gx*2] << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;

void code()
{       
    int n;
    cin>>n;
    int g;
    cin>>g;
    cout<<n*g<<endl;
    
                                                
        
}
signed main()

{

        FAST_IO;
        int t = 1;

        //cin>>t;

        while(t--)
        {
                code();
        }
        
        return 0;
}


Measured memory_bytes: 3652
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}
vector<ll> range(ll end)
{
    vector<ll> result;
    for (ll i = 0; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}
vector<ll> range(ll begin, ll end, ll step)
{
    vector<ll> result;
    for (ll i = begin; i < end; i += step)
    {
        result.push_back(i);
    }
    return result;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    ll np2 = n / 2;
    vector<ll> first;
    vector<ll> second;

    first = range(1, np2 + 1);
    second = range(np2 + 1, n + 1);

    vector<array<ll, 2>> ans;
    for (ll i = 0; i < first.size() - 1 - i; i++)
    {
        ans.push_back(array<ll, 2>{first[i], first[first.size() - 1 - i]});
    }
    if (n % 2 == 0)
    {
        second.erase(--second.end());
    }
    for (ll i = 0; i < second.size() - 1 - i; i++)
    {
        ans.push_back(array<ll, 2>{second[i], second[second.size() - 1 - i]});
    }
    for (ll i = 0; i < m; i++)
    {
        cout << ans[i][0] << ' ' << ans[i][1] << endl;
    }
}

Measured memory_bytes: 6348
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

unordered_map<int, int> mp, mp2;
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    int d;
    cin >> d;
    mp[d]++;
  }
  int m;
  cin >> m;
  REP(i, m) {
    int t;
    cin >> t;
    mp2[t]++;
  }

  for(auto i: mp2) {
    if(mp[i.first] < i.second) {cout << "NO" << endl; return 0;}
  }
  cout << "YES" << endl;

  return 0;
}


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

typedef long long ll;

bool checker (int a, int b, int c) {
	return a!=b && a!=c && b!=c && a+b>c && a+c>b && b+c>a;
}

int main () {
	int N;
	int L[100];
	cin >> N;
	for (int i=0; i<N; i++)
		cin >> L[i];
	int ans = 0;
	for (int i=0; i<N; i++)
		for (int j=i+1; j<N; j++) 
			for (int k=j+1; k<N; k++) 
				if (checker(L[i],L[j],L[k]))
					ans ++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

//???????????¨
bool lt(const complex<double>& a,const complex<double>& b){
  return a.real()<b.real() || (a.real()==b.real() && a.imag()<b.imag());
}

double cp(complex<double> a, complex<double> b){
  return (conj(a)*b).imag();
}

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

  vector<complex<double> > v; 
  for(int i=0;i<n;i++){
    int x, y;
    cin >> x >> y;
    v.push_back(complex<double>(x+0.0,y+0.0));
  }

  sort(v.begin(),v.end(),lt);

  vector<complex<double> > u,b;
  u.push_back(v[0]);
  int i;
  for(i=0;i<n;i++){
    if(v[i].real()!=v[0].real()) break;
  }
  b.push_back(v[0]);
  b.push_back(v[i]);

  i=i+1;
  while(b.back()!=v.back()){
    b.push_back(v[i]);
    i++;

    int l=b.size();
    if(l<3) continue;
    if(cp(b[l-1]-b[l-2],b[l-3]-b[l-2])>=0) continue;
    else{
      b.pop_back();
      b.pop_back();
      i--;
    }
  }
  
  i=1;
  while(u.back()!=v.back()){
    u.push_back(v[i]);
    i++;

    int l=u.size();
    if(l<3) continue;
    if(cp(u[l-1]-u[l-2],u[l-3]-u[l-2])<=0) continue;
    else{
      u.pop_back();
      u.pop_back();
      i--;
    }
  }

  double min=b[0].imag(), index=0;
  for(int i=1;i<b.size();i++){
    if(b[i].imag()<min){
      min=b[i].imag();
      index=i;
    }
  }

  cout << (b.size()+u.size()-2) << endl;
  for(int i=index;i<b.size();i++)
    cout << noshowpoint << b[i].real() << ' ' << b[i].imag() << endl;
  for(int i=u.size()-2;i>=1;i--)
    cout << noshowpoint << u[i].real() << ' ' << u[i].imag() << endl;
  for(int i=0;i<index;i++)
    cout << noshowpoint << b[i].real() << ' ' << b[i].imag() << endl;

  return 0;
}

Measured memory_bytes: 6420
import sys;input = lambda : sys.stdin.readline()
import collections
n = int(input())
a = sorted(list(map(int, input().split())))
d = collections.Counter(a)
need = {}
for k,v in d.items():
    if v>1:
        need[k]=v
if (sum(list(need.values()))-len(need))%2==0:
    print(len(set(a)))
else:
    print(len(set(a))-1)


Measured memory_bytes: 25736
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
 
using namespace std;
typedef long long int ll;

struct ten {ll height; vector<int> path;};
int N, M;
vector<ten> H;

int main()
{
  int i,j,k;
  int A,B;
  int s;
  int g;

  cin >> N >> M;

  H.resize(N);

  for (i=0; i<N; i++) {
    cin >> H[i].height;
  }
  for (i=0; i<M; i++) {
    cin >> A >> B;
    A--; B--;
    s = H[A].path.size();
    H[A].path.resize(s+1);
    H[A].path[s] = B;
    s = H[B].path.size();
    H[B].path.resize(s+1);
    H[B].path[s] = A;
  }

  for (g=0, i=0; i<N; i++) {
    for (j=0; j<H[i].path.size(); j++) {
      if (H[i].height <= H[H[i].path[j]].height) break;
    }
    if (j>=H[i].path.size()) g++;
  }
  printf("%d\n", g);
  return 0;
}
/*
  ��1
  1-3-2-4
*/


Measured memory_bytes: 8940
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 read_str() -> Vec<char> {
    return read::<String>().chars().collect();
}



fn main() {
    let b: Vec<char> = read_str();

    let ans = match b[0] {
        'A' => 'T',
        'T' => 'A',
        'G' => 'C',
        'C' => 'G',
         _  =>  'X'
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():

    N, K, Q = map(int, input().split())

    As = [int(input())-1 for _ in range(Q)]

    points = [K-Q for _ in range(N)]

    for a in As:
        points[a] += 1

    for i in range(N):
        if points[i] > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 11776
a , b , c, d=map(int,input().split())
if b<=c and a<= c:
    print(0)
elif d >= b and c <= b and a <= c:
    print(b-c)
elif d >= b and a>=c:
    print(b-a)
elif b >=d and c>=a:
    print(d-c)
elif c <= a and d <=a:
    print(0) 
else:
    print(d-a)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

void Trace( int *A, int N, int cnt){
	//?????????????????????????????????N-1??¨??????
	for (int i = 0; i < N - 1; i++){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[N - 1]);
	printf("%d\n", cnt);
}

int BubbleSort(int *A, int N){
	int cnt = 0;

	for (int i = N-1; i > 0; i--){
		for (int j = N-1; j >= 0; j--){

			//??\???????????????
			if (A[j - 1] > A[j]){
				int t = A[j - 1];
				A[j - 1] = A[j];
				A[j] = t;
				cnt++;
			}
		}
	}

	return cnt;
}

int main(int argc, char *argv[]){
	int N;

	scanf("%d", &N);

	int *A = (int*)malloc(sizeof(int) * N);

	//??\???
	for (int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}

	int cnt = BubbleSort(A, N);
	Trace(A, N, cnt);

	free(A);

	return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

const long long int llinf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

#define Endl endl
#define pr(x) cout << x << endl
#define FOR(i,a,b) for(int i = a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define atcoder int(1e9) +7;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
#define all(x) x.begin,x.end();

string s;
ll ans = 0;

void dfs(int n, ll v, ll sum) {
	if (s.length() == n) {
		sum += v;
		ans += sum;
		return;
	}
	ll next = v * 10 + s[n] - '0';
	dfs(n + 1, 0, sum + next);
	dfs(n + 1, next, sum);
}

int main() {

	cin >> s;
	dfs(0, 0, 0);
	pr(ans / 2);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
from bisect import*
class BTreeNode:
    def __init__(self):self.key,self.child=[],[]
class BTree:
    def __init__(self):self.root=BTreeNode()
    def search_higher(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect(ptr.key,key)
            if i!=len(ptr.key):ret=ptr.key[i]
            ptr=ptr.child[i]
        i=bisect(ptr.key,key)
        if i!=len(ptr.key):ret=ptr.key[i]
        return ret
    def search_lower(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect_left(ptr.key,key)
            if i:ret=ptr.key[i-1]
            ptr=ptr.child[i]
        i=bisect_left(ptr.key,key)
        if i:ret=ptr.key[i-1]
        return ret
    def insert(self,key):
        def insert_rec(ptr,key):
            b_size=512
            if not ptr.child:
                insort(ptr.key,key)
                if len(ptr.key)==b_size*2-1:
                    ret=BTreeNode()
                    ret.key=ptr.key[:b_size]
                    ptr.key=ptr.key[b_size:]
                    return ret
            else:
                i=bisect(ptr.key,key)
                tmp=insert_rec(ptr.child[i],key)
                if tmp:
                    ptr.key.insert(i,tmp.key.pop())
                    ptr.child.insert(i,tmp)
                    if len(ptr.child)==b_size*2:
                        ret=BTreeNode()
                        ret.child=ptr.child[:b_size]
                        ptr.child=ptr.child[b_size:]
                        ret.key=ptr.key[:b_size]
                        ptr.key=ptr.key[b_size:]
                        return ret
        tmp=insert_rec(self.root,key)
        if tmp:
            root=BTreeNode()
            root.key=[tmp.key.pop()]
            root.child=[tmp,self.root]
            self.root=root
def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=BTree()
    t.insert(0)
    t.insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(t.search_higher(v)-v)*(v-t.search_lower(v))*i
        t.insert(v)
    print(c)
main()

Measured memory_bytes: 25884
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        int i = in.nextInt();
        int[] r = new int[i];
        for (int j = 0; j < i; j++) {
            r[j] = in.nextInt();
        }
        int maxNum = -1000000000;
        int minNum = r[0];
        for (int k = 1; k < i; k++) {
            maxNum = (maxNum > (r[k]-minNum))? maxNum:(r[k]-minNum);
            minNum = minNum < r[k] ?minNum:r[k];
        }
        System.out.println(maxNum);

    }
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 2e5+10;
const int mod = 1e9+7;

using namespace std;

int p[maxn],sz[maxn],qtd;

void start(){
    for(int i=0;i<maxn;++i){
        p[i] = i;
        sz[i] = 1;
    }
}

int find_set(int x){
    return p[x] = (p[x] == x ? x : find_set(p[x])); 
}

int same_set(int x,int y){
    return find_set(x) == find_set(y);
}

void union_set(int a,int b){
    a = find_set(a);
    b = find_set(b);
    if(a==b) return;
    if(sz[a] > sz[b]) swap(a,b);
    p[a] = b;
    sz[b]+=sz[a];
}

void solve(){
    int n,m;
    cin >> n >> m;
    while(m--){
        int x,y;
        cin >> x >> y;
        union_set(x,y);
    }
    for(int i=1;i<=n;++i){
        if(p[i] == i){
            qtd=max(qtd,sz[i]);
        }
    }
    cout << qtd << endl;
}

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

    start();

    int t = 1;

    // cin >> t;

    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 5136
#include<iostream>
#include<string>
using namespace std;
void nstr(string st,int n){
  for(int k =0;k<st.length();k++){
    if(st[k] != ' ' && st[k] != '.'){
      if(st[k]+n > 122){
	st[k] = st[k]+n - 26;
      } else {st[k] = st[k] + n;}
    }
  }
  if(st.find("the") != string::npos ||st.find("this") != string::npos ||st.find("that") != string::npos){
      cout << st << endl;
    }
}

int main(){
  int i = 0,count=0;
  string str;
  string tmp;
  while(getline(cin,str)){
     for(int p=0;p<=25;p++){
       nstr(str,p);
     }
  }
}

Measured memory_bytes: 0
import sys
n,k = map(int,input().split())

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

dp = [sys.maxsize]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1,i+k+1):
    if j<n:
      dp[j]= min(dp[j],dp[i]+abs(a[i]-a[j]))
      
      
print(dp[n-1])


Measured memory_bytes: 52448
#include<iostream>
#include<queue>
#include <utility>
#include<sstream>

#define INF 100000000

using namespace std;

int delta_x[4] = {1, -1, 0, 0};
int delta_y[4] = {0, 0, 1, -1};
int H, W, K;
int SX, SY, GX, GY;

void print_board(int **mapp) {
 
  for (int i = 0; i < H + 2; i++) {
    ostringstream oss;
    for (int j = 0; j < W + 2; j++) {
      oss << mapp[i][j] << " ";
    }
    cout << oss.str() << endl;
  }
}

int main(){
  scanf("%d %d %d", &H, &W, &K);
  scanf("%d %d %d %d", &SX, &SY, &GX, &GY);
  char a[H][W + 1];
  for (int h = 0; h < H;h++){
    scanf("%s", a[h]);
  }

  int map[H + 2][W + 2];
  int *mapp[W + 2];
  for (int i = 0; i < H + 2; i++){
    mapp[i] = map[i];
  }
  // make wall of up and down
  for (int w = 0; w < W + 2; w++) {
    map[0][w] = map[H + 1][w] = -1;
  }
  for (int h = 1; h <= H; h++){
    map[h][0] = map[h][W + 1] = -1; // wall of left and right
    for (int w = 1; w <= W; w++){
      map[h][w] = a[h - 1][w - 1] == '.' ? INF : -1;
    }
  }

  queue< pair<int, int> > que;
  que.push(make_pair(SX, SY));
  map[SX][SY] = 0;
  pair<int, int> pos;

  int ct = 0;
  while(!que.empty()){
    pos = que.front();
    que.pop();
    int x = pos.first;
    int y = pos.second;

    for (int i = 0; i < 4;i++){
      int dx = delta_x[i];
      int dy = delta_y[i];

      for (int j = 1; j <= K; j++){
        int xx = x + j * dx;
        int yy = y + j * dy;
        if (map[xx][yy] <= map[x][y]) {
          break;
        }
        if(map[xx][yy] == INF){
          map[xx][yy] = map[x][y] + 1;
          que.push(make_pair(xx, yy));
        }
      } 
    }
  }

  int ans = map[GX][GY];
  if(ans == INF){
    ans = -1;
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 16468
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var ai = Sarray();
            var pre = true;
            var bp = ai.Max();
            if (ai.Max() + ai.Min() < 0)
            {
                pre = false;
                bp = ai.Min();
            }
            var bi = 0;
            var ansStrings = new List<string>();
            for (var i = 0; i < N; ++i)
                if (ai[i] == bp)
                    bi = i;
            if (pre)
            {
                for (var i = 0; i < N; ++i)
                {
                    ansStrings.Add($"{bi + 1} {i + 1}");
                    if (ai[i] < 0)
                        ansStrings.Add($"{bi + 1} {i + 1}");
                    bi = i;
                }
            }
            else
            {
                for (int i = (int)N - 1; 0 <= i; --i)
                {
                    ansStrings.Add($"{bi + 1} {i + 1}");
                    if (0 < ai[i])
                        ansStrings.Add($"{bi + 1} {i + 1}");
                    bi = i;
                }
            }
            WriteLine(ansStrings.Count);
            foreach (var a in ansStrings)
                WriteLine(a);
        }
    }
}

Measured memory_bytes: 28316
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  char a;
  cin >> a;
  if (a <= 90) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}

Measured memory_bytes: 3616
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        if (a <= 8 && b <= 8) Console.WriteLine("Yay!");
        else Console.WriteLine(":(");
    }
}


Measured memory_bytes: 11092
parseInt(x)=parse(Int32,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function eval(a::Array{Int32,1},m,n,k)
	dp = Int32[0]
	chk = zeros(Int32,k)
	chk[1] = 1
	f = 0
	for i in 1:n
		if i!=m
			l = length(dp)
			for j in 1:l
				v = a[i]+dp[j]
				if v<k && chk[v+1]==0
					push!(dp,v)
					chk[v+1] = 1
				end
				if k-a[m]<=v<k
					f = 1
					break
				end
			end
		end
		if f == 1
			break
		end
	end
	f
end

function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	a = sort(a)
	l,r = 0,n+1
	while r-l>1
		m = (l+r)>>1
		f = eval(a,m,n,k)
		if a[m]>=k
			f = 1
		end
		if f == 1
			r = m
		else
			l = m
		end
	end
	println(l)
end

main()

Measured memory_bytes: 121876
S=input()
T=input()

s_list=list(S)
t_list=list(T)
maxmax=0
for i in range(len(S)-len(T)+1):
    ss=len([j for j in range(len(T)) if s_list[i+j]==t_list[j]])
    if maxmax<ss:
        maxmax=ss
print(str(len(T)-maxmax))

Measured memory_bytes: 9120
#include <cstdio>
#define maxn 200010
#define ll long long

int n,a[maxn];ll m;
ll check(int x){
	ll re=0;
	for(int i=1;i<=n;i++)re+=a[i]/x+(a[i]%x>0)-1;
	return re;
}

int main()
{
	scanf("%d %lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int l=1,r=1e9,mid,ans;
	while(l<=r){
		mid=l+r>>1;
		if(check(mid)<=m)ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2464
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
float a,b;
cin>>a>>b;
int c=(a+b)/2;
if((a+b)/2-c<0.5) cout<<c<<endl;
 else
   cout<<++c<<endl; 
}

Measured memory_bytes: 384