akhauriyash/Code-Regression huggingface dataset:
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;
const ll inf=1e18;

int n, m;

vi graf[nax];
int parz[nax];

vi cyk;

void nope()
{
	printf("No\n");
	exit(0);
}

void tak()
{
	printf("Yes\n");
	exit(0);
}

vi faj;

int licz=0;

int bylo[nax];

void dfs(int v, int oj=0)
{
	if (v==faj[1])
	{
		licz++;
		return;
	}
	bylo[v]=1;
	for (int i : graf[v])
	{
		if (bylo[i])
			continue;
		dfs(i, v);
	}
	bylo[v]=0;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		parz[a]^=1;
		parz[b]^=1;
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	int czy=1;
	for (int i=1; i<=n; i++)
		if (parz[i])
			czy=0;
	if (!czy)
		nope();
	map <int,int> sto;
	for (int i=1; i<=n; i++)
		sto[graf[i].size()]++;
	if (sto[2]==n)
		nope();
	if (sto[2]==n-1 && sto[4]==1)
		nope();
	if (!(sto[2]==n-2 && sto[4]==2))
		tak();
	for (int i=1; i<=n; i++)
		if ((int)graf[i].size()==4)
			faj.push_back(i);
	assert((int)faj.size()==2);
	dfs(faj[0]);
	if (licz==4)
		nope();
	tak();
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i=0; i<n; i++)
		cin >> a[i];

	int cnt = 0;
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++)
			cnt += a[i] * a[j];
	}

	cout << cnt << endl;
	
	return 0;
}

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


int main() {
  string s;
  cin >> s;
  bool ok=true;
  for(int i = 0; i < s.size()-1; i++) {
    if(s[i]==s[i+1]) ok=false;
  }
  cout << (ok? "Good":"Bad") << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int x, a, b;
    cin >> x >> a >> b;
    char c = (abs(x - a) < abs(x -b)) ? 'A': 'B';
    cout << c << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
#include <iostream>

#define N 100

int main() {
    int W[N];
    int n, diff, s1=0, s2=0;
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        std::cin >> W[i];
        s2 += W[i];
    }
    diff = s2;
    for (int i=0; i<n; ++i) {
        s1 += W[i];
        s2 -= W[i];
        diff = std::min(diff, std::abs(s2-s1));
    }
    std::cout << diff << std::endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

var f []int

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	f = make([]int, n+1)
	f[0] = 0
	f[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		f[i] = min(f[i-1]+abs(h[i-1]-h[i]), f[i-2]+abs(h[i-2]-h[i]))
	}
	fmt.Println(f[n-1])
}

Measured memory_bytes: 5504
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <string>
#include <list>

void update_list(std::string& substr, std::list<std::string>& list, const int32_t k){
    if(substr == ""){
        return;
    }
    if(list.empty()){
        list.push_back(substr);
        return;
    }
    for(auto it = list.begin(); it != list.end(); it++){
        if(*it == substr){
            return;
        }
        else if(*it > substr){
            list.insert(it, substr);
            if((int32_t)list.size() > k){
                list.pop_back();
            }
            return;
        }
    }
    if((int32_t)list.size() < k){
        list.push_back(substr);
    }
    return;
}

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

    std::string s;
    int32_t K;
    std::cin >> s;
    std::cin >> K;
    std::list<std::string> substr_list;

    for(int32_t i = 0; i < (int32_t)s.size(); i++){
        for(int32_t j = i; j < (int32_t)s.size() && j<i+K; j++){
            std::string substr = s.substr(i,j - i + 1);
            update_list(substr, substr_list, K);
        }
    }

    assert((int32_t)substr_list.size() == K);
    std::cout << substr_list.back() << std::endl;

    return 0;

}


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

typedef int Weight;
struct Edge {  
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : 
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const int INF=1e8;

bool shortestPath(const Graph &g,int s,vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = true;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(auto e : g[i]){
        if(dist[e.dst] > dist[e.src] + e.weight){
          dist[e.dst] = dist[e.src] + e.weight;
          prev[e.dst] = e.src;
          if(k == n-1){
            dist[e.dst] = -INF;
            negative_cycle = false;
          }
        }
      }
    }
  }
  return negative_cycle;
}

