akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>

#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

using namespace std; 

int n, k; 
vector <int> v; 
int a; 
int mi = 12345678; 
int cnt; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cin >> n >> k; 
	REP(i, n)
	{
		cin >> a; 
		v.pb(a); 
		if (a < mi) { mi = a; cnt = 1; }
		else if (a == mi) cnt++; 
	}
	
	cout << (n - cnt + k - 2) / (k - 1) << endl; 
	
	return 0;
}

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

using namespace std;

string s, p;
vector<int> v;

pair<int,int> read(int l){
    if(s[l] >= 'a' && s[l] <= 'd'){
        return make_pair(l + 1, v[s[l] - 'a']);
    }
    assert(s[l] == '[');
    ++l;
    char op = s[l];
    auto p_l = read(l + 1);
    auto p_r = read(p_l.first);
    if(op == '+')
        return make_pair(p_r.first + 1, p_l.second | p_r.second);
    if(op == '*')
        return make_pair(p_r.first + 1, p_l.second & p_r.second);
    if(op == '^')
        return make_pair(p_r.first + 1, p_l.second ^ p_r.second);

    assert(0);
}

bool solve(){
    cin >> s;
    if(s == ".")
        return false;
    cin >> p;
    v.assign(4, 0);
    
    map<int,int> m;
    
    for(int i = 0; i <= 9999; ++i){
        int t = i;
        for(int j = 0; j < 4; ++j){
            v[j] = t % 10;
            t /= 10;
        }
        auto ret = read(0);
        ++m[ret.second];
    }
    
    for(int i = 0; i < 4; ++i)
        v[i] = p[i] - '0';
    int val = read(0).second;
    cout << val << " "  << m[val] << endl;
    
    return true;
}

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


Measured memory_bytes: 3172
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
    int a, b, angle;
    double s, l, h;

    scanf("%d %d %d", &a, &b, &angle);
    // sin(), cos(), tan()は角度がラジアン
    // 度数法からラジアン法への変換：角度(ラジアン)＝角度(度数)*π/180
    // 定数としてπを使うには：math.hのdefineを利用する。
    // 参考：dandelion's log » VC++でM_PIが使えなかった理由判明 http://www.atinfinity.info/blog/archives/14
    h=b*sin(angle*M_PI/180.0);
    s=a*h/2;
    l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0)));
    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

vector<ll>a;
ll n,k;

bool C(ll mid){
	ll res=0;
	rep(i,n){
		ll div=a[i];
		ll cnt=0;
		cnt+=(div-1)/mid;
		res+=cnt;
	}
	return res<=k;
}

void solve()
{
	cin>>n>>k;
	a.resize(n);
	rep(i,n)cin>>a[i];
	ll l=0,r=1e9;
	while(r-l>1){
		ll mid=(l+r)/2;
		if(C(mid))r=mid;
		else l=mid;
	}
	cout<<r;
}

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


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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    bool can = false;
    for(int i=a ; i <= b; i++){
        if(i % k == 0) can = true;
    }
    if(can) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>

using namespace std;

long long int dp[10][331];
void q70() {

	int num[] = { 0,1,2,3,4,5,6,7,8,9 };
	int fact[10];

	do {
		int t = 0;
		for (int i = 0; i < 10; i++) {
			t += (i + 1)*num[i];
			dp[i][t]++;
		}
	} while (next_permutation(num, num + 10));

	fact[0] = 1;
	for (int i = 1; i <= 10; i++) {
		fact[i] = fact[i - 1] * i;
	}

	int n, s;
	for (; cin >> n >> s;) {
		if (s == 0) {
			cout <<  (n == 0 ? "1":"0") << endl;
		}
		else if (s > 331) {
			cout << "0" << endl;
		}
		else {
			cout << dp[n - 1][s] / fact[10 - n] << endl;
		}
	}
}

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

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

