akhauriyash/Code-Regression huggingface dataset:
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= i & -i
        return ret

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())

bit = Bit(2000)

intra, inter = 0, 0
for i, a in enumerate(map(int, input().split())):
    bit.add(a, 1)
    intra += i + 1 - bit.sum(a)
    inter += bit.sum(a - 1)

mod = 10**9 + 7
ans = (intra * K * (K + 1) // 2) % mod
ans += (inter * (K - 1) * K // 2) % mod
print(ans % mod)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s == "A")cout << "T" << "\n";
	if (s == "T")cout << "A" << "\n";
	if (s == "G")cout << "C" << "\n";
	if (s == "C")cout << "G" << "\n";
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import heapq


def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]

    graph_data = defaultdict(set)
    weight_data = defaultdict(int)

    for i in range(edge_num):
        a, b, c = data[i]
        graph_data[a].add(b)
        graph_data[b].add(a)
        weight_data[(a, b)] = c
        weight_data[(b, a)] = c

    # used_edge = set()

    inf = 10 ** 5 + 1

    length_data = [[inf for i in range(node_num + 1)] for j in range(node_num + 1)]

    for i in range(1, node_num + 1):
        visit_flg = [0 for i in range(node_num + 1)]
        visit_flg[i] = 1
        length_data[i][i] = 0
        # for j in range(1, i):
        #     visit_flg[j] = 1
        #     length_data[i][j] = length_data[j][i]
        # print(length_data, ',,mm')
        heap_list = []
        for ele in graph_data[i]:
            weight = weight_data[(i, ele)]
            heapq.heappush(heap_list, (weight, ele, i))

        while len(heap_list) > 0:
            now_weight, now_ele, pre_ele = heapq.heappop(heap_list)
            # print(visit_flg, 'vf')
            if visit_flg[now_ele]:
                continue
            visit_flg[now_ele] = 1
            length_data[i][now_ele] = length_data[i][pre_ele] + weight_data[(pre_ele, now_ele)]
            # used_edge.add((min(now_ele, pre_ele), max(now_ele, pre_ele)))
            for next_ele in graph_data[now_ele]:

                if visit_flg[next_ele]:
                    continue
                next_weight = weight_data[(now_ele, next_ele)] + length_data[i][now_ele]
                heapq.heappush(heap_list, (next_weight, next_ele, now_ele))

            # print(used_edge, 'ue')
            # print(heap_list, 'hl')
            # print(visit_flg, 'vf')
            # print(length_data, 'ld')
            # print()
        # print(length_data[i])

    # print(length_data)

    ans = 0
    for i in range(edge_num):
        a, b, c = data[i]
        if c > length_data[a][b]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
    std::deque<int> a{1,3,5,7,8,10,12};
    std::deque<int> b{4,6,9,11};
    if (find(a.begin(),a.end(),x)!=a.end()&&find(a.begin(),a.end(),y)!=a.end()) {
        cout<<"Yes"<<endl;
    } else if (find(b.begin(),b.end(),x)!=b.end()&&find(b.begin(),b.end(),y)!=b.end()) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin>>a>>b;
  if (a == b) {
  	cout << "Draw" <<endl;
  } else if(a < b) {
  	if (a == 1) {
      cout << "Alice" << endl;
    } else {
      cout << "Bob"<< endl;
    }
  }  else {
  	if (b == 1) {
      cout << "Bob" << endl;
    } else {
      cout << "Alice"<< endl;
    }
  }
}

Measured memory_bytes: 256
#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 flagcount __builtin_popcount
#define flag(x) (1 << 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 & (1 << 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 Gput(a, b) G[a].push_back(b)
#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 0;
}
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 N;
    cin >> N;
    vec C(N);
    loop(i, N)
    {
        cin >> C[i];
        C[i]--;
    }
    vec dp(N + 1);
    dp[0] = 1;
    vec lastcolor(200000, -1);
    loop(i, N)
    {
        ll nowcolor = C[i];
        if (lastcolor[nowcolor] == -1 || lastcolor[nowcolor] == i - 1)
            dp[i + 1] = dp[i];
        else
        {
            dp[i + 1] = dp[i] + dp[lastcolor[nowcolor] + 1];
            dp[i + 1] %= mod;
        }
        lastcolor[nowcolor] = i;
    }
    putout(dp[N]);
    return 0;
}


