akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var T = ReadSplitInt();
            var M = ReadInt();
            var list = new List<IList<int>>();
            for (var i = 0; i < M; i++)
                list.Add(ReadSplitInt());

            foreach (var l in list)
            {
                var sum = 0;
                for (var i = 0; i < N; i++)
                {
                    if (l[0] - 1 == i)
                        sum += l[1];
                    else
                        sum += T[i];
                }
                Println(sum);
            }
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();

        static void Print(object value = null) => Console.Write(value.ToString());
        static void Println(object value = null) => Console.WriteLine(value.ToString());
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <algorithm>
using namespace std;
double unit = 0.001;
typedef complex<double> P;
#define rep(i,n) for(int i=0;i<n;i++)

bool cmp(const pair<P,P>&a,const pair<P,P>&b){
	return a.first.imag() < b.first.imag();
}
int main(){
	int n,N=0;
	while(cin >> n ,n){
		vector< pair<P,P> > data;
		double ans = 0;
		rep(i,n){
			double a,b,r;
			cin >> a >> b >> r;
			data.push_back(make_pair(P(a-r,b-r),P(a+r,b+r)));
		}
		sort(data.begin(),data.end(),cmp);
		for(double x=-200;x<=400;x += unit){
			vector< pair<double,double> > L;
			rep(i,n){
				if(data[i].first.real() <= x && x <= data[i].second.real()){
					L.push_back(make_pair(data[i].first.imag(),data[i].second.imag()));
				}
			}
			if(L.size() == 0)continue;
			double sz = 0;
			double cs = L[0].first, ce = L[0].second;		
			for(int i=1;i<L.size();i++){
				if(L[i].first <= ce)ce = max(ce,L[i].second);
				else sz += ce-cs , cs = L[i].first , ce = L[i].second;
			}
			sz += ce-cs;
			ans += sz * unit;
		}
		printf("%d %.2lf\n",++N,ans);
	}
 
}

