akhauriyash/Code-Regression huggingface dataset:
#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        sc: [[u32;2];m],
    }
    let mut target = vec!['a';n];
    let mut valid = true;
    for i in 0..m {
        let idx = (sc[i][0] - 1) as usize;
        let num = std::char::from_digit(sc[i][1], 10).unwrap();
        if target[idx] != 'a' && target[idx] != num {
            valid = false;
        }else{
            target[idx] = num;
        }
    }
    for i in 0..n {
        if n==1 &&(target[0]  == 'a' || target[0]  == '0'){
            target[0] = '0';
        }else if target[0] == '0'{
            valid = false;
        }else if i == 0 && target[i] == 'a' {
            target[i] = '1';
        }else if target[i] == 'a'{
            target[i] = '0';
        }
    }
    if valid {
        println!("{}", target.into_iter().collect::<String>());
    }else{
        println!("-1");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <cassert>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int N = 1000000 + 7;
const int M = 1007;
const int inf = 1e9 + 7;
const long long linf = 1e18 + 7;
const double pi = acos(-1);
const double eps = 1e-7;
const bool multipleTest = 0;


int a[N], b[N];
int n;
ll ans = 0;

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", a + i, b + i);
    }
    
    for(int i = n - 1; i >= 0; --i) {
        ll cur = (a[i] + ans) % b[i];
        if (cur > 0) cur = b[i] - cur;
        ans += cur;
//        cout << i << ' ' << cur << '\n';
    }
    
    cout << ans << '\n';
    
    
}




int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
#endif
    
//    freopen("out.txt", "w", stdout);
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        
        solve();
    }
    
#ifdef _LOCAL_
    //    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC<<endl;
#endif
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int count = 0;
        int tmp;
        int tmp2;
        int elemCount;
        HashSet<Integer> b = new HashSet<Integer>();
        if (a<105) {
        	System.out.println(count);
        }else {
        	for (int i=105;i<=a;i++) {
        		if(i%2 != 0) {
        			b=new HashSet<Integer>();
        			elemCount = 0;
        			tmp = 3;
        			tmp2 = i;
        			while(tmp2 != 1) {
        			    if(tmp2%tmp == 0) {
        			          b.add(tmp);
        			          elemCount++;
        			          tmp2 /= tmp;
        			    }
        			    else {
        			    	tmp+=2;
        			    }
        			}
        			if((b.size()==3&&elemCount==3)||(b.size()==2&&elemCount==4)) {
        				count++;
        			}

        		}
        	}
        	System.out.println(count);
        }

        //int[] sosuu = {3 ,5 ,7 ,11 ,13};
        /*
         * 3,5,7   = 105 # 3,5,7,15,21,35
         * 3,3,3,5 = 135 # 3,5,9,15,27,45
         * 3,3,5,5 = 225 X
         * 3,5,11  = 165 # 3,5,11,15,33,55
         * 3,3,3,7 = 175
         * 3,5,13  = 195 # 3,5,13,15,39,65
         * 5,7,11  = 385 X
         */
        /*
        if (a < 105) {
        	System.out.println(0);
        }else if(a < 135) {
        	System.out.println(1);
        }else if(a < 165) {
        	System.out.println(2);
        }else if(a < 175) {
        	System.out.println(3);
        }else if(a < 195) {
        	System.out.println(4);
        }else {
        	System.out.println(5);
        }
        */

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <map>

using namespace std;

map <string, int> m;
string s;
int n, dist;

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    m[s]++;
    if (m[s] == 1)
      dist++;
  }
  cout << dist;
  return 0;
}


Measured memory_bytes: 18744
main=do
    [x,y]<-map read.words<$>getLine
    print $ sol x y
sol x y =  minimum $ map (uncurry (+)) $ filter (\(a,_)->a>=0) [(a00,0),(a10,1),(a01,1),(a11,2)]
    where
        a00 = y-x
        a10 = y-(-x)
        a01 = (-y)-x
        a11 = (-y)-(-x)


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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int cnt = 0;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        if (s[i - 1] != s[i]) {
            cnt++;
        }
        else {
            ans++;
        }
    }

    if (cnt % 2 == 0) {
        if (cnt / 2 <= k) {
            ans += (cnt / 2) * 2;
        }
        else {
            ans += 2 * k;
        }
    }
    else {
        if ((cnt / 2) + 1 <= k) {
            ans += (cnt / 2) * 2 + 1;
        }
        else {
            ans += 2 * k;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var dic = new Dictionary<string, int>();
            for(var i=0;i<N;i++)
            {
                var tmp = Console.ReadLine();
                if(dic.ContainsKey(tmp))
                {
                    dic[tmp]++;
                }
                else
                {
                    dic.Add(tmp,1);
                }
            }

            var max = dic.Values.Max();
            var keys = dic.Where(d => d.Value == max).Select(x => x.Key).ToList();
            keys.Sort(StringComparer.OrdinalIgnoreCase);
            foreach (var item in keys)
            {
                WriteLine(item);
            }
        }

    }
}