Measured memory_bytes: 7992
def modexp(a,b,mod):
    if b==0:
        return 1
    elif b%2==0:
        x=modexp(a%mod,b//2,mod)%mod
        return (x*x)%mod
    else:
        return ((a%mod)*(modexp(a%mod,b-1,mod)%mod))

mod=10**9+7
n=int(input())
a=modexp(10,n,mod)
b=modexp(9,n,mod)
c=modexp(8,n,mod)
ans=((a+c)%mod)-((2*b)%mod)
print(ans%mod)

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

int main(){
	int H, W;
	while(1){
		cin>>H>>W;
		if(H==0 && W==0) break;

		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j) % 2 == 0) cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1152
s=input()
all_hatena = s.count('?')

a_cnt = 0
ab_cnt = 0
hatena_cnt = 0
ans = 0

MOD = 10**9+7
for si in s:
    if si == 'A':
        a_cnt += 1
    elif si == 'B':
        ab_cnt += a_cnt*pow(3,all_hatena,MOD)
        if all_hatena >= 1: ab_cnt += hatena_cnt*pow(3,all_hatena-1,MOD)
    elif si == 'C':
        ans += ab_cnt
    else:
        ans += ab_cnt*333333336 # modinv(3,MOD)
        ab_cnt += a_cnt*pow(3,all_hatena-1,MOD)
        if all_hatena >= 2: ab_cnt += hatena_cnt*pow(3,all_hatena-2,MOD)
        hatena_cnt += 1
    ab_cnt%=MOD
    ans%=MOD
print(ans)

Measured memory_bytes: 73612
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

At = [0]*(N+1)
Bt = [0]*(M+1)

for i in range(N):
  At[i+1] = At[i] + A[i]
for i in range(M):
  Bt[i+1] = Bt[i] + B[i]

j = M
ans = 0
for i in range(N+1):
  if At[i] > K:
    break
  while At[i] + Bt[j] > K:
    j = j - 1
  if ans < i + j:
  	ans = i+j 

print(ans)

Measured memory_bytes: 47616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

			if(str.matches("^((dreamer)|(eraser)|(dream)|(erase))+$") ){
				System.out.println("YES");
			}else{
				System.out.println("NO");
				System.exit(0);
			}
		}

}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d,n; cin>>d>>n;
    ll m = 1;
    rep(i,d) m*=100;
    if (n<100){
        cout<<m*n<<endl;
    }else{
        cout<<m*(n+1)<<endl;
    }
    return 0;
}


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

int n;
char s[200];
map<pair<string, string>, long long > mp;

