akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
#define erase(i) erase(i, 1)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main()
{
    int n,k;
    cin >> n >> k;
    vi l(n);
    rep(i,n)cin >> l[i];
    RSORT(l);
    int ans = 0;
    rep(i,k)ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>

#define MAX 20000010
#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n, m, L[MAX], R[MAX], Q[MAX];

int main(){
    int i, j, k, l, x, y;

    while (scanf("%d %d", &n, &m) != EOF){
        clr(Q);
        while (m--){
            scanf("%d %d", &x, &y);
            Q[x] = y;
        }

        for (i = 0; i < MAX; i++) L[i] = R[i] = i;
        for (i = 0; i < MAX; i++){
            if (Q[i]){
                k = Q[i], l = Q[i] + 1;
                L[k] = L[l] = min(L[k], L[l]);
                R[k] = R[l] = max(R[k], R[l]);
            }
        }

        for (i = 1; i <= n; i++){
            if (i > 1) putchar(32);
            printf("%d", R[i] - L[i] + 1);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 234992
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e18
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 

ll ncr(ll n,ll r)
{
    if(n<2)
        return 0;
    ll ans = 1;
    r = min(r,n-r);
    for(int i=0;i<r;i++)
    {
        ans = ans*(n-i)/(i+1);
    }
    return ans;
}

void solve()
{
	ll n;
	cin>>n;
	map<ll,ll> fre;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		fre[arr[i]]++;
	}
	ll ans = 0;
	for(auto it1:fre)
	{
		ans = ans + ncr(it1.second,2);
	}
	ll dp[200010];
	memset(dp,-1,sizeof(dp));
	ll ans1 = ans;
	for(int i=0;i<n;i++)
	{
		if(dp[arr[i]]!=-1)
		{
			cout<<dp[arr[i]]<<"\n";
			continue;
		}
		ans = ans - ncr(fre[arr[i]],2);
		fre[arr[i]]--;
		ans = ans +	ncr(fre[arr[i]],2);
		fre[arr[i]]++;
		cout<<ans<<"\n";
		dp[arr[i]] = ans;
		ans = ans1;
	}

}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int N;
int a[20000], b[20000];

int main(int argc, char **argv) {
	cin >> N;
	REP(i, N) {
		a[i] = 1 + i;
		b[i] = 999999999 - i;
	}
	REP(i, N) {
		int p;
		cin >> p;
		--p;
		FOR(j, p, N) a[j] += i;
		FOR(j, p + 1, N) b[j] -= i;
	}
	REP(i, N) {
		if (i != 0) cout << " ";
		cout << a[i];
	}
	cout << endl;
	REP(i, N) {
		if (i != 0) cout << " ";
		cout << b[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(){
    int A, B, K;
    cin >> A >> B >> K;
    
    for(int i = 0; i < K; i++){
        if(i % 2 == 0){
            if(A % 2 != 0){
                A -= 1;
            }
            B += A / 2;
            A -= A / 2;
        }
        else{
            if(B % 2 != 0){
                B -= 1;
            }
            A += B / 2;
            B -= B / 2;
        }
    }
    
    cout << A << " " << B << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;


int mod = 1e9 + 7;

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

void add(int& a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;

    vector<int> invs(N), suminv(N + 1);
    REP(i, N) {
        invs[i] = modinv(i + 1, mod);
        suminv[i + 1] = (suminv[i] + invs[i]) % mod;
    }

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

        add(ans, a * (suminv[i + 1] + suminv[N - i] - 1) % mod);
    }

    FOR(i, 1, N) {
        ans = (ans * i) % mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n, m, x, y;
  
  cin >> n >> m >> x >> y;
  
  vector<ll> xx(n);
  vector<ll> yy(m);
  rep(i, 0, n) cin >> xx[i];
  rep(i, 0, m) cin >> yy[i];
  sort(allg(xx));
  sort(all(yy));
  
  bool war = false;
  rep(i, x+1, y+1) {
    if(xx[0] < i and yy[0] >= i)
      war = true;
  }
  
  cout << ( !(war) ?"War" :"No War") << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

ll mul3(int a){
    ll ans = 1;
    rep(i, 3) ans *= a;
    return ans;
}

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

    ll ans = 1;
    if(K % 2 == 1){
        int a = N / K;
        ans = mul3(a);
    } else {
        int a = N / K;
        int b = N / (K / 2) - a;
        ans = mul3(a) + mul3(b);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int, int);

int main(){
    int n, i, max=0, work;
    int a[100000], l[100000], r[100000], m;

    scanf("%d", &n);

    l[0] = 0;
    r[n] = 0;

    for(i=0; i<n; i++)
        scanf("%d", &a[i]);

    for(i=0; i<n; i++)
        l[i+1] = gcd(l[i], a[i]);

    for(i=n-1; i>=0; i--){
        r[i] = gcd(r[i+1], a[i]);
    }

    for(i=0; i<n; i++){
        m = gcd(l[i], r[i+1]);
        if(max < m)
            max = m;
    }

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

    return 0;
}

int gcd(int a, int b){
    int r, work;

    if((a == 0 && b != 0) || (a != 0 && b == 0)){
        if(a == 0)
            return b;
        else
            return a;
    }

    if(a < b){
        work = a;
        a = b;
        b = work;
    }

    r = a % b;

    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}


Measured memory_bytes: 1280
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let t1: i64 = sc.read();
    let t2: i64 = sc.read();
    let mut a: Vec<i64> = sc.vec(2);
    let mut b: Vec<i64> = sc.vec(2);
    if a[0] < b[0] {
        std::mem::swap(&mut a, &mut b);
    }
    let a_sum = a[0] * t1 + a[1] * t2;
    let b_sum = b[0] * t1 + b[1] * t2;
    if a_sum == b_sum {
        println!("infinity");
        return;
    }
    // println!("{:?} {:?}", a, b);
    let c: Vec<i64> = vec![a[0] - b[0], a[1] - b[1]];
    let top = c[0] * t1;
    let down = top + c[1] * t2;
    if top > 0 && down < 0 {
        let d = down.abs();
        let cnt = top / d;
        let plus = if top % d == 0 { 1 } else { 0 };
        println!("{}", 2 * (cnt - plus) + plus + 1);
    } else {
        println!("0");
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(max(a) + 2)]

for num in a:
    if num != 0:
        b[num - 1] += 1
    b[num] += 1
    b[num + 1] += 1

print(max(b))


Measured memory_bytes: 13964
#include <iostream>
using namespace std;
int main(void){
    int i,j,count=0;
    int a,b,c,d,e;
    cin>>i>>j;
    for(int l=i;l<=j;l++){
        int k;
        k=l;
        a=k/10000;
        k=k-a*10000;
        b=k/1000;
        k=k-b*1000;
        c=k/100;
        k=k-c*100;
        d=k/10;
        k=k-d*10;
        e=k;
        if(a==e && b==d )
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import sys

n = ''
n = str(input())

darr = []
sp = []
s = []
for i in range(len(n)):
    if n[i] == '\\':
        darr.append(i)
    elif n[i] == '/':
        if len(darr) == 0:
            continue
        pre = darr.pop() 
        tmps = i - pre
        while len(sp) > 0 and sp[-1] > pre:
            sp.pop()
            tmps += s.pop()
        sp.append(pre)
        s.append(tmps)

print(sum(s))
arr = []
arr.append(len(s))
for i in s:
    arr.append(int(i))
print(' '.join(map(str, arr)))



Measured memory_bytes: 6168
// ABC058
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> count(26);
    vector<int> minCount(26, 100);

    rep(i, n)
    {
        string s;
        cin >> s;

        count.assign(count.size(), 0);

        rep(j, s.size()) count[s[j] - 'a']++;

        rep(j, 26) minCount[j] = min(minCount[j], count[j]);
    }

    rep(i, 26)
    {
        while (minCount[i] > 0)
        {
            cout << char('a'+i);
            minCount[i]--;
        }        
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;
int main() {
	int a;
	char s[10];
	cin >> a >> s;
	if (a >= 3200) {
		cout << s << endl;
	}
	if (a < 3200) {
		cout << "red" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp
K = gets.to_i

dict = []

s.chars.uniq.sort.each do |c|
  s.chars.each_with_index do |c2, i|
    if c == c2
      mx = i + K - 1
      if mx > s.size
        mx = s.size - 1
      end
      i.upto(mx) do |j|
        dict << s[i..j]
      end
    end
  end

  dict.uniq!
  dict.sort!

  if dict.size >= K
    puts dict[K - 1]
    exit
  end
end

Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	int n,m;
	cin>>n>>m;
	
	set<int> posx;
	
	vector<pii> v(n);
	rep(i,n){
		int x,y;
		cin>>x>>y;
		v[i] = pii(x,y);
		posx.insert(x);
	}
	
	map<int,int> zip,unzip;
	
	int c=0;
	for(auto &e:posx){
		zip[e] = c;
		unzip[c] = e;
		c++;
	}
	
	vector<vector<int>> r(posx.size());
	
	rep(i,v.size()){
		r[zip[v[i].first]].pb(v[i].second);
	}
	
	rep(i,r.size()-1){
		rep(j,r[i].size()){
			r[i+1].pb(r[i][j]);
		}
	}
	rep(i,r.size())sort(all(r[i]));
	
	
	rep(i,m){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		
		auto left = posx.lower_bound(x1);
		auto right = posx.upper_bound(x2);
		
		int sub=0,add=0;
		
		if(left==posx.begin())sub=0;
		else{
			left--;
			vector<int> &t = r[zip[*left]];
			
			sub = lower_bound(all(t),y1) - upper_bound(all(t),y2);
		}
		
		if(right==posx.begin())add=0;
		else{
			right--;
			vector<int> &t = r[zip[*right]];
			add = lower_bound(all(t),y1) - upper_bound(all(t),y2);
		}
		cout<<sub-add<<endl;
	}
}

Measured memory_bytes: 65148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string S;
    cin >> S;
    vll cnt(3000, 0);
    cnt[0] = 1;
    ll num = 0;
    ll digit = 1;
    for(ll i = S.size()-1; i>=0; i--) {
        ll a = S[i] - '0';
        num += digit * a;
        num %= 2019;
        digit *= 10;
        digit %= 2019;
        cnt[num]++;
    }
    ll ans = 0;
    rep(i, 2019) if(cnt[i] >= 2) ans += cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 3716
import sys
MAX_INT = int(10e9)
MIN_NUM = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B = IL()

cnt = 1
ans = 0
while True:
  if cnt >= B:
    break
  cnt += A-1
  ans += 1

print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

int dp[1000001];
int kind[31];


const int MAX_SIZE = 10000;
const int MAX_PRIME = 1000000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeXgðú»
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// Óé¢É©¯é
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
	}
}


int main(){

	int n;
	int x;
	erats();
	while(cin>>n>>x&&!(n==0&&x==0)){
		for(int i = 0; i < n; i++){
			cin>>kind[i];
		}
		// eàzÌ¥¢ûª½íÞ é©ðßé
		//fill(dp,dp+1000001,0);
		dp[0]=1;
		int maxCost=-1;

		//for(int j = 0; j < n; j++){
		//	for(int i = kind[j]; i <= x; i++){
		//		dp[i]+=dp[i-kind[j]];
		//	}
		//}

		for(int i = 1; i <= x; i++){
			dp[i]=0;
			for(int j = 0; j < n; j++){
				if(i-kind[j]>=0){
					dp[i]+=dp[i-kind[j]];
				}
			}
			//if(dp[i]>=1&&(isPrime[i])){
			//	maxCost=max(i,maxCost);
			//}
		}
		for(int i = 0; i <= x; i++){
			if(dp[i]&&isPrime[i])
				maxCost=i;
		}


		if(maxCost==-1)
			cout<<"NA"<<endl;
		else
			cout<<maxCost<<endl;
	}

	return 0;
}

Measured memory_bytes: 6056
#include<bits/stdc++.h>
#define int long long
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    int n;
    cin >> n;
    vi s(n);
    rep(i, n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    int ans = 0;
    rep(i, n){
        ans += s[i];
        /* cout << s[i] << endl; */
    }
    if(ans % 10 != 0){
        cout << ans << endl;
        return 0;
    }
    int idx = 0;
    int tmp = ans;
    while(tmp- s[idx] >= 0){
        if((tmp - s[idx]) % 10 != 0){
            cout << tmp - s[idx] << endl;
            return 0;
        }
        idx++;
    }
    cout << 0 << endl;
}

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

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  LL res = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(ALL(a), greater<int>());
  res = a[0];
  for (int i = 2; i < n; i++) {
    res += a[i / 2];
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3996
fun main(args: Array<String>) {
    val (n , m) = readLine()!!.split(" ").map { it.toInt() }
    val graph = MutableList<MutableList<Int>>(n){ mutableListOf()}
    for(i in 0 until m){
        val (a , b) = readLine()!!.split(" ").map { it.toInt() }
        graph[a-1].add(b-1)
        graph[b-1].add(a-1)
    }

    val par = MutableList(n){-1}
    val que = java.util.ArrayDeque<Int>()
    par[0] = 0
    que.add(0)
    while(!que.isEmpty()){
        val v = que.pop()

        for(nv in graph[v]){
            if(par[nv] != -1) continue
            par[nv] = v
            que.add(nv)
        }
    }
    println("Yes")
    for(i in 1 until n){
        println(par[i]+1)
    }
}


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

using namespace std;

int main()
{
    char c1,c2,c3,b1,b2,b3,a[100];
    cin >> c1 >> c2 >> c3;
    cin >> b1 >> b2 >> b3;

       a[2] = c1;
       a[1] = c2;
       a[0] = c3;

     if(a[0] == b1 && a[1] == b2 && a[2] == b3)
        cout << "YES" << endl;
     else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
B = [list(map(int,input().split())) for _ in range(m)]
BT = [list(x) for x in zip(*B)]

for a in A:
    c = []
    for b in BT:
        c.append(sum(x*y for x,y in zip(a,b)))
    print(*c)


Measured memory_bytes: 6688
#include<stdio.h>
int main(){
	int h, w, i, j;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		for (i = 1; i <= h; i++){
			for (j = 1; j <= w; j++){
				if(i != 1 && i != h && j != 1 && j != w){
					printf(".");
				}else{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
} 


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}

    // 集合をマージする
    // 既に同じ集合なら false が返る
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        // 要素数の少ない方を多い方に繋げる
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    // ある要素がどの集合に属しているかを答える
    int root(int x) {
        // 根に直接つなぎ直す
        return data[x] < 0 ? x : (data[x]=root(data[x]));
    }
    // ある集合の大きさを答える
    int size(int x) {
        return -data[root(x)];
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M);
    vector<ll> b(M);
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind UF(N);
    vector<ll> ans(M, 0);
    // 不便さ
    ans[M-1] = N*(N-1)/2;

    for (int i = M-1; i > 0; i--) {
        if(UF.root(a[i]) == UF.root(b[i])) {
            ans[i-1] = ans[i];
            continue;
        }
        // 新たに行き来できるようになった頂点のペアの数だけ不便さが減る
        // オーバーフローに注意
        ans[i-1] = ans[i] - 1ll*UF.size(a[i])*UF.size(b[i]);
        UF.merge(a[i], b[i]);
    }
	rep(i, M) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	char S[11];

	scanf("%s",S);

	int len;
	for(len = 0; S[len] != '\0'; len++);

	if(S[0] != 'A'){

		printf("WA\n");
		return 0;
	}

	int count = 0;
	for(int i = 2; i <= len-2; i++){
		if(S[i] == 'C')count++;
	}

	if(count != 1){

		printf("WA\n");
		return 0;
	}

	int num_small = 0;
	for(int i = 0; i < len; i++){
		if(S[i] >= 'a' && S[i] <= 'z'){

			num_small++;
		}
	}

	if(num_small+2 != len){

		printf("WA\n");
		return 0;
	}

	printf("AC\n");

	return 0;
}


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

string s;
int mo=1000000007; 
struct  stnode
{
    int ma; 
};
stnode st[1000005];

int h[200005];
int bty[200005];
int n;
void merge(stnode &f,stnode &n1,stnode &n2)
{
   f.ma=max(n1.ma,n2.ma);
}
void build(int node ,int l ,int r)
{
    if(l==r)
    {
        st[node].ma=0;
        return ; 
    }
    int m=(l+r)/2;
    build(2*node , l, m);
    build(2*node + 1, m+1 ,r);
    merge(st[node],st[2*node],st[2*node +1]);
 
}
  
void update(int node,int l,int r,int pos,int val)
{
    if(l==r)
    {
        st[node].ma=max(st[node].ma,val);
    }
    else
    {
        int mid=(l+r)/2;
        if(pos<=mid)
            update(2*node , l ,mid,pos,val);
        else
            update(2*node +1 , mid +1 ,r,pos,val);
        merge(st[node],st[2*node],st[2*node + 1]);
        //cout<<ind<<" "<<st[ind].best<<"\n";
    }
}
 
stnode query(int ind, int l, int r, int lo, int hi)
{
    if(l==lo && r==hi)
        return st[ind];
    int mid =(l+r)/2;
    if(lo > mid)
        return query(2*ind + 1,mid +1,r,lo,hi);
    if(hi<=mid)
        return query(2*ind,l,mid,lo,hi);
    stnode left = query(2*ind, l, mid,lo,mid);
    stnode right = query(2*ind +1, mid +1,r,mid + 1,hi);
    stnode result ;
    merge(result,left,right);
    return result;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    build(1,1,n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<n;i++)
        cin>>bty[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int q=0;
        if(h[i]>1)
            q=query(1,1,n,1,h[i]-1).ma;
        ans=max(ans,q+bty[i]);
        update(1,1,n,h[i],q+bty[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 10848
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll n,k;
    cin >> k >> n;
    ll a[n],d[n] = {};
    rep(i,0,n){
        cin >> a[i];

        if(i == n-1){
            d[i] = k - (a[i] - a[0]);
        }
        if(i > 0){
            d[i-1] = a[i] - a[i-1];
        }
    }

    sort(d,d+n);
    cout << k - d[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3456
n = int(input())
s = input()
west = []
east = []
count_w = 0
count_e = 0

for i in s:
    if i == "W":
        count_w+=1
    west.append(count_w)
for j in reversed(s):
    if j == "E":
        count_e +=1
    east.append(count_e)
r_east = [k for k in reversed(east)]
   
attention = [west[i] + r_east[i] for i in range(n)]
print(min(attention)-1)

Measured memory_bytes: 32288
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    vector<P> v(n);
    for (P &p: v) cin >> p.first >> p.second;

    ll t = 1, a = 1;

    auto calc = [](ll x, ll y) -> ll {
        if (x <= y) return 1;
        return (x + y - 1) / y;
    };

    for (P p : v) {
        ll tr = calc(t, p.first);
        ll ar = calc(a, p.second);

        ll r = max(tr, ar);
        t = p.first * r;
        a = p.second * r;

    }


    cout << t + a << endl;

}


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

typedef long long ll;

using vi = vector<int>;

using vii = vector<vector<int>>;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
       const int INF=1e9+7;
    int n,k,temp=INF;
 
    cin>>n;
    vii arr(n+1,vi(3));




    for(int i=1;i<=n;i++)
        for(int j=0;j<3;j++)cin>>arr[i][j];


for(int i=2;i<=n;i++)
{
    arr[i][0]+=max(arr[i-1][1],arr[i-1][2]);
    arr[i][1]+=max(arr[i-1][0],arr[i-1][2]);
    arr[i][2]+=max(arr[i-1][0],arr[i-1][1]);
}    
 int ans=max(arr[n][0],max(arr[n][1],arr[n][2]));

 cout<<ans<<endl;

return 0;

}


Measured memory_bytes: 5760
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){


    int K, A, B;
    cin >> K >> A >> B;
    FOR(i, A, B+1){
        if (i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3632
import sys

import numpy as np

sys.setrecursionlimit(100000)
INF = float('inf')

H, W = list(map(int, sys.stdin.readline().split()))
_ = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))


def hw(i):
    h = i // W
    w = i % W
    return h, w if h % 2 == 0 else W + ~w


c = 1
board = np.zeros((H, W), dtype=int)
i = 0
for a in A:
    for _ in range(a):
        board[hw(i)] = c
        i += 1
    c += 1
for row in board:
    print(*row)


Measured memory_bytes: 13436
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(void){
    int N;
    ll D, A;
    cin >> N >> D >> A;
    vector<pair<ll, ll>> XH(N);
    for(int i = 0; i < N; i++) cin >> XH[i].first >> XH[i].second;
    sort(XH.begin(), XH.end());
    ll ans = 0;
    vector<ll> damage(N + 1, 0);
    for(int tgt = 0; tgt < N; tgt++){
        if(tgt >= 1) damage[tgt] += damage[tgt - 1];
        XH[tgt].second -= damage[tgt];
        if(XH[tgt].second <= 0) continue;
        ll left = XH[tgt].first;
        ll right = left + 2 * D;
        auto ritr = upper_bound(XH.begin(), XH.end(), make_pair(right, 1LL << 32LL));
        int rpos = distance(XH.begin(), ritr);
        ll nb = (XH[tgt].second + A - 1) / A;
        ans += nb;
        damage[tgt] += A * nb;
        damage[rpos] -= A * nb;
    }
    cout << ans << endl;
}


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

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

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
   int h,w;
   cin>>h>>w;
   char a[h+2][w+2];
   memset(a,'0',sizeof(a));
   for(int i=1;i<h+1;i++){
      string s;
      cin>>s;
      for(int j=1;j<w+1;j++){
         a[i][j]=s[j-1];
      }
   }

   for(int i=1;i<=h+1;i++){
      for(int j=1;j<=w+1;j++){
         if(a[i][j]=='.'){
            char ans='0';
            for(int p=i-1;p<=i+1;p++){
               for(int q=j-1;q<=j+1;q++){
                  if(a[p][q]=='#') ans++;
               }
            }
            a[i][j]=ans;
         }
      }
   }

   for(int i=1;i<h+1;i++){
      for(int j=1;j<w+1;j++){
         cout<<a[i][j];
      }
      cout<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n,m; cin>>n>>m;
    int arr[n];
    cin>>arr[0];
    for(int i=1; i<n; i++){
		cin>>arr[i];
		arr[i]+=arr[i-1];
	}
	int b=1;
	for(int i=0; i<n; i++){
		if(arr[i]<=m)b++;
	}
	cout<<b<<endl;
}


Measured memory_bytes: 3648
q = int(input())
vec = []
for i in range(q):
    a = list(map(int, input().split()))
    k = a[0]
    if k == 0:
        vec.append(a[1]) 
    if k == 1:
        print(vec[a[1]])
    if k == 2:
        vec.pop(-1)


Measured memory_bytes: 13360
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Fri Sep 29 19:23:24 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b, c;
  cin >> a >> b >> c;

  if ((a == b) && (b == c)) {
    cout << 1;
  } else if (a == b) {
    cout << 2;
  } else if (b == c) {
    cout << 2;
  } else if (c == a) {
    cout << 2;
  } else {
    cout << 3;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;
typedef pair<int, pair<int, int>> Trio;
typedef pair<int, int> Pair;

int main(void) {
	LL n, m, i, j, k, ansn = 1, ansm = 1;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	
		for (i = 1; i <= n; ++i) {
			ansn *= i;
			ansn %= 1000000000 + 7;
		}
		for (i = 1; i <= m; ++i) {
			ansm *= i;
			ansm %= 1000000000 + 7;
		}
		ansn *= ansm;
		ansn %= 1000000000 + 7;
		if (abs(n - m) == 0) {
			ansn *= 2;
			ansn %= 1000000000 + 7;
			cout << ansn << endl;
		}
		else {
			cout << ansn << endl;
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

string solve() {
    int A, B;
    cin >> A >> B;

    return (A<=8 && B<=8)?"Yay!":":(";
}

int main() {
    cout << solve() << endl;
#ifdef DEBUG
    while (1) {
        cout << solve() << endl;
    }
#endif
}


Measured memory_bytes: 256
import java.util.*;

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

		while(sc.hasNext()){
			String s = sc.nextLine();
			StringBuffer ans = new StringBuffer();
			int p = 0;
			for(int i=0;i<s.length();i++){
				p = s.codePointAt(i);
				if(p>96 && p<123)p-=32;
				ans.append((char)p);
			}
			System.out.println(ans.toString());
			
		}
	}	
}

Measured memory_bytes: 15288
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,m,t = LI()
        a = [1] * (t+1)
        l = LI()
        for c in l:
            a[c] = 0
        for c in l:
            for ci in range(c+1,min(c+m,t+1)):
                if a[ci] < 1:
                    break
                a[ci] = 0
            for ci in range(c-1,max(-1,c-m),-1):
                if a[ci] < 1:
                    break
                a[ci] = 0
        r = 0
        for i in range(t):
            if a[i] == 1 and a[i+1] == 1:
                r += 1

        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())




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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N + 2, 0);
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll total = 0;
  for (int i = 1; i < N + 2; ++i) {
    total += abs(A[i - 1] - A[i]);
  }
  for (int i = 1; i <= N; ++i) {
    ll val = total - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) + abs(A[i - 1] - A[i + 1]);
    printf("%lld\n", val);
  }
  return 0;
}


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



int main(){
   ll N, K;
   cin >> N >> K;
   ll ans = 0;
   ll tmp = N % K;
   if(tmp < K - tmp) ans = tmp;
   else ans = K - tmp;
   cout << ans << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int S,W;cin>>S>>W;
    if(W>=S)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}


Measured memory_bytes: 3620
#!/usr/bin/env python3
import sys


def solve(r, d, x):
    for i in range(1, 11):
        ret = r * x - d
        print(ret)
        x = ret
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    solve(r, d, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	long long x;
	while(cin>>x&&x!=-1){
	long long z[100000],cnt=0;
	while(true){
		if(x<4)break;
		z[cnt]=x%4;
		x=(x-x%4)/4;
		cnt++;
	}
	z[cnt]=x;
	for(long long i=cnt;i>=0;i--){
		if(z[i]==0)cout<<"0";
		else cout<<z[i];
	}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2948
#include<iostream>
#include<string>
#define MAXN 200000
#define MAXM 200000
using namespace std;
typedef long long ll;

int N, M;
int ac[MAXN];
int wa[MAXN];
int nwa, nac;

int p;
string s;

int main() {
	nwa = 0;
	nac = 0;

	cin >> N >> M;
	for (int i = 0; i<M; i++) {		
		cin >> p >> s;

		if (s == "AC") {
			ac[p] = 1;
		}
		else if (s == "WA") {
			if (ac[p] != 1) {
				wa[p]++;
			}
		}
	}

	for (int i = 1; i <= N; i++) {
		nac += ac[i];
		if (ac[i] == 1) {
			nwa += wa[i];
		}
	}

	cout << nac << " " << nwa << endl;
	return 0;
}

Measured memory_bytes: 1024
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}

ll D;


int main() {
	
	cin >>N>> a >> b;

	e = min(N * a, b);

	cout << e << endl;
	
	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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 a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

#define CMAX 26

void solve()
{
  ll D; cin >> D;
  vector<ll> c(CMAX + 1); rep1(i, CMAX) cin >> c[i];
  vector<vector<ll>> s(D + 1, vector<ll>(CMAX + 1));
  rep1(i, D) rep1(j, CMAX) cin >> s[i][j];
  vector<ll> last(CMAX + 1, 0);

  
  vector<ll> t(D + 1);
  //rep1(i, D) {cin >> t[i];}
  rep1(i, D) {
    ll id;
    ll smax = 0;
    rep1(ct, CMAX) {
      if(s[i][ct] - (c[ct] * (i - last[ct])) > smax) {
	
	t[i] = ct;
	smax = s[i][ct];
      }
    }
    last[t[i]] = i;
  }

  rep1(i, D) {
    cout << t[i] << "\n";
  }

  

  ll sat = 0;
  ll dis;
  for(ll day = 1; day <= D; day++) {
    sat += s[day][t[day]];
    last[t[day]] = day;
    dis = 0;
    rep1(i, CMAX) {
      dis += c[i] * (day - last[i]);
    }
    
    sat -= dis;

    cerr << sat << endl;
  }

  
  
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3796
class Dice:
        def __init__(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def reset(self, strList):
                self.label = strList[:]
                self.label[0] = int(self.label[0])
                self.label[1] = int(self.label[1])
                self.label[2] = int(self.label[2])
                self.label[3] = int(self.label[3])
                self.label[4] = int(self.label[4])
                self.label[5] = int(self.label[5])
        def rollE(self):
                temp = self.label[3]
                self.label[3] = self.label[5]
                self.label[5] = self.label[2]
                self.label[2] = self.label[0]
                self.label[0] = temp
        def rollN(self):
                temp = self.label[0]
                self.label[0] = self.label[1]
                self.label[1] = self.label[5]
                self.label[5] = self.label[4]
                self.label[4] = temp
        def rollA(self):
                temp = self.label[3]
                self.label[3] = self.label[4]
                self.label[4] = self.label[2]
                self.label[2] = self.label[1]
                self.label[1] = temp
        def printDice(self):
                print(self.label)

def check(d1, d2):
        for i in range(6):
                if d1.label[i] != d2.label[i]:
                        return False
        return True
        
num = int(input())
diceList = []

for i in range(num):
        diceList.append(Dice(input().split()))

isSame = False

for a in range(num):
        for b in range(a + 1, num):
                for j in range(6):
                        for k in range(4):
                                diceList[a].rollA()
                                if check(diceList[a], diceList[b]):
                                        isSame = True
                                        break
                        if j % 2 == 0:
                                diceList[a].rollE()
                        else:
                                diceList[a].rollN()
                        if isSame:
                                break
                if isSame:
                        break
        if isSame:
                break

if isSame:
        print('No')
else:
        print('Yes')


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

int main() {
	int n;
	int mod;
	cin >> n >> mod;
	map<int, int> dp;
	dp[0] = 1;
	int a = 0;
	long long s = 0;
	for (int i(0); i < n; ++i) {
		int b;
		cin >> b;
		a += b;
		a %= mod;
		s += dp[a];
		++dp[a];
	}
	cout << s << endl;
}


Measured memory_bytes: 3200
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int a, b, c;
int main()
{
	scanf("%d%d%d", &a, &b, &c);
	for(int i = 1; i < 1000000; i++)
	{
		if(((i * a) % b == c % b)) 
    	{
    		printf("YES\n");
    		return 0;
		}
	}
	printf("NO\n");
}


Measured memory_bytes: 256
N = int(input())
m = 1
d_cnt = 0
for i in range(1, N+1):
    num = i
    cnt = 0
    while True:
        if num % 2 == 0:
            num /= 2
            cnt += 1
        else:
            break
    if d_cnt < cnt:
        d_cnt = cnt
        m = int(i)
print(m)

Measured memory_bytes: 9128