akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import *
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    m, d = LI()
    ans = 0
    for i in range(1, m + 1):
        for j in range(10, d + 1):
            if int(str(j)[0]) < 2 or int(str(j)[1]) < 2:
                continue
            if i == int(str(j)[0]) * int(str(j)[1]):
                ans += 1
    print(ans)
    return

#B
def B():
    n, l = LI()
    a = LI()
    d0 = defaultdict(int)
    d1 = defaultdict(int)
    for i in a:
        d0[i] += 1
    for i in range(n):
        b = 0
        for k in range(i+1, n):
            if a[i] > a[k]:
                b += 1
        d1[i] = b
    ans = 0
    d2 = list(d0.items())
    d2.sort()
    d3 = defaultdict(int)
    d = 0
    for key, value in d2:
        d3[key] = d
        d += value
    for i in range(n):
        ans += d3[a[i]] * l * (l-1) // 2 + d1[i] * l
        ans %= mod
    print(ans % mod)
    return

#C
def C():
    n = II()
    s = S()
    lis = [0]
    for i in range(2 * n - 1):
        lis.append(lis[-1] ^ (s[i] == s[i+1]))
    l = [0] * (2 * n)
    r = [0] * (2 * n)
    for i in range(2 * n):
        l[i] += l[i - 1] + (lis[i] == 0)
        r[i] += r[i - 1] + (lis[i] == 1)
    ans = 1
    if l[-1] != r[-1] or s[0] == "W":
        print(0)
        return
    for i in range(2 * n):
        if lis[i]:
            ans *= l[i] - (r[i] - 1)
            ans %= mod
    print(ans * math.factorial(n) % mod)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 66028
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;

