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

int main() {
  vector<int> A(5);
  for(int i = 0; i < 5; i++) {
    cin >> A.at(i);
    if(A.at(i) == 0) {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define mod 1000000007
int n;
string s[2];
int ans=1;
signed main(){
	cin>>n;
	cin>>s[0]>>s[1];
	rep(i,n){
		if(i==0){
			if(s[0][0]==s[1][0])ans*=3;
			else{
				ans*=6;
				i++;
			}
		}
		else{
			if(s[0][i]==s[1][i]){
				if(s[0][i-1]==s[1][i-1])ans*=2;
				else ans*=1;
			}
			else{
				if(s[0][i-1]==s[1][i-1])ans*=2;
				else ans*=3;
				i++;
			}
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  map<ll, ll> AB;
  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    AB[a] += b;
  }
  for (auto const &ab : AB) {
    if (K - ab.second > 0) {
      K -= ab.second;
    } else {
      cout << ab.first << '\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 4224
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

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

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  int n, m;cin>>n>>m;
  cout<<(n+m)*(n+m-1)/2-n*m<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mp make_pair
#define fr first
#define sc second
#define M 200005
ll dx[]={1,-1,0,0};
ll dy[]={0,0,1,-1};

int main()
{
    int n,a[202],ans=0;
    cin>>n;
    for(int i=0;i<2*n;i++) cin>>a[i];
    sort(a,a+2*n);
    for(int i=0;i<2*n;i+=2){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
const int INF = 1 << 20;
const int N = 11;
int tim[N][N];
using namespace std;
int main()
{
	int a, b, ti, n;
	while (1){
		cin >> n;
		if (n == 0)break;

		for (int i = 0; i < N; i++){
			for (int i2 = 0; i2 < N; i2++){
				if (i != i2){
					tim[i][i2] = INF;
				}
				else
					tim[i][i2] = 0;
			}
		}

		int m = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> ti;
			tim[a][b] = ti;
			tim[b][a] = ti;
			m = max(m, a);
			m = max(m, b);
		}

		for (int k = 0; k <= m; k++)
			for (int i = 0; i <= m; i++)
				for (int j = 0; j <= m; j++){
					tim[i][j] = min(tim[i][j], tim[i][k] + tim[k][j]);
				}

		int mint = INF;
		vector<int>p;
		p.clear();
		for (int i = 0; i <= m; i++){
			int mt = 0;
			for (int i2 = 0; i2 <= m; i2++){
					mt += tim[i][i2];
			}
			p.push_back(mt);
			mint = min(mt, mint);
		}

		for (int i = 0; i <= p.size(); i++){
			if (p[i] == mint){
				cout << i << " " << mint << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1216
d=[list(raw_input()) for i in range(8)]
p=[d,[],[],[]]
for r in range(3):
	print 90*(r+1)
	for j in range(8):
		p[r+1].append([p[r][i][j] for i in range(7,-1,-1)])
		print "".join(p[r+1][j])

Measured memory_bytes: 4208
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(string, a, b);
    int cnt = 0;
    rep(i, 0, a.length()) {
        if (a[i] != b[i]) ++cnt;
    }

    print(cnt);

    return 0;
}


Measured memory_bytes: 3808
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>

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

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

int main() {
  int n;
  cin >> n;
  int odd = 0;
  vector<int> vec(n);
  rep(i,n) {
    cin >> vec[i];
    if( vec[i] & 1 ) ++odd;
  }
  if( odd & 1 ) puts("NO");
  else puts("YES");
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  while(N>0){
    if(N%10==7){
      cout << "Yes" << endl;
      return 0;
    }
    N/=10;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        double money;
        String unit;
        double sum = 0;
        for(int i=0; i<num; i++){
			money = sc.nextDouble();
     		unit = sc.next();
            if(unit.equals("BTC")) money = money * 380000.0;
            sum += money;
        }
        
		System.out.println(sum);
	}
}

Measured memory_bytes: 22868
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    ans+=B[A[i]-1]
for j in range(N-1):
    if A[j]+1==A[j+1]:
        ans+=C[A[j]-1]
print(ans)

Measured memory_bytes: 9152
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
   
    _FAST
    lli n;cin>>n;
    map<pair<lli,lli>,lli> mp,dp;
    for(lli a:{0,1,2,3,4,5,6,7,8,9})
        for(lli b:{0,1,2,3,4,5,6,7,8,9})
        {
            mp[{a,b}]=0;
            dp[{a,b}]=0;
        }
    for(lli i=1;i<=n;i++)
    {
        string t=to_string(i);
        char a=t[0],b=t[t.size()-1];
        mp[{a-'0',b-'0'}]++;
    }
    lli ans=0;
    for(lli a:{0,1,2,3,4,5,6,7,8,9})
        for(lli b:{0,1,2,3,4,5,6,7,8,9})
        {
            if(a==b && mp[{a,b}]!=0)
            {
                ans+=mp[{a,b}]*mp[{a,b}];
                dp[{a,b}]=1;
            }
            else if(a!=b && dp[{a,b}]==0 && dp[{b,a}]==0)
            {
                dp[{a,b}]=1;
                dp[{b,a}]=1;
                ans+=mp[{a,b}]*mp[{b,a}]*2;
            }
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	int i,n,k;
	cin >> n >> k >> s;
	if(s[k-1]=='A') s[k-1] = 'a';
	if(s[k-1]=='B') s[k-1] = 'b';
	if(s[k-1]=='C') s[k-1] = 'c';
	cout << s << endl;
} 

Measured memory_bytes: 256
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
    
    ### intチェック
    def is_integer(self, n):
        try:
            float(n)
        except ValueError:
            return False
        else:
            return float(n).is_integer()

    ### 幾何学問題用
    def dist(self, A, B):
        d = 0
        for i in range(len(A)):
            d += (A[i]-B[i])**2            
        d = d**(1/2)
        return d

    ### 絶対値
    def abs(self, n):
        if n >= 0:
            return n
        else:
            return -n   

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート（代入する必要なし）
# N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            #N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
            N.append([int(x) for x in input().split()])
        except EOFError:
            break
    return N

#D = get_input()

n = int(input())

ans = 1

for i in range(1,n+1):
    ans *= i

print(ans)



Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r, c, k;
    cin, r, c, k;
    auto v = make_v(r, c, 0LL);
    REP(i, 0, k) {
        int a, b, c;
        cin, a, b, c;
        a--;
        b--;
        v[a][b] = c;
    }
    auto dp = make_v(r + 1, c + 1, 4, 0LL);

    REP(i, 0, r) {
        REP(j, 0, c) {
            REP(t, 0, 4) {
                ll vv = v[i][j] * (t < 3);
                chmax(dp[i + 1][j][0], dp[i][j][t] + vv);

                chmax(dp[i][j + 1][t], dp[i][j][t]);
                if (t < 3) {
                    chmax(dp[i][j + 1][t + 1], dp[i][j][t] + v[i][j]);
                }
            }
        }
    }
    ll ans = 0;
    REP(t, 0, 4) {
        REP(i, 0, r) {
            chmax(ans, dp[i][c][t]);
        }
        REP (i, 0, c) {
            chmax(ans, dp[r][i][t]);
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 707272
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always




int main() {
    
    
    
    
    int n; cin >> n;
    int d[n]; rep(i, n) cin >> d[i];
    
    sort(d, d + n);
    
    out(d[n / 2] - d[n / 2 - 1]);
    
    
}



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

int main() {
    int N,K,A,B,X;
    cin >> N >> K;
    X=1;
    A=0;
    B=0;
    for (int i=0; i<N; i++){
    A = X * 2;
    B = X + K;
      if(A>=B){
        X=B;
      }
      else{
        X=A;
      }
    }
    cout << X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3e5+10;
const int mod=1e9+7;
ll a[N],p[N];
ll sum[N];
int n;
int main()
{
    //freopen("H:\\c++1\\in.txt","r",stdin);
    //freopen("H:\\c++1\\out.txt","w",stdout);
    p[0]=1;
    for(int i=1;i<=100;i++)p[i]=(p[i-1]*2)%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    ll ans=0;
    for(ll i=0;i<=60;i++){
        for(int j=1;j<=n;j++){
            if((a[j]>>i)&1)sum[j]=sum[j-1]+1;
            else sum[j]=sum[j-1];
        }
        ll cnt=0;
        for(int j=1;j<n;j++){
            if((a[j]>>i)&1){
                cnt+=(n-j-(sum[n]-sum[j]));
            }else{
                cnt+=(sum[n]-sum[j]);
            }
        }
        cnt%=mod;
        ans=(ans+(1ll*cnt*p[i]%mod))%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){ 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    auto choco = scan<matrix<char>>(H, W);
    int min_cut_num = numeric_limits<int>::max();
    for (unsigned h_cut = 0; h_cut < (1 << H - 1); h_cut++) {
        int cut_num = __builtin_popcount(h_cut);
        vector<int> h_part(cut_num + 1);
        int last_cut_w = -1;
        for (int w = 0; w < W; w++) {
            bool over = false;
            for (int h = 0, h_part_i = 0; h < H; h++) {
                h_part[h_part_i] += (choco[h][w] - '0');
                if (h_part[h_part_i] > K) {
                    over = true;
                    break;
                }
                if (h_cut & (1 << h)) {
                    h_part_i++;
                }
            }
            if (over) {
                if (last_cut_w == w) {
                    cut_num = numeric_limits<int>::max();
                    break;
                } else {
                    fill(h_part, 0);
                    cut_num++;
                    last_cut_w = w;
                    w--;
                }
            }
        }
        chmin(min_cut_num, cut_num);
    }
    cout << min_cut_num << LN;
}


Measured memory_bytes: 256
N = int(input())
W = list(map(int,input().split()))

S1 = W[0]
S2 = sum(W)-W[0]
ans = abs(S1-S2)

for i in range(1,N):
    S1 += W[i]
    S2 -= W[i]
    ans = min(ans,abs(S1-S2))

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
    int n,m;
    cin>>n>>m;
    if(n==m)
    {
        for(int i=0;i<n;i++)
        cout<<n;
    }
    else if(n>m)
    {
        for(int i=0;i<n;i++)
        cout<<m;
    }
    else
    {
        for(int i=0;i<m;i++)
        cout<<n;
    }
    
}
    


Measured memory_bytes: 3580
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#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()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> A[i][j];
    queue<pair<pii, int>> que;
    rep(i, H) rep(j, W) {
        if(A[i][j] == '#')
            que.push(MP(MP(j, i), 0));
    }
    int res = 0;
    while(!que.empty()) {
        pair<pii, int> p = que.front();
        res = max(p.second, res);
        que.pop();
        int x = p.first.first, y = p.first.second;
        rep(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if(0 <= nx && nx < W && 0 <= ny && ny < H) {
                if(A[ny][nx] == '.') {
                    A[ny][nx] = '#';
                    que.push(MP(MP(nx, ny), p.second + 1));
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 13328
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

const int nAlpha = (int)('Z'-'A')+1;

int n;
char c[100];

void solve(){
    std::vector< std::pair<int,char> > vote(nAlpha);
    for(int i=0; i<nAlpha; ++i){
        vote[i].first = 0;
        vote[i].second = i + 'A';
    }

    for(int i=0; i<n; ++i){
        for(int j=0; j<nAlpha; ++j){
            if(vote[j].second == c[i]){
                ++vote[j].first;
                break;
            }
        }

        std::sort(vote.begin(), vote.end());

        int first  = vote[nAlpha-1].first;
        int second = vote[nAlpha-2].first;
        int remain = n-i-1;

        if(first > second + remain){
            std::cout << vote[nAlpha-1].second << " " << i+1 << std::endl;
            return;
        }
    }
    std::cout << "TIE" << std::endl;
    return;
}

int main(void){
    while(std::cin >> n, n != 0){
        for(int i=0; i<n; ++i){
            std::cin >> c[i];
        }
        solve();
    }
}

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

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

int main()
{
  int N, M; cin >> N >> M;
  vector<int> X(M); rep(i, M) cin >> X[i];

  sort(ALL(X));

  vector<ll> diff(M-1);
  for (int i = 0; i < M-1; ++i) {
    diff[i] = abs(X[i+1]-X[i]);
  }

  sort(ALL(diff), greater<ll>());

  ll ans = 0;
  for (int i = N-1; i < diff.size(); ++i) {
    ans += diff[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define trav(a,x) for(auto& a : x)

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

int n;
int a;

int main(){
    IOS;
    cin >> n;
    while(n--){
        cin >> a;
        if(a % 2 == 0){
            if(!(a%5==0) && !(a%3==0)){
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
    // You should actually read the notes to self.
}

Measured memory_bytes: 256
# DAGの最長経路...トポロジカルソートもどきか？
# 普通にDAGに沿ったdpをすればいいのでは?
# 再帰だと実装楽そうだけどどうしよう
# 問題は終了と最初がわからんこと
# いや最初は全部長さ0をセットすればいいだろ
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

N, M = ints()
dag = defaultdict(lambda: [])
indeg = [0] * N
for _ in ra(M):
    x, y = mina(*ints())
    indeg[y] += 1
    dag[x].append(y)

q = deque()
for u, inn in enu(indeg):  # 多点DFS初期化
    if inn == 0:
        q.append((u, 0))

dp = [0] * N
while q:  # トポロジカル順序でdpテーブルを埋めていく
    u, l = q.popleft()
    # dp[u] = max(dp[u], l)
    dp[u] = max(dp[u], l)
    for nx in dag[u]:
        indeg[nx] -= 1
        if indeg[nx] == 0:
            q.append((nx, l + 1))
print(max(dp))


Measured memory_bytes: 96752
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    long long int n,d;
    cin>>n>>d;
    long long int count=0;
    long long int j=d*d;
    while(n--){
     long long int p,q;
     cin>>p>>q;
     long long int r=p*p+q*q;
     if(r<=j){
      count++;
     }
     
    }
    cout<<count<<endl;
   return 0;
}

Measured memory_bytes: 3632
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	vector < pair < pair < string, int >, int > > v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first.first >> v[i].first.second;
		v[i].second = i;
	}
	sort(all(v), [](auto a, auto b) {
		if (a.first.first == b.first.first) {
			return a.first.second > b.first.second;
		} else {
			return a.first.first < b.first.first;
		}
	});
	for (auto &el: v) {
		cout << el.second + 1 << "\n";
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      int t = Integer.parseInt(sc.next());

      int ans = 0;

      for(int i=a;i<=t+0.5;i+=a){
        ans += b;
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 23124
text=input()
N=len(text)
count0=0
count1=0
sgn=0
for i in range(N):
  if(int(text[i])==sgn):
    count1=count1+1
  else:
    count0=count0+1
  sgn=1-sgn
print(min([count0,count1]))


  

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int X[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    int K;
    cin >> K;
    cout << X[K - 1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int main() {
  int n;
  cin >> n;
  cout << n / 3 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

const int N = 1e6+7;
int l,r;

int32_t main()
{
	fast;

	cin>>l>>r;
	if(r-l+1>=2019)
		cout<<0;
	else
	{
		int min1 = 2019, min2 = 2019;
		int cnt[2019];
		memset(cnt,0,sizeof(cnt));
		for(int i=l;i<=r;i++)
			cnt[i%2019]++;
		int ans = 1000000000;
		for(int i=0;i<2019;i++)
			if(cnt[i])
				for(int j=i+1;j<2019;j++)
					if(cnt[j])
						ans = min(ans,(i*j)%2019);
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
/**
*
* Author: MARS
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair<int,int>

typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl pi = acos(-1);
const ll inf = 1LL<<30;
const dbl eps = 1e-9;
const ll mod = 1e9+7;

/** /////////// ** Code ** /////////// **/

const int N=0;

int main(){
    char a[11];
    scanf("%s",&a);
    if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R'){
        printf("3");
        return 0;
    }

    if(a[0] == 'R' && a[1] == 'R'){
        printf("2");
        return 0;
    }

    if(a[1] == 'R' && a[2] == 'R'){
        printf("2");
        return 0;
    }

    if(a[0] == 'R' || a[1] == 'R' || a[2] == 'R'){
        printf("1");
        return 0;
    }

    printf("0");
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

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

int main() {
	FAST;

	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	c *= 2;

	int f1=0,f2=0,f3=0;
	if (c < a+b) f1=1;
	if (c<a) f2=1;
	if (c<b) f3=1;
	int sxy = min(x,y);
	int sum = 0;

	if (f1) {
		x-=sxy;
		y-=sxy;
		sum += c*sxy;
		if (x>y) {
			if (f2) sum += c*x;
			else sum += a*x;
		}
		else {
			if (f3) sum += c*y;
			else sum += b*y;
		}
	}
	else {
		sum+=a*x+b*y;
	}

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

vector<bool> seen;
void dfs(vector<vector<int>> &Graph,vector<int> &cnt,int v){
  seen[v]=true;
  for(auto nv:Graph[v]){
    if(seen[nv]==true){
      continue;
    }
    cnt[nv]+=cnt[v];
    dfs(Graph,cnt,nv);
  }
}

int main()
{
  int N, Q;
  cin >> N >> Q;
  vector<P> A(N-1);
  vector<vector<int>> C(N,vector<int>());
  REP(i,N-1){
    cin >> A[i].first >> A[i].second;
    A[i].first--;
    A[i].second--;
    C.at(A[i].first).push_back(A[i].second);
    C.at(A[i].second).push_back(A[i].first);
  }
  vector<P> B(Q);
  REP(i,Q){
    cin >> B[i].first >> B[i].second;
    B[i].first--;
  }
  vector<int> cnt(N,0);
  REP(i,Q){
    cnt[B[i].first]+=B[i].second;
  }

  seen.assign(N,false);
  dfs(C,cnt,0);

  REP(i,N){
    if(i!=N-1){
      cout << cnt[i] << " ";
    }else{
      cout << cnt[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 29824
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll N;
	std::cin >> N;

	ll ans = 0;
	for(ll i=1;i*i<N;i++)	{
		if ((N - i) % i == 0) {
			ll tmp = (N - i) / i;
			if (N / tmp == N % tmp) {
				ans += tmp;
			}
		}
	}
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;
 
int main() {
  int N, A, B, ret;
  cin >> N >> A >> B;
  
  ret = min(N*A, B);
  cout << ret << endl;
  
  return 0;
}

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

typedef long long ll;
const int mx=200009;
ll mod=1000000007;
  ll a[mx];
 /*
  int siz[mx];
  int par[mx];
  


  int parent(int i){
      while(i!=par[i]){
          i=par[i];
      }
      return i;
  }
  void unit(int x,int y){
      
      if(siz[x]<siz[y]){swap(x,y);}
     
          int par1=parent(x);
          int par2=parent(y);
      par[par2]=par1;
      siz[par1]+=siz[par2];
      
      
  }bool same(int a, int b) {
return parent(a) == parent(b);
}
*/
vector<int>edges[mx];
int visited[mx];
int dfs(int i){
    if(visited[i]){return 0;}
    visited[i]=1;ll ans=0;
    for(int j=0;j<edges[i].size();j++){
        ans+=dfs(edges[i][j]);
    }return ans+1;
    
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
  
  ll n,m;
  cin>>n>>m;
 int ans=0;
  for(int i=1;i<=m;i++){
    int x,y;
    cin>>x>>y;
    
   edges[x].push_back(y);edges[y].push_back(x);
  }
    for(int i=1;i<=n;i++){
 if(!visited[i]){
     ans=max(ans,dfs(i));
 }
  } 
cout<<ans;
    
}


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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  dsu d(N);
  REP(i, M){
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    d.merge(A[i], B[i]);
  }
  cout << (int)d.groups().size()-1 << endl;
  return 0;
}


Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> e_num(n, 0);
    vector<int> w_num(n, 0);
    if ( s[0] == 'E' ) e_num[0] = 1;
    if ( s[0] == 'W' ) w_num[0] = 1;
    for ( int i = 1; i < n; i++ ) {
        if ( s[i] == 'E' ) e_num[i] = e_num[i-1] + 1;
        else               e_num[i] = e_num[i-1];
        if ( s[i] == 'W' ) w_num[i] = w_num[i-1] + 1;
        else               w_num[i] = w_num[i-1];
    }
    int ans = 1e8;
    rep(i, n) {
        if ( i == 0 ) {
            ans = min( ans, e_num[n-1] - e_num[i] );
        }
        else if ( i == n - 1 ) {
            ans = min( ans, w_num[i-1] );
        }
        else {
            ans = min( ans, e_num[n-1] - e_num[i] + w_num[i-1] );
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      vs: [usize; n],
    }

    use std::collections::HashMap;
    let mut a = HashMap::new();
    let mut b = HashMap::new();

    for i in 0..n/2 {
        let x = i*2;
        let y = i*2+1;
        *a.entry(vs[x]).or_insert(0) += 1;
        *b.entry(vs[y]).or_insert(0) += 1;
    }
    let mut a: Vec<(usize, usize)> = a.iter().map(|(&a, &b)| (a, b)).collect();
    a.sort_by_key(|&(_, b)| b);
    a.reverse();
    let mut b: Vec<(usize, usize)> = b.iter().map(|(&a, &b)| (a, b)).collect();
    b.sort_by_key(|&(_, b)| b);
    b.reverse();

    let (r1, c1) = a[0];
    let (r2, c2) = b[0];
    if r1 != r2 {
        return println!("{}", n-c1-c2);
    }
    let mut ans = n;
    if a.len() >= 2 {
        ans = min(ans, n-a[1].1-b[0].1);
    }
    if b.len() >= 2 {
        ans = min(ans, n-a[0].1-b[1].1);
    }
    if a.len()==1 && b.len() == 1 {
        ans = min(ans, n/2);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
const long long M=1e9+7;
map<long long,long long>d;
long long n,ans;
long long qwq(long long x){
    if(d[x]!=0) return d[x];
    else return d[x]=((qwq(x/2)+qwq((x-1)/2)+qwq((x-2)/2)))%M;
}
int main(void){
    d[0]=1,d[1]=2;
    cin>>n;
    ans=qwq(n);
    printf("%lld\n\r",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int a[N], diff[N];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, m;
	cin >> n >> m;

	for(int i = 0; i < m; i++){
		cin >> a[i];
	} 
	sort(a, a + m);

	for(int i = 0; i < m-1; i++){
		diff[i] = a[i+1] - a[i];
	}
	sort(diff, diff + m - 1);
	int sum = 0;

	if(n >=  m) cout << "0";
	else{
		for(int i = 0; i < m-n; i++){
			sum += diff[i];
		}
		cout << sum ;
	}

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ull i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();
  ll n,w,smv=0;cin>>n>>w;
  vector<ll>a(n),v(n);
  for(int i = 0;i<n;i++)cin>>a[i]>>v[i],smv+=v[i];

  vector<ll>dp(smv+5,1e18);
  dp[0] = 0;
  for(int i = 0;i<n;i++)
  {
    for(int j = smv-v[i];j>=0;j-- )
    {
      dp[j+v[i]] = min(dp[j+v[i]],dp[j]+a[i]);
    }
  }
  for(int i = smv+1;i>=0;i--)if(dp[i]<=w){cout<<i;return 0;}



  return 0;
}

Measured memory_bytes: 1024
import math
a,b,x = map(int,input().split())
if x>=a*a*b*0.5:
    theta = math.degrees(math.atan(2*(a*a*b-x)/a**3))
else:
    theta = math.degrees(math.atan(0.5*a*b*b/x))
print(theta)

Measured memory_bytes: 9208