int main(void) {
  scanf("%d", &n); 
  scanf("%s", s);
  for(int i = 0; i < (1 << n); i++) {
    string a = "", b = "";
    for(int j = 0; j < n; j++)
      ((i >> j & 1) ? a : b) += s[j];
    //cerr << a << " " << b << endl;
    mp[make_pair(a, b)]++;
  }
  long long ans = 0;
  reverse(s, s + n + n);
  for(int i = 0; i < (1 << n); i++) {
    string a = "", b = "";
    for(int j = 0; j < n; j++)
      ((i >> j & 1) ? a : b) += s[j];
    //cerr << a << " " << b << " " << mp[make_pair(a, b)] << endl;
    ans += mp[make_pair(a, b)];
  }
  cout << ans << endl;
  return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    
    // par[i] は i のすぐ上の親
    vector<int> par(n);
    par[0] = -1;
    // dep[i] は 0 を 0 としたときの i の深さ
    vector<int> dep(n);
    dep[0] = 0;
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int c;
            cin >> c;
            par[c] = i;
            dep[c] = dep[i] + 1;
        }
    }

    int klim = (int)log2(n)+1;
    // kpar[k][i] は i の 2^k 上の親、kpar[0][i] = par[i]
    vector<vector<int>> kpar(klim, vector<int>(n, -1));
    for(int i=0; i<n; i++){
        kpar[0][i] = par[i];
    }
    
    for(int k=1; k<klim; k++){
        for(int i=0; i<n; i++){
            if(kpar[k-1][i] != -1){
                kpar[k][i] = kpar[k-1][kpar[k-1][i]];
            }
        }
    }

    int q;
    cin >> q;
    vector<int> ans(q);
    for(int qu=0; qu<q; qu++){
        int u, v;
        cin >> u >> v;
        if(dep[u] < dep[v]){
            int t = u;
            u = v;
            v = t;
        }
        // u を v と同じ高さまで持ち上げる
        int dd = dep[u] - dep[v];
        for(int k=0; k<klim; k++){
            if((dd & (1<<k)) == (1<<k)){
                u = kpar[k][u];
            }
        }

        if(u == v){
            ans[qu] = u;
        }
        // 二分探索
        else{
            for(int k=klim-1; k>=0; k--){
                int pu = kpar[k][u];
                int pv = kpar[k][v];
                if(pu != pv){
                    u = pu;
                    v = pv;
                }
            }
            ans[qu] = par[u];
        }
    }
    
    for(int i=0; i<q; i++){
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 18876
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


table = input()

FLG = False

for i in range(len(table)):
    if table[i] == '9':
        FLG = True
        break

if FLG == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3436
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int n;
  cin >> n;
  int ten[n];
  memset(ten,0,sizeof(ten));
  REP(i, n*(n-1)/2) {
    int a,b,c,d;
    cin >> a >> b>> c>>d;
    a--;b--;
    if (c>d) ten[a] += 3;
    else if (c<d) ten[b] += 3;
    else ten[a]++, ten[b]++;
  }
  vector<pii> v(n);
  REP(i,n) v[i] = pii(ten[i], i);
  sort(ALL(v), greater<pii>());
  int rank[n];
  int now;
  int pre = -1;
  REP(i, n) {
    if (v[i].first == pre) ;
    else {
      pre = v[i].first;
      now = i+1;
    }
    rank[v[i].second] = now;
  }
  REP(i, n) cout << rank[i] << endl;
}

Measured memory_bytes: 0
#include<iostream>

using namespace std;

int main(){
	long long N,M,ans=0;
	cin>>N>>M;
	if(N>M/2){
		ans+=M/2;
		M=M%2;
	}else{
		ans+=N;
		M-=N*2;
	}
	ans+=M/4;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Tenka1C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long N = ConsoleInput.Long();
            string S = ConsoleInput.String();

            long[] dpW = new long[N + 1];
            long[] dpB = new long[N + 1];
            dpW[0] = 0;
            dpB[0] = 0;
            for (int i = 1; i <= N; i++)
            {
                if (S[i - 1] == '#')
                {
                    dpW[i] = dpW[i - 1];
                    dpB[i] = dpB[i - 1] + 1;
                    continue;
                }

                if (S[i - 1] == '.')
                {
                    dpB[i] = dpB[i - 1];
                    dpW[i] = dpW[i - 1] + 1;
                }
            }

            long ans = Math.Min(N - dpB[N], N - dpW[N]);
            long[] m = new long[N];
            for (int i = 0; i < N; i++)
            {
                m[i] = dpB[i] + dpW[N] - dpW[i];
            }
            
            Console.WriteLine(Math.Min(ans, m.Min()));
        }
    }

    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 16480
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,y;
    cin>>a>>b>>c;
    y=(a*100)+(b*10)+c;
    if(y%4==0)
    {
        cout<<"YES";
    }
    else 
    {
        cout<<"NO";
    }

    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;
            var sba = new StringBuilder();
            var sbb = new StringBuilder();

            for (int i = 0; i < n;i++)
            {
                sba.Append(i % 2 == 0 ? '0' : '1');
                sbb.Append(i % 2 != 0 ? '0' : '1');
            }

            string sa = sba.ToString();
            string sb = sbb.ToString();

            int[] sum = new int[2];
            for (int i = 0;i< s.Length; i++)
            {
                if (s[i] != sa[i]) sum[0]++;
                if (s[i] != sb[i]) sum[1]++;
            }

            Console.WriteLine(sum.Min());
        }
    }
}