struct { int a, b; } s[MAX_N];
multiset<pair< int, pair<int, int> > > mpa, mpb;
multiset<pair< int, pair<int, int> > >::iterator it1, it2;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d%d", &s[i].a, &s[i].b);
	for (int i = 0; i < n; i++) mpa.insert(make_pair(s[i].a+s[i].b, make_pair(s[i].b, i)));
	for (int i = 0; i < n; i++) mpb.insert(make_pair(s[i].b+s[i].a, make_pair(s[i].a, i)));

	long long sum = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			it1 = mpa.end();
			it1--;
			sum += it1->first - it1->second.first;
			int ind = it1->second.second;
			mpb.erase(mpb.find(make_pair(s[ind].b+s[ind].a, make_pair(s[ind].a, ind))));
			mpa.erase(it1);
		}
		else {
			it1 = mpb.end();
			it1--;
			sum -= it1->first - it1->second.first;
			int ind = it1->second.second;
			mpa.erase(mpa.find(make_pair(s[ind].a+s[ind].b, make_pair(s[ind].b, ind))));
			mpb.erase(it1);
		}
	}
	cout << sum;
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);

  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i) {
    if (n % i == 0 and n / i <= 9) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c;
  int sum;
  scanf("%d %d %d",&a,&b,&c);
  sum=a+b+c;

  if(sum<22){
    printf("win\n");
  }else{
    printf("bust\n");
  }
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,k,r,s,p,ans;
string t;
map<char,int> m;
bool hoge[100000];

signed main() {
    cin >> n >> k >> r >> s >> p;
    m['s'] = r;
    m['p'] = s;
    m['r'] = p;
    cin >> t;
    rep(i,n) {
        if (i >= k) {
            if (!hoge[i-k] || t[i-k] != t[i]) ans += m[t[i]], hoge[i] = true;
        } else ans += m[t[i]], hoge[i] = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Edge{
  int src, dst, cap, rev;
  Edge(int u, int v, int c, int r) : 
    src(u), dst(v), cap(c), rev(r) {}
};
typedef vector<Edge> Node;
typedef vector<Node> Graph;
void add_edge(Graph& G, int a, int b, int c){
  G[a].push_back(Edge(a, b, c, G[b].size()));
  G[b].push_back(Edge(b, a, c, G[a].size() - 1));
}
int dfs(Graph& G, int u, int t, int f, vector<bool>& used){
  if(u == t) return f;
  used[u] = true;
  FORIT(e, G[u])if(e->cap > 0 && !used[e->dst]){
    int g = dfs(G, e->dst, t, min(f, e->cap), used);
    if(g > 0) {
      e->cap -= g;
      G[e->dst][e->rev].cap += g;
      return g;
    }
  }
  return 0;
}
int max_flow(Graph G, int s, int t){
  int N = G.size();
  int flow = 0;
  while(true){
    vector<bool> used(N, false);
    int f = dfs(G, s, t, INF, used);
    if(f == 0) return flow;
    flow += f;
  }
}

int main(){
  int N, M;
  while(cin >> N >> M && N){
    Graph G(N);
    int minus = 0;
    REP(i, M){
      int a, b, c;
      cin >> a >> b >> c;
      if(c <= 0){
        minus += c;
        continue;
      }
      add_edge(G, a, b, c);
    }
    int ans = INF;
    FOR(t, 1, N){
      ans = min(ans, max_flow(G, 0, t));
    }
    cout << ans + minus << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
using namespace std;
#define MAX 10000;

int F[10000];

int fib(int n)
{
  if (n <= 1)
    return F[n] = 1;
  if(F[n]!=0)
    return F[n];
  return F[n] = fib(n - 1) + fib(n - 2);
}

int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++) F[i] = 0;
  cout << fib(n) << endl;
  return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
int main(void){
    char s[15];
    int k=0;
    int i;
    
    if(scanf("%d",&k)==1);
    
    s[0]='A';
    s[1]='C';
    s[2]='L';
    
    for(int i=0;i<k;i++){
        printf("%s",s);
    }
    
    return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	vector<ll>s,e;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		s.push_back(x);
		e.push_back(y);
	}
	sort(s.begin(),s.end());
	sort(e.begin(),e.end());
	if(n%2!=0){
		ll l=s[n/2];
		ll r=e[n/2];
		cout <<r-l+1;
	}
	else{
		ll l=s[n/2-1]+s[n/2];
		ll r=e[n/2-1]+e[n/2];
		cout << r-l+1;
	}
	// your code goes here
	return 0;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> ws(n+2, 0), es(n+2, 0);
	for(int i=0; i<m; i++){
		for(int j=1; j<=n; j++){
			char cul;
			cin >> cul;
			if(cul=='W') ws[j]++;
			else es[j]++;
		}
	}
	
	for(int i=1; i<=n; i++){
		es[i]+=es[i-1];
	}
	for(int i=n; i>0; i--){
		ws[i]+=ws[i+1];
	}
	
	int ans = -1;
	int err = 1e9;
	for(int i=0; i<=n; i++){
		if(es[i]+ws[i+1] < err){
			ans = i;
			err = es[i]+ws[i+1];
		}
	}
	cout << ans << " " << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 3132
n = int(input())
data_list = []
for _ in range(n):
    data_list.append(input(""))

data_list_a = set(data_list)
data_list_a = list(data_list_a)
m = len(data_list_a)

data_a = [0 for _ in range(m)]

data_dic = dict(zip(data_list_a, data_a))

for i in range(n):
    data_dic[data_list[i]] += 1

data_score = data_dic.values()
max_value = max(data_score)
ans = []


for i in range(m):
    if data_dic[data_list_a[i]] == max_value:
        ans.append(data_list_a[i])


ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 46092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace Multiplication_of_Big_Integers_II
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            BigInteger[] nums = { BigInteger.Parse(input[0]), BigInteger.Parse(input[1]) };

            Console.WriteLine(nums[0] % nums[1]);
        }
    }
}



Measured memory_bytes: 18120
#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
    if (b <= 0) { return 1; } if (b == 1) { return a % mod; } if (b == 2) { return (a * a) % mod; }
    return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
}
constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
    return (a * mpow(b, mod - 2, mod)) % mod;
}

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

    int ans = 0, f = 0, m = 0, b = 0;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;

        f += s.front() != 'B' && s.back() == 'A';
        m += s.front() == 'B' && s.back() == 'A';
        b += s.front() == 'B' && s.back() != 'A';

        for (int j = 0; j < s.size() - 1; ++j) {
            ans += s[j] == 'A' && s[j + 1] == 'B';
        }
    }

    if ((f == 0 || b == 0) && m == 0) {
        cout << ans << endl;
        return 0;
    }

    if (f != 0) {
        --f;
        ++ans;
    }
    if (b != 0) {
        --b;
        ++ans;
    }

    ans += m - 1;
    ans += min(f, b);

    cout << ans << endl;
}



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

using namespace std;
const int mod = 1e9+7;

const int N = 100005;

int n, m;
int broken[N];
int dp[N];

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x;
		scanf("%d", &x);
		broken[x] = 1;
	}
	dp[0] = 1;
	dp[1] = !broken[1];
	for(int i = 2; i <= n; i++) {
		if(broken[i]) continue;
		dp[i] = dp[i - 1] + dp[i - 2];
		if(dp[i] >= mod) dp[i] -= mod;
	}
	printf("%d\n", dp[n]);
}


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

