akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = []
for _ in range(n):
    l.append(input()) # l += [input()]でもOK
#rint(l)

ac,wa,tle,re = 0,0,0,0
for i in l:
    if i == 'AC':
        ac += 1
    elif i == 'WA':
        wa += 1
    elif i =='TLE':
        tle += 1
    elif i == 'RE':
        re += 1

print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

    
    


Measured memory_bytes: 16320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long x,y;
  cin >> x >> y;
  long long r =__gcd(x, y);
  int f = 0;
  for(long long i=2;i < 1000010;i++){
    if(r%i==0)f++;
    while(r%i==0){r /= i;}
  }
  if(r != 1){f++;}
  f++;
  cout << f << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int r;
    scanf("%d",&r);
    printf("%d\n",(int)pow(r,2));
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0){
            return 0;
        }
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a.at(i);
        }
        vector<int> b(n+1);
        b.at(0)=0;
        for(int i=1;i<=n;i++){
            b.at(i)=b.at(i-1)+a.at(i-1);
        }
        int ans=b.at(1);
        for(int i=1;i<=n;i++){
            for(int j=0;j<i;j++){
                ans=max(ans,b.at(i)-b.at(j));
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3088
n = int(input())
w = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + w[i]
ans = 1000000
for i in range(n+1):
    ab = abs(s[i] - (s[n]-s[i]))
    if ans >= ab:
        ans = ab

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    pair<int, int> a[n];
    rep(i, n)
    {
        cin >> a[i].first;
        a[i].second = i + 1;
    }
    sort(a, a + n);
    rep(i, n)
    {
        cout << a[i].second << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll a, b; cin >> a >> b;

    reps(i, 1, 4){
        if(i == a || i == b) continue;
        else{
            cout << i << endl;
            break;
        }
    }

    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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
   // #endif
    cin>>n;
    map<string,int>mp;
    pair<string,int>pp[n];
    int mx=0;
    for(int i=0; i<n; i++){
    	cin>>s;
    	mp[s]++;
    	//pp[s]++;
    	mx=max(mx,mp[s]);
    }
  // for(auto it:mp)cout<<it.ff<<" "<<it.ss<<endl;
    
	//cout<<mx<<endl;
	for(auto it:mp){
		if(mp[it.ff]==mx){
			cout<<it.ff<<endl;
		}
	}

    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

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

if (a>b){
x=a;
a=b;
b=x;
}
if(b>c){
x=b;
b=c;
c=x;
}
if(a>b){
x=a;
a=b;
b=x;
}
cout << a << " " << b << " " << c << endl;
return 0;
}

Measured memory_bytes: 3088
def binom(n,r):
    if n<r or n<0:
        return 0

    result=1
    for i in range(r):
        result*=(n-i)
        result//=(i+1)
    return result

inputs=[int(c) for c in input().split()]
n=inputs[0]
m=inputs[1]
print(binom(n,2)+binom(m,2))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int H, W;
int N;
int mp[111][111];

int main(){
    for(int y = 0; y < 111; y++){
        for(int x = 0; x < 111; x++){
            mp[y][x] = 114514;
        }
    }
    cin >> H >> W >> N;
    for(int y = 1; y <= H; y++){
        for(int x = 1; x <= W; x++){
            mp[y][x] = 0;
        }
    }
    int x = 1, y = 1, dx = 1;
    for(int i = 1; i <= N; i++){
        int A;
        cin >> A;
        for(int a = 0; a < A; a++){
            mp[y][x] = i;
            if(mp[y][x + dx] == 114514){
                dx = -dx;
                y++; 
            }
            else x += dx;
        }
    }
    for(int y = 1; y <= H; y++){
        for(int x = 1; x <= W; x++){
            cout <<mp[y][x];
            if(x==W)cout<<endl;
            else cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
int main()
{
    boost;
    string s,t;
    cin>>s;
    t=s;
    reverse(s.begin(),s.end());
    if(s.compare(t)==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

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


int main()
{
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R), A(M), B(M), C(M);
    for( int i = 0; i < R; ++i ) cin >> r[i];
    for( int i = 0; i < M; ++i ) cin >> A[i] >> B[i] >> C[i];


    int length[201][201];
    for( int i = 1; i <= N; ++i ){
        for( int j = 1; j <= N; ++j ){
            length[i][j] = (i == j)? 0: 1e+7;
        }
    }

    for( int i = 0; i < M; ++i ){
        length[A[i]][B[i]] = C[i];
        length[B[i]][A[i]] = C[i];
    }

    for( int k = 1; k <= N; ++k ){
        for( int i = 1; i <= N; ++i ){
            for( int j = 1; j <= N; ++j ){
                length[i][j] = min( length[i][j], length[i][k] + length[k][j] );
            }
        }
    }

    int ans = INT_MAX;
    sort( r.begin(), r.end() );
    do{
        int total_length = 0;
        for( int i = 0; i < R-1; ++i ) total_length += length[r[i]][r[i+1]];
        ans = min( ans, total_length );
    }while( next_permutation( r.begin(), r.end() ) );

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>

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

    int n;
    std::cin >> n;
    while (n--) {
        /* A(x1, y1)
         * B(x2, y2)
         * C(x3, y3)
         * */
        double x1, y1, x2, y2, x3, y3;
        double px, py, r;
        double radA, radB, radC;
        double a, b, c;
        std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        a = std::sqrt(std::pow(x3 -  x2, 2) + std::pow(y3 - y2, 2));
        b = std::sqrt(std::pow(x1 -  x3, 2) + std::pow(y1 - y3, 2));
        c = std::sqrt(std::pow(x2 -  x1, 2) + std::pow(y2 - y1, 2));
        radA = std::acos((b*b + c*c - a*a) / (2*b*c));
        radB = std::acos((c*c + a*a - b*b) / (2*c*a));
        radC = std::acos((a*a + b*b - c*c) / (2*a*b));
        double sin2A = std::sin(2*radA);
        double sin2B = std::sin(2*radB);
        double sin2C = std::sin(2*radC);
        px = (sin2A*x1 + sin2B*x2 + sin2C*x3) / (sin2A + sin2B + sin2C);
        py = (sin2A*y1 + sin2B*y2 + sin2C*y3) / (sin2A + sin2B + sin2C);
        r = a / (2 * std::sin(radA));
        std::printf("%.3lf %.3lf %.3lf\n", px, py, r);
        //std::printf("(x1,y1)=(%.1lf,%.1lf)\n(x2,y2)=(%.1lf,%.1lf)\n(x3,y3)=(%.1lf,%.1lf)\n", x1, y1, x2, y2, x3, y3);
        //std::printf("a:%.3lf b:%.3lf c:%.3lf\n", a, b, c);
        //std::printf("radA:%.3lf radB:%.3lf radC:%.3lf\n", radA, radB, radC);
        //std::printf("A:%.3lf B:%.3lf C:%.3lf\n", radA * 180 / M_PI, radB * 180 / M_PI, radC * 180 / M_PI);
    }
}



Measured memory_bytes: 3476
import itertools as it
n=int(input())
xy_li=[list(map(int,input().split())) for i in range(n)]
li=[i for i in range(n)]
pattern=list(it.permutations(li))

ans=0
for i in pattern:
  for j in range(n-1):
    x=(xy_li[i[j]][0]-xy_li[i[j+1]][0])**2
    y=(xy_li[i[j]][1]-xy_li[i[j+1]][1])**2
    ans+=(x+y)**0.5

print(ans/len(pattern))

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

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D.at(i);

  sort(D.begin(), D.end());

  cout << D.at(N / 2) - D.at(N / 2 - 1) << "\n";
}

Measured memory_bytes: 640
N,M=map(int,input().split())
tree=[[] for i in range(N)]
ans=[0]*N
ischecked=[0]*N
ischecked[0]=1
for i in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)
q=[0]
while q:
    now=q.pop(0)
    for i in tree[now]:
        if ischecked[i]==1:
            continue
        ans[i]=now+1
        ischecked[i]=1
        q.append(i)
flag=0
for i in range(1,N):
    if ans[i]==0:
        flag=1
        break
if flag==0:
    print("Yes")
    for i in range(1,N):
        print(ans[i])
else:
    print("No")

Measured memory_bytes: 37516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int ans_a = (int)Math.floor(num / 1.08);
		int ans_b = (int)Math.ceil(num / 1.08);
		int chk = (int)Math.floor(ans_a * 1.08);
		if (chk == num) {
			System.out.println(ans_a);
		}else {
			chk = (int)Math.floor(ans_b * 1.08);
			if (chk == num) {
				System.out.println(ans_b);
			}else {
				System.out.println(":(");
			}
		}
	}
}


Measured memory_bytes: 35864
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;(a)<=i;--i)
template<class T> class segtree{
	int n = 1;
	vector<T> dat;
	T def;
	function<T(T, T)> f1;
	function<void(T&, T)> f2;
public:
	segtree(const int& _n, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
	}
	segtree(const vector<T>& _dat, function<T(T, T)> _f1, function<void(T&, T)> _f2, const T _def = 0)
		: f1(_f1), f2(_f2), def(_def) {
		int _n = _dat.size();
		while (n < _n)n <<= 1;
		dat.resize(n << 1, def);
		FOR(i, 0, _n)dat[i + n] = _dat[i];
		rFOR(i, 1, n)dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
	}
	void update(int i, T a) {
		i += n;
		f2(dat[i], a);
		while (1 < i) {
			i >>= 1;
			dat[i] = f1(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	T value(int l, int r) {
		T ret = def;
		for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
			if (l & 1)ret = f1(ret, dat[l++]);
			if (r & 1)ret = f1(ret, dat[--r]);
		}
		return ret;
	}
};

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

	vector<int> a(n);
	FOR(i, 0, n)a[i] = 1 << (s[i] - 'a');
	segtree<int> seg(a,
		[](int a, int b) {return a | b; },
		[](int& a, int b) {a = b; });

	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			int i; char c; cin >> i >> c;
			seg.update(i - 1, 1 << (c - 'a'));
		}
		else {
			int l, r; cin >> l >> r;
			int b = seg.value(l - 1, r);
			int ans = 0;
			FOR(i, 0, 26)if (b & (1 << i))++ans;
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 6916
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
using namespace std;
int const MAXN = 1 << 13;
int f[MAXN];
int main() {
  int n, m; cin >> n >> m;
  memset(f, 0x7f, sizeof(f));
  f[0] = 0;
  int all = 1 << n;
  for (RI i = 1; i <= m; ++i) {
    int cost, cnt; cin >> cost >> cnt;
    int s = 0;
    for (RI j = 1, x; j <= cnt; ++j)
      cin >> x, s |= (1 << (x - 1));
    for (RI j = 0; j < all; ++j)
      f[j | s] = min(f[j | s], f[j] + cost);
  }
  if (f[all - 1] == 0x7f7f7f7f) puts("-1");
  else printf("%d\n", f[all - 1]);
  
  return 0;
}


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

#define MAX_N 500 

ll N;


int main() {
    cin >> N;
    vector<ll> C(N), S(N), F(N);

    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

    // N 個の駅
    rep(i, N) {
        ll t = 0;

        // N - 1個目は初めから目的地にいるので 0
        for (ll j = i; j < N - 1; j++) {
            if (t < S[j]) t = S[j];
            else if (t % F[j] == 0);
            else t = t + F[j] - (t % F[j]);

            t += C[j];
        }

        cout << t << endl;
    }

}

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

int par[1000000]; //union-find
int ranks[1000000]; //union-find
void init(int n){ //union-find 
    for(int i=0;i<n;i++){
        par[i]=i;
        ranks[i]=1;
    }
}

int find(int x){ //union-find
    if(par[x]==x){
        return x;
    }
    else{
        return par[x]=find(par[x]);
    }
}

void unite(int x, int y){ //union-find
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(ranks[x]<ranks[y]){
        swap(x,y);
    }
    par[y]=x;
    ranks[x]+=ranks[y];
    //if(ranks[x]==ranks[y]) ranks[x]++;
    

}

bool same(int x, int y){ //union-find
    return find(x) == find(y);
}

int size(int x){
    return ranks[find(x)];
}

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> friends[n];
    vector<int> block[n];
    int ans[n];
    memset(ans,0,sizeof(ans));

    init(n);

    rep(i,m){
        int a,b;
        cin >>a >> b;
        a--;
        b--;
        unite(a,b);
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    rep(i,k){
        int c,d;
        cin >> c >> d;
        d--;
        c--;
        block[c].push_back(d);
        block[d].push_back(c);
    }

    rep(i,n){
        ans[i]=size(i)-1;
        for(auto x:block[i]){
            if(same(i,x)) ans[i]--;
        }
        for(auto x:friends[i]){
            if(same(i,x)) ans[i]--;
        }
        printf("%d ",ans[i]);
    }
    

    




}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 0;
    REP(i, N){
        ll a;
        cin >> a;

        while(a%2==0){
            a = a/2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>

int main()
{
	int a, b;
	std::cin >> a >> b;
	int d, r;
	double f;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %.8lf\n", d, r, f);

	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
using namespace std;
int main() {
  int N; cin >> N;
  for (int i = 1; i <= 9; i++) {
    for (int p = 1; p <= 9; p++) {
      if (i * p == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main() {
  
 int N,M,max,count;
 string hikaku;
 count = 0;
 max = 0;
 cin >> N;
 vector<string> blue(N);
 
 
 for (int i=0; i < N; i++) {
   cin >> blue.at(i);
 }
 cin >> M;
 vector<string> red(M);
 for (int i=0; i < M; i++) {
   cin >> red.at(i);
 }
 
 for (int i=0; i < N; i++) {
   hikaku = blue.at(i);
   for (int j=0; j < N; j++) {
     if (hikaku == blue.at(j)) {
     count++;
     }
   }
   for (int j=0; j < M; j++) {
     if (hikaku == red.at(j)) {
     count--;
     }
   }
   
  
   if (max < count) {
     max = count;
   }
   count = 0;
 }
  
 
  cout << max << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int l=0,r=0,cnt=0,prev=0;
        for(int i=0;i<n;i++){
            char str[4];
            scanf("%s",str);
            int t;
            if(str[1]=='u')t=1;
            else t=0;
            if(str[0]=='l')l=t;
            else r=t;
            if(l==r&&prev!=l){
                prev=1-prev;
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

int main(){
	string a,b,out="EQUAL";
	cin >> a >> b;
	if(a.length()>b.length()) out="GREATER";
	else if(a.length()<b.length()) out="LESS";
	else{
		for(int i=0;i<a.length();++i){
			if(a[i]==b[i]) continue;
			else if(a[i]>b[i]) {
				out="GREATER";
				break;
			}
			else {
				out="LESS";
				break;
			}
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()


N, K = map(int, input().split())
# 2 * a, 2 * b, 2 * c
if K % 2 == 1:
    print((N // K) ** 3)
else:
    print((N // K) ** 3 + (N // (K // 2) - N // K) ** 3)


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

int main(){
  char A;
  cin>>A;
  
  if(A=='a'||A=='e'||A=='i'||A=='o'||A=='u'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <cfloat>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int64_t i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int64_t i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int64_t i = beg; end <= i; i--)

using namespace std;

enum Dir {
	kR,
	kL,
	kU,
	kD
};

struct Point {
	int64_t x;
	int64_t y;
	Dir d;
};

pair<bool, int64_t> intersect(int64_t add, int64_t sub) {
	if (sub < add) return { false, 0 };
	else return { true, (sub - add) / 2 };
}

void add_cand(int64_t add, int64_t sub, set<int64_t> & cand) {
	auto ret = intersect(add, sub);
	if (ret.first) cand.insert(ret.second);
}

void add_cand_a(int64_t add, int64_t cons, set<int64_t>& cand) {
	if (cons < add) return;
	cand.insert(cons - add);
}

void add_cand_d(int64_t sub, int64_t cons, set<int64_t>& cand) {
	if (sub < cons) return;
	cand.insert(sub - cons);
}

double evaluate(vector<Point> & ps, double t) {
	double xmax = -DBL_MAX, xmin = DBL_MAX;
	double ymax = -DBL_MAX, ymin = DBL_MAX;

	for (auto& p : ps) {
		double x = p.x;
		double y = p.y;
		switch (p.d) {
		case kR: x += t; break;
		case kL: x -= t; break;
		case kU: y += t; break;
		case kD: y -= t; break;
		}

		xmax = max(xmax, x);
		xmin = min(xmin, x);
		ymax = max(ymax, y);
		ymin = min(ymin, y);
	}

	return (xmax - xmin) * (ymax - ymin);
}

double trisearch(vector<Point>& ps, double first, double last)
{
	double val = DBL_MAX;

	FOR_LT(i, 0, 300) {
		double first_third = evaluate(ps, (first + first + last) / 3);
		double second_third = evaluate(ps, (first + last + last) / 3);
		val = min(val, min(first_third, second_third));
		if (second_third > first_third) {
			last = (first + last + last) / 3;
		}
		else {
			first = (first + first + last) / 3;
		}
	}

	return val;
}

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

	int64_t n; cin >> n;

	vector<Point> ps(n);
	for (auto& p : ps) {
		cin >> p.x >> p.y;
		char c; cin >> c;
		if (c == 'R') p.d = kR;
		if (c == 'L') p.d = kL;
		if (c == 'U') p.d = kU;
		if (c == 'D') p.d = kD;
	}

	double min_val = DBL_MAX;
	min_val = trisearch(ps, 0, 10000000000.0);

	cout << fixed << setprecision(15) << min_val  << endl;

	return 0;
}


Measured memory_bytes: 2560
package main

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

/*-----------Main-----------*/

func main() {
	x := readI()
	m := 100

	for i := 0; ; i++ {
		if m >= x {
			fmt.Println(i)
			return
		}
		m += m / 100
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll n,m,k,q;


priority_queue<P,vp,greater<P>> pq[51]; //<dis,idx>
int main(){

    //freopen("test.in","r",stdin);

    cin>>n>>m;
    vp cot;
    int a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        cot.pb({a,b});
    }
    vp dcot;
    for(int j=0;j<m;j++){
        cin>>a>>b;
        dcot.pb({a,b});
    }
    int dx,dy;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            dx=abs(cot[i].first - dcot[j].first);
            dy=abs(cot[i].second - dcot[j].second);
            pq[i].push({dx+dy,j});
        }
    }
    for(int i=0;i<n;i++){
        cout<<pq[i].top().second +1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
program r20718e
 
implicit none
integer :: n, i
character(len=4) :: s
 
read *, s


do i = 1, 4
 if(s(i:i) == '+') then
  n = n + 1
 else
  n = n - 1
 end if
end do

print *, n

end program r20718e

Measured memory_bytes: 2784
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N;
bool chk(ll x){
	ll m=x-1;
	if(m==0)return false;
	return (m+1)*(N/m)==N;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	ll ans=0;
	for(ll x=1;x*x<=N;x++){
		if(N%x>0)continue;
		if(chk(x)){
			ans+=x-1;
		}
		if(N/x!=x && chk(N/x)){
			ans+=N/x-1;
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define int long long

typedef pair<int,int> pii;

const int N = 1e5 + 100;

int d[N], sz[N], a[N];
vector<int> adj[N];
vector<pii> ans;
pii b[N];
int n, mx, val;

bool cmp(int x, int y) {
	return d[x] > d[y];	
}

inline int getPar(int v) {
	int hp = d[v] - n + 2 * sz[v];
	auto tmp = lower_bound(b, b + n, pii(hp, 0)) - b;
	if (b[tmp].first != hp) {
		cout << -1;
		exit(0);
	}
	return b[tmp].second;
}

int dfs(int v) {
	int res = 0;
	for (auto u : adj[v])
		res += dfs(u) + sz[u];
	return res;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		b[i] = {d[i], i};
		a[i] = i;
		sz[i] = 1;
	}
	sort(b, b + n);
	sort(a, a + n, cmp);
	for (int i = 0; i < n - 1; i++) {
		int v = a[i];
		int p = getPar(v);
		sz[p] += sz[v];
		ans.push_back({v, p});
		adj[p].push_back(v);
		if (2 * sz[v] > n)
			return cout << -1, 0;
	}
	int root = a[n - 1];
	if (dfs(root) != d[root])
		return cout << -1, 0;
	for (auto e : ans)
		cout << e.first + 1 << " " << e.second + 1 << '\n', 0;
}

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

const ll MOD = 1000000007;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(),s.end());
    vector<vector<int>> dp(100005,vector<int>(13,0));
    dp.at(0).at(0) = 1;
    int mul = 1;
    rep(i,n){
        if(s.at(i) == '?'){
            rep(j,10){
                rep(k,13){
                    dp.at(i+1).at((j*mul + k)%13) += dp.at(i).at(k);
                    dp.at(i+1).at((j*mul + k)%13) %= MOD;
                }
            }
        }else{
            int c = s.at(i) - '0';
            rep(k,13){
                dp.at(i+1).at((c*mul + k)%13) += dp.at(i).at(k);
                dp.at(i+1).at((c*mul + k)%13) %= MOD;
            }
        }
        mul *= 10;
        mul %= 13;
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 11900
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long INF = 1_000_000_000_000_000L;
        int n = sc.nextInt();
        int[] row = new int[n];
        int[] c = new int[n];
        for (int i=0;i<n;i++) {
            row[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        long[][] dp = new long[n+1][n+1];
        for (int w=1;w<=n;w++) {
            for (int l=0;l<n;l++) {
                int r = l+w;
                if (r>n) continue;
                long tmp = INF;
                if (r-l==1) tmp = 0;
                for (int mid=l+1;mid<r;mid++) {
                    tmp = Math.min(tmp, dp[l][mid]+dp[mid][r]+(long)row[l]*c[mid-1]*c[r-1]);
                }
                dp[l][r] = tmp;
            }
        }
        System.out.println(dp[0][n]);
    }
}


Measured memory_bytes: 26716
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	vector<char> result;
	while (n > 0) {
		result.push_back((n + 25) % 26 + 'a');
		n =  (n - 1) / 26;
	}
	reverse(all(result));
	for (auto c: result) {
		cout << c;
	}
	cout << endl;
}



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

import sys
import os
import math

for s in sys.stdin:
    s = s.strip()
    s = s.replace(',', ' ')
    s = s.replace('.', ' ')
    words = s.split()
    words = [word for word in words if 3 <= len(word) <= 6]
    print(*words)

Measured memory_bytes: 7488
n = int(input())
a = [int(i) for i in input().split()]

min = 1000001
max = -1000001
sum = 0

for i in a:
    if i < min: min = i
    if i > max: max = i
    sum += i
    
print(str(min) + " " + str(max) + " " + str(sum))


Measured memory_bytes: 6608
#include <iostream>

using namespace std;

int main()
{
    int t;

    while (cin >> t, t) {
        int n, s, f;

        cin >> n;
        while (n--) {
            cin >> s >> f;
            t -= f - s;
        }
        if (t > 0)
            cout << t << endl;
        else
            cout << "OK" << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
from collections import Counter
N = int(input())

def getPrimes():
    isPrime = [True] * 100
    primes = []
    for p in range(2, 100):
        if not isPrime[p]:
            continue
        primes.append(p)
        for i in range(p, 100, p):
            isPrime[i] = False
    return primes

P = getPrimes()
A = Counter()

for n in range(1, N + 1):
    cnt = Counter()
    for p in P:
        while n % p == 0:
            n //= p
            cnt[p] += 1
    A += cnt

D = {3: 0, 5: 0, 15: 0, 25: 0, 75: 0}
for k in D.keys():
    for c in A.values():
        if (c + 1) >= k:
            D[k] += 1

ans = 0
ans += (D[5] * (D[5] - 1) // 2) * (D[3] - 2)
ans += D[15] * (D[5] - 1)
ans += D[25] * (D[3] - 1)
ans += D[75]
print(ans)


Measured memory_bytes: 3316
N=int(raw_input())
B=[int(x) for x in raw_input().split()]
A=[-1]
for b in B:
    if b != A[-1]:
        A.append(b)
A.pop(0)
N=len(A)
i=1
ans=1
while i<N-1:
    if (A[i]-A[i-1])*(A[i+1]-A[i])<0:
        ans+=1
        i+=1
    i+=1
print ans

 


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

using namespace std;

#define ll long long

#define DEBUG (0)


int main()
{
  ll N = 0;
  cin >> N;

  vector<string>S(N,"");
  for(ll i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(),S.end());

  ll count = 1;
  for(ll i = 1; i < N; i++){
    if(S[i-1] != S[i]){
      count++;
    }
  }

  cout << count << "\n";

#if DEBUG
  for(int i = 0; i < N; i++){
    cout << S[i] << endl;
  }
#endif
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
ll n;
string s;
cin>>s;
ll ans=0;
ll cur=0;
for(ll i=0;i<s.length();i++)
{
    if(s[i]=='R') cur++;
    else
    {
        ans=max(cur,ans);
        cur=0;
    }
}
ans=max(ans,cur);
cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}


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

int main(){
	int N,A,x,a=30;
  cin >> N;
	for(int i=0;i<N;i++){
  		cin >> A;
    	while(A%2==0){
          A/=2;
      	  x++;
        }
      if(a > x) a = x;
      x=0;
       }
  cout << a;
}

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

#define fastIO                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef long double ld;

vector<int> parent;

int find_parent(int n)
{
	if (n != parent[n]) 
		parent[n] = find_parent(parent[n]);
	return parent[n];
}

int main()
{
	fastIO;
	int N, M;
	cin >> N >> M;
	parent.resize(N + 1);
	for (int i = 1; i <= N; i++) 
		parent[i] = i;
	int A, B;
	while (M--)
	{
		cin >> A >> B;
		if (A > B) swap(A, B);
		int parent_A = find_parent(A), parent_B = find_parent(B);
		parent[parent_B] = parent_A;
	}
	set<int> unique_parents;
	for (int i = 1; i <= N; i++)
		unique_parents.insert(find_parent(i));
	cout << unique_parents.size() - 1;
}

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = true;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> data(m);
  vector<int> p(m);
  REP(i, m) {
    int x;
    cin >> x;
    REP(j, x) {
      int y;
      cin >> y;
      data[i].push_back(y - 1);
    }
  }

  REP(i, m) {
    int x;
    cin >> x;
    p[i] = x;
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    int tmp = 0;
    REP(i, m) {
      int count = 0;
      for (int x : data[i]) {
        if (bit & (1 << x)) {
          count++;
        }
      }
      if (count % 2 == p[i]) {
        tmp++;
      }
    }
    if (tmp == m) ans++;
  }
  cout << ans << endl;
}

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

int main() {
    int n; cin>>n;
    int k; cin>>k;
    
    int h[n+1];
    h[0]=0;
    for(int i=1; i<=n; i++) cin>>h[i];

    if(k>=n-1) {
        cout<< abs(h[1] - h[n])<<'\n';
        return 0;
    }

    int cost[n+1];
    for(int i=0; i<=n; i++) cost[i] = INT_MAX;
    cost[1] = 0;

    for(int i=1; i<=n-k; i++) {

        for(int j=i+1; j<=i+k; j++) {
            if( cost[j] > cost[i] + abs(h[j] - h[i]) ) {
                cost[j] = cost[i] + abs(h[j] - h[i]);
            }
        }
    }

    for(int i=n-k+1; i<n; i++) {
        for(int j=i+1; j<=n; j++) {
            if( cost[j] > cost[i] + abs(h[j] - h[i]) ) {
                cost[j] = cost[i] + abs(h[j] - h[i]);
            }
        }
    }
    
    cout<<cost[n]<<'\n';
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	int n;
	int mmax = -1;
	int mmin = 10000;
	int tmp;
	ll int sum;
	while(cin >> n,n){
		mmax = -1;
		mmin = 10000;
		sum = 0;
		REP(i,n){
			cin >> tmp;
			mmax = max(tmp,mmax);
			mmin = min(tmp,mmin);
			sum += tmp;
		}
		cout << (int)((sum-mmax-mmin)/(n-2)) << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {
	long long x, y;

	cin >> x >> y;
	long long res = 0;
	long long cur = x;
	while (true) {
		if (cur <= y) {
			++res;
			cur *= 2;
		}
		else {
			break;
		}
	}
	cout << res << endl;
	return 0;
}


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


 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int x;
  cin>>x;
  if(x>=400 && x<=599){
    cout<<"8";
  }
   if( x>=600 && x<=799 ){
    cout<<"7";
  }
  if( x>=800 && x<=999 ){
    cout<<"6";
  }
  if( x>=1000 && x<=1199 ){
    cout<<"5";
  }
  if( x>=1200 && x<=1399 ){
    cout<<"4";
  }
  if( x>=1400 && x<=1599 ){
    cout<<"3";
  }
  if( x>=1600 && x<=1799 ){
    cout<<"2";
  }
  if( x>=1800 && x<=1999 ){
    cout<<"1";
  }
  
  

}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> like(m,0);
    rp(i,n){
        int k;
        cin >> k;
        rp(j,k){
            int a;
            cin >> a;
            a--;
            like[a]++;
        }
    }
    int ans=0;
    for(auto l:like){
        if(l==n) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

const int MX = 3e5;
vector<int> G[MX];
int n;
int a[MX];
int t[4 * MX];
pair<int, int> b[MX];
int pos[MX];
int ans[MX];

void modify(int i, int tl, int tr, int pos, int key) {
        if (tl + 1 == tr) {
                t[i] = key;
                return;
        }
        int md = (tl + tr) / 2;
        if (pos < md)
                modify(i * 2, tl, md, pos, key);
        else
                modify(i * 2 + 1, md, tr, pos, key);
        t[i] = max(t[i * 2], t[i * 2 + 1]);
}

int getMax(int i, int tl, int tr, int l, int r) {
        if (l <= tl && tr <= r)
                return t[i];
        if (tl >= r || l >= tr)
                return -MX;
        int md = (tl + tr) / 2;
        return max(getMax(i * 2, tl, md, l, r), getMax(i * 2 + 1, md, tr, l, r));
}

void dfs(int u = 1, int p = -1, int mx = 0) {
        int dp = 1;
        int up = lower_bound(b, b + n, make_pair(a[u], -MX)) - b;
        dp = max(dp, getMax(1, 0, n, 0, up) + 1);
        ans[u] = max(mx, dp);
        mx = max(mx, dp);
        modify(1, 0, n, pos[u], dp);
        for (int v : G[u]) {
                if (v == p) continue;
                dfs(v, u, mx);
        }
        modify(1, 0, n, pos[u], 0);
}

int main() {
        cin.sync_with_stdio(0);
       
        cin >> n;

        for (int i = 1; i <= n; ++i) {
                cin >> a[i];
                b[i - 1] = make_pair(a[i], i);
        }

        sort(b, b + n);
        
        for (int i = 0; i < n; ++i) {
                pos[b[i].second] = i;
        }

        for (int i = 0; i < n - 1; ++i) {
                int u, v;
                cin >> u >> v;
                G[u].push_back(v);
                G[v].push_back(u);
        }
        
        dfs();
        
        for (int i = 1; i <= n; ++i)
                cout << ans[i] << " ";

        return 0;
}

Measured memory_bytes: 37172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using PLL = pair<ll, ll>;
#define fst first
#define snd second

int n;
vector<PLL> ranges;

ll get(int ltsz, int rtsz) {
  ll med_lo = 0;
  {
    ll lo = 0, hi = 1e9 + 10;
    while (lo < hi) {
      ll mid = (lo + hi) / 2;
      int c = 0;
      for (auto& [L, R]: ranges) {
        if (L <= mid) c++;
      }
      if (c >= ltsz) {
        hi = mid;
      } else {
        lo = mid + 1;
      }
    }
    med_lo = lo;
  }
  ll med_hi = 0;
  {
    ll lo = 0, hi = 1e9 + 10;
    while (lo + 1 < hi) {
      ll mid = (lo + hi) / 2;
      int c = 0;
      for (auto& [L, R]: ranges) {
        if (R >= mid) c++;
      }
      if (c >= rtsz) {
        lo = mid;
      } else {
        hi = mid;
      }
    }
    med_hi = lo;
  }
  return max(0ll, med_hi - med_lo + 1);
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  cin >> n;
  ranges.resize(n);
  for (auto& [L, R]: ranges) {
    cin >> L >> R;
  }

  if (n & 1) {
    cout << get((n + 1) / 2, (n + 1) / 2) << endl;
  } else {
    ll w1 = get(n / 2, n / 2 + 1);
    ll w2 = get(n / 2 + 1, n / 2);
    cout << (w1 + w2 - 1) << endl;
  }


  return 0;
}
// 1,2
// 1,2
// 2,3,4

Measured memory_bytes: 6304
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int n;
    cin >> n;
    v_ll a(n);
    ll l = 0, r = 0;

    irep(i, n) {
        cin >> a[i];
    }

    sort(a.rbegin(), a.rend());

    ll l_index = 0;
    irep(i, n-1) {
        if(a[i] == a[i+1]) {
            l = a[i];
            l_index = i+2;
            break;
        }
    }
    
    irep2(i, l_index, n-1) {
        if(a[i] == a[i+1]) {
            r = a[i];
            break;
        }
    }

    cout << l * r << endl;
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
m=1000
k=0
peak=-1
for i in range(n-1):
    if a[i]<a[i+1]:
        peak=i+1

for i in range(peak):
    if a[i+1]>a[i] and k==0:
        k=m//a[i]
        m-=k*a[i]
#        print(k,m,"rise")
    elif a[i+1]<a[i]:
        m+=k*a[i]
        k=0
#        print(k,m,"fall")
if peak!=-1:
    m+=k*a[peak]
    k=0
#    print(k,m,"peak")
print(m)


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

int index(int numToFind, std::vector<int> vectorToFindIn) {int len = vectorToFindIn.size();for (int i = 0; i < len; i++){if (vectorToFindIn[i] == numToFind){return i;}}return -1;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n;
  cin>>n;
  cout<<3*n*n;
  return 0;
}

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

int main() {
  string S, T;
  int a=0;
  cin >> S >> T;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) != T.at(i))
      a++;
  }
  cout << a << endl;
}


Measured memory_bytes: 3848
import bisect

H,W,K=map(int,input().split())
s=[""]*H
ans=[[0]*W for _ in range(H)]
St=[0]*H#i行目にイチゴがあるか？
St2=[]


for i in range(H):
    s[i]=input()
    if "#" in s[i]:
        St[i]=1
        St2.append(i)
        
    
    
a=1
#i行目，aからスタートして埋める
for i in range(H):
    if St[i]==1:
        flag=0
        for j in range(W):
            if s[i][j]=="#":
                if flag==0:
                    flag=1
                else:
                    a+=1
            ans[i][j]=a
        a+=1
        

for i in range(H):
    k=bisect.bisect_left(St2,i)
    #近いところを参照したいけど参照したいけど，端での処理が面倒
    if k!=0:
        k-=1
    if St[i]==0:
        ans[i]=ans[St2[k]]
        
for i in range(H):
    print(" ".join(map(str, ans[i])))

Measured memory_bytes: 42860
#include<stdio.h>

int main(){
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H'){
        if(b=='H') printf("H\n");
        else printf("D\n");
    }else {
        if(b=='H') printf("D\n");
        else printf("H\n");
    }

    return 0;
}


Measured memory_bytes: 128
def main():

    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    cnt = 0
    for _ in range(N):
        A = list(map(int, input().split()))
        total = 0
        for i in range(M):
            total += A[i] * B[i]
        if total + C > 0:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int

using namespace std;

int main(void)
{

    
    int x, y;
    
    cin >> x >> y;
    
    for(int i = 0; i <= x; i++)
    {
        if(2*(i)+4*(x - i) == y)
        {
            cout << "Yes";
            return 0;
        }
    }
    
    cout << "No";
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

char a, b;
string n1, n2;
void solve() {
    cin >> a >> b;
    rep(i, a - '0') { n1 += b; }
    rep(i, b - '0') { n2 += a; }

    cout << min(n1, n2) << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256