Measured memory_bytes: 14176
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(3 * n);
            Arrays.sort(a);
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += a[3 * n - 2 - 2 * i];
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 56248
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;


int main()
{
    long long n, k;
    cin >> n >> k;
    long long x = n % k;
    while (true) {
        long long y = abs(x-k);
        if (y >= x) break;
        x = y;
    }
    cout << x << '\n';
   
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define ort ((bas+son+1ll)/2ll)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009

using namespace std;

int N, X,res,cur;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> X;
	vector<int> A(N);
	
	res = 1;
	cur = 0;
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cur += A[i];
		if (cur <= X) {
			res++;
		}
	}
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    itn x;
    cin >> x;
    if(x < 600)
        println(8);
    else if(x < 800)
        println(7);
    else if(x < 1000)
        println(6);
    else if(x < 1200)
        println(5);
    else if(x < 1400)
        println(4);
    else if(x < 1600)
        println(3);
    else if(x < 1800)
        println(2);
    else if(x < 2000)
        println(1);
    
    return 0;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            if (input[2] <= input[0] + input[1]) WriteLine("Yes");
            else WriteLine("No");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define int long long
#define rg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
using namespace std;
const int mod=1e9+7;
int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
    while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();
    return f*x;
}
int f[41][262143+10];
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
main(){
    //file("");
	int n=read(),x=read(),y=read(),z=read(),len=(1<<(x+y+z))-1,res=1<<(x+y+z-1),ans=0;
    res=res|(1<<(y+z-1)),res=res|(1<<(z-1)),f[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=len;j++){
			if(f[i-1][j]==0) continue;
			for(int k=1;k<=10;k++){
				int z=(j<<k)|(1<<(k-1));
				z&=len;
				if((z&res)==res) continue;
				f[i][z]=(f[i-1][j]+f[i][z])%mod;
			}
		}
	for(int i=0;i<=len;i++)
		ans=(ans+f[n][i])%mod;
	cout<<(ksm(10,n)-ans+mod)%mod;
    return 0;
}

Measured memory_bytes: 82176
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    long long int N;
    cin>>N;

    long long int min=1e18;
    for(long long int i=1;i<=sqrt(N);i++){
        if(N%i==0){
            long long int tmp=N/i;
            if(i+tmp<min)min=i+tmp;
        }
    }
    cout<<min-2<<endl;
    return 0;
}

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




const int N = 51, MOD = 1e9 + 7;




int n;
long long k;


struct matrix{
    int matr[N][N];
};
matrix A, B;

matrix operator * (matrix a, matrix b){
    matrix c;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            c.matr[i][j] = 0;
            for(int k = 1; k <= n; k++){
                c.matr[i][j] += 1LL * a.matr[i][k] * b.matr[k][j] % MOD;
                if(c.matr[i][j] >= MOD){
                    c.matr[i][j] -= MOD;
                }
            }
        }
    }
    return c;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> A.matr[i][j];
            if(i == j){
                B.matr[i][j] = 1;
            }
        }
    }
    while(k){
        if(k & 1){
            B = A * B;
        }
        A = A * A;
        k >>= 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            ans = (ans + B.matr[i][j]) % MOD;
        }
    }
    cout << ans;
}


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