signed main() {
  string S, T;
  cin >> S >> T;
  
  string A = "abcdefghijklmnopqrstuvwxyz";
  for( int i = 0; i < 26; i++ ){
    string B = S + A.at(i);
    if( B == T ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

}


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

#define ll long long

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

const ll INF = 1LL << 60;
const ll MAX = 3005;
const ll MAX_N = 110;
const ll MAX_V = 100100;

string s, t;
ll dp[MAX][MAX];

int main() {
    cin >> s >> t;

    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < t.size(); j++) {
            if(s[i] == t[j]) {
                chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            }
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
        }
    }

    // for(int i = 0; i <= s.size(); i++) {
    //     for(int j = 0; j <= t.size(); j++) {
    //         if(j)
    //             cout << " ";
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }

    string res = "";
    int s_i = s.size();
    int t_i = t.size();
    while(s_i > 0 && t_i > 0) {
        if(dp[s_i][t_i] == dp[s_i - 1][t_i]) {
            s_i--;
        } else if(dp[s_i][t_i] == dp[s_i][t_i - 1]) {
            t_i--;
        } else {
            res = s[s_i - 1] + res;
            s_i--;
            t_i--;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 70656
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> V(N), C(N);

    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }
    int max = 0;
    for(int i = 0; i < N; i++) {
        if(V[i] - C[i] > 0) {
            max = max + V[i] - C[i];
        }
    }
    cout << max << endl;
}


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

#define CIN(T, x) T x; cin >> x;
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, Q);
    CIN(string, S);
    vector<int> ans(N + 10, 0);

    int temp = 0;
    for (int i = 1; i < N ; i++) {
        if ( S[i-1] == 'A' && S[i] == 'C' ) temp++;
        ans[i + 1] = temp;
    }

    for (int i = 0; i < Q ; i++) {
        int l, r;
        cin >> l >> r;
        cout << (ans[r] - ans[l]) << "\n";
    }

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const ll N=1E6+7;
const ll mod=1e9+7;
ll arr[N];
ll mp[N];
ll ksm(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
int main()
{
    ll n;
    cin>>n;
    ll mx=0;
    for(ll i=1;i<=n;i++){
        cin>>arr[i];
        mx=max(mx,arr[i]);
    }
    ll pos=0;
    for(ll i=1;i<=n;i++){
        ll x=arr[i];
        ll y=sqrt(x);
        for(ll j=2;j<=y;j++){
            ll cnt=0;
            while(x%j==0){
                x/=j;
                cnt++;
            }
            mp[j]=max(mp[j],cnt);
        }
        if(x!=1) mp[x]=max(mp[x],(ll)1);
    }
    ll sum=1;
    for(ll i=1;i<=mx;i++)
        sum=(sum%mod*ksm(i,mp[i])%mod)%mod;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=sum*ksm(arr[i],mod-2)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

Measured memory_bytes: 8192
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        String[] words = new String[N];
        for (int i = 0; i < words.length; i++) words[i] = in.next();

        Map<String, Long> cnt = new HashMap<>();
        for (String word : words) {
            char[] arr = word.toCharArray();
            Arrays.sort(arr);
            String sorted = String.valueOf(arr);
            cnt.put(sorted, cnt.getOrDefault(sorted, (long) 0) + 1);
        }
        long res = 0;
        for (Long i : cnt.values())
            res += i * (i - 1) / 2;
        System.out.println(res);
    }
}


Measured memory_bytes: 54148
# 文字列S'（s）および文字列Tを入力する
s = input()
T = input()
# Sを設定する（初期状態 =  "UNRESTORABLE"）
S = "UNRESTORABLE"
# |s|が|T|以上である場合に探索する
if len(s) >= len(T):
    # sの|T|文字の部分文字列（s_partial）について探索する
    for i in range(len(s) - len(T) + 1):
        s_partial = s[i:i + len(T)]
        # 部分文字列中のj番目の文字を調べる
        for j in range(len(T)):
            # j番目の文字が"?"でもTのj番目の文字でもない場合、繰り返しを抜ける
            if s_partial[j] not in ("?", T[j]):
                s_partial = None
                break
        if s_partial == None:
            continue
        # sの部分文字列をTに置き換えた文字列をtextとする
        text = s[:i] + T + s[i + len(T):]
        # textの"?"を"a"に置き換える
        text = text.replace("?", "a")
        # Sが初期状態のままである場合、もしくはSよりもtextの方が辞書順で小さい場合
        if S == "UNRESTORABLE" or text < S:
            # Sをtextに更新する
            S = text