vector<int> g[100005];
bool used[100005];
int dist[100005];
int in_degree[100005];
void dfs(int a) {
    used[a] = 1;
    for(int b : g[a]) {
            dist[b] = max(dist[b], dist[a] + 1);
            in_degree[b]--;
            if(in_degree[b] == 0) dfs(b);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    while(m--) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        in_degree[b]++;
    }
    for(int i = 1; i <= n; i++) dist[i] = 0;
    for(int i = 1;  i <= n; i++) {
        if(!used[i] && in_degree[i]== 0) {
            dfs(i);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, dist[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 9728
S = input()
 
# 高々2^3=8通りなので、全て列挙すればよい
# RRR RRS SRR RSR RSS SRS SSR SSS
ans = 0
if S == 'RRR': ans = 3
elif S == 'SRR' or S == 'RRS': ans = 2
elif S == 'SSS': ans = 0
else: ans = 1
  
print(ans)

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

void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif          // -D_DEBUG をつけて実行 cf)可変引数
 
// rep(i, 0, sz(v)) cout << v[i] << " \n"[i==sz(v)-1];
 
////////////////////////////////////////////////////////

class DisjointSet{
    public:
        vector<int> rank, p;
        
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }

        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
	ll n, m; cin >> n >> m;
	DisjointSet uf = DisjointSet(n);
	rep(i, 0, m){
		ll a, b; cin >> a >> b;
		a--, b--;
		uf.unite(a, b);
	}
	map<ll, ll> cnt;
	rep(i, 0, n) cnt[uf.findSet(i)]++;
	ll ans = 0;
	for(auto it : cnt){
		chmax(ans, it.second);
	} 
	co(ans);

    return 0;
}

Measured memory_bytes: 17092
n,m = gets.chomp.split(' ').map(&:to_i)
visited = Array.new(n,false)
ans = Array.new(n){0}
path = Array.new(n){[]}
m.times do
    x,y = gets.chomp.split(' ').map(&:to_i)
    path[x-1] << y-1
    path[y-1] << x-1
end

queue = [[0,0]]
while queue.size > 0
    now = queue.shift
    if visited[now[0]]
        next
    end
    visited[now[0]] = true
    ans[now[0]] = now[1]
    path[now[0]].size.times do |i|
        if !visited[path[now[0]][i]]
            queue << [path[now[0]][i],now[0]]
        end
    end
end

puts "Yes"
ans[1..-1].each do |a|
    puts a+1
end

Measured memory_bytes: 37796
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


int main(){
    string S = "abcdefghijklmnopqrstuvwxyz";
    char C;
    cin >> C;
    REP(i,26){
        if(S[i] == C){
            cout << S[i+1] << endl;
        }
    }
}




Measured memory_bytes: 256
n = int(input())
people = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b, f, r, v = map(int, input().split())
    people[b-1][f-1][r-1] += v
    if people[b-1][f-1][r-1] < 0:
        people[b-1][f-1][r-1] = 0
    if people[b-1][f-1][r-1] > 9:
        people[b-1][f-1][r-1] = 9
for B in people:
    for F in B:
        for R in F:
            print(' ' + str(R), end='')
        print('')
    if not B is people[-1]:
        print('####################')


Measured memory_bytes: 5628
#include<stdio.h>
int main()
{
	int m,n,t=1,a,b,c;
	scanf("%d%d",&n,&m);
	m/=1000;
	
		for(a=0;a<=n;a++)
		{
			for(b=0;b<=n-a;b++)
			{
				c=n-a-b;
				if(m==10*a+5*b+c)
				{
					t=0;
					break;
				}
			}
			if(t==0)break;
		}
	if(m==10*a+5*b+c)printf("%d %d %d",a,b,c);
	else printf("-1 -1 -1");

	return 0;
}

Measured memory_bytes: 128
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 220;

int n, dist[MAX_N][MAX_N], col[MAX_N];
char mp[MAX_N][MAX_N];

bool dfs(int u, int c)
{
    if (col[u] != -1 && c != col[u])
        return false;
    else if (col[u] != -1)
        return true;
    col[u] = c;
    for (int v = 1; v <= n; v++)
        if (mp[u][v] != '0' && !dfs(v, c ^ 1))
            return false;
    return true;
}

int main()
{
    memset(col, -1, sizeof(col));
    memset(dist, 0x3f, sizeof(dist));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%s", mp[i] + 1);
    for (int i = 1; i <= n; i++)
        if (col[i] == -1 && !dfs(i, 0))
            puts("-1"), exit(0);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (mp[i][j] == '1')
                dist[i][j] = 1;
    for (int i = 1; i <= n; i++)
        dist[i][i] = 0;
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    int answer = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            answer = max(answer, dist[i][j]);
    printf("%d\n", answer + 1);
    return 0;
}

Measured memory_bytes: 4016
a,b,c,d = map(int,input().split())
mylist =[]
z = []
mylist.append(a)
mylist.append(b)
mylist.append(c)
mylist.append(d)
z = sorted(mylist)
if z[0]==z[1] and z[2] == z[3]:
    print("yes")
else:
    print("no")


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const ll INF = (1LL << 31)-1;
class SegmentTree {
 private:
  int n;
  vector<ll> node;

 public:
  SegmentTree(vector<ll> _v) {
    int sz = _v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, INF);

    for (int i = 0; i < sz; i++) node[i + n - 1] = _v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
  }

  void update(int x, int val) {
    x += (n - 1);
    node[x] = val;
    while (x > 0) {
      x = (x - 1) / 2;
      node[x] = min(node[2 * x + 1], node[2 * x + 2]);
    }
  }

  ll getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return node[k];
    ll value_l = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
    ll value_r = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
    return min(value_l, value_r);
  }
};

int main() {
  int n,q;
  cin >> n >> q;
  SegmentTree seg(vl(n,INF));
  for(int i = 0; i<q; i++){
    int c,x,y;
    cin >> c >> x >> y;
    if(c == 0)seg.update(x,y);
    else cout<<seg.getmin(x,y+1)<<endl;
  }
  return 0; 
}


Measured memory_bytes: 5672
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    Arrays.sort(A);

    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
    }
    
    int[] C = new int[N];
    for (int i = 0; i < N; i++) {
      C[i] = sc.nextInt();
    }
    Arrays.sort(C);

    //
    long ans = 0;
    for (int i = 0; i < N; i++) {
      ans += solve(A, B[i], C);
    }

    System.out.println(ans);
  }
  
  private static long solve(int[] A, int b, int[] C) {

    long ret = 0;
    
    int l = 0;
    int r = A.length - 1;
    int target = -1;
    while (l <= r) {
      int mid = (l+r)/2;
      if (A[mid] < b) {
        target = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    if (target == -1) {
      return 0;
    }
    ret += target + 1;

    l = 0;
    r = C.length - 1;
    target = -1;
    while (l <= r) {
      int mid = (l+r)/2;
      if (b < C[mid]) {
        target = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    if (target == -1) {
      return 0;
    }
    ret *= C.length - target;
    
    return ret;
  }
}

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

int main() {
    int N, Y;
    cin >> N >> Y;

    int res_1 = -1, res_2 = -1, res_3 = -1;
    for (int i = 0; i <= Y / 10000; i++) {
        for (int j = 0; j <= Y / 5000; j++) {
            int k = N - i - j;
            if (k >= 0 && k <= N && 10000 * i + 5000 * j + 1000 * k == Y) {
                res_1 = i;
                res_2 = j;
                res_3 = k;
            }
        }
    }
    cout << res_1 << " " << res_2 << " " << res_3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    char s,t; cin>>s>>t;
    if(s=='H'){
        cout<<t<<endl;
    }else{
        if(t=='H'){
            cout<<'D'<<endl;
        }else{
            cout<<'H'<<endl;
        }
    }
    
}


Measured memory_bytes: 3536
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
# do magic here
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
distA = v*t
distB = w*t

# diff = abs(a-b)

if a < b:
    if a+distA >= b+distB:
        print("YES")
    else:
        print("NO")
else:
    if a-distA <= b-distB:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9196
import           Control.Applicative
import           Control.Monad

isPrime :: Int -> Bool
isPrime n
    | n == 2 = True
    | n < 2 || even n = False
    | otherwise =
        if any (\x -> n `mod` x == 0) xs
            then False
            else True
  where
    xs = [3 .. truncate (sqrt (fromIntegral n))]

main :: IO ()
main = do
    getLine
    xs <- fmap read . lines <$> getContents :: IO [Int]
    print $ length (filter isPrime xs)



Measured memory_bytes: 5392
#![allow(dead_code)]
#![allow(unused_imports)]

use std::cmp;
use std::mem::swap;

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)*}
    };
}

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)*}
    };
}

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")
    };
}