int main(){
  	int x1, x2, A, B;
  
  	cin >> A >> B;
  
  	for (int i = 1; i < 2000; i++) {
      int A1 = i * 0.08;
      int B1 = i * 0.1;
      if (A1 == A && B1 == B) {
        cout << i << endl;
        return 0;
      }
    }
  	cout << -1 << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef signed long long int slli;

int main()
{
  unsigned N;
  std::cin >> N;
  
  std::vector<unsigned> T(N);
  slli S = 0;
  for(unsigned n = 0; n < N; ++n)
  {
    std::cin >> T[n];
    S += T[n];
  }
  
  unsigned M;
  std::cin >> M;
  
  for(unsigned m = 0; m < M; ++m)
  {
    long P, X;
    std::cin >> P >> X;
    
    std::cout << (S + X - T[P - 1]) << std::endl;
  }
  
  return 0;
}

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;

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

	ll n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll sm = 0;
	rep(i, n) sm += a[i];

	ll ans = sm;
	ll t = 0;
	rep(i, n-1){
		t += a[i];
		ans = min(ans, max(t - (sm - t), (sm - t) - t));
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        sc.close();

        int ab = a * b;
        int cd = c * d;
        int s = ab > cd ? ab : cd;
        
        System.out.println(s);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
int main(void){
  int n,m;
  cin >> n >> m;
  if (n!=m){
    for (int i=0; i<MAX(n,m); i++) cout << MIN(n,m);
    cout << endl;
  } else {
    for (int i=0; i<n; i++) cout << n;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	N = int(input())
	S = input()
	K = int(input())

	S=S[:-1]
	
	tmp = S[K-1]

	ans = ""
	for i in S:
		if i == tmp:
			ans += i
		else:
			ans += "*"

	print(ans)

	
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if((i+1)%2!=0){
            if(a[i]%2!=0)ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < 5; i++) {
				list.add(scanner.nextInt());
				scanner.nextLine();
			}
			int k = scanner.nextInt();
			scanner.nextLine();
			list.sort((x, y) -> x - y);
			if ((list.get(list.size() - 1) - list.get(0)) > k) {
				System.out.println(":(");
			} else {
				System.out.println("Yay!");
			}
		}
	}
}

Measured memory_bytes: 30420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
int main () {
    int R ;
    cin >> R ;
    cout << R * 2 * PI << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    string s;
    cin >> s;
    int n = s.size();
    for(i=0;i<n-1;i++){
        if(s[i] == s[i+1]) {
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
    for(i=0;i<n-2;i++){
        if(s[i] == s[i+2]) {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 3736
#include<stdio.h>

void solve(int n, int a, int b);
int max(int a, int b);
int min(int a, int b);
int gcm(int M, int m);

int main()
{
    char buf[64];
    int n, a, b;

    while(1){
        fgets(buf, sizeof(buf), stdin);
        sscanf(buf, "%d %d %d", &n, &a, &b);
        if(n == 0) break;
        solve(n, a, b);
    }

    return 0;
}

void solve(int n, int a, int b)
{
    int dp[1000001];
    int M, m;
    int G, mp;
    int i, j;
    int ans;

    for(i = 0; i < 1000001; i++) dp[i] = 1;
    M = max(a, b);
    m = min(a, b);
    G = gcm(M, m);
    mp = m / G;

    for(i = 0; i < mp; i++)
        for(j = 0; M*i+m*j <= n; j++)
            dp[M*i+m*j] = 0;

    ans = 0;
    for(i = 1; i <= n; i++)
        if(dp[i]) ans++;

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

int max(int a, int b)
{
    return (a > b ? a : b);
}

int min(int a, int b)
{
    return (a < b ? a : b);
}

int gcm(int M, int m)
{
    int b = M;
    int a = m;
    int q, r;
    while(1){
        q = b / a;
        r = b % a;
        if(r == 0) break;
        b = a;
        a = r;
    }

    return a;
}



Measured memory_bytes: 5640
def cnt(A, B, X):
    A1 = -(-A // X)
    B1 = B // X
    return B1 - A1 + 1

def gcd(A, B):
    mul = A * B
    if A < B:
        A, B = B, A
    while B:
        A, B = B, A % B
    return mul // A 

A, B, C, D = map(int,input().split())
print((B - A + 1) - cnt(A, B, C) - cnt(A, B, D) + cnt(A, B, gcd(C, D)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1e9+5;

using namespace std;


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();  
	int n,k;
	cin>>n>>k;
	vector<int> stones(n);
	for(int& x:stones)
	{
		cin>>x;
	}
	vector<long long int> dp(n,INF);
	dp[0] = 0;
	for(int i = 0 ; i< n ;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j<n) dp[j] = min(dp[j],dp[i]+abs(stones[i]-stones[j]));
		}
	}
	cout<<dp[n-1];


	//time_req = clock()- time_req;cout << "Time Compexity:"<< (float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
}

Measured memory_bytes: 1408
# input
N, M = map(int, input().split())
P = [0]*M
S = [0]*M

for i in range(M):
    p, S[i] = input().split()
    P[i] = int(p)-1

# process
ac = [0]*N
wa = [0]*N

for i in range(M):
    if S[i] == "AC":
        ac[P[i]] = 1
    else:
        if ac[P[i]] == 0:
            wa[P[i]] += 1

wa_num = 0
for i in range(N):
    if ac[i] == 1:
        wa_num += wa[i]

# output
print("{} {}".format(ac.count(1), wa_num))


Measured memory_bytes: 14836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 100002

int n;
int m;

int s;
int t;

vector<pair<int, long long int> > v[MAX];

queue<int> q;
vector<pair<long long int, int> > vv;

#define MOD 1000000007

void bfs(int b, vector<long long int> &dist, vector<long long int> &way) {
	dist.assign(n, -1);
	way.assign(n, 0);
	dist[b] = 0;
	q.push(b);
	way[b] = 1;
	while (!q.empty()) {
		b = q.front();
		q.pop();
		for (auto go : v[b]) {
			long long int cost = dist[b] + go.second;
			int nex = go.first;
			if (dist[nex] == -1 || dist[nex] > cost) {
				dist[nex] = cost;
				q.push(nex);
			}
		}
	}
	vv.clear();
	for (int i = 0; i < n; i++) {
		vv.push_back(make_pair(dist[i], i));
	}
	sort(vv.begin(), vv.end());
	for (int i = 0; i < vv.size(); i++) {
		int node = vv[i].second;
		for (auto go : v[node]) {
			int nex = go.first;
			if (dist[node] + go.second == dist[nex]) {
				way[nex] += way[node];
				if (way[nex] >= MOD) {
					way[nex] %= MOD;
				}
			}
		}
	}
}
vector<long long int> dist[2];
vector<long long int> way[2];


#define MOD 1000000007

vector<pair<int, int> > ed;
vector<long long int> len;
int main() {
	cin >> n >> m;
	cin >> s >> t;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		ed.push_back(make_pair(a, b));
		v[a].push_back(make_pair(b, c));
		v[b].push_back(make_pair(a, c));
		len.push_back(c);
	}
	s--;
	t--;
	bfs(s, dist[0], way[0]);
	bfs(t, dist[1], way[1]);
	long long int need = dist[0][t];
	//collison on the node
	long long int ALL = way[0][t];
	ALL *= ALL;
	ALL %= MOD;
	for (int i = 0; i < n; i++) {
		long long int sd = dist[0][i];
		long long int td = dist[1][i];
		if (sd == td&&sd + td == need) {
			long long int w = way[0][i];
			w *= way[1][i];
			if (w >= MOD)w %= MOD;
			w *= w;
			if (w >= MOD) {
				w %= MOD;
			}
			w = MOD - w;
			ALL += w;
			ALL %= MOD;
		}
	}
	//edge
	for (int i = 0; i < ed.size(); i++) {
		if (dist[0][ed[i].first]>dist[0][ed[i].second]) {
			swap(ed[i].first, ed[i].second);
		}
		int a = ed[i].first;
		int b = ed[i].second;
		if (dist[0][a] + len[i] != dist[0][b]) {
			continue;
		}
		if (dist[1][b] + len[i] != dist[1][a]) {
			continue;
		}
		if (dist[0][a] + len[i] + dist[1][b] != need) {
			continue;
		}
		if (dist[0][a] * 2LL >= need)continue;
		if (dist[1][b] * 2LL >= need)continue;
		long long int w = way[0][a];
		w *= way[1][b];

		w %= MOD;
		w *= w;
		w %= MOD;
		w = MOD - w;
		ALL += w;
		if (ALL >= MOD)ALL %= MOD;
	}
	ALL %= MOD;
	printf("%lld\n", ALL);
	return 0;
}

Measured memory_bytes: 21728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int m = in.nextInt();
        int d = in.nextInt();
        int total = 0;
        for(int i = 22; i <= d; i++){
            int total_digits = Integer.toString(i).length();
            if (total_digits == 2){
                int copy = i;
                int first = copy % 10;
                copy /= 10;
                int second = copy% 10;
                if (first >= 2 && second >= 2 && first*second >= 1 && first* second <= m){
                    //System.out.println(first + " " + second);
                    total++;
                }
            }
        }
        System.out.println(total);
    }
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;



int main() {
//    freopen("input.in", "r", stdin);
	char c;
	scanf("%c", &c);
	puts((c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') ? "vowel" : "consonant");
	return 0;
}

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

const int INF = 0x3f3f3f3f;
const int mod = 1000000007;

int cnt[1009];

int main()
{
	int n;
	cin >> n;
	for(int i = 2; i <= n; ++i) {
		int _i = i;
		for(int j = 2; _i > 1; ++j) {
			while(_i % j == 0) ++cnt[j], _i /= j;
		}
	}
	LL ans = 1;
	Rep(i, n) ans = ans * (cnt[i]+1) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
     
char number[1001]={0};
int i,sum=0;
 
 
while(1){
    sum=0;
    scanf("%s",&number);
    if(number[0]== '0' ) break;
     
    for(i=0;number[i]!='\0';i++){
            sum=sum+(number[i]-'0');
    }
    printf("%d\n",sum);
}
return 0;
 
}

Measured memory_bytes: 536
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Shiritori
public class Main{

Set<String> words;
	
	String make(char s, char t){
		String x = s+""+t;
		if(!words.contains(x))return x;
		for(int i=0;i<26;i++){
			String r = s + ""+((char)(i+'a')) + t + "";
			if(!words.contains(r))return r;
		}
		return s+"a"+t;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		words = new HashSet<String>();
		System.out.println("?a");
		System.out.flush();
		words.add("a");
		while(true){
			String res = sc.next();
			if(res.length()==1 || res.charAt(0)!='a' || words.contains(res)){
				System.out.println("!OUT");
				System.out.flush();
				break;
			}
			words.add(res);
			char h = res.charAt(1);
			String n = make(h, 'a');
			words.add(n);
			System.out.println("?"+n);
			System.out.flush();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

bool isprime(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++) if( n % i == 0)return false;
	return true;
}
int main(){
	int n;
	while(cin >> n , n){
		while(n){
			if(isprime(n) & isprime(n-2)){
				cout << n-2 << " " << n << endl;
				break;
				}
			n--;
		}
	}
}

Measured memory_bytes: 868
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int a;
  std::cin >> a;
  std::cout << (a + 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>

struct {
  using value_type = std::tuple<size_t, size_t, intmax_t>;
  bool operator ()(const value_type& lhs, const value_type& rhs) const {
    size_t w0, s0, w1, s1;
    intmax_t v0, v1;
    std::tie(w0, s0, v0) = lhs;
    std::tie(w1, s1, v1) = rhs;
    return w0 + s0 < w1 + s1;
  }
} cmp;

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::tuple<size_t, size_t, intmax_t>> a(N);
  size_t wsum = 0;
  for (auto& ai: a) {
    size_t w, s;
    intmax_t v;
    scanf("%zu %zu %jd", &w, &s, &v);
    ai = std::make_tuple(w, s, v);
    wsum += w;
  }
  std::sort(a.begin(), a.end(), cmp);

  std::vector<intmax_t> dp(wsum+1);
  for (size_t i = 0; i < N; ++i) {
    size_t w, s;
    intmax_t v;
    std::tie(w, s, v) = a[i];
    for (size_t j = s+1; j--;) {
      if (j+w > wsum) continue;
      dp[j+w] = std::max(dp[j+w], dp[j]+v);
    }
  }

  printf("%jd\n", *std::max_element(dp.begin(), dp.end()));
}


Measured memory_bytes: 78336
#include<stdio.h>

int main(){
  int i,j,k,n,a[100],min,count=0;

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

  for(i = 0;i < n;i++){
    min = i;
    for(j = i;j < n;j++){
      if(a[j] < a[min]){
	min  = j;
      }
    }
    if(a[i] != a[min]){
      k = a[i];
      a[i] = a[min];
      a[min] = k;
      count++;
    }
  }

  for(i = 0;;i++){
    printf("%d",a[i]);
    if(i >= n - 1)break;
    printf(" ");
  }
  printf("\n%d\n",count);

  return 0;
}

Measured memory_bytes: 604
fn main() {
    let scan = std::io::stdin();

    let mut line = String::new();

    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let a: i32 = vec[0].parse().unwrap_or(0);
    let b: i32 = vec[1].parse().unwrap_or(0);
    let c: i32 = vec[2].parse().unwrap_or(0);

    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 5020
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(){
  int i,n;
  string x;
  stack<char> sta;
  cin >> x;
  n = x.size();
  for(i=0;i<n;i++){
    if(sta.empty()) sta.push(x[i]);
    else if(sta.top() == 'S' && x[i]=='T') sta.pop();
    else sta.push(x[i]);
  }
  
  cout << sta.size() << endl;
  return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    string s,t;cin>>s>>t;int n=s.length();int m=t.length();int dp[n+1][m+1];
   
    for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)
    {
       if(i==0||j==0)dp[i][j]=0;
      else   if(s[i-1]==t[j-1])
        {
            dp[i][j]=dp[i-1][j-1]+1;
        }
        else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
   
  int p=n;int q=m;string ans={};//cout<<p<<" "<<q<<endl;
  while(p>0 && q>0)
  {
      if(s[p-1]==t[q-1])
      {
       ans+=t[q-1];p--;q--; 
      }
      else if(dp[p-1][q]>dp[p][q-1])
      p--;
    else  q--; 
      
          
      }
      reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
//for(int pp=0;pp<ans.size();pp++)cout<<ans[pp];
 //  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++)cout<<dp[i][j]<<" ";cout<<endl;}
    
}

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

typedef long long ll;

ll a, b, c, d;
unordered_map<ll, ll> m;

long long f(long long n) {
    if (!n) return 0;
    if (n == 1) return d;
    if (m.count(n)) return m[n];

    const int mo[] = { 2, 3, 5 };
    const ll co[] = { a, b, c };

    ll ans = (n <= (ll) 1e18 / d) ? n * d : LLONG_MAX;

    for (int i = 0; i < 3; ++i) {
        ll target = (n / mo[i]) * mo[i];
        ans = min(ans, (n - target) * d + f(n / mo[i]) + co[i]);

        target = (n + mo[i] - 1) / mo[i] * mo[i];
        ans = min(ans, (target - n) * d + f((n + mo[i] - 1) / mo[i]) + co[i]);
    }

    return m[n] = ans;
}

long long n;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
#endif
    int T;
    cin >> T;
    while (T--) {
        m.clear();
        cin >> n;
        cin >> a >> b >> c >> d;
        cout << f(n) << endl;
    }
    return 0;
}


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

using namespace std;

int n;
map <string ,int> mp;

bool cmp(pair<string, int> x, pair<string, int> y){
	if(x.first.size() != y.first.size())
	return x.first.size() < y.first.size();
	return x.first < y.first;
}

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		string s;
		int x;
		
		cin >> s >> x;
		
		mp[s] += x;
	}
	
	vector <pair<string, int> > res;
	
	for(auto g : mp)
	res.push_back(g);
	
	sort(res.begin(), res.end(), cmp);
	
	for(int i = 0; i < res.size(); i++)
	cout << res[i].first << " " << res[i].second << endl;
}



Measured memory_bytes: 3288
n = int(input())
la = [int(w) for w in input().split()]
la.sort(reverse=True)

ans = la[0]
cnt = n - 2
for a in la[1:]:
    if cnt >= 2:
        cnt -= 2
        ans += a * 2
    elif cnt == 1:
        cnt -= 1
        ans += a
    else:
        break
print(ans)


Measured memory_bytes: 31444
N = int(input())
A = list(map(int, input().split()))

i = 1
j = 0
cnt = 0
while j <= N-1:
    if i == A[j]:
        i += 1
        j += 1
    else:
        j += 1
        cnt += 1

print(cnt if cnt <= N-1 else "-1")

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int a, b, c;
signed main() {
    cin >> a >> b >> c;
    if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }
}


Measured memory_bytes: 256