# Sを出力する
print(S)

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

int	main() {
	int M, N;
	cin >>N >>M;
	vector<string> A(N);
	vector<string> B(M);
	for (int i=0; i<N; i++)
		cin >>A.at(i);
	for (int i=0; i<M; i++)
		cin >>B.at(i);
	for (int i=0; i<=N-M; i++)
		for (int j=0; j<=N-M; j++) {
			bool OK=true;
			for (int k=0; k<M; k++) {
				for (int l=0; l<M; l++) 
					if (A.at(i+k).at(j+l)!=B.at(k).at(l)) {
						OK=false;
						break;
					} else
						continue;
				if (!OK)
					break;
			}
			if (OK) {
				cout <<"Yes" <<endl;
				return 0;
			}
		}
	cout <<"No" <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int cnt;
	string str;
	cin >> cnt >> str;
	
	int min = 9999999999;

	std::vector<int> west(cnt,0), east(cnt,0);
	if(str[0] == 'W')
		west[0] = 1;
	else
		east[0] = 1;
	
	for(int i = 1; i < cnt; ++i){
		if(str[i] == 'W'){
			west[i] = west[i-1] + 1;
			east[i] = east[i-1];
		}else{
			west[i] = west[i-1];
			east[i] = east[i-1] + 1;
		}
	}
	
	int ans;
	for(int i = 0; i < cnt; ++i){
		if(i == 0)
			ans = east[cnt-1] - east[i];
		else if(i == cnt-1)
			ans = west[i-1];
		else
			ans = west[i-1] + (east[cnt-1] - east[i]);
		
		if(min > ans)
			min = ans;
	}

	cout << min << endl;
	
	return 0;
}


Measured memory_bytes: 3076
from collections import deque

N = int(input())
nmax = 2*10**5
nhalf = 10**5

G = [[] for i in range(nmax)]
for i in range(N):
    x,y = map(int,input().split())
    G[x-1].append(nhalf+y-1)
    G[nhalf+y-1].append(x-1)

used = [False] * nmax
ans = 0
# 全探索
for i in range(nhalf):
    # 見つかったノードからBFS
    if G[i] != [] and not used[i]:
        cnt_1 = 0  #前半の連結
        cnt_2 = 0  #後半の連結
        q = deque([i])
        used[i] = True # 始めどこから行くか
        while len(q) > 0:
            a = q.popleft()
            if a < nhalf:
                cnt_2 += 1
            else:
                cnt_1 += 1
            Vs = G[a]
            # print(Vs)
            for u in Vs: # 頂点以外の要素がグラフにあるときはここ
                if not used[u]:
                    q.append(u)
                    # なにか処理を書きたいときはここに書く
                    used[u] = True
        ans += cnt_1*cnt_2
print(ans-N)

Measured memory_bytes: 30432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(),int.Parse) ;
            var N = NK[0];
            var K = NK[1];

            var S = Console.ReadLine().ToCharArray();

            S[K-1]=Char.ToLower(S[K-1]);

            for(int i = 0; i < N; i++)
            {
                Console.Write(S[i]);
            }


        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 1; i * i <= n; i++)
        if (!(n % i))
            s.insert(i), s.insert(n / i);
    n--;
    for (int i = 1; i * i <= n; i++)
        if (!(n % i))
            s.insert(i), s.insert(n / i);
    n++;
    int res = 0;
    for (int i : s)
    {
        if (i == 1)
            continue;
        int cur = n;
        while (!(cur % i))
            cur /= i;
        res += cur % i == 1;
    }
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 512
S = input()

g = 0
p = 0
w = 0
l = 0
for s in S:
    if g <= p:
        t = "g"
    else:
        t = "p"

    if t == "p" and s == "g":
        w += 1
    elif t == "g" and s == "p":
        l += 1
    if t == "g":
        g += 1
    else:
        p += 1

print(w-l)

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;

  int res = 0;

  cout << z << " " << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

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

ac = Counter(a)
sm = 0
for v in ac.values():
    if v > 1:
        sm += v * (v - 1) // 2
for v in a:
    print(
        sm
        if ac[v] <= 1
        else sm - ac[v] * (ac[v] - 1) // 2 + (ac[v] - 1) * (ac[v] - 2) // 2
    )