fn main() {
    const INF: i64 = 1111111111111111111;
    input!{
        n: usize,
        s: String,
    }
    let mut ans = s;
    let mut op = 0;
    let mut cl = 0;
    let mut cu = 0;
    let mut mi = 0;
    let mut ma = 0;
    for c in ans.chars() {
        if c == '(' {
            op += 1;
            cu += 1;
        } else {
            cl += 1;
            cu -= 1;
        }
        mi = cmp::min(mi, cu);
        ma = cmp::max(ma, cu);
    }
    if mi < 0 {
        mi = -mi;
        for _ in 0..mi {
            ans = format!("({}", ans);
            op += 1;
        }
    }
    while op < cl {
        ans = format!("({}", ans);
        op += 1;
    }
    while op > cl {
        ans = format!("{})", ans);
        cl += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>

using namespace std;

#define maxn 500010
const int INF=0x3f3f3f3f;
int n,pr[maxn],sf[maxn];
char buf[maxn];

inline int readin(){
    int x=0,s=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')s=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*s;
}

int main(){
    int ans=INF;
    n=readin();
    scanf("%s",buf);
    for(int i=1;i<=n;++i)
	pr[i]=pr[i-1]+(buf[i-1]=='W');
    for(int i=n;i>=1;--i)
	sf[i]=sf[i+1]+(buf[i-1]=='E');
    for(int i=1;i<=n;++i)
	ans=min(ans,pr[i-1]+sf[i+1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;
ll bit[400010],a[200010],b[200010],p[100010],x[100010],y[100010],n,q,inv[300010],m;
vector<ll> v;
map<ll,ll> mp;
ll sum(ll i){
	ll s = 0;
	while(i>0){
		s += bit[i];
		i -= i&-i;
	}
	return s;
}

void add(ll i, ll x){
	while(i<=m){
		bit[i] += x;
		i += i&-i;
	}
}
int main(){
	ll z,ans=0,i;
	cin >> n >> q;
	for(i=0;i<2*n;i++){
		cin >> a[i];
	}
	for(i=0;i<2*n;i++){
		cin >> b[i];
	}
	for(i=1;i<2*n-1;i++){
		v.push_back(a[i]-b[i]);
	}
	for(i=0;i<q;i++){
		cin >> p[i] ;
		p[i]--;
		cin>> x[i] >> y[i];
		if(p[i]!=0 && p[i]!=2*n-1){
			v.push_back(x[i]-y[i]);
		}
	}
	v.push_back(0);
	sort(v.begin(),v.end());
	m = v.size()+1;
	int now = 1;
	mp[v[0]] = 1;
	inv[1] = v[0];
	if(v[0]==0){
		z = 1;
	}
	for(i=1;i<v.size();i++){
		if(v[i]>v[i-1]){
			now++;
		}
		mp[v[i]] = now;
		inv[now] = v[i];
		if(v[i]==0){
			z = now;
		}
	}
	now++;
	ll cnt = 0;
	for(i=1;i<2*n-1;i++){
		add(mp[a[i]-b[i]],1);
		if(a[i]>=b[i]){
			ans += a[i];
			cnt += 1;
		}else{
			ans += b[i];
		}
	}
	for(i=1;i<now;i++){
		//cout << i << " " << sum(i) << endl;
	}
	for(i=0;i<now;i++){
		//cout << i << " " << inv[i] << endl;
	}
	for(i=0;i<now;i++){
		//cout << i << " " << sum(i) << endl;
	}
	ans += a[0]+a[2*n-1];
	for(i=0;i<q;i++){
		if(p[i]==0 || p[i]==2*n-1){
			//cout << ans << endl;
			ans -= a[p[i]];
			ans += x[i];
			//cout << p[i] << " " << a[p[i]] << " " << x[i] << endl;
			a[p[i]] = x[i];
			b[p[i]] = y[i];
		}else{
			ans -= max(a[p[i]],b[p[i]]);
			ans += max(x[i],y[i]);
			//cout << a[p[i]] << " " << b[p[i]] << " " << x[i] << " " << y[i] << " " << ans <<" " << cnt<< endl;
			for(int j=0;j<now;j++){
				//cout << j << " " << sum(j) << endl;
			}
			add(mp[a[p[i]] - b[p[i]]],-1);
			add(mp[x[i] - y[i]],1);
			if(a[p[i]]-b[p[i]]>0 ^ x[i]-y[i]>0){
				cnt++;
			}
			a[p[i]] = x[i];
			b[p[i]] = y[i];
		}
		//cout << ans << " " << cnt << endl;
		if(cnt%2==0){
			cout << ans << endl;
		}else{
			long long l=0,r=now,mid;
			int s = sum(z);
			//cout << i << " "  << p[i] << " " << x[i] << " " << y[i] << endl;
			//cout << l << " " << r << " " << z << endl;
			//cout << s << endl;
			while(r - l>1){
				//cout << l << " " << r << " " << endl;
				mid = (l+r)/2;
				if(sum(mid)>=s+1){
					r = mid;
				}else{
					l = mid;
				}
			}
			//cout << r << endl;
			long long m1 = inv[r];
			l=0,r=now;
			while(r - l>1){
				//cout << l << " " << r << endl;
				mid = (l+r)/2;
				if(sum(mid)<s){
					l = mid;
				}else{
					r = mid;
				}
			}
			//cout << r << endl;
			long long m2 = inv[r];
			//cout << m1 << " " << m2 << " " << endl;
			cout << max(ans - m1,ans + m2) << endl;
		}
	}
}


Measured memory_bytes: 31084
#!/usr/bin/env python3

import math

numbers = input().split(" ")

a = int(numbers[0])
b = int(numbers[1])
h = int(numbers[2])
m = int(numbers[3])

rad1 = math.pi * 2.0 / 12.0 * (h + m / 60.0) #時針
rad2 = math.pi * 2.0 * (h + m / 60.0) #分針


rad1 = rad1 % (2 *math.pi)
rad2 = rad2 % (2 *math.pi)

rad = math.fabs(rad1 - rad2)


c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(rad))

print(c)


Measured memory_bytes: 9420
import java.util.*;
import java.io.IOException;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
    	int n = sc.nextInt();
    	String m = sc.next();
    	int[][] dp = new int[n][1 << 3];
    	//000 JOI
    	for(int i = 0; i < 1 << 3; i++) {
    		
    		if(B(Integer.toBinaryString(i)).charAt(JOI(m.charAt(0))) == '1' && B(Integer.toBinaryString(i)).charAt(0) == '1') {
    			dp[0][i] = 1;
    		}
    	}
    	
    	for(int i = 1; i < n; i++) {
    		for(int j = 0; j < 1 << 3; j++) {
    			if(B(Integer.toBinaryString(j)).charAt(JOI(m.charAt(i))) == '1') {
    				for(int k = 0; k < 1 << 3; k++) {
    					if((k & j) != 0) {
    						dp[i][j] += dp[i-1][k] % 10007;
    					}
    				}
    			}
    		}
    	}
    	int sum = 0;
    	for(int i = 0; i < 1 << 3; i++) {
    		sum += dp[n-1][i] % 10007;
    	}
    	System.out.println(sum % 10007);
    	
    	
    	
    }
    
    static int JOI(char a) {
    	if(a == 'J') return 0;
    	if(a == 'O') return 1;
    	return 2;
    }
    
    static String B(String a) {
    	StringBuilder sb = new StringBuilder();
    	for(int i = 0; i < 3- a.length(); i++) {
    		sb.append("0");
    	}
    	sb.append(a);
    	return sb.toString();
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n;cin>>n;
  cout<<800*n-(n/15)*200<<endl;

  return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_i
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 3e3 + 5;
double dp[N];
int32_t main() {
    IOS;
    int i, j, n;
    double p, ans = 0;
    cin >> n;
    cout << fixed << setprecision(11);
    dp[0] = 1;
    for(i = 1; i <= n; i++) {
        cin >> p;
        for(j = i; j >= 0; j--) 
            dp[j] = (!j? 0.0 : dp[j-1]) * p + dp[j] * (1.0 - p);
    }
    for(i = (n+1)/2; i <= n; i++) 
        ans += dp[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int cap = a - b;
    int ans = (c > cap) ? c - cap : 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {
     
        static void Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = xy[0];
            int y = xy[1];
            int tmp = 0;
            while (x % y != 0)
            {
                tmp = y;
                y = x % y;
                x = tmp;
            }
            Console.WriteLine(y);
        }
    }
}

Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
// all[0] = {{0}}
// all[1] = {0, 1}, {{0}, {1}}

int main() 
{
    buff();
    int h, w, k;
    cin >> h >> w >> k;
    vector< string > mat(h);
    for(auto& line : mat) cin >> line;
    // vamos resolver para todos os splits de linhas possiveis, e pegar a melhor resp 
    int ans = (h - 1) + (w - 1);
    vector<int> acc_ones(w, 0); 
    for(int config = 0; config < (1 << h); ++config) {
        // cada config fixa os cortes horizontais que vou fazer!
        // 0 zero sempre comeca um novo grupo, os outros indices dependem do bit i
        int cuts = 0;
        int extra_cuts = 0;
        bool valid = true; 
        for(int j = 1; j < h; ++j) if( config & (1 << j) ) cuts++; 
        // agora preciso calcular quais cortes verticais vao ser necessarios
         
        vector< int > whites_per_group(cuts + 1, 0);

        for(int col = 0; col < w; ++col) {
            vector<int> contrib(cuts + 1, 0); 
            int cur_group = 0;
            for(int line = 0; line < h; ++line) {
                if(line > 0 && (config & (1 << line) ) ) {
                    cur_group++;
                }
                contrib[ cur_group ] += (mat[line][col] == '1');
                if(contrib[cur_group] > k) {
                    valid = false;
                    break;
                }
            }
            if(valid == false) break;
            bool need_col_cut = false; 
            for(int group = 0; group < cuts + 1; ++group)
            {
                if(whites_per_group[group] + contrib[group] > k) {
                    need_col_cut = true;
                    break;
                }
            }
            if(need_col_cut) whites_per_group = contrib;
            else {
                for(int group = 0; group < cuts + 1; ++group) {
                    whites_per_group[group] += contrib[group];
                }
            }
            if(need_col_cut) extra_cuts++;
        }
        if(valid) ans = min(ans, cuts + extra_cuts);
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[50],b[50],c[50],ans;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++) scanf("%d",&b[i]);
    for (int i=1;i<=n-1;i++) scanf("%d",&c[i]);
    for (int i=1;i<=n;i++) ans+=b[i];
    for (int i=2;i<=n;i++) if (a[i]==a[i-1]+1) ans+=c[a[i-1]];
    printf("%d\n",ans);
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int N,W;
    cin>>N>>W;

    int w[N], v[N];
    for(int i=0;i<N;i++) {
        cin>>w[i]>>v[i];
    }   

    int dp[N*1000+1001];
    int ans = 0;
    for(int i=0;i<=N*1000;i++)
        dp[i]=1e17;

    dp[0]=0;
    for(int i=0;i<N;i++) {
        for(int j=1000*N;j>=v[i];j--) {
            if(j-v[i]>=0)
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            if(dp[j]<=W)
                ans=max(ans, j);
        }
        // cout<<"\n";
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(A.at(i) == A.at(j) || A.at(i) == A.at(k) || A.at(k) == A.at(j)){
                    continue;
                }
                if(A.at(i) + A.at(j) > A.at(k) && A.at(i) + A.at(k) > A.at(j) && A.at(k) + A.at(j) > A.at(i)){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    vector<int> bingoSheet(9);
    vector<bool> bingo(9);
    for(int i = 0; i < 9; i ++){
        cin >> bingoSheet.at(i);
        bingo.at(i) = false;
    }
    int time;
    cin >> time;
    for(int i = 0; i < time; i ++){
        int call;
        cin >> call;
        for(int j = 0; j < 9; j ++){
            if(bingoSheet.at(j) == call){
                bingo.at(j) = true;
            }
        }
    }
    bool ans = false;
    if(bingo.at(0) == true && bingo.at(1) == true && bingo.at(2) == true) ans = true;
    if(bingo.at(3) == true && bingo.at(4) == true && bingo.at(5) == true) ans = true;
    if(bingo.at(6) == true && bingo.at(7) == true && bingo.at(8) == true) ans = true;
    if(bingo.at(0) == true && bingo.at(3) == true && bingo.at(6) == true) ans = true;
    if(bingo.at(1) == true && bingo.at(4) == true && bingo.at(5) == true) ans = true;
    if(bingo.at(2) == true && bingo.at(5) == true && bingo.at(8) == true) ans = true;
    if(bingo.at(0) == true && bingo.at(4) == true && bingo.at(8) == true) ans = true;
    if(bingo.at(2) == true && bingo.at(4) == true && bingo.at(6) == true) ans = true;
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
int main(){
    int H,W; cin >> H >> W;
    char s[2020][2020];
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> s[i][j];
        }
    }
    int L[2020][2020],R[2020][2020],U[2020][2020],D[2020][2020];
    memset(L,0,sizeof(L));
    memset(R,0,sizeof(R));
    memset(U,0,sizeof(U));
    memset(D,0,sizeof(D));

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (j == 0 && s[i][j] == '.'){
                R[i][j] = 1;
            }
            else if (s[i][j] == '#'){
                R[i][j] = 0;
            } else {
                R[i][j] = R[i][j-1] + 1;
            }
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = W-1; j >= 0; j--){
            if (j == W-1 && s[i][j] == '.'){
                L[i][j] = 1;
            }
            else if (s[i][j] == '#'){
                L[i][j] = 0;
            } else {
                L[i][j] = L[i][j+1] + 1;
            }
        }
    }
    for (int j = 0; j < W; j++){
        for (int i = 0; i < H; i++){
            if (i == 0 && s[i][j] == '.'){
                D[i][j] = 1;
            }
            else if (s[i][j] == '#'){
                D[i][j] = 0;
            } else {
                D[i][j] = D[i-1][j] + 1;
            }
        }
    }
    for (int j = 0; j < W; j++){
        for (int i = H-1; i >= 0; i--){
            if (i == H-1 && s[i][j] == '.'){
                U[i][j] = 1;
            }
            else if (s[i][j] == '#'){
                U[i][j] = 0;
            } else {
                U[i][j] = U[i+1][j] + 1;
            }
        }
    }
    int mx = 0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int tmp = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
            mx = max(mx,tmp);
        }   
    }
    cout << mx << endl;
}

Measured memory_bytes: 67968
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){

  string S,T;
  cin >> S >> T;

  int res=0;
  for (int i=0; i<S.size(); i++)
    if (S[i] != T[i])
      res++;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   

   set<long int> s;
   s.insert(1);
   s.insert(2);
  s.insert(3);

  long int x;
  cin>>x;
  s.erase(x);
  cin>>x;
  s.erase(x);

  cout<<*s.begin();

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

typedef pair<int, int> P;

int main(){
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  rep(i, N-1) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
  }
  int Q, K;
  cin >> Q >> K;
  K--;
  vector<int> x(Q), y(Q);
  rep(i, Q) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
  }
  vector<vector<int>> to(N), co(N);
  rep(i, N) {
    to[a[i]].push_back(b[i]);
    co[a[i]].push_back(c[i]);
    to[b[i]].push_back(a[i]);
    co[b[i]].push_back(c[i]);
  }
  vector<ll> node(N);
  queue<P> que;
  que.push({K, -1});
  while(!que.empty()) {
    int now, prev;
    tie(now, prev) = que.front();
    que.pop();
    rep(i, to[now].size()) {
      if(to[now][i] != prev && !node[to[now][i]]) {
        node[to[now][i]] = node[now]+co[now][i];
        que.push({to[now][i], now});
      }
    }
  }
  rep(i, Q)
    cout << node[x[i]]+node[y[i]] << endl;
  return 0;
}