int main(){
	int n; cin >> n;
	Graph g(n);
    int u, k, v, c;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v >> c;
            g[u].push_back({u, v, c});
        }
    }

    vector<Weight> dist;
    vector<int> prev; 
    shortestPath(g, 0, dist, prev);
    
    for(int i=0; i<n; i++){
        cout << i << " " << dist[i] << endl;
    }
}


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

int main() {
    string S;
    cin >> S;
    int l = S.size();

    if(l%2==0){
        int m = l/2;
        int a=0;
        int b=0;
        for(int i=0; i<m; i++){
            if(S[2*i]=='0') a++;
            if(S[2*i]=='1') b++;
        }
        for(int i=0; i<m; i++){
            if(S[2*i+1]=='0') b++;
            if(S[2*i+1]=='1') a++;
        }
        cout << min(a,b) << endl;
        return 0;
    }
    else{
        int m = l/2;
        int a=0;
        int b=0;
        for(int i=0; i<m+1; i++){
            if(S[2*i]=='0') a++;
            if(S[2*i]=='1') b++;
        }
        for(int i=0; i<m; i++){
            if(S[2*i+1]=='0') b++;
            if(S[2*i+1]=='1') a++;
        }
        cout << min(a,b) << endl;
        return 0;
    }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define maxn 200050
#define LL long long
using namespace std;
struct node
{
	LL fi,se;
}a[maxn];
multiset<LL>m1,m2;
int cmp(node a,node b){
	if(a.fi==b.fi) return a.se<b.se;
	return a.fi<b.fi;
}
int main(){
//	freopen("input.txt","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i].fi,&a[i].se);
		if(a[i].fi>a[i].se) swap(a[i].fi,a[i].se);
		m1.insert(a[i].fi),m2.insert(a[i].se);
	}
	sort(a+1,a+1+n,cmp);
	LL ans=(*m1.rbegin()-*m1.begin())*(*m2.rbegin()-*m2.begin());
	for(int i=1;i<=n;i++){
		m1.erase(m1.find(a[i].fi)),m2.erase(m2.find(a[i].se));
		m1.insert(a[i].se),m2.insert(a[i].fi);
		ans=min(ans,(*m1.rbegin()-*m1.begin())*(*m2.rbegin()-*m2.begin()));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 24192
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define NUM_MAX 100000
#define BUF_SIZE (NUM_MAX*7+50)

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define min(a,b) ((a) > (b) ? (b) : (a))

int main(void) {
    int num, max_step;
    get_int2(&num, &max_step);
    static int arr[NUM_MAX+1];
    static int dp[NUM_MAX+1];
    memset(dp, 0x3f, sizeof(int)*(NUM_MAX+1));
    fget_array(&arr[1], num);
    int i, k;
    dp[1] = 0;
    for(i = 2; i <= num; i++) {
        for(k = 1; k <= max_step; k++) {
            if(i-k<=0) break;
            dp[i] = min(dp[i], dp[i-k] + abs(arr[i]-arr[i-k]));
        }
    }
    printf("%d\n", dp[num]);
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        char[] alps = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[][] count = new int[n][26];
        for(int i = 0; i < n; i++){
            char[] s = sc.next().toCharArray();
            for(char c : s){
                int j = c - 'a';
                count[i][j]++;
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int j = 0; j < 26; j++){
            int min = Integer.MAX_VALUE;
            for(int i = 0; i < n; i++){
                min = Math.min(min,count[i][j]);
            }
            for(int i = 0; i < min; i++) sb.append(alps[j]);
        }
        System.out.println(sb.toString());
    }
}

class Drink implements Comparable<Drink>{
    int y,m;
    public Drink(int y, int m){
        this.y = y;
        this.m = m;
    }
    
    public int compareTo(Drink d){
        if(this.y < d.y){
            return -1;
        }else if(this.y > d.y){
            return 1;
        }else{
            return 0;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 23508
import java.util.Scanner;


public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static int n, m;
	public static int[] taro;
	public static int[] hanako;
	
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}

	public static boolean read(){
		n = sc.nextInt();
		m = sc.nextInt();
		
		if(n==0 && m==0)  return false;
		
		taro = new int[n];
		hanako = new int[m];
		
		for(int i=0; i<n; i++){
			taro[i] = sc.nextInt();
		}
		
		for(int i=0; i<m; i++){
			hanako[i] = sc.nextInt();
		}
		
		return true;
	}
	
	public static void solve(){
		int dif = 0;
		
		for(int i=0; i<n; i++){
			dif += taro[i];
		}
		
		for(int i=0; i<m; i++){
			dif -= hanako[i];
		}

		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				 if(dif == (taro[i] - hanako[j])*2){
					 System.out.println(Integer.toString(taro[i]) + " " + Integer.toString(hanako[j]));
					 return;
				 }
			}
		}
		
		System.out.println("-1");
		
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    string  s, t;
    cin >> s >> t;

    bool check = false;
    rep(i, s.length()){
        if(s==t){
            check = true;
            break;
        }
        s = s.substr(1) + s.front(); 
    }

    if(check){
        std::cout << "Yes";
    }
    else{
        std::cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N,R;

    cin >> N >> R;

    if(N < 10)cout << R + 100 * (10 - N) << endl;
    else cout << R << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  string s;
  cin>>s;
  string devide[4]={"dream","dreamer","erase","eraser"};
  reverse(s.begin(),s.end());
  for(int i=0;i<4;i++){
    reverse(devide[i].begin(),devide[i].end());
  }
  bool ok=true;
  for(int i=0;i<s.size();){
    bool can2=false;
    for(int j=0;j<4;j++){
      string d=devide[j];
      if(s.substr(i,d.size())==d){//dと一致するか
        can2=true;
        i+=d.size();

      }
    }
    if(!can2){
      ok=false;
      break;
    }
  }
  if(ok){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
  



}



  

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int x,y;
    cin >> x >> y;
    vector<int> c(3); 
    rep(i,3) cin >> c[i];
    vector<vector<int>> p(3);
    rep(i,3) {
        rep(j,c[i]) {
            int pin;
            cin >> pin;
            p[i].push_back(pin);
        }
        sort(p[i].begin(),p[i].end(),greater<>());
    }
    vector<int> vans;
    rep(i,x) vans.push_back(p[0][i]);
    rep(i,y) vans.push_back(p[1][i]);
    rep(i,c[2]) vans.push_back(p[2][i]);
    sort(vans.begin(),vans.end(),greater<>());
    ll ans=0;
    rep(i,x+y) ans+=vans[i];
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <functional>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<pair<int, int>>> g(n), dp(n);
        for (int i = 1; i < n; i ++) {
                int a, v;
                scanf("%d%d", &a, &v);
                a --;
                g[a].emplace_back(v, i);
        }
        function<void (int, int)> dfs = [&](int u, int x) {
                if (g[u].size() == 0) return;
                pair<int, int> a = g[u][0], b = g[u][1];
                dfs(a.second, x);
                dfs(b.second, x);
                int l = a.first + b.first;
                vector<pair<int, int>> v;
                if (dp[a.second].size() > dp[b.second].size()) swap(a, b);
                for (int i = 0, j = 0; i < dp[a.second].size(); i ++) {
                        while (j < dp[b.second].size() && dp[b.second][j].first + dp[a.second][i].second + l <= x) j ++;
                        if (j != 0) {
                                v.emplace_back(dp[a.second][i].first + a.first, dp[b.second][j - 1].second + b.first);
                        }
                }
                for (int i = 0, j = 0; i < dp[a.second].size(); i ++) {
                        while (j < dp[b.second].size() && dp[b.second][j].second + dp[a.second][i].first + l > x) j ++;
                        if (j != dp[b.second].size()) {
                                v.emplace_back(dp[b.second][j].first + b.first, dp[a.second][i].second + a.first);
                        }
                }
                sort(v.begin(), v.end());
                int now = ~0u>>1;
                cerr << now << endl;
                for (int i = 0; i < v.size(); i ++) {
                        if (i > 0 && v[i].first == v[i - 1].first) continue;
                        if (now > v[i].second) {
                                dp[u].push_back(v[i]);
                                now = v[i].second;
                        }
                }
        };        
        function<bool (int)> check = [&](int x) {
                for (int i = 0; i < n; i ++) if (g[i].size() == 0) dp[i].emplace_back(0, 0);
                dfs(0, x);
                int ok = dp[0].size();
                for (int i = 0; i < n; i ++) dp[i].clear();
                return ok != 0;
        };
        int lb = 0, ub = 1e9, ans = -1;
        while (lb <= ub) {
                int mid = (lb + ub) / 2;
                if (check(mid)) ans = mid, ub = mid - 1;
                else lb = mid + 1;
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 23120
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void add(int &x, int v) {
	x += v;
	if(x >= mod) x -= mod;
}
char s[100005];
int dp[100005][20];
int main() {
	scanf("%s", s);
	int len = strlen(s);
	dp[0][0] = 1;
	
	for(int i = 1; i <= len; i++) {
		if(s[i - 1] == '?') {
			for(int j = 0; j <= 9; j++) {
				for(int k = 0; k <= 12; k++) {
					add(dp[i][(k * 10 + j) % 13], dp[i - 1][k]);
				}
			}
		}
		else {
			for(int k = 0; k <= 12; k++) {
				add(dp[i][(k * 10 + s[i - 1] - '0') % 13], dp[i - 1][k]);
			}
		}
	}
	cout << dp[len][5] << endl;
	return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=0;
    n = sc.nextInt();
    int[] a = new int[n] ;
    int i,j;
    for(i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    for(i=n;i>1;i--){
      for(j=0;j<i-1;j++){
        int c=a[j];
        a[j]=a[j+1];
        a[j+1]=c;
      }
    }
    System.out.printf("%d",a[0]);
    for(i=1;i<n;i++){
      System.out.printf(" %d",a[i]);
    }
    System.out.println();
    sc.close();
  }
}


Measured memory_bytes: 26520
#include <bits/stdc++.h>
//freopen("transmitters.in","r",stdin);
using namespace std;

void fast(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
/*long long mn=1e9;
void lucky (long long a, long long c,int b)
{
    if(a > 1e11)
    return ;
    if(a>=b&&c==0)
    mn=min(mn,a);
    
    lucky (a*10+7,c-1,b);
    lucky (a*10+4,c+1,b);
    
}*/
long long toint(string s){
	long long a = 0, c = 1;;
	for (int i = 0; i<s.size(); i++){
		a += (s[s.size() - i - 1] - '0')*c;
		// cout<<a<<endl;
		c *= 10;
	}
	return a;
}
int prime(int x)
{
int c=0;
 if(x==1)
 {
    return 0;
    
 }
 else
 {
  for(int j=2; j*j<=x;j++ ) 
  {
   if(x%j==0) 
   {
    c++;
     } 
   }

     if(c==0) 
      return 1;
    
    return 0;
     }
}
long long arr[100000];
int main()
{

  fast();

   long long n,m,c=1e13,x=0,y=0,t,h,z;
   string s;
   cin>>n>>m;
   m--;
   for(int i=0;i<n;i++)
   cin>>arr[i];
   sort(arr,arr+n);
   for(int i=0;i<n;i++)
     if((m+i)<=(n-1))
       c=min(c,abs(arr[i]-arr[m+i]));
     
   
   cout<<c<<endl;
//	system("pause");
	//cout << "-1" << endl;
	//  transform(x.begin(), x.end(), x.begin(), ::tolower); 

	return 0;
}
	

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

using namespace std;

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

long long lcm(long long a, long long b) {
	long long res = a / gcd(a, b) * b;
	return res;
}

int main() {
	long long A, B;
	cin >> A >> B;
	long long ans = lcm(A, B);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3560
#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];
  sort(a.begin(), a.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2)
      ans -= a[i];
    else
      ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;
const int mod = 1e9 + 7;

long long mod_pow(long long x,long long n){
    if(n==0) return 1;
    long long res = mod_pow(x*x % mod, n/2);
    if(n & 1) res = res*x % mod;
    return res;
}
long long fact[200010];//書き換えよう!
long long get_nCk(long long n, long long k, long long mod = 1e9 + 7){
    if(fact[0] == 0){
        fact[0] = 1;
        for(int i = 1; i < 200010; i++) fact[i] = fact[i-1] * i % mod;
    }
    if(n < 0 || k < 0 || n < k) return 0;
    return fact[n] * mod_pow(fact[k], mod - 2) % mod * mod_pow(fact[n - k], mod - 2) % mod;
}

signed main(){
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int w = -1;
    set<int> st;
    rep(i, 0, n + 1){
        cin >> a[i];
        if(st.count(a[i])) w = a[i];
        st.insert(a[i]);
    }
    int l = -1, r = -1;
    rep(i, 0, n + 1){
        if(l == -1 && a[i] == w) l = i;
        else if(a[i] == w) r = i;
    }
    // cout << r - l + 1 << endl;
    rep(k, 1, n + 2){
        int ans = 0;
        ans = get_nCk(n - 1, k - 2) + (int)2 * get_nCk(n - 1, k - 1) - get_nCk(n - 1 - (r - l - 1), k - 1) + get_nCk(n - 1, k);
        // cout << get_nCk(n - 1, k - 2) << " " << get_nCk(n - 1, k - 1) << " " << get_nCk(n - 1 - (r - l - 1), k - 1)<< endl;
        cout << (ans + mod) % mod << endl;
    }
}

Measured memory_bytes: 8192
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7




def main():
    a, b = map(int, input().split())
    if a >= 10 or b >= 10:
        print(-1)
    else:
        print(a*b)



            
            
            
            
            
        


if __name__ == '__main__':
    main()


Measured memory_bytes: 69868
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    string s;
    string fr = "";
    string b = "";
    cin >> s;
    int q;cin >> q;
    int flag = 0;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            flag++;
            flag %= 2;
        }
        else{
            int f;
            string c;
            cin >> f;
            cin >> c;
            if((f==1 && flag == 0) || (f==2 && flag == 1)) fr += c;
            else b += c;
        }
    }
    if(flag==1){
        reverse(b.begin(),b.end());
        reverse(s.begin(),s.end());
        s = b + s + fr;
    }
    else{
        reverse(fr.begin(),fr.end());
        s = fr + s + b;
    }
    cout << s << endl;
}


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

using namespace std;

int main(){
	string w; cin >> w;
	int ac[26] = {};
	for(int i = 0; i < w.size(); ++i){
		ac[w[i] - 'a']++;
	}
	bool isEven = true;
	for(int i = 0; i < 26; ++i) if(ac[i] % 2 != 0) isEven = false;
	cout << (isEven ? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> sC(26, -1), tC(26, -1);
    rep(i, s.size()){
        int si = s[i] - 'a';
        int ti = t[i] - 'a';
        if (sC[si] != -1 || tC[ti] != -1){
            if (sC[si] != ti || tC[ti] != si){
                cout << "No" << endl;
                return 0;
            }
        }
        sC[si] = ti;
        tC[ti] = si;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    ll n;
    cin >> n;
    if(n==1){
      cout << 1 << endl;
      return 0;
    }
    vector<ll> t(n+1,1);
    for(long long i=2;i<=n;i++){
      ll j=1;
      while(i*j<=n){
        t[i*j]++;
        j++;
      }
    }
    ll res=0;
    for(ll i=1;i<=n;i++){
      res+=i*t[i];
    }
    cout <<res <<endl;
}


Measured memory_bytes: 81348
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c>a+b){
		printf("NA\n");
		return 0;
	}
	if(c<=a)c=0;
	else c=c-a;
	printf("%d\n",c);
	return 0;
}


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

int main(){
    // Your code here!
    int n,q,tmp;
    cin>>n>>q;
    string name[n];
    int Time[n];
    std::queue<pair<string,int>>Q ;
    for(int i=0;i<n;i++){
        cin>>name[i]>>Time[i];
        Q.push({name[i],Time[i]});
    }
    int fin=0;
    while(!Q.empty()){
        auto tmp=Q.front();
        Q.pop();
        if(tmp.second>q){
            tmp.second-=q;
            Q.push(tmp);
            fin+=q;
        }
        else{
            fin+=tmp.second;
            cout<<tmp.first<<" "<<fin<<endl;
        }
    }
}


Measured memory_bytes: 6828
package main

import "fmt"

func swap(m, n int) (int, int) {
	var i, j = n, m
	return i, j
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	a, b = swap(a, b)
	a, c = swap(a, c)
	fmt.Println(a, b, c)
}

Measured memory_bytes: 1748
#include <iostream>
using namespace std;
int main(){
    long  n;
    cin >> n;
    long  val=7%n;
    bool check=false;
        
            for(long  i=1;i<n+1;i++){
                if(val==0){
                    cout << i;
                    check=true;
                    break;
                }
                val=(val*10+7)%n;
            }
            if(check==false){
               cout << "-1";
            } 
    return 0;
}

Measured memory_bytes: 3608
import sys
input = sys.stdin.readline


def main():
    A,B = [int(i) for i in input().strip().split()]

    if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
        print("Possible")
    else:
        print("Impossible")

if __name__ == "__main__":
    main()

Measured memory_bytes: 61656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int T, X;
	cin >> T >> X;

	double kotae = 1.0 * T / X;
	
	cout << fixed << kotae << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    long A[N],B[N];vector<long> C(N);
    long result=0;
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i];
        C[i]=A[i]+B[i];
        result-=B[i];
    }sort(C.begin(),C.end());
    reverse(C.begin(),C.end());
    for(int j=0;j<N;j=j+2){
        result+=C.at(j);
    }cout<<result<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string.h>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <stack>
#include <iomanip>
#include <functional>
#include <limits.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,n) for(ll i=1;i<=n;i++)
#define N 1000
#define kr 1000000007
ll binarys(ll low,ll high,ll a[],ll x)
{
    while (high-low>1) {
        ll mid=low+(high-low)/2;
        if(a[mid]>x)
            high=mid;
        else
            low=mid;
    }
    if(a[high]<=x)
        return high;
    else if(a[low]<=x)
        return low;
    else
        return -1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    string a;
    cin>>a;
    set<char>s;
    rep(i,a.length())
    {
        s.insert(a[i]);
    }
    if(s.size()==a.length())
        cout<<"yes";
    else
        cout<<"no";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int main(){
  ll n,m;
  cin >> n >> m;
  ll a[m];
  ll total = 0;
  for(int i = 0; i < m; i++){
    cin >> a[i];
    total += a[i];
  }
  ll ans = n - total;;
  if(ans < 0){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}

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

typedef unsigned long long int ull;
int main() {
    int n,k;
    vector<ull> h;
    int tmp;
    cin >> n >> k;
    for(int i=0;i<n;i++) {
        cin >> tmp;
        h.push_back(tmp);
    }
    if(k>=n) {
        cout << 0 << endl;
        return 0;
    }
    sort(h.begin(),h.end());
    ull total=0;
    for(int i=0;i<n-k;i++) {
        total+=h[i];
    }
    cout << total << endl;
    return 0; 
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A == B)
        cout << C << endl;
    if(A == C)
        cout << B << endl;
    if(B == C)
        cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n,a[100],t;

int main(){
	while(cin>>n&&n){
		rep(i,n)cin>>a[i];
		cin>>t;
		int lb=0,ub=n-1;
		int ans=0;
		while(++ans){
			//cout<<ans<<" "<<a[lb]<<" "<<a[ub]<<" "<<a[(lb+ub)/2]<<endl;
			if(a[(lb+ub)/2]==t||lb==ub||lb>ub){cout<<ans<<endl;break;}
			else if(a[(lb+ub)/2]<t)lb=(lb+ub)/2+1;
			else ub=(lb+ub)/2-1;
			if(lb>ub){cout<<ans<<endl;break;}
		}
	}
}

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

int main()
{
int n,i,k=0,sum=0;
  
  cin >> n;
  
  int a[n];
  
  for(i=0;i<n;i++)
  {
  cin >> a[i];
  }
  
 for(i=0;i<n;i++)
  {
  if(k<a[i])k=a[i];
   sum+=a[i];
  }
  
  if(sum-k > k){cout << "Yes" << endl;}
   else{cout << "No" << endl;} 
  return 0;
}

Measured memory_bytes: 256
# C - : (Colon)
from math import cos, radians, sqrt


def main():
    A, B, H, M = map(int, input().split())
    rad = abs(H * 30 - M * 5.5)
    ans = sqrt(A ** 2 + B ** 2 - 2 * A * B * cos(radians(rad)))
    print(ans)


if __name__ == "__main__":
    main()


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

#include <atcoder/all>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define PI 3.14159265358979323846

using namespace std;
using namespace atcoder;

using mint = modint1000000007;
// using mint = modint998244353;

template <typename T>
static inline void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T> &A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T> &A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first > b.first;
  }
}

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

static inline u64 gcd(u64 a, u64 b) { return __gcd(a, b); }

static inline u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

vector<i64> p;
std::vector<bool> is_prime(1000000 + 1, true);
void Eratosthenes(const int N) {
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      p.emplace_back(i);
    }
  }
}