Measured memory_bytes: 109616
use std::io::stdin;

fn main() {
    let mut input: String = String::new();
    stdin().read_line(&mut input).unwrap();
    let input = input.trim().parse::<i32>().unwrap();
    // assert!(input >= 1 && input <= 32);
    let arr: [i32; 32] = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    println!("{}", arr[input as usize-1]);
}


Measured memory_bytes: 4352
import java.util.*;

class UnionFind {
    int[] parent, size;

    public UnionFind(int n) {
        parent = new int[n];
        size = new int[n];
        for(int i = 0; i < n; i++){
            parent[i] = i;
            size[i] = 1;
        }
    }
    int root(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = root(parent[x]);
        }
    }
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(size[x] < size[y]){
            parent[x] = y;
            size[y] += size[x];
        }else{
            parent[y] = x;
            size[x] += size[y];
        }
    }
    boolean same(int x, int y){
        return root(x) == root(y);
    }
}

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        UnionFind uF = new UnionFind(N);
        for(int i=0;i<M;i++){
            int A = sc.nextInt()-1;
            int B = sc.nextInt()-1;
            uF.unite(A,B);
        }
        int ans = 0;
        for(int i = 0; i < N; i++){
            ans = Math.max(uF.size[i], ans);
        }
        System.out.println(ans);

    }

}




Measured memory_bytes: 61048
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define absdiff(a,b) (a>b)?a-b:b-a
#define debug cout<<"debug";
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 1000000007
#define ll_MAX 19223372036859
#define endl "\n"
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }


int main()
{
    ll t;t=1;
    // cin>>t;
    for(ll x=0;x<t;++x){
        ll n;cin>>n;
        vector<pair<ll,ll>> arr[n+1];
        for(ll i=1;i<=n;++i){
            ll q;cin>>q;
            for(ll j=1;j<=q;++j){
                ll a,b;cin>>a>>b;
                arr[i].pb(mp(a,b));
            }
        }

        ll ans=0;
        for(ll i=0;i<(1<<n);++i){
            ll cnt=0;
            ll flag[n+1]{};

            for(ll j=0;j<n;++j){
                if(i&(1<<j)){
                    flag[j+1]=1;
                    cnt++;
                }
            }

            ll temp=0;
            for(ll j=1;j<=n;++j){
                if(flag[j]){
                    for(ll k=0;k<arr[j].size();++k){
                        if(arr[j][k].second==0){
                            if(flag[arr[j][k].first]==1){
                                temp=1;
                                break;
                            }
                        }
                        else if(arr[j][k].second==1){
                            if(flag[arr[j][k].first]==0){
                                temp=1;
                                break;
                            }
                        }
                    }
                    if(temp==1) break;
                }
            }

            if(temp==0) {
                ans=max(ans,cnt);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n, q;
ll niz[maxn];
ll cnt[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    ll zbir = 0;
    for(int i=1;i<=n;i++){
        cin >> niz[i];
        cnt[niz[i]]++;
        zbir += niz[i];
    }
    cin >> q;
    while(q--){
        int a, b;
        cin >> a >> b;
        zbir -= cnt[a] * a;
        cnt[b] += cnt[a];
        zbir += cnt[a] * b;
        cnt[a] = 0;
        cout << zbir << endl;
    }
    return 0;
}


Measured memory_bytes: 5140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int h[] = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int cnt = 0;
		int idx = 0;
		int endidx = 0;
		boolean b;
		while (true) {
			idx = 0;
			b = false;
			for (; idx < n; idx++) {
				if (h[idx] > 0) {
					break;
				}
			}
			endidx = idx;
			for (; endidx < n; endidx++) {
				if (h[endidx] <= 0) {
					break;
				}
			}
			for (; idx < endidx; idx++) {
				h[idx]--;
				b = true;
			}
			if (b) {
				cnt++;
			} else {
				break;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

ll mul(ll a, ll b)
{
    ll sg = b / abs(b);
    b = abs(b);
    ll res = 0;
    while(b > 0)
    {
        if(b & 1)
            res = (res + a) % mod;
        a = (a + a) % mod;
        b = b / 2;
    }
    res *= sg;
    res = (res + mod) % mod;
    return res;
}

void cp()
{
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n);
    for(ll &x : arr)
        cin >> x;
    ll res = 1;
    sort(all(arr));
    // If we have to pick odd amount and largest number is 0
    // It is better to have answer = 0 than answer = -ve
    if(arr.back() == 0 && (k & 1))
    {
        cout << 0;
        return;
    }
    // If Numbers are less than zero and we have to pick odd numbers
    // Answer is going to be -ve/zero
    // Pick largest k -ve numbers
    if (arr.back() <= 0 && (k & 1))
    {
        for (int i = n - 1; i >= n - k; i--)
            res = mul(res, (arr[i] + mod) % mod);
        cout << res;
        return;
    }
    int i = 0;
    int j = n - 1;
    // If we have to pick odd numbers just pick 1 +ve number
    if (k & 1)
    {
        res = (arr[j]) % mod;
        j--;
        k--;
    }
    // Else we can pick -ve numbers and +ve numbers in pairs greedily deciding which one to keep
    k /= 2;
    for (int it = 0; it < k; it++)
    {
        ll lp = arr[i] * 1LL * arr[i + 1];
        ll rp = arr[j] * 1LL * arr[j - 1];
        if (lp > rp)
        {
            res = mul(res, (lp + mod) % mod);
            i += 2;
        }
        else
        {
            res = mul(res, (rp + mod) % mod);
            j -= 2;
        }
    }
    cout << res;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 4752
// #define NDEBUG

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,bmi,bmi2,lzcnt")
#endif

#include <bits/extc++.h>
#include <x86intrin.h>

#define ALL(c) begin(c), end(c)
#ifndef DUMP
#define DUMP(...) void(0)
#endif

using namespace std;

template <class T>
constexpr T inf = numeric_limits<T>::max() / 2;
auto chmin = [](auto&& a, auto b) { return b < a ? a = b, true : false; };
auto chmax = [](auto&& a, auto b) { return a < b ? a = b, true : false; };
auto sz = [](auto&& c) -> int { return size(forward<decltype(c)>(c)); };
template <class F>
struct y_combinator : F {
  y_combinator(F f) : F(f) {}
  template <class... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (auto&& e : a) cin >> e, --e;

  vector dp(n, vector(n, -inf<int>));
  vector max_dp(n, -inf<int>);
  int offset = 0;

  vector<array<int, 3>> v;
  auto lazy_update = [&](int p, int q, int val) -> void {
    v.push_back({p, q, val});
  };
  auto push_all = [&]() -> void {
    while (sz(v)) {
      auto [p, q, val] = v.back();
      chmax(dp[p][q], val);
      chmax(dp[q][p], val);
      chmax(max_dp[p], val);
      chmax(max_dp[q], val);
      v.pop_back();
    }
  };

  lazy_update(a[0], a[1], 0);
  push_all();

  for (int i = 0; i < n - 1; ++i) {
    sort(begin(a) + (i * 3 + 2), begin(a) + (i * 3 + 5));
    int x = a[i * 3 + 2];
    int y = a[i * 3 + 3];
    int z = a[i * 3 + 4];
    if (x == z) {
      ++offset;
      continue;
    }
    if (x == y) {
      for (int p = 0; p < n; ++p) lazy_update(p, z, dp[p][y] + 1);
    }
    if (y == z) {
      for (int p = 0; p < n; ++p) lazy_update(p, x, dp[p][y] + 1);
    }
    for (int e : {x, y, z}) {
      for (int p = 0; p < n; ++p) lazy_update(p, e, max_dp[p]);
    }
    auto max_all = *max_element(ALL(max_dp));
    lazy_update(x, y, max_all);
    lazy_update(x, z, max_all);
    lazy_update(y, z, max_all);
    lazy_update(y, z, dp[x][x] + 1);
    lazy_update(x, z, dp[y][y] + 1);
    lazy_update(x, y, dp[z][z] + 1);
    push_all();
  }

  int res = -inf<int>;
  for (int p = 0; p < n; ++p)
    for (int q = 0; q < n; ++q)
      chmax(res, offset + dp[p][q] + (p == q and q == a.back()));
  cout << res << '\n';
}


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

int n,awal=1,ulang=0,k;

int main(){
    cin>>n;
    cin>>k;
    while(ulang<n){
        if(awal*2<awal+k){
            awal=awal*2;
            ulang=ulang+1;
        }else{
            awal=awal+k;
            ulang=ulang+1;
        }
    }
    cout<<awal<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
ll a[N];
ll dp[N];
ll find(ll i,ll n){
	if(i==n)
	return 0;
	if(dp[i]!=-1)
	return dp[i];
	ll cost=abs(a[i]-a[i+1])+find(i+1,n);
	if(i+2<=n)
	cost=min(cost,abs(a[i]-a[i+2])+find(i+2,n));
	return dp[i]=cost;
}
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	memset(dp,-1,sizeof(dp));
	cout<<find(1,n);
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
const int maxn = 301;
int n, m, f[maxn][maxn][maxn];
char buf[maxn];
int F(int L, int R, int c) {
	if(L >= R)
		return L == R;
	if(f[L][R][c] != -1)
		return f[L][R][c];
	int ret = max(F(L + 1, R, c), F(L, R - 1, c));
	if(buf[L] == buf[R])
		ret = max(ret, F(L + 1, R - 1, c) + 2);
	if(c)
		ret = max(ret, F(L + 1, R - 1, c - 1) + 2);
	return f[L][R][c] = ret;
}
int main() {
	scanf("%s%d", buf, &m);
	n = strlen(buf);
	memset(f, -1, sizeof f);
	printf("%d\n", F(0, n - 1, m));
	return 0;
}

Measured memory_bytes: 106880
#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 N;
	cin >> N;
	int num=(N-1)/2;
	vector<LL> A(N), B(N);
	rep(i,N) cin >> A[i] >> B[i];
	sort(A.begin(),A.end());
	sort(B.begin(),B.end(),greater<LL>());
	LL m1=A[num], M1=B[num], m2=A[num+1], M2=B[num+1];
	if(N%2==1) cout << M1-m1+1 << endl;
	else{
		LL m=m1+m2, M=M1+M2;
		cout << M-m+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 6428
//AtCoder Grand Contest 006 A問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,x;
	scanf("%d", &n);
	scanf("%d", &x);
	int plus = 0;
	int re;
	if(n == 2){
		if(x == 2){
			printf("Yes\n");
			for(int i=1; i<=3; i++){
				printf("%d\n", i);
			}
		}
		else printf("No\n");
	}
	if(n >= 3){
		if(1 < x && x < n*2-1){
			printf("Yes\n");
			for(int i=1; i<=n-2; i++){
				if(i == x-1){
					plus = 3;
				}
				printf("%d\n", i+plus);
				re = n-2+plus;
			}
			for(int i=x-1; i<=x+1; i++){
				printf("%d\n", i);
			}
			plus = 0;
			for(int i=1; i<=n-2; i++){
				if(re+1+i-1 == x-1){
					plus = 3;
				}
				printf("%d\n", re+1+i-1+plus);
			}
		}
		else printf("No\n");
	}
}

Measured memory_bytes: 1536
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut l: Vec<i64> = vec![];
    let mut r: Vec<i64> = vec![];

    for _ in 0..m {
        l.push(read());
        r.push(read());
    }

    println!(
        "{}",
        max(0, r.iter().min().unwrap() - l.iter().max().unwrap() + 1)
    );
}


Measured memory_bytes: 3840
n,a,b = map(int,input().split())
def amari(n,a,b):
  amari = n % (a+b)
  if amari >= a:
    return(a)
  else:
    return(amari)
cou = n//(a+b)
result = a * (n//(a + b)) + amari(n,a,b)
print(result)
  

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    long long N;
    cin >> N;
    long long count = 0;
    for (int i = 1; i <= N; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0)
            count += i;
    }
    cout << count << "\n";
}


Measured memory_bytes: 3668
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;

int n, A[CMax], ats;
string S;

int main() {
    cin >> S;

    for (int i = 0; i < S.length() - 8; i++) {
        cout << S[i];
    }

    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] ans = new Integer[N];
		for(int n = 0; n < N; n++){
			ans[n] = sc.nextInt();
		}
		sc.close();
		int sunuke = 0;
		for (int an = 0; an < ans.length; an++){
			if (ans[an] == sunuke + 1){
				sunuke++;
			}
		}
		if (sunuke == 0){
			System.out.println("-1");
		}else{
		System.out.println(N-sunuke);
		}
	}}

Measured memory_bytes: 89132
#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() { long long N,a,b,c,temp;
    cin >> N;
    a = modpow(10, N, 1000000007);
    b = modpow(9, N, 1000000007);
    c = modpow(8, N, 1000000007);
    temp = (a + c - b * 2)%1000000007;
    if (temp < 0) temp += 1000000007;
    cout << temp << endl;
}

Measured memory_bytes: 3628
import collections

N = int(input())
Heights = list(map(int, input().split()))

i_s = [i + 1 + Heights[i] for i in range(N)]
j_s = [j + 1 - Heights[j] for j in range(N)]

CTR_i = collections.Counter(i_s)
CTR_j = collections.Counter(j_s)

i_value = CTR_i.keys()
total = 0

for v in i_value:
    N_i = CTR_i[v]
    N_j = CTR_j[v]
    
    total += N_i * N_j

print(total)



Measured memory_bytes: 63372
def main():
    N, K = map(int, input().split())
    children_with_sweets = set()
    for i in range(K):
        d = int(input())
        a = set(map(int, input().split()))
        children_with_sweets = children_with_sweets | a        

    print(N - len(children_with_sweets))

main()

Measured memory_bytes: 67412
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<char> arr;
  map<char, int> amap, bmap;
  for(int i=0;i<N;++i) {
    if(amap[S[i]]==0) arr.push_back(S[i]);
    amap[S[i]]++;
  }
  for(int i=N;i<2*N;++i) bmap[S[i]]++;
  bool can = true;
  for(int i=0;i<arr.size();++i) {
    if(amap[arr[i]]!=bmap[arr[i]]) can = false;
  }
  if(!can) {
    cout<<0<<endl;
    return 0;
  }
  map<pair<string, string>, ll> cmap;
  string tmp1, tmp2;
  vector<string> arr1;
  for(int bit=0;bit<(1<<N);++bit) {
    tmp1.clear();
    tmp2.clear();
    for(int i=0;i<N;++i) {
      if((bit&(1<<i))!=0) tmp1.push_back(S[i+N]);
      else tmp2.push_back(S[i+N]);
    }
    reverse(tmp2.begin(), tmp2.end());
    cmap[mp(tmp1, tmp2)]++;
  }
  ll ans = 0;
  for(int bit=0;bit<(1<<N);++bit) {
    tmp1.clear();
    tmp2.clear();
    for(int i=0;i<N;++i) {
      if((bit&(1<<i))!=0) tmp1.push_back(S[i]);
      else tmp2.push_back(S[i]);
    }
    reverse(tmp2.begin(), tmp2.end());
    ans += cmap[mp(tmp2, tmp1)];
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 60728
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    ans = 0
    for i in range(n - 1):
        if al[i] == al[i + 1]:
            ans += 1
            al[i + 1] = 99999
    print(ans)

if __name__=="__main__":
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#include <math.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;

/*-----Library-----*/

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        sizeuf[x]+=sizeuf[y];
        return true;
    }
    
    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*-----Library-----*/

signed main(){
    long double a,b,x;
    cin>>a>>b>>x;
    long double k=x/a;
    if(a*b/2>=k){
        cout<<setprecision(16)<<90-atan((k*2/b)/b)*(long double)180/M_PI<<endl;
    }else{
        cout<<setprecision(16)<<atan((2*b-k*2/a)/a)*(long double)180/M_PI<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)
#define N          1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,p,r,u,v,w,x,y,z,mn,mx;

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        mn=LONG_LONG_MAX;
        mx=LONG_LONG_MIN;
        cin>>n>>w;
        ll dp[n+1][w+1];
        ll val[n],wgt[n];
        rep(i,0,n)
        {
            cin>>wgt[i]>>val[i];
        }
        
        for(ll i=0;i<=n;i++)
        {
            for(j=0;j<=w;j++)
            {
                if(i==0 or j==0)dp[i][j]=0;
                else
                {
                    if(j>=wgt[i-1])dp[i][j]=max(dp[i-1][j],dp[i-1][j-wgt[i-1]]+val[i-1]);
                    else dp[i][j]=dp[i-1][j];
                }
            }
        }
        
        cout<<dp[n][w];
        
        
        
        
        
        
        
        
        h:;
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 82440
/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

int a[1234567];

void solve() {
    ll n, a, ans(0);
    vl v;
    priority_queue<ll> q;
    cin >> n;
    F0R(i, n){
        cin >> a;
        v.push_back(a);
        q.push(a);
    }
    q.pop();
    sort(v.rbegin(), v.rend());
    ans += v[0];
    for(int i = 2; i < v.size(); i += 2){
        a = q.top();
        q.pop();
        ans += a;
        if(i + 1 < n){
            ans += a;
        }
    }
    cout << ans<< nl;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 6736
import java.util.*;

public class Main {
  public static void main(String[] args) {
    final Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int N = sc.nextInt();

    if (W >= H) {
      for (int i = 1; i <= H; ++i) {
        if (N - W * i <= 0) {
          System.out.println(i);
          System.exit(0);
        }
      }
    } else {
      for (int i = 1; i <= W; ++i) {
        if (N - H * i <= 0) {
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
}


Measured memory_bytes: 21844