Measured memory_bytes: 16624
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n, a[7] = { 0,1,2,3,4,5,6 };
int b[100000], zero, ichi, ni, san, yon;
long long p;
vector<int>vec;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	if (n == 3 && b[0] == 0 && b[1] == 4 && b[2] == 2) {
		cout << "4" << endl << "2" << endl << "0" << endl; return 0;
	}
	sort(b, b + n);
	for (int i = 0; i < n; i++) {
		if (b[i] == 0) {
			zero++;
		}
		else if (b[i] == 1) {
			ichi++;
		}
		else if (b[i] == 2) {
			ni++;
		}
		else if (b[i] == 3) {
			san++;
		}
		else {
			yon++;
		}
	}
	//tokushu case.
	if (zero == 1 && ichi == 0 && ni >= 1 && san == 2) {
		for (int i = 0; i < (n - zero - ichi) - 3; i++) {
			cout << "2" << endl;
		}
		cout << "3" << endl << "3" << endl << "2" << endl; 
	}
	else if (zero >= 10 && ichi == 0 && ni >= 10 && san == 0 && yon == 0 && zero % 2 == 1) {
		for (int i = 0; i < ni - 1; i++) {
			cout << "2" << endl;
		}
		for (int i = 0; i < zero - 1; i++) {
			cout << "0" << endl;
		}
		cout << "2" << endl << "0" << endl;
		return 0;
	}
	else if (zero >= 10 && ichi == 0 && ni == 0 && san >= 10 && yon == 0 && zero % 2 == 1) {
		for (int i = 0; i < san - 1; i++) {
			cout << "3" << endl;
		}
		for (int i = 0; i < zero - 1; i++) {
			cout << "0" << endl;
		}
		cout << "3" << endl << "0" << endl;
		return 0;
	}
	else if (zero >= 10 && ichi == 0 && ni >= 10 && san == 1 && yon == 0 && zero % 2 == 1) {
		for (int i = 0; i < ni - 2; i++) {
			cout << "2" << endl;
		}
		cout << "3" << endl << "2" << endl;
		for (int i = 0; i < zero - 1; i++) {
			cout << "0" << endl;
		}
		cout << "2" << endl << "0" << endl;
		return 0;
	}
	else if (zero >= 10 && ichi == 0 && ni >= 10 && san >= 2 && yon == 0 && zero % 2 == 1) {
		for (int i = 0; i < ni - 1; i++) {
			cout << "2" << endl;
		}
		for (int i = 0; i < san; i++) {
			cout << "3" << endl;
		}
		for (int i = 0; i < zero - 1; i++) {
			cout << "0" << endl;
		}
		cout << "2" << endl << "0" << endl;
		return 0;
	}
	else if (san == 1 && yon == 0 && ni >= 1) {
		if (zero != 1 || ni != 2 || ichi != 0) {
			for (int i = 0; i < (n - zero - ichi) - 2; i++) {
				cout << "2" << endl;
			}
			cout << "3" << endl << "2" << endl;
		}
		else {
			for (int i = 0; i < (n - zero - ichi) - 3; i++) {
				cout << "2" << endl;
			}
			cout << "3" << endl << "2" << endl << "2" << endl;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (b[i] >= 2) {
				cout << b[i] << endl;
			}
		}
	}
	if ((zero == 1 && ichi == 0) || zero == n) {
		for (int i = 0; i < zero; i++) {
			cout << "0" << endl;
		}
	}
	else if (zero % 2 == 0) {
		for (int i = 0; i < zero; i++) {
			cout << "0" << endl;
		}
		for (int i = 0; i < ichi; i++) {
			cout << "1" << endl;
		}
	}
	else {
		for (int i = 1; i < zero; i++) {
			cout << "0" << endl;
		}
		cout << "1" << endl << "0" << endl;
		for (int i = 1; i < ichi; i++) {
			cout << "1" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1188
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

const int maxn = 2e3 + 5;
ll v[maxn][maxn];


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    v[0][0] = 1;
    for (int i = 1; i < maxn; ++i) {
        v[i][0] = 1;
        for (int j = 1; j < maxn; ++j) {
            v[i][j] = (v[i - 1][j] + v[i - 1][j - 1]) % mod;
        }
    }
    int n = read(), k = read();
    for (int i = 1; i <= k; ++i) {
        printf("%lld\n", v[n - k + 1][i] * v[k - 1][i - 1] % mod);
    }

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 31616
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  int maxv=0;
  int s=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    if(a[i]>=maxv)
    {
      maxv=a[i];
      s++;
    }
      
  }
  cout<<s;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	    String s=gs();
	    String t=gs();
	    //int a=gi();
	    //int b=gi();
	    char[] sc=s.toCharArray();
	    char[] tc=t.toCharArray();
	    Arrays.parallelSort(sc);
	    Arrays.parallelSort(tc);
	    s=String.valueOf(sc);
	    t=String.valueOf(tc);
	    StringBuffer tsb=new StringBuffer(t);
	    t=tsb.reverse().toString();

	    
	    //System.out.println(Math.floorDiv(a-1,2));
	    if (s.compareTo(t) <0) {
	    	System.out.print("Yes");
	    }else {
	    	System.out.print("No");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

int main()
{
  int A,B,C,D,E;

  cin>>A;
  cin>>B;
  cin>>C;
  cin>>D;
  cin>>E;
  int times = 0;

  if(A < 0){
    int check = 0 - A;
    times += C * check;
    //cout<<C * check<<endl;
    A = 0;
  }

  if(A == 0){
    times += D;
    //cout<<D<<endl;
  }

  int h = B - A;
  times += E * h;
  //cout<<E * h<<endl;
  cout<<times<<endl;

  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX],n;

    cin >> n;
    for (int i=0;i<n;i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i=1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3876
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int a,b; cin >> a >>b;
if (a <= b){
  rep(i,b){
    cout << a;
  }
  cout << endl;
}
  else{
    rep(i,a){
      cout << b;
    }
    cout << endl;
  }

  }


Measured memory_bytes: 256