Measured memory_bytes: 988
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    ll N, K, s, p, r, ans=0;
    cin >> N >> K >> s >> p >> r;
    string T;
    cin >> T;
    for(int i=0; i<N; i++){
        if(i<K){
            if(T[i] == 's') ans += s;
            if(T[i] == 'p') ans += p;
            if(T[i] == 'r') ans += r;
        }else if(T[i] == T[i-K]){
            T[i] = 'e';
        }else{
            if(T[i] == 's') ans += s;
            if(T[i] == 'p') ans += p;
            if(T[i] == 'r') ans += r;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	int sum=0;
	bool flag=0;
	scanf("%lld",&n);
	while(n>=10)
	{
		int temp=n%10;
		if(temp!=9)flag=1;//19999不用退位 否则19879需退成9999 
		n/=10;
		sum++;//如果只有一位 是几就是几 
	}
	if(sum)printf("%d\n",9*sum+n-flag);
	else printf("%d\n",n);
} 

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

int main() {
	ll h; cin >> h;
	ll ans = 1;
	ll tmp = 1;
	while (h > 1) {
		tmp *= 2;
		h /= 2;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
S_bef = int(S[:2])
S_aft = int(S[-2:])

is_bef_yy = False
is_bef_mm = False
is_aft_yy = False
is_aft_mm = False

if S_bef >= 1 and S_bef <= 12:
    is_bef_mm = True
if S_bef >= 0:
    is_bef_yy = True
if S_aft >= 1 and S_aft <= 12:
    is_aft_mm = True
if S_aft >= 0:
    is_aft_yy = True

if is_bef_yy and is_bef_mm and is_aft_yy and is_aft_mm:
    print('AMBIGUOUS')
elif is_bef_yy and is_aft_mm:
    print('YYMM')
elif is_aft_yy and is_bef_mm:
    print('MMYY')
else:
    print('NA')



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

int N, W;

int w[110];
int v[110];

long long INF = 1LL<<60;
long long dp[110][100100];
long long max_val = 100100;

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

    for (int i = 0; i < N; i++) for(int j = 0; j < max_val; j ++) dp[i][j] = INF;

    dp[0][0] = 0;
    for(int i = 0; i < N; i++){
        for(long long val = 0; val < max_val ; val++){
            if(val - v[i] >= 0) dp[i+1][val] = min(dp[i][val], dp[i][val-v[i]] + w[i]);
            else dp[i+1][val] = dp[i][val];
        }
    }

    long long ans = 0;
    for (int val = 0; val < max_val; val++){
        if (dp[N][val] <= W) ans = val;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80128
from collections import deque
from copy import deepcopy

N, K = map(int, input().split())
V = list(map(int, input().split()))
q = deque()
for v in V:
    q.append(v)
ans = 0
jotai = []
for l in range(K + 1):
    for r in range(K + 1 - l):
        if l + r <= N and l + r  <= K:
            jotai.append([l, r, K - l - r])

for i in range(len(jotai)):
    d = deepcopy(q)
    tmp = []
    for l in range(jotai[i][0]):
        tmp.append(d.popleft())
    # print(tmp)
    for r in range(jotai[i][1]):
        tmp.append(d.pop())
    # print(tmp)
    for k in range(jotai[i][2]):
        if (tmp and min(tmp) < 0):
            tmp.remove(min(tmp))
    # print(tmp)
    ans = max(sum(tmp), ans)
print(ans)

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    string S;
    cin >> S;
    
    string ans = (S=="hi" or S=="hihi" or S=="hihihi" or S=="hihihihi" or S=="hihihihihi") ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign


signed main()
{
    int2(b, a);
    while (a) {
        Int(n);
        vvi dp(a+1, vi(b+1, 0));
        vvb state(a, vb(b, true));
        rep(i, n) {
            int2(c, d);
            state[d-1][c-1] = false;
        }
        dp[0][0] = 1;
        rep(i, a) {
            rep(j, b) {
                if (state[i][j]) {
                    dp[i+1][j] += dp[i][j];
                    dp[i][j+1] += dp[i][j];
                }
            }
        }
        /*
        rep(i, a) {
            rep(j, b) {
                if (state[i][j]) {
                    cout << dp[i][j] << " ";
                } else {
                    cout << 0 << " ";
                }
            }cout << endl;
        }
        */
        cout << dp[a-1][b-1] << endl;
        cin >> b >> a;
    }

    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int H, W;
int c[10][10];


signed main()
{
  cin >> H >> W;
  REP(i,10) REP(j,10) cin >> c[i][j];

  REP(k,10) REP(i,10) REP(j,10) {
    c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  }

  int ans = 0;
  REP(i,H) REP(j,W) {
    int A;
    cin >> A;
    if (A != -1) {
      ans += c[A][1];
    }  
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// C++ implementation of the above approach 
#include <bits/stdc++.h> 
using namespace std; 

enum name_t
{
    TARO=1,
    JERO=2
};

name_t coin_game_winner(vector<int> &allowed_denoms, int total_coins)
{
    vector<vector<name_t>> dp(total_coins+1, vector<name_t>(allowed_denoms.size(), JERO));
    for(int ri=0; ri<dp.size(); ri++)
    {
        for(int ci=0; ci<dp[0].size(); ci++)
        {
            if(ri == 0)
            {
                dp[ri][ci] = (allowed_denoms[ci] == 0) ? TARO : JERO;
            }
            else if(ci == 0)
            {
                int total_coins = ri;
                int allowed_denom = allowed_denoms[ci];
                if(total_coins < allowed_denom)
                {
                    dp[ri][ci] = JERO;
                }
                else if (total_coins == allowed_denom)
                {
                    dp[ri][ci] = TARO;
                }
                else
                {
                    int quot = total_coins/allowed_denom;
                    if(quot%2 != 0)
                    {
                        dp[ri][ci] = TARO;
                    }
                    else
                    {
                        dp[ri][ci] = JERO;
                    }
                }
            }
            else
            {
                int total_coins = ri;
                int allowed_denom = allowed_denoms[ci]; 
                if(total_coins < allowed_denom)
                {
                    dp[ri][ci] = dp[ri][ci-1];
                }
                else if (total_coins == allowed_denom)
                {
                    dp[ri][ci] = TARO;
                }
                else
                {
                    int poss_ri;
                    int curr_ci = ci;
                    int total_coins = ri;
                    dp[ri][ci] = JERO;
                    while(curr_ci >= 0)
                    {
                        poss_ri = total_coins - allowed_denoms[curr_ci];
                        if(dp[poss_ri][ci] == JERO)
                        {
                            dp[ri][ci] = TARO;
                            break;
                        }
                        curr_ci--;
                    }
                }
            }
        }
    }
    /*
    for(int ri=0; ri<dp.size(); ri++)
    {
        for(int ci=0; ci<dp[0].size(); ci++)
        {
            cout << dp[ri][ci] << " ";
        }
        cout << endl;
    }
    */
    return dp[dp.size()-1][dp[0].size()-1];
}

// Driver Code 
int main() 
{ 
    int num_inputs, k, temp;
    vector<int> allowed_denoms;
    cin >> num_inputs;
    cin >>  k;
    for(int i=0; i < num_inputs; i++)
    {
        cin >> temp;
        allowed_denoms.push_back(temp);
    }
    
    string result =  (coin_game_winner(allowed_denoms, k) == TARO) ? "First" : "Second";
    cout << result;

	return 0; 
} 


Measured memory_bytes: 43264
#include<stdio.h>

int main(){
    short town[4][4];
    short visit[4];
    int count1=0, count2=0;
    short a,b,i;

    for(a=0;a<4;a++){
        for(b=0;b<4;b++)
            town[a][b]=0;
        visit[a]=0;
    }

    for(i=0;i<3;i++){
        scanf("%d%d",&a,&b);
        town[a-1][b-1]=1;
        town[b-1][a-1]=1;
    }

    for(a=0;a<4;a++){
        for(b=0;b<4;b++){
            visit[a] = visit[a]+town[a][b];
        }
    }

    for(a=0;a<4;a++){
        if(visit[a]==1)
            count1++;
        if(visit[a]==2)
            count2++;
    }

    if(count1==2&&count2==2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
 
int mp[12][12];
 
void dfs_fill(int y, int x)
{
    if (y < 0 || y >= 12 || x < 0 || x >= 12) return;
 
    if (!mp[y][x]) return;
 
    mp[y][x] = 0;
 
    for (int i = 0; i < 4; ++i) dfs_fill(y + dy[i], x + dx[i]);
}
 
int main()
{
    string s;
    while (getline(cin, s)) {
        if (s.empty()) continue;
 
        for (int y = 0; y < 12; ++y) {
            for (int x = 0; x < 12; ++x) mp[y][x] = s[x] - '0';
            getline(cin, s);
        }
 
        int ans = 0;
 
        for (int i = 0; i < 12; ++i) for (int j = 0; j < 12; ++j) {
            if (mp[i][j]) {
                dfs_fill(i, j);
                ans++;
            }
        }
 
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	long long ans=0,Count=0;
	int len=s.length();
	for(int j=len-1;j>=0;j--)
	{
		if(s[j]=='W')
			Count++;
		else 
			ans+=Count;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a := r.nextStringArray().toInts()

	count := map[int]int{}
	for _, v := range a {
		count[v]++
	}

	ans := "No"
	for _, v := range count {
		if v == 2 {
			ans = "Yes"
			break
		}
	}

	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,S=pin()
    A=tupin()#調子にのるな
    mod=998244353

    #形式的冪級数を考える
    #普通の部分和ッ->集合内の各アイテムについて、選ぶか選ばないか。O(2^n)の探索
    #これを形式的冪級数でいえば、（1+x^a）を掛ける計算になる　指数時間ではない
    #つまり、集合A,Sに対して、[x^s]PI(1+x^a_i) (ひだりのカッコ部分をf_iとする)

    #次に、Aの部分集合、じゃなくて問題の区間について考える (ABC169と異なる部分はここ)
    #サンプル1の場合。区間に含まれるのは…って考える前に
    #区間なので終点があるね、a3が追加されることで終点にf3がある区間が追加されるよね
    #じゃあこれももしかしたら漸化式で作れるかも
    #F0=f0=1,F1=1+f1,F2=1+f1f2+f1+f2,F3=1+f1f2f3+f1f2+f1+f2f3+f2+f3...
    #F2=f2(f1+1)+f1+1 ,F3=f3(f1f2+f2+1)+f1f2+f1+f2+1=f3(f1f2+f2+1)+f2(f1+1)+f1+1
    #えっこれ漸化式の和？G3=f3(f1f2+f2+1)みたいに終点ごとにわける
    #G3=f3(f2(f1+1)+1)=f3(G2+1),G2=f2(f1+1)=f2(G1+1) Gn=fn(1+Gn-1)=(1+x^a)(1+Gn-1)
    #F3=G3+G2+G1=f2(G2+1)+G2+G1,
    #Fn+1-Fn=fn+1*(1+Gn)=(1+x^a_(n+1))*(1+Gn)=Gn+1=(1+x^a)(1+Gn)
    #FもGも漸化式で求められることがわかりました（？）

    from collections import defaultdict #本当は良くないがわかりやすさのためココに置く
    from copy import deepcopy

    F=defaultdict(int)
    G=defaultdict(int)
    F[0]=1 #init
    #F1-F0=f1*(1+G0)=f1+1
    #print(ans)
    for a in A:
        #G
        if len(G)==0:
            G[0]=1
            if a<=S:
                G[a]=1
        else:
            G[0]+=1
            temp=defaultdict(int)
            for g in G:
                temp[g]+=G[g]
                if g+a<=S:
                    temp[g+a]+=G[g]
                    temp[g+a]%=mod
            G=temp
            
        #Fの計算
        for g in G:
            F[g]+=G[g]
            F[g]%=mod
                    #print(F)
    print(F[S])



#%%submit!
resolve()


Measured memory_bytes: 88556
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> in(n);
	for (int i = 0; i < n; i++) {
		cin >> in[i];
	}
	sort(in.begin(), in.end());
	long long sum = 0;
	int ans = 0;
	for (int i = 0; i + 1 < n; i++) {
		sum += in[i];
		ans++;
		if (sum * 2 < in[i + 1]) ans = 0;
	}
	cout << ans + 1 << '\n';
	return 0;	
}


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

#[allow(dead_code)]
macro_rules! d {
    ($e:expr) => {println!("{} = {:?}", stringify!($e), $e)}
}

#[allow(dead_code)]
fn read_string() -> String{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf
}

fn read_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn read_ints() -> Vec<i64>{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n = read_int();
    let mut ls = read_ints();

    ls.sort();

    println!("{}", (0..n).map(|i| ls[(i * 2) as usize])
             .fold(0, std::ops::Add::add));
}


Measured memory_bytes: 380
#include <iostream>

using namespace std;

const int MAXN=1e5;

int dp[MAXN][3]={0};

int main()
{
    int n;

    cin >>n;

    for (int i=0; i<n; ++i)
    {
        int a[3];

        for (int j=0; j<3; ++j)
        {
            cin >>a[j];
        }

        if (i==0)
        {
            for (int j=0; j<3; ++j)
            {
                dp[i][j]=a[j];
            }
        }
        else
        {
            for (int j=0; j<3; ++j)
            {
                int maxi=-1;
                for (int k=0; k<3; ++k)
                {
                    if (j!=k)
                    {
                        maxi=max(maxi, dp[i-1][k]);
                    }
                }

                dp[i][j]=a[j]+maxi;
            }
        }
    }

    cout <<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

    return 0;
}


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

using namespace std;

void inf() {
    cout << "-1\n";
    exit(0);
}

int n, x, y;
vector<vector<int> > gr1, gr2;
vector<int> d, pr, d2, pr2;

void readGr(vector<vector<int> > &gr1) {
    gr1.assign(n, vector<int>());
    for (int i = 1; i < n; ++i) {
        int v1, v2;
        scanf("%d%d", &v1, &v2);
        --v1;
        --v2;
        gr1[v1].push_back(v2);
        gr1[v2].push_back(v1);
    }
}

void dfs(int v, int prv, vector<vector<int> >& gr, vector<int>& d, vector<int>& pr) {
    for (int nv : gr[v])
        if (nv != prv) {
            d[nv] = d[v] + 1;
            pr[nv] = v;
            dfs(nv, v, gr, d, pr);
        }
}

int findDst(int v1, int v2, vector<int> &d, vector<int>& pr) {
    if (d[v1] > d[v2])
        swap(v1, v2);
    if (d[v2] >= d[v1] + 3)
        return 3;
    int ans = 0;
    while (d[v2] != d[v1]) {
        ++ans;
        v2 = pr[v2];
    }
    while (ans < 3 && v1 != v2) {
        ans += 2;
        v1 = pr[v1];
        v2 = pr[v2];
    }
    return min(ans, 3);
}

int main() {
    scanf("%d%d%d", &n, &x, &y);
    --x; --y;
    readGr(gr1);
    readGr(gr2);
    
    d2.assign(n, 0);
    pr2.assign(n, -1);
    dfs(y, -1, gr2, d2, pr2);
    
    vector<int> good(n, 0);
    for (int i = 0; i < n; ++i)
        for (int v : gr1[i])
            if (i < v)
                if (findDst(i, v, d2, pr2) >= 3) {
                    good[i] = good[v] = 1;
                }
    vector<int> d(n, -1);
    queue<int> Q;
    Q.push(x);
    
    d[x] = 0;
    int ans = d2[x];
    while (!Q.empty()) {
        int v = Q.front();
        Q.pop();
        if (good[v])
            inf();
        for (int nv : gr1[v])
            if (d[nv] < 0 && d[v] + 1 < d2[nv]) {
                Q.push(nv);
                ans = max(ans, d2[nv]);
                d[nv] = d[v] + 1;
            }
            else if (d[v] + 1 == d2[nv])
                ans = max(ans, d2[nv]);
    }
    cout << 2*ans << "\n";   
    return 0;
}

Measured memory_bytes: 39420
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
int arr1[10001];
int arr2[10001];
//
ll a, b;
bool ispossible(ll mid, ll u, ll v) {
	if (u + 2 * mid - v >= 0) return true;
	return false;
}
int main() {
	scanf("%d", &N);
	for (int n = 0; n < N; n++) scanf("%d", &arr1[n]), a += (ll)arr1[n];
	for (int n = 0; n < N; n++) scanf("%d", &arr2[n]), b += (ll)arr2[n];

	if (b - a < 0) return !printf("No\n");
	ll t = b - a;
	ll s1 = 0, s2 = 0;
	for (int n = 0; n < N; n++) {
		ll l = 0, r = 1e9;
		ll x, y;
		ll idx = 2e9;
		while (l <= r) {
			ll mid = (l + r) >> 1;
			if (ispossible(mid, arr1[n], arr2[n])) idx = min(idx, mid), r = mid - 1;
			else l = mid + 1;
		}
		x = idx;
		y = arr1[n] + 2 * x - arr2[n];
		s1 += x; s2 += y;
	}
	if (s1 >= s2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

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

    if(a + b == 15) cout << "+" << endl;
    else if(a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 3632
h,w=map(int,input().split())
a=[]
for i in range(h):
    li=list(input())
    a.append(li)
for i in range(w):
    b=0
    for j in range(h):
        if a[j][i]=='.':
            b+=1
    if b==h:
        for k in range(h):
            a[k][i]=''
for j in range(h):
    if a[j].count('#')!=0:
        print(''.join(a[j]))


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

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

use std::collections::BinaryHeap;

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      aa: [usize; n],
    }

    let mut heap = BinaryHeap::new();
    for a in aa {
        heap.push(a);
    }

    for _ in 0..m {
        let mut v = heap.pop().unwrap();
        v = v/2;
        heap.push(v);
    }

    let mut ans = 0usize;
    for &v in heap.iter() {
        ans += v;
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 6396
local mfl, mce, mmi = math.floor, math.ceil, math.min
local mma = math.max
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, ary, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < #ary do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, #ary do self.stage[stagenum][i] = ary[i] end
  for i = #ary + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getTop = function(self)
  return self.stage[1][1]
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(ary, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(ary, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local a, b, stb = {}, {}, {}
for i = 1, n do
  a[i] = io.read("*n")
end
for i = 1, n do
  b[i] = io.read("*n")
  stb[i] = {i, b[i]}
end
local st = SegTree.new(stb, function(x, y)
  return x[2] < y[2] and y or x
end, {0, 0})

local rem = n
local cnt = 0
while 0 < rem do
  local top = st:getTop()
  local idx = top[1]
  local l, r = idx - 1, idx + 1
  if l == 0 then l = n end
  if r == n + 1 then r = 1 end
  local mul = b[l] + b[r]
  if a[idx] == b[idx] then
    rem = rem - 1
    st:setValue(idx, {idx, 0})
  elseif b[l] <= a[idx] and b[r] <= a[idx] then
    if (b[idx] - a[idx]) % mul ~= 0 then
      cnt = -1
      break
    else
      cnt = cnt + (b[idx] - a[idx]) / mul
      rem = rem - 1
      st:setValue(idx, {idx, 0})
      b[idx] = a[idx]
    end
  else
    local dst = mma(b[l] - 1, b[r] - 1)
    local x = mce((b[idx] - dst) / mul)
    dst = b[idx] - mul * x
    if dst < 1 then
      cnt = -1
      break
    else
      cnt = cnt + x
      b[idx] = dst
      st:setValue(idx, {idx, dst})
    end
  end
end
print(cnt)


Measured memory_bytes: 97252
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    char tile[2][4];
    cin >> tile[0] >> tile[1];
    if(tile[0][0]==tile[1][2] && tile[0][1]==tile[1][1] && tile[0][2]==tile[1][0]){
        cout << "YES";
    }else{
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int popcount(int x){
    int ret = 0;
    while (x) {
        ret += (x % 2);
        x /= 2;
    }
    return ret;
}

int calc(int x){
    if (x == 0) return 0;
    x %= popcount(x);
    return 1 + calc(x);
}

int main(void){
    int n;
    string s;
    cin >> n >> s;
    VI a(n);
    REP(i,n) a[i] = (s[i] - '0');
    reverse(ALL(a));
    int c = 0;
    REP(i,n) c += a[i];
    int sp = 0, sn = 0;
    int xp = 1, xn = 1;
    REP(i,n){
        if (a[i]) {
            sp = (sp + xp) % (c + 1);
            if (c > 1) sn = (sn + xn) % (c - 1);
        }
        xp = (2 * xp) % (c + 1);
        if (c > 1) xn = (2 * xn) % (c - 1);
    }

    xp = xn = 1;
    VI ans(n);
    REP(i,n){
        int x = 0;
        if (a[i]){
            if (c > 1){
                int d = (sn - xn + c - 1) % (c - 1);
                x = 1 + calc(d);
            }
        }else{
            int d = (sp + xp) % (c + 1);
            x = 1 + calc(d);
        }
        xp = (2 * xp) % (c + 1);
        if (c > 1) xn = (2 * xn) % (c - 1);
        ans[n - 1 - i] = x;
    }

    REP(i,n) printf("%d\n", ans[i]);

    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return x / g * y;
}

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

  vector<ll> t(n);
  for (ll i = 0; i < n; ++i) {
    cin >> t[i];
  }
  
  ll ans = 1;
  each (i, t) {
    ans = lcm(ans, i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3608
def main():
    n, k = map(int, input().split())
    s = input()
    result = ''
    for i in range(0, len(s)):
        if i == k-1:
            result += s[i].lower()
        else:
            result += s[i]
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9112
x=list(input())
stack=[]
t_f=[]
for i in range(len(x)):
    if x[i]=="S":
        stack.append(x[i])
    elif x[i]=="T":
        if len(stack)!=0:
            stack.pop()
        else:
            t_f.append(x[i])
print(len(stack)+len(t_f))



Measured memory_bytes: 6436
import sys
input = sys.stdin.readline
from collections import Counter, deque


INF = float('inf')


def main():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)

    counter = 0
    for a in A:
        if sum(A) <= a * (4 * M):
            counter += 1

    if counter < M:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38660
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll h, w;
ll vis[405][405];
vector<string> s;
ll cb = 0, cw = 0;
int xx[5] = {0, 0, 1, -1};
int yy[5] = {1, -1, 0, 0};
void dfs(int i, int j)
{
    int type ;
    vis[i][j] = 1;
    if(s[i][j] == '.')
    {
        cw++;
        type = 0;
    }
    else
    {
        cb++;
        type = 1;
    }
    //cout<<i<<" "<<j<<endl;
    int xd, yd;
    int k;
    FOR0(k, 4) 
    {
        xd = i + xx[k], yd = j + yy[k];
        if(xd>=0&&xd<h&&yd>=0&&yd<w&&!vis[xd][yd])
        {
            int ctype;
            if(s[xd][yd]=='.') ctype = 0;
            else ctype = 1;
            if(ctype!=type)
                dfs(xd, yd);
        }
    }
    return;
} 
int main()
{
    she_told_me_dont_worry
    cin>>h>>w;
    int i, j;
    FOR0(i, h)
    {
        string in;
        cin>>in;
        s.pb(in);
    }
    FOR0(i, 401)FOR0(j, 401) vis[i][j] = 0;
    ll ans = 0;
    FOR0(i, h)FOR0(j, w)
    {
        cb = 0, cw =0;
        if(!vis[i][j])
        {
            dfs(i, j);
            //cout<<cb<<" "<<cw<<endl;
            ans += cb*cw;
        }
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 14208
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void proc(int n, int m);
int compare_int(const void *p1, const void *p2);

int main ()
{
	while (1) {
		int n, m;
		scanf("%d %d", &n, &m);
		if (n == 0 && m == 0) {
			break;
		}
		proc(n, m);
	}
	return 0;
}

void proc(int n, int m)
{
	int i, j;
	int mp;
	int *ps, *ps2;

	ps = calloc(n, sizeof(int));
	for (i=0; i<n; i++) {
		scanf("%d", &ps[i]);
	}

	ps2 = calloc(1+n+n*n, sizeof(int));
	ps2[0] = 0;
	for (i=0; i<n; i++) {
		ps2[1+i] = ps[i];
	}
	for (i=0; i<n; i++) {
		for (j=0; j<n; j++) {
			ps2[1+n+(n*i)+j] = ps[i]+ps[j];
		}
	}
	qsort(ps2, 1+n+n*n, sizeof(int), compare_int);

	i = 0;
	j = n*n+n;
	mp = 0;
	while (i <= j) {
		int cp;
		cp = ps2[i] + ps2[j];
		if (cp <= m) {
			if (cp > mp) {
				mp = cp;
			}
			i++;
		} else {
			j--;
		}
	}

	free(ps);
	free(ps2);

	printf("%d\n", mp);
}

int compare_int(const void *p1, const void *p2)
{
	return *(const int*)p1 - *(const int*)p2;
}

Measured memory_bytes: 8556
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int x = in.nextInt();
            int y = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            int dx = x2 - x;
            int dy = y2 - y;
            int x3 = x2 - dy;
            int y3 = y2 + dx;
            int x4 = x3 - dx;
            int y4 = y3 - dy;
            System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
        }
    }
}


Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

int before[200001];
ll ans[200000];

int main() {
    int N;
    vector<int> C;
    cin >> N;
    REP(i, N) {
        int c;
        cin >> c;
        if (C.empty() || !C.empty() && C[C.size() - 1] != c) C.push_back(c);
    }
    N = C.size();

    fill(before, before + 200001, -1);
    vector<pll> vp;
    REP(i, N) {
        if (before[C[i]] != -1) vp.push_back({before[C[i]], i});
        before[C[i]] = i;
    }
    if (vp.empty()) {
        cout << 1 << endl;
        return 0;
    }
    sort(ALL(vp));

    ll vpi = 0;
    REP(i, N - 1) {
        if (vp[vpi].first == i) {
            ans[vp[vpi].second] += ans[i] + 1;
            ans[vp[vpi++].second] %= MOD;
        }
        ans[i + 1] += ans[i];
        ans[i + 1] %= MOD;
    }
    cout << ans[N - 1] + 1 << endl;
    return 0;
}

Measured memory_bytes: 8048
N = input()
P = list(input().split())
count = 0

for i in range(len(P)-2) :
	judge_list = list() 
	midle = int(P[i+1])
	judge_list.extend([int(P[i]),int(P[i+1]),int(P[i+2])])
	judge_list.sort()

	if midle == judge_list[1]:
		count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
            using namespace std;
             
            int main() {
              int N, A,B,X1;
               
              cin >> N >> A >> B;
              X1= N*A;
              if(X1==B){cout << X1 << endl;}
              else if(X1>B){cout << B << endl;}
              else{cout << X1 << endl;}
            }

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]*n
wa=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA" and a[p-1]!=1:
        a[p-1]-=1
    elif s=="AC" and a[p-1]!=1:
        wa-=a[p-1]
        a[p-1]=1

print(a.count(1),wa)

Measured memory_bytes: 9576
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	Scanner sc;

	void run() {

		boolean p[] = new boolean[1300000];
		Arrays.fill(p, true);
		p[0] = false;
		p[1] = false;

		for (int i = 0; i < 1300; i++) {
			if (p[i]) {
				for (int j = i + i; j < 1300000; j += i) {
					p[j] = false;
				}
			}
		}

		LinkedList<Integer> l = new LinkedList<Integer>();
		for (int i = 0; i < 1300000; i++) {
			if (p[i]) {
				l.add(i);
			}
		}

		for (;;) {
			int n = sc.nextInt();

			if (n == 0) {
				break;
			}

			int index = Collections.binarySearch(l, n);
			if(index >= 0){
				System.out.println(0);
			}else{
//				System.out.println(l.get(-index));
//				System.out.println(l.get(-index-1));
				System.out.println(l.get(-index-1) - l.get(-index-2));
			}
		}
	}

	Main() {
		sc = new Scanner(System.in);
		try {
			sc = new Scanner(new File(""));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim?year=2006>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int n; cin >> n;
    vector<ll> a(n); for(auto& in:a) cin >> in;
    sort(a.begin(),a.end());
    
    vector<ll> ts;
    for(int i = 0; i < min(100,n);i++){
        for(int j = 0; j < n;j++){
            if(i==j)continue;
            string t = to_string(a[i]) + to_string(a[j]);
            ts.push_back(atoll(t.c_str()));
        }
    }
    sort(ts.begin(),ts.end());
    res = ts[2];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 11300
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>> arm;
	for (int i = 0; i < n; i++)
	{
		int x, l;
		cin >> x >> l;
		arm.push_back(make_pair(x - l, x + l));
	}
	sort(arm.begin(), arm.end(), [](pair<int, int> a, pair<int, int> b)
		{
			return a.second < b.second;
		});
	int remove = 0;
	int right = arm[0].second;
	for (int i = 1; i < n; i++)
	{
		if (right <= arm[i].first)
		{
			right = arm[i].second;
		}
		else
		{
			remove++;
		}
	}
	cout << (n - remove);
}


Measured memory_bytes: 32632
import itertools
n,m=map(int,input().split())
path=[[False]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    path[a][b]=True
    path[b][a]=True
ans=0;

for i in itertools.permutations(range(n),n):
    if i[0]==0:
        for j in range(n):
            if j==n-1:
                ans+=1
                break
            if not path[i[j]][i[j+1]]:
                break
print(ans)

Measured memory_bytes: 3064