Measured memory_bytes: 42460
import sys
N, A, B = map(int,input().split())
AB = A + B
n = N//AB
amari = N%AB
if A >= N:
  print(N)
  sys.exit()
if AB > N:
  print(A)
  sys.exit()
add = min(amari, A)
print(n*A + add)

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

using namespace std;

int main(){
    int n,m,ans;
    ans=0;
    cin >> n >> m;
    int s[m],c[m];
    for (int i=0;i<m;i++){
        cin >> s[i] >> c[i];
    }
    int x[n];
    for(int i=0;i<n;i++){
        x[i]=-1;
    }
    for(int i=0;i<m;i++){
        if(n>1&&s[i]==1&&c[i]==0){
            ans=-1;
            break;
        }
        if(x[s[i]-1]==-1){
            x[s[i]-1]=c[i];
        }
        else if(x[s[i]-1]!=c[i]){
            ans=-1;
            break;
        }
    }
    if(ans!=-1){
        if(x[0]==-1){
            x[0]=((n>1)? 1:0);
        }
        for(int i=0;i<n;i++){
            if(x[i]==-1){
                x[i]=0;
            }
            ans+=x[i]*pow(10,n-i-1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c = input()

if 'R' not in c or 'W' not in c:
    print(0)
    exit()

r_cnt = 0
w_cnt = 0
for i in c:
    if i =='R':
        r_cnt += 1
    else:
        w_cnt += 1

r_cnt2 = 0
for i in c[:-w_cnt-1:-1]:
    if i == 'R':
        r_cnt2 += 1
w_cnt2 = 0
for i in c[:r_cnt]:
    if i == 'W':
        w_cnt2 += 1

ans = min(w_cnt2, r_cnt2)
print(ans)

Measured memory_bytes: 9356
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
int main(){
  int n, m, x[100000], sx[100000], max = 0, smax=0;
  scanf("%d %d",&n, &m);
  for(int i = 0; i < m; i++){
    scanf("%d", &x[i]);
  }
  sort(x, x+m);
  for(int i = 0; i < m - 1; i++){
    sx[i] = x[i + 1] - x[i];
    max += sx[i];
  }
  sort(sx, sx+(m-1));
  for(int i = 0; i < n - 1; i++){
    smax +=  sx[m- (2 + i)];
  }
  printf("%d", (max - smax));
  
}


Measured memory_bytes: 896
Scanf.scanf "%d %d %s" @@ fun a b s ->
  let c = Array.fold_left (+) 0 @@ Array.init (a + b + 1) @@ fun i -> if s.[i] = '-' then 1 else 0 in
  print_endline @@ if c = 1 && s.[a] = '-' then "Yes" else "No"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

constexpr int m = 5001;
int main() {
    init();

    int n, k; cin >> n >> k;
    VI a(n); cin >> a;
    SORT(a);

    function<bool(int)> check = [&](int x) {
        vector<bitset<m>> dp(2);
        dp[0][0] = true;
        FOR(i, 0, n){
            dp[(i + 1) & 1] = false;
            dp[(i + 1) & 1] |= dp[i & 1];
            if (x == i)continue;
            dp[(i + 1) & 1] |= (dp[i & 1] << a[i]);
        }

        FOR(j, max(k - a[x], 0), k)if (dp[n & 1][j])return true;
        return false;
    };

    int ok = n, ng = -1;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if (check(mid))ok = mid;
        else ng = mid;
    }

    cout << ok << "\n";
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

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

ll nCk(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;
}

ll nPk(ll n,ll k){
  if(n==0||k==0)return 1;
  return fac[n] * finv[n - k] % MOD;
}
class mint {
  long long x;

 public:
  mint(long long 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;
  }

  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,m;
cin>>n>>m;
mint ans=0;
COMinit();
//nCk*mPk*(m-kPn-k)^2
rep(k,n+1){
  mint now = nPk(m-k,n-k);
  now*=now;
  now*=nPk(m,k);
  now*=nCk(n,k);
  if(k%2!=0) now=-now;
  ans+=now;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 123176
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nmq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //始点降順ソート
        var lrs = Enumerable.Repeat(0, nmq[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[0]).ToArray();
        int ptr = lrs.Length - 1;
        var queries = Enumerable.Range(0, nmq[2]).Select(x => new Tuple<int, int[]>(x, Console.ReadLine().Split().Select(int.Parse).ToArray())).OrderByDescending(x => x.Item2[0]).ToArray();
        int[] res = new int[nmq[2]];
        SegmentTree<int> sum = new SegmentTree<int>(nmq[0] + 1, 0, (x, y) => x + y);
        foreach (var query in queries)
        {
            while (0 <= ptr && query.Item2[0] <= lrs[ptr][0])
            {
                sum.Operate(lrs[ptr][1], nmq[0], 1);
                ptr--;
            }
            res[query.Item1] = sum.Query(query.Item2[1]);
        }
        Console.WriteLine(string.Join("\n", res));
    }
}


class SegmentTree<T>
{
    public int Size { get; private set; }
    T IdentityElement;
    T[] Operators;
    Func<T, T, T> Merge;
    int LeafCount;

    public SegmentTree(int size, T identityElement, Func<T, T, T> merge) : this(Enumerable.Repeat(identityElement, size).ToArray(), identityElement, merge) { }

    public SegmentTree(T[] elems, T identityElement, Func<T, T, T> merge)
    {
        Size = elems.Length;
        Merge = merge;
        IdentityElement = identityElement;
        LeafCount = 1;
        while (LeafCount < elems.Length) LeafCount <<= 1;

        Operators = new T[LeafCount * 2];
        elems.CopyTo(Operators, LeafCount);
        for (int i = LeafCount - 1; i >= 1; i--) Operators[i] = Merge(Operators[i * 2], Operators[i * 2 + 1]);
    }

    public T this[int index]
    {
        get { return Query(index); }
        set { Operate(index, index + 1, value); }
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int l, int r, T x)
    {
        l += LeafCount;
        r += LeafCount;
        while (l <= r)
        {
            if (l % 2 == 1) Operators[l] = Merge(x, Operators[l]);
            if (r % 2 == 0) Operators[r] = Merge(x, Operators[r]);
            l = (l + 1) / 2;
            r = (r - 1) / 2;
        }
    }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int i)
    {
        i += LeafCount;
        T res = Operators[i];
        while (0 < (i >>= 1)) res = Merge(res, Operators[i]);
        return res;
    }
}

Measured memory_bytes: 49708
import java.util.StringTokenizer

fun main() {
    val reader = System.`in`.bufferedReader()
    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun solve() {
        var n = nextInt()
        var arr = LongArray(n){next().toLong()}

        var sum = arr.sum()

        var map = mutableMapOf<Long,Long>()

        for (i in arr){
            map[i] = map.getOrDefault(i,0L) + 1
        }


        repeat(nextInt()){
            var b = next().toLong()
            var c=  next().toLong()

            if (b !in map)println(sum)
            else {
                var diff = (c-b)*map[b]!!
                sum+=diff
                println(sum)
                var v = map[b]!!
                map.remove(b)
                map[c] = map.getOrDefault(c,0) + v
            }


        }



    }

    solve()


}




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

int main(){
    int n;cin>>n;//card枚数
    vector<int> a(n,0);//上からi枚目のcardはa[i]
    vector<int> num(100010,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
        num[a[i]]++;
    }

    for(int i=0;i<n;i++){
        if(num[a[i]]>=3){
            num[a[i]]%=2;
            if(num[a[i]]==0){num[a[i]]+=2;}
        }
    }

    sort(num.begin(),num.end(),greater<int>());


    int two=0,ans=0;
    for(int i=0;num[i]!=0;i++){
        if(num[i]==2){two++;}
        ans++;
    }

    if(two%2==0){cout<<ans<<endl;}
    else{cout<<ans-1<<endl;}

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin >> A >> B >> C;
    if(A + B + C >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string str;
  cin>>str;
  int flag=0;
  for(int i=0;i<str.size()-1;i++)
  {
    if(str.at(i)==str.at(i+1))
    {
      flag=1;
      break;
    }
  }
  if(flag==1)
    cout<<"Bad";
  else
    cout<<"Good";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 200005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second

ll n, m, i, j, k, t, l, r,tmp, ans, cnt,curr, flag, sum, mn, mx, mxi,x,pre,strt,en;
ll brr[MAX], arr[MAX];
string s;
queue<pair<pair<ll,ll> , ll > > q, q2;
pair<pair<ll,ll> , ll > pp;
map<ll, multiset<ll> > mpp;


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

        cin>>n>>s;
        for(i=0;i<n;i++)
            arr[s[i]-'a']++;
        ans = 1;
        for(i=0;i<26;i++)ans = (ans * (arr[i]+1))%MOD;
        cout<<(ans-1+MOD)%MOD;


       
    
    return 0;   
}

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

typedef int int_t;
#define int long long

const int maxn=1e6+5;
const int mod =1e9+7;

int F[maxn],S[maxn],N;

int_t main(){
	cin>>N;F[1]=N;S[1]=N;
	int pp=(N-1)*(N-1)%mod;
	for(int i=2;i<=N;i++){
		F[i]=(S[max(i-3,0ll)]+(N-max(i-1,2ll)+1)+F[i-1]+pp)%mod;
		S[i]=(S[i-1]+F[i])%mod;
	}
	cout<<F[N]<<'\n';
	return 0;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        SegTree t = new SegTree(n, s);
        int q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int c = sc.nextInt();
            if(c == 1){
                int a = sc.nextInt()-1;
                int b = sc.next().charAt(0) - 'a';
                t.update(a, b);
            }else{
                int l = sc.nextInt()-1;
                int r = sc.nextInt();
                int x = t.query(l, r, 0, 0, t.size);
                sb.append(Integer.bitCount(x) + "\n");
            }
        }
        System.out.print(sb.toString());
        sc.close();

    }

}

class SegTree {

    public int n;
    public int size;
    /**
     * 要素全体を含むノードのindex：0.
     * k番目(0-indexed)の要素のindex：k + size - 1
     * ノードkの親要素のindex：(k - 1) / 2.
     * ノードkの子要素のうち左側のindex：k*2+1.
     * ノードkの子要素のうち右側のindex：k*2+2.
     */
    public int[] data;

    /**
     * コンストラクタ.
     * @param n 要素数
     */
    public SegTree(int n, String s){
        this.n = n;
        size = 1;
        while(size < n) size *= 2;
        data = new int[size*2];
        // 初期化処理
        for (int i = 0; i < s.length(); i++) {
            int x = s.charAt(i) - 'a';
            update(i, x);
        }
    }

    /**
     * k番目（0-indexed）の要素をaに更新します.
     * @param k 変更対象要素のindex（0-indexed）
     * @param a 変更後の値
     */
    public void update(int k, int a){
        k += size - 1;
        if(data[k] != 1<<a){
            data[k] = 1<<a;
            while(0 < k){
                k = (k - 1) / 2;
                data[k] = data[k * 2 + 1] | data[k * 2 + 2];
            }
        }
    }

    /**
     * 区間[a, b)での○○を求めます.
     * 最初に呼ぶ際は、query(a, b, 0, 0, size)として呼ぶ.
     * @param a 求める区間の下限（含む）
     * @param b 求める区間の上限（含まない）
     * @param k 確認するノードのindex
     * @param l 確認するノードの下限（含む）
     * @param r 確認するノードの上限（含まない）
     * @return 区間[a, b)での○○
     */
    public int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return 0;

        if(a <= l && r <= b) return data[k];

        int vl = query(a, b, k*2+1, l, (l+r)/2);
        int vr = query(a, b, k*2+2, (l+r)/2, r);
        return vl | vr;
    }
}


Measured memory_bytes: 63052
/*
title:

url:

Kが５以下であることに注目
教訓
最初の方針よりも単純にかけた
まずは計算量を試算することが大事。あと、メモリ使用量
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string s;
    int k;
    cin >> s >> k;
    //find min alpahbet(a, b, c...)

    priority_queue<string, vector<string>, greater<string>> q;
    for (unsigned int i = 0; i < s.size(); i++)
    {
        string tmp = "";
        for (unsigned int j = 0; j < 5 && j + i < s.size(); j++)
        {
            tmp = tmp + s[i + j];
            q.push(tmp);
        }
    }
    string ans;
    for (int i = 0; i < k; i++)
    {
        ans = q.top();
        while ((!q.empty()) && q.top() == ans)
        {
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1000000000;

int main() {FIN
    
    int n, i, e, mx = -INF, mn = INF;
    cin >> n;
    for (i = 0; i < n; i++) {
		cin >> e;
		if (i > 0)
			mx = max(e - mn, mx);
		mn = min(mn, e);
	}
	cout << mx << "\n";
    
    return 0;
}



Measured memory_bytes: 3208
import sys
import math
from collections import deque
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)


N = I()
l = [input() for i in range(N)]
d = {}
ans = 0
for item in l:
    if item in d:
        continue
    else:
        ans += 1
        d[item] = 1
        continue
print(ans)


Measured memory_bytes: 145700
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N;
	cin>>N;
	vector<int> A(N+1,0),cnts(N+1,0);
	rep(i,N)cin>>A[i+1];
	for(int i=N;i>0;i--){
		int times = 2;
		int cnt=0;
		while(i*times<=N){
			cnt+=cnts[i*times];
			times++;
		}
		cnts[i] = cnt%2==A[i]?0:1;
	}

	cout<<accumulate(cnts.begin(), cnts.end(),0)<<endl;
	rep(i,N)if(cnts[i+1]==1)cout<<i+1<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vec A(X), B(Y), C(Z);
    loop(i, X) cin >> A[i];
    loop(i, Y) cin >> B[i];
    loop(i, Z) cin >> C[i];
    sort(all(A));
    sort(all(B));
    sort(all(C));
    reverse(all(A));
    reverse(all(B));
    reverse(all(C));
    vec ans;
    loop(i, X)
    {
        loop(j, Y)
        {
            loop(k, Z)
            {
                if ((i + 1) * (j + 1) * (k + 1) <= K)
                    ans.push_back(A[i] + B[j] + C[k]);
                else
                    break;
            }
        }
    }
    sort(all(ans));
    reverse(all(ans));
    loop(i, K) putout(ans[i]);
    return 0;
}


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

using namespace std;

int main()
{
        long long int n,k;

        cin>>n;
        cin>>k;
        long long int h[n];
        long long int i,j;

        for(i=0;i<n;i++)
        {
            cin>>h[i];
        }
        long long int temp;


        sort(h,h+n);





        long long int sum=0;

        for(i=0;i<n-k;i++)
        {
            sum=sum+h[i];
        }

        cout<<sum;







        return 0;
}


Measured memory_bytes: 1792
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int kaijou(int n){
  int kaijou_sum = 1;
  if(n!=0){
    for(int i=1;i<=n;i++){
      kaijou_sum *= i;
    }
    return kaijou_sum;
  }
  else return 1;
}

int main() {
  int n;
  cin >> n;
  int k = n/1000;
  k = k + 1;
  if(n%1000==0)cout<<0<<endl;
  else{
  cout << k*1000 - n << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=2e5+10;
char s[mx];
int main(){
  scanf("%s",s);
  int o=0;
  int n=strlen(s);
  int rem=0;
  for(int i=0;i<n;i++){
    if(s[i]=='S')o++;
    else{
      if(o>0)o--,rem++;
    }
  }
  int ans=n-rem*2;
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	static InputStream is = System.in;
	static String INPUT = "";

	public static void main(String[] args) throws Exception
	{
		int n = ni();
		int M = 1000001;
		int W = (M>>>6)+1;
		long[] f1 = new long[W];
		long[] f2 = new long[W];
		long[] ex = new long[W];
		for(int i = 0;i < n;i++){
			int v = ni();
			if(f1[v>>>6]<<~v>=0){
				f1[v>>>6] |= 1L<<v;
			}else{
				f2[v>>>6] |= 1L<<v;
			}
		}
		for(int t = 0;t < W;t++){
			for(long x = f1[t]&~ex[t];x != 0;x &= x-1){
				int i = t<<6|Long.numberOfTrailingZeros(x);
				for(int j = i*2;j < M;j+=i){
					ex[j>>>6] |= 1L<<j;
				}
			}
		}
		int ans = 0;
		for(int i = 0;i < W;i++){
			ans += Long.bitCount((f1[i]^f2[i])&~ex[i]);
		}
		System.out.println(ans);
	}
	
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;
	
	private static int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
//	private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
	private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private static double nd() { return Double.parseDouble(ns()); }
	private static char nc() { return (char)skip(); }
	
	private static String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private static char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private static char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private static int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private static int ni()
	{
		int num = 0, b;
//		boolean minus = false;
//		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
//		if(b == '-'){
//			minus = true;
//			b = readByte();
//		}
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9')));
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return num;
//				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 34256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

constexpr int kMax = 2001;
LL dp[kMax][kMax];

int main() {
  int N, M; std::cin >> N >> M;
  std::vector<int> S(N+1), T(M+1);
  for (int i = 1; i <= N; ++i) std::cin >> S[i];
  for (int j = 1; j <= M; ++j) std::cin >> T[j];

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

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      if (S[i] != T[j]) {
        dp[i][j] = (dp[i][j-1] + dp[i-1][j] + kMod) - dp[i-1][j-1];
      } else {
        dp[i][j] = dp[i][j-1] + dp[i-1][j] + 1;
      }
      dp[i][j] %= kMod;
    }
  }

#if DEBUG
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      std::cout << dp[i][j] << "\t";
    }
    std::cout << std::endl;
  }
  std::cout << std::endl;
#endif
  std::cout << dp[N][M] + 1 << std::endl;
}


Measured memory_bytes: 31488
import sys

ans=[0]*123
letters="abcdefghijklmnopqrstuvwxyz"
input_str=sys.stdin.read()
for a in input_str:
    index=0
    for b in letters:
        if a==b or a==b.upper():
            ans[index]+=1
        else :
            index+=1
        
for i in range(len(letters)):
    print(letters[i],":",ans[i])


Measured memory_bytes: 5576
/*
      author : nishi5451
      created: 11.08.2020 01:13:00
*/

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


int main(){
    int r,g;
    cin >> r >> g;
    //r+x = 2g
    cout << 2*g-r << endl;
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
Money = []
Tot   = 0


for n in range(N):
	 Money.append(input().split())

for n in range(N):
	if Money[n][1] == "JPY":
		Tot += float(Money[n][0])
	else:
		Tot += float(Money[n][0])*380000

print(Tot)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String str = stdR.readLine();
        int w = Integer.parseInt(stdR.readLine());
        StringBuilder sb = new StringBuilder();
        int index = 0;
        while(index < str.length()) {
            sb.append(str.charAt(index));
            index += w;
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
using namespace std;
int main() {

	long long int x[50], xs[50], y[50], ys[50];
	int n, k;
	cin >> n >> k;
	int i1,i2,j1,j2,i,l;
	for (i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		xs[i] = x[i]; ys[i] = y[i];
	}
	sort(xs, xs + n);
	sort(ys, ys + n);
	int counter;
	long long int rectangle = 4000000000000000000;
	for (i1 = 0; i1 < n-1; i1++) {
		for (j1 = i1 + 1; j1 < n; j1++) {
			for (i2 = 0; i2 < n - 1; i2++) {
				for (j2 = i2 + 1; j2 < n; j2++) {
					if ((xs[j1] - xs[i1]) * (ys[j2] - ys[i2]) < rectangle) {


						counter = 0;
						for (i = 0; i < n; i++) {
							if ((x[i] >= xs[i1]) && (x[i] <= xs[j1]) && (y[i] >= ys[i2]) && (y[i] <= ys[j2])) {
								counter++;
							}
						}
						if (counter >= k) {
							rectangle = (xs[j1] - xs[i1]) * (ys[j2] - ys[i2]);
						}
					}
				}
			}
		}
	}
	cout << rectangle << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());

        scanner.close();

        int sum = A + B;
        if (sum >= 10) {
            System.out.println("error");
        } else {
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#define mod 998244353
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
//const int INF=0x3f3f3f3f;
const ll INF=1000000000000000000;
//priority_queue<int, vector<int>, greater<int> >p;
struct node
{
    ll x,y,k;
}a[200005];
int mmp(node i,node j)
{
    return i.k<j.k;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll sum=0,ans=0,num=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",&a[i].x,&a[i].y);
        a[i].k=a[i].x-a[i].y;
    }
    sort(a,a+n,mmp);
    if(a[0].k==0&&a[n-1].k==0)
    {
        printf("0\n");
        return 0;
    }
    int i;
    for(i=0;i<n;i++)
        if(a[i].k<=0){sum+=a[i].y;num-=a[i].k;}
        else break;
    ans=INF;
    for(;i<n;i++)
    {
        sum+=a[i].y;
        ans=min(a[i].y,ans);
    }
    printf("%lld\n",sum-ans);
    return 0;
}


Measured memory_bytes: 768
import java.util.*

private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val (N, M) = readInts()
    val intervals = (1..M).map { readInts() }.map { ints -> ints[0] to ints[1] }
    val islandsTargets = (1..N).map { HashSet<Int>() }

    intervals.forEach { islandsTargets[it.first - 1].add(it.second - 1) }

    var brokenCount = 0
    val inclusions = mutableSetOf<Int>()
    (0 until N-1).forEach { bridgeIndex ->
        inclusions.addAll(islandsTargets[bridgeIndex])
        if (inclusions.contains(bridgeIndex + 1)) {
            inclusions.clear()
            brokenCount += 1
        }
    }
    println(brokenCount)
}

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

int main()
{
	int a,b,x,y,answer,tmp;

	cin >> a >> b ;

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

	while(1 < b && b < a){

		x = b ;
		y = a % b ;

		a = x ;
		b = y ;
		
		if((a % b)==0){
			answer = b;
			break ;
		}
	}

	cout << b << endl ;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = max(a*c,a*d);
    ll y = max(b*c,b*d);
    ll ans = max(x,y);
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
int a[26]; bool OK = false; string S;
int main() {
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		a[S[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++)if (a[i] % 2 == 1)OK = true;
	if (OK == false)cout << "Yes" << endl;
	else { cout << "No" << endl; }
	return 0;
}

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

// Macros
#define F  first
#define S  second
#define PB push_back
#define MP make_pair
#define ALL(container)   container.begin(),container.end()
#define RALL(container)  container.rbegin(),container.rend()
#define MAKE_UNIQUE(vec) vec.erase(unique(ALL(vec)),vec.end())

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = std::pair <int,int>;

// Random
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/* [a,b] */ template<class T> T rnd_IntType(T a, T b){ return uniform_int_distribution<T>(a, b)(rng); }
/* [a,b) */ template<class T> T rnd_RealType(T a, T b){ return uniform_real_distribution<T>(a,b)(rng); }

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// Helpers
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
// vec.assign() GOOD; vec.resize() BAD
// comparator, <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef VOID_d1097589d5c8e3676b0fd9e08281f3d4
	#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); d__f(_it, args); }
	void d__f(__attribute__((unused)) istream_iterator<string> it) {}
	template<typename Head, typename... Tail> void d__f(istream_iterator<string> it, Head H, Tail... T) { cerr << *it << " <=> [" << H << "]\n"; d__f(++it, T...); }
#else
	#define trace(args...)
#endif


void solve(){
	int n;
	cin >> n;

	vector<int> a(n);
	for(auto &i: a) cin >> i;

	const int max_sz = (int)1e6 + 1;

	vector<vector<int>> pos(max_sz);
	for(int i = 0; i < n; ++i) pos[a[i]].PB(i);

	vector<bool> possible(max_sz, true);

	for(int i = 1; i < max_sz; ++i){
		if(pos[i].size() > 1) possible[i] = false;
		if(pos[i].size() == 0) continue;
		for(int j = 2 * i; j < max_sz; j += i) possible[j] = false;
	}

	int ans = 0;
	for(auto i: a) if(possible[i]) ++ans;
	cout << ans << "\n";
}

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

	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 33988
# -*- coding: utf-8 -*-
x = int(input())

if x <= 6:
    print(1)
    exit()
if 6 < x <= 11:
    print(2)
    exit()
ans = (x // 11)
point = ans * 11
ans *= 2
#print(point, ans)
#print(point)
while point < x:
    if ans % 2 == 0:
        point += 6
        ans += 1
    elif ans % 2 == 1:
        point += 5
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<map>
using namespace std;
int main()
{
    int t;
    cin>>t;
    map<string,int> m;

    while(t--)
    {
        string s;
        cin>>s;

        m[s]++;
    }

    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;

    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	string a,b;
	cin >> a >> b;
	if(a==b) cout << "EQUAL" << endl;
	else{
		if(a.size()==b.size()){
			cout << (a>b ? "GREATER" : "LESS") << endl;
		}else{
			cout << (a.size()>b.size() ? "GREATER" : "LESS") << endl;
		}
	}
//////////////////////////////////////////////
}


Measured memory_bytes: 256