int main() {
  cout << setprecision(18);

  u32 N, M;
  cin >> N >> M;

  dsu d(N);

  for (u32 i = 0; i < M; ++i) {
    u32 A, B;
    cin >> A >> B;
    A--, B--;
    d.merge(A, B);
  }
  vector<vector<int>> v = d.groups();

  cout << d.groups().size() - 1 << endl;

  return 0;
}


Measured memory_bytes: 13616
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let m: i32 = input();
    let d: i32 = input();

    let mut ans = 0;
    for m in 1..m + 1 {
        for d in 1..d + 1 {
            let d0 = d % 10;
            let d1 = d / 10;
            if d0 >= 2 && d1 >= 2 && m == d0 * d1 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int n =0;
int m =0;
struct card
{
	char sign;
	char num;
	char index;
};

card a[36];
card s[36];
card b[36];

void select_sort(card * a)
{
	for(int i=0; i<n-1; i++)
	{
		int minj = i;
		for (int j=i+1; j<n; j++)
		{
			if (a[minj].num > a[j].num)
			{
				minj = j;
			}
		}
		
		if (minj != i)
		{
			card ai = a[i];
			a[i] = a[minj];
			a[minj] = ai;
			m++;
		}
	}
	
}

void bubble_sort(card * a)
{
	bool flag = true;
	while (flag)
	{
		flag =false;  
		for (int i=n-1; i>0; i--)
		{
			card ai = a[i];
			if(ai.num < a[i-1].num) 
			{
				a[i] = a[i-1];
				a[i-1] = ai;
				flag = true;
				m++;
			}
		}
	}
}

void output(card * a)
{
	bool stable = true;
	for (int i=0; i<n;	i++)
	{
		if (i) cout << ' ';
		cout << a[i].sign << a[i].num;
		if (i)
		{
			if (a[i].num == a[i-1].num)
			{
				if (a[i].index < a[i-1].index)
				{
					stable = false;
				}
			}
		}
	}
	cout << endl;
	
	cout << (stable ? "Stable" : "Not stable");
	
	cout << endl;
}


int main()
{
	cin >> n;
	for (int i = 0; i < n;	i++)
	{
		char c[3];
		cin >> c;
		a[i].sign = c[0];
		a[i].num = c[1];
		a[i].index = i;
		b[i] = s[i] = a[i];
	}
	
	bubble_sort(b);
	output(b);
	
	select_sort(s);
	output(s);
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

class UnionFind
{
    int *parent, *rank;
public:
    UnionFind(int n)
    {
        parent = new int[n];
        rank = new int[n];
        for(int i=0;i<n;++i) 
        {
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int findSet(int x)
    {
        if(x != parent[x])
        {
            parent[x] = findSet(parent[x]);
        }
        return parent[x];
    }

    bool same(int x, int y)
    {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y)
    {
        int root_x = findSet(x);
        int root_y = findSet(y);
        if(rank[root_x] < rank[root_y])
        {
            parent[root_x] = root_y;
        }
        else{
            if(rank[root_x] == rank[root_y])
            {
                ++rank[root_x];
            }
            parent[root_y] = root_x;
        }
    }
};

int main()
{
    int com, n, q, x, y;
    cin >> n >> q;
    UnionFind uf(n);
    for(int i=0;i<q;++i)
    {
        cin >> com >> x >> y;
        if(com)
        {
            cout << uf.same(x, y) << endl;
        }
        else
        {
            uf.unite(x, y);
        }
    }
}



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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()

int main() {
    int N;
    cin >> N;
    int ec = 0;
    int oc = 0;
    REP(i, N) {
        int x;
        cin >> x;
        x%2 ? oc++ : ec++;
    }
    cout << pow(3, N) - pow(2, ec) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int powm(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }


vector<vector<int> > ans( 101 , vector<int> (100001, 0));

void solve()
{
    int n,w;
    cin>>n>>w;
    vector<pair<int,int>> v;
    int a,b;
    v.pb({0,0});
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v.pb({a,b});
    }
    sort(all(v));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            ans[i][j]=ans[i-1][j];
            if(j-v[i].F>=0)
            {
                ans[i][j]=max(ans[i][j],v[i].S+ans[i-1][j-v[i].F]);
            }
        }
    }
    // for(int i=0;i<=n;i++)
    // {
    //     for(int j=0;j<=w;j++)
    //     {
    //         cout<<ans[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    int ans1=0;
    for(int i=1;i<=w;i++)
        ans1=max(ans1,ans[n][i]);
    cout<<ans1;
    return;
}



int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
   int t;
    t=1;
    while(t--)
   {
      solve();
   }
}

Measured memory_